bookmarks: show detailed status about outgoing bookmarks
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Wed, 08 Apr 2015 02:56:19 +0900
changeset 24661 8cf70c97a6e1
parent 24660 bf13b44bbb0a
child 24662 b5cd8c2f6e65
bookmarks: show detailed status about outgoing bookmarks Before this patch, "hg outgoing -B" shows only difference of bookmarks between two repositories, and it isn't user friendly. This patch shows detailed status about outgoing bookmarks at "hg outgoing -B". To avoid breaking backward compatibility with other tool chains, this patch shows status, only if --verbose is specified,
mercurial/bookmarks.py
mercurial/commands.py
tests/test-bookmarks-pushpull.t
--- a/mercurial/bookmarks.py	Wed Apr 08 02:56:19 2015 +0900
+++ b/mercurial/bookmarks.py	Wed Apr 08 02:56:19 2015 +0900
@@ -494,18 +494,22 @@
         getid = lambda id: id
     else:
         getid = lambda id: id[:12]
-    def add(b, id):
-        outgoings.append("   %-25s %s\n" % (b, getid(id)))
+    if ui.verbose:
+        def add(b, id, st):
+            outgoings.append("   %-25s %s %s\n" % (b, getid(id), st))
+    else:
+        def add(b, id, st):
+            outgoings.append("   %-25s %s\n" % (b, getid(id)))
     for b, scid, dcid in addsrc:
-        add(b, scid)
+        add(b, scid, _('added'))
     for b, scid, dcid in adddst:
-        add(b, ' ' * 40)
+        add(b, ' ' * 40, _('deleted'))
     for b, scid, dcid in advsrc:
-        add(b, scid)
+        add(b, scid, _('advanced'))
     for b, scid, dcid in diverge:
-        add(b, scid)
+        add(b, scid, _('diverged'))
     for b, scid, dcid in differ:
-        add(b, scid)
+        add(b, scid, _('changed'))
 
     if not outgoings:
         ui.status(_("no changed bookmarks found\n"))
--- a/mercurial/commands.py	Wed Apr 08 02:56:19 2015 +0900
+++ b/mercurial/commands.py	Wed Apr 08 02:56:19 2015 +0900
@@ -4795,6 +4795,31 @@
 
     See pull for details of valid destination formats.
 
+    .. container:: verbose
+
+      With -B/--bookmarks, the result of bookmark comparison between
+      local and remote repositories is displayed. With -v/--verbose,
+      status is also displayed for each bookmark like below::
+
+        BM1               01234567890a added
+        BM2                            deleted
+        BM3               234567890abc advanced
+        BM4               34567890abcd diverged
+        BM5               4567890abcde changed
+
+      The action taken when pushing depends on the
+      status of each bookmark:
+
+      :``added``: push with ``-B`` will create it
+      :``deleted``: push with ``-B`` will delete it
+      :``advanced``: push will update it
+      :``diverged``: push with ``-B`` will update it
+      :``changed``: push with ``-B`` will update it
+
+      From the point of view of pushing behavior, bookmarks
+      existing only in the remote repository are treated as
+      ``deleted``, even if it is in fact added remotely.
+
     Returns 0 if there are outgoing changes, 1 otherwise.
     """
     if opts.get('graph'):
--- a/tests/test-bookmarks-pushpull.t	Wed Apr 08 02:56:19 2015 +0900
+++ b/tests/test-bookmarks-pushpull.t	Wed Apr 08 02:56:19 2015 +0900
@@ -534,13 +534,13 @@
   $ hg -R repo1 outgoing -B repo2 -v
   comparing with repo2
   searching for changed bookmarks
-     ADD_ON_REPO1              66f7d451a68b
-     ADD_ON_REPO2                          
-     ADV_ON_REPO1              fa942426a6fd
-     DIFF_ADV_ON_REPO1         6100d3090acf
-     DIFF_ADV_ON_REPO2         1ea73414a91b
-     DIFF_DIVERGED             6100d3090acf
-     DIVERGED                  66f7d451a68b
+     ADD_ON_REPO1              66f7d451a68b added
+     ADD_ON_REPO2                           deleted
+     ADV_ON_REPO1              fa942426a6fd advanced
+     DIFF_ADV_ON_REPO1         6100d3090acf advanced
+     DIFF_ADV_ON_REPO2         1ea73414a91b changed
+     DIFF_DIVERGED             6100d3090acf changed
+     DIVERGED                  66f7d451a68b diverged
 
   $ hg -R repo2 incoming -B repo1 -v
   comparing with repo1
@@ -553,13 +553,13 @@
   $ hg -R repo2 outgoing -B repo1 -v
   comparing with repo1
   searching for changed bookmarks
-     ADD_ON_REPO1                          
-     ADD_ON_REPO2              66f7d451a68b
-     ADV_ON_REPO2              66f7d451a68b
-     DIFF_ADV_ON_REPO1         1ea73414a91b
-     DIFF_ADV_ON_REPO2         e7bd5218ca15
-     DIFF_DIVERGED             e7bd5218ca15
-     DIVERGED                  fa942426a6fd
+     ADD_ON_REPO1                           deleted
+     ADD_ON_REPO2              66f7d451a68b added
+     ADV_ON_REPO2              66f7d451a68b advanced
+     DIFF_ADV_ON_REPO1         1ea73414a91b changed
+     DIFF_ADV_ON_REPO2         e7bd5218ca15 advanced
+     DIFF_DIVERGED             e7bd5218ca15 changed
+     DIVERGED                  fa942426a6fd diverged
 
   $ cd ..