Mercurial > hg
diff mercurial/commands.py @ 16097:8dc573a9c5e5
phase: when phase cannot be reduced, hint at --force and return 1 (BC)
Before, trying to change the phase of a "public" node to "draft" would result
in:
$ hg phase --draft .
no phases changed
[0]
With this patch:
$ hg phase --draft .
cannot move 1 changesets to a more permissive phase, use --force
no phases changed
[1]
On partial failures, the exit status is now 1 instead of 0 and the number of
changed nodes is displayed while it was only with --verbose. It seems useful to
tell the user that despite the apparent failure, something changed.
$ hg phase --draft '5 or 7'
cannot move 1 changesets to a more permissive phase, use --force
phase changed for 1 changesets
[1]
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Wed, 08 Feb 2012 20:00:52 +0100 |
parents | 3eab42088be4 |
children | 5535e66b3016 |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Feb 09 21:03:07 2012 +0100 +++ b/mercurial/commands.py Wed Feb 08 20:00:52 2012 +0100 @@ -4210,7 +4210,8 @@ public < draft < secret - Return 0 on success, 1 if no phases were changed. + Return 0 on success, 1 if no phases were changed or some could not + be changed. """ # search for a unique phase argument targetphase = None @@ -4252,8 +4253,18 @@ changes = 0 newdata = repo._phaserev changes = sum(o != newdata[i] for i, o in enumerate(olddata)) + rejected = [n for n in nodes + if newdata[repo[n].rev()] < targetphase] + if rejected: + ui.warn(_('cannot move %i changesets to a more permissive ' + 'phase, use --force\n') % len(rejected)) + ret = 1 if changes: - ui.note(_('phase change for %i changesets\n') % changes) + msg = _('phase changed for %i changesets\n') % changes + if ret: + ui.status(msg) + else: + ui.note(msg) else: ui.warn(_('no phases changed\n')) ret = 1