Mercurial > hg-stable
changeset 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 | b8be450638f6 |
children | 4e4c416a0b1f |
files | mercurial/commands.py tests/test-phases.t |
diffstat | 2 files changed, 44 insertions(+), 2 deletions(-) [+] |
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
--- a/tests/test-phases.t Thu Feb 09 21:03:07 2012 +0100 +++ b/tests/test-phases.t Wed Feb 08 20:00:52 2012 +0100 @@ -402,3 +402,34 @@ | o 0 public A +test partial failure + + $ hg phase --public 7 + $ hg phase --draft '5 or 7' + cannot move 1 changesets to a more permissive phase, use --force + phase changed for 1 changesets + [1] + $ hg log -G --template "{rev} {phase} {desc}\n" + @ 7 public merge B' and E + |\ + | o 6 public B' + | | + +---o 5 draft H + | | + o | 4 public E + | | + o | 3 public D + | | + o | 2 public C + |/ + o 1 public B + | + o 0 public A + + +test complete failure + + $ hg phase --draft 7 + cannot move 1 changesets to a more permissive phase, use --force + no phases changed + [1]