[PATCH 5 of 5 V7] bookmarks: show detailed status about outgoing bookmarks

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Apr 7 13:04:07 CDT 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1428429379 -32400
#      Wed Apr 08 02:56:19 2015 +0900
# Node ID 758dc9b5159d33f21473bb784e0e3301ff1610ee
# Parent  403afd0068bbec4a0b6481bf5eff0cc68ccd70ab
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,

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -494,18 +494,22 @@ def outgoing(ui, repo, other):
         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"))
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4792,6 +4792,31 @@ def outgoing(ui, repo, dest=None, **opts
 
     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 bookmarks like below::
+
+        BM1               01234567890a added
+        BM2                            deleted
+        BM3               234567890abc advanced
+        BM4               34567890abcd diverged
+        BM5               4567890abcde changed
+
+      Action on the remote repository side at pushing depends on the
+      status of each bookmarks:
+
+      :``added``: will create it, only if specified by ``-B``
+      :``deleted``: will delete it, only if specified by ``-B``
+      :``advanced``: will update it
+      :``diverged``: will update it, only if specified by ``-B``
+      :``changed``: will update it, only if specified by ``-B``
+
+      From the point of view of pushing behavior, the bookmark
+      existing only in the remote repository is treated as
+      ``deleted``, even if it is added remotely in fact.
+
     Returns 0 if there are outgoing changes, 1 otherwise.
     """
     if opts.get('graph'):
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -534,13 +534,13 @@ be excahnged)
   $ 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 @@ be excahnged)
   $ 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 ..
 


More information about the Mercurial-devel mailing list