Page MenuHomePhabricator

phabricator: add an option to fold several commits into one review (issue6244)
Needs RevisionPublic

Authored by mharbison72 on Fri, Mar 20, 5:24 PM.

Details

Reviewers
Alphare
Group Reviewers
hg-reviewers
Summary

Now that all of the pieces are in place, alter the user facing command to allow
it. This is the default behavior when using arc, but I much prefer the 1:1
approach, and I'm tempted to mark this advanced to limit its abuse. I started
out calling this --no-stack like the feature request suggested, but I found it
less obvious (especially when writing the code), so I went with the hg fold
analogue.

This will populate the Commits tab in the web UI with the hash of each commit
folded into the review. From experimentation, it seems to list them in the
order they are received from the extension instead of the actual parent/child
relationship. The extension sends them in sorted order, thanks to
templatefilters.json(). Since there's enough info there for them to put
things in the right order, JSON is unordered aside from lists (IIUC), and there
doesn't seem to be any harmful side effects, I guess we write this off as their
bug. It is simple enough to workaround by putting a check for util.sortdict
into templatefilters.json(), and don't resort in that case.

There are a handful of restrictions that are documented in the code, which
somebody could probably fix if they're interested. Notably, this requires the
(default) --amend option, because there's not an easy way to apply a local tag
across several commits. This also doesn't do preflight checking to ensure that
all previous commits that were part of a single review are selected when
updating. That seems expensive. What happens is the excluded commit is dropped
from the review, but it keeps the Differential Revision line in the commit
message. Not everything can be edited, so it doesn't seem worth making the code
even more complicated to handle this edge case.

The tests were run against an internal Docker container. Once I get the sense
that everyone is happy with the behavior and test coverage, I'll rerun it
against the usual server to avoid spamming it in the meantime.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

mharbison72 created this revision.Fri, Mar 20, 5:24 PM
mharbison72 added inline comments.Mon, Mar 30, 10:26 PM
hgext/phabricator.py
1507

This also needs to check that newnodes is a non-empty list. It's empty in the case where the commits are already public, so nothing is amended.

Since these tests are rather large, I'll hold off on resending this until everything is accepted.

Alphare requested changes to this revision.Tue, Mar 31, 4:57 AM
Alphare added a subscriber: Alphare.
Alphare added inline comments.
hgext/phabricator.py
1291

I prefer the explicit abort, but that can be argued either way.

1424

Not sure I understand (None, None, None)[2]

tests/test-phabricator.t
644

I think we should have a test for split as well

This revision now requires changes to proceed.Tue, Mar 31, 4:57 AM
mharbison72 marked 2 inline comments as done.Tue, Mar 31, 9:42 AM
mharbison72 added inline comments.
hgext/phabricator.py
1424

Good catch. The subscript should be outside.

tests/test-phabricator.t
644

I'll add in the test I have locally for splitting on the end, based on your last review.

Does it look good enough otherwise to run the tests against the upstream phab server?