changeset 15906:aad565319fa3

phase: report phase movement When used in "set" mode, the phase command now display the number of changeset who changed phase.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 17 Jan 2012 20:43:41 +0100
parents 634d49a8b6db
children 51fc43253a52
files mercurial/commands.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Mon Jan 16 19:45:35 2012 +0100
+++ b/mercurial/commands.py	Tue Jan 17 20:43:41 2012 +0100
@@ -4237,6 +4237,8 @@
     lower phase to an higher phase. Phases are ordered as follows::
 
         public < draft < secret
+
+    Return 0 on success, 1 if no phases were changed.
     """
     # search for a unique phase argument
     targetphase = None
@@ -4253,6 +4255,7 @@
         raise util.Abort(_('no revisions specified!'))
 
     lock = None
+    ret = 0
     if targetphase is None:
         # display
         for ctx in repo.set('%lr', revs):
@@ -4264,11 +4267,22 @@
             nodes = [ctx.node() for ctx in repo.set('%lr', revs)]
             if not nodes:
                 raise util.Abort(_('empty revision set'))
+            olddata = repo._phaserev[:]
             phases.advanceboundary(repo, targetphase, nodes)
             if opts['force']:
                 phases.retractboundary(repo, targetphase, nodes)
         finally:
             lock.release()
+        if olddata is not None:
+            changes = 0
+            newdata = repo._phaserev
+            changes = sum(o != newdata[i] for i, o in enumerate(olddata))
+            if changes:
+                ui.note(_('phase change for %i changesets\n') % changes)
+            else:
+                ui.warn(_('no phases changed\n'))
+                ret = 1
+        return ret
 
 def postincoming(ui, repo, modheads, optupdate, checkout):
     if modheads == 0: