Mercurial > public > mercurial-scm > hg-stable
comparison hgext/phabricator.py @ 41163:0101a35deae2
phabricator: warn if unable to amend, instead of aborting after posting
There was a divergence in behavior here between obsolete and strip based
amending. I first noticed the abort when testing outside of the test harness,
but then had trouble recreating it here after reverting the code changes. It
turns out, strip based amend was successfully amending the public commit after
it was posted! It looks like the protection is in the `commit --amend` command,
not in the underlying code that it calls.
I considered doing a preflight check and aborting. But the locks are only
acquired at the end, if amending, and this is too large a section of code to be
wrapped in a maybe-it's-held-or-not context manager for my tastes.
Additionally, some people do post-push reviews, and amending is the default
behavior, so they shouldn't see a misleading error message.
The lack of a 'Differential Revision' entry in the commit message breaks a
{phabreview} test, so it had to be partially conditionalized.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 05 Jan 2019 15:20:33 -0500 |
parents | 9d35ae3d9999 |
children | 43fd1947301d |
comparison
equal
deleted
inserted
replaced
41162:cc1f545c4075 | 41163:0101a35deae2 |
---|---|
57 httpconnection as httpconnectionmod, | 57 httpconnection as httpconnectionmod, |
58 mdiff, | 58 mdiff, |
59 obsutil, | 59 obsutil, |
60 parser, | 60 parser, |
61 patch, | 61 patch, |
62 phases, | |
62 registrar, | 63 registrar, |
63 scmutil, | 64 scmutil, |
64 smartset, | 65 smartset, |
65 tags, | 66 tags, |
66 templateutil, | 67 templateutil, |
582 drev = [d for d in drevs if int(d[r'id']) == drevid][0] | 583 drev = [d for d in drevs if int(d[r'id']) == drevid][0] |
583 newdesc = getdescfromdrev(drev) | 584 newdesc = getdescfromdrev(drev) |
584 newdesc = encoding.unitolocal(newdesc) | 585 newdesc = encoding.unitolocal(newdesc) |
585 # Make sure commit message contain "Differential Revision" | 586 # Make sure commit message contain "Differential Revision" |
586 if old.description() != newdesc: | 587 if old.description() != newdesc: |
588 if old.phase() == phases.public: | |
589 ui.warn(_("warning: not updating public commit %s\n") | |
590 % scmutil.formatchangeid(old)) | |
591 continue | |
587 parents = [ | 592 parents = [ |
588 mapping.get(old.p1().node(), (old.p1(),))[0], | 593 mapping.get(old.p1().node(), (old.p1(),))[0], |
589 mapping.get(old.p2().node(), (old.p2(),))[0], | 594 mapping.get(old.p2().node(), (old.p2(),))[0], |
590 ] | 595 ] |
591 new = context.metadataonlyctx( | 596 new = context.metadataonlyctx( |