diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4210,7 +4210,8 @@ def phase(ui, repo, *revs, **opts): 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 @@ def phase(ui, repo, *revs, **opts): 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 diff --git a/tests/test-phases.t b/tests/test-phases.t --- a/tests/test-phases.t +++ b/tests/test-phases.t @@ -402,3 +402,34 @@ move changeset forward and backward | 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]