Patchwork [5,of,5,V6-3] bookmarks: show more detail about outgoing bookmarks

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 3, 2015, 5:21 p.m.
Message ID <6d18e52b266b9793adb7.1428081664@juju>
Download mbox | patch
Permalink /patch/8482/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - April 3, 2015, 5:21 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1428081282 -32400
#      Sat Apr 04 02:14:42 2015 +0900
# Node ID 6d18e52b266b9793adb7eca1dbd9453bb05750d6
# Parent  52464858f510461d6714d50d68bcc961c8097ebc
bookmarks: show more detail about outgoing bookmarks

Before this patch, "hg outgoing -B" shows only difference of bookmarks
between two repositories, and it isn't user friendly.

With "--verbose", this patch shows more detail about outgoing
bookmarks for "hg outgoing -B" as follows:

    BM1                       01234567890a (-) advanced locally
    BM2                       1234567890ab (B) diverged
    BM3                                    (B) deleted locally, perhaps

Each lines consist of four columns: "bookmark name", "local value",
"action at pushing" and "detail of difference".

"action at pushing" column shows about bookmark updating in the remote
repository by marks below:

  - "-": updated implicitly
  - "B": not updated implicitly (use -B to update forcibly)

From the point of view of "hg push" behavior, this patch shows
"deleted locally, perhaps" for the bookmark existing only in the
remote repository, even if it is added remotely in fact.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -497,20 +497,25 @@  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, act, msg):
+            outgoings.append("   %-25s %s (%s) %s\n" %
+                             (b, getid(id), act, msg))
+    else:
+        def add(b, id, act, msg):
+            outgoings.append("   %-25s %s\n" % (b, getid(id)))
     for b, scid, dcid in addsrc:
-        add(b, scid)
+        add(b, scid, 'B', _('added locally'))
     for b, scid, dcid in adddst:
-        add(b, ' ' * 40)
+        add(b, ' ' * 40, 'B', _('deleted locally, perhaps'))
     for b, scid, dcid in advsrc:
-        add(b, scid)
+        add(b, scid, '-', _('advanced locally'))
     for b, scid, dcid in advdst:
-        add(b, scid)
+        add(b, scid, 'B', _('advanced remotely'))
     for b, scid, dcid in diverge:
-        add(b, scid)
+        add(b, scid, 'B', _('diverged'))
     for b, scid, dcid in differ:
-        add(b, scid)
+        add(b, scid, 'B', _('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,25 @@  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. In addition to it,
+      -v/--verbose shows also detail for each bookmarks in the format
+      below::
+
+        BM1               01234567890a (-) advanced locally
+        BM2               1234567890ab (B) diverged
+
+      Each lines consist of four columns: "bookmark name", "local
+      value", "action at pushing" and "detail of difference".
+
+      "action at pushing" column shows about bookmark updating in the
+      remote repository by marks below:
+
+      :``-``: updated implicitly
+      :``B``: not updated implicitly (use -B to update forcibly)
+
     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
@@ -536,14 +536,14 @@  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
-     ADV_ON_REPO2              1ea73414a91b
-     DIFF_ADV_ON_REPO1         6100d3090acf
-     DIFF_ADV_ON_REPO2         1ea73414a91b
-     DIFF_DIVERGED             6100d3090acf
-     DIVERGED                  66f7d451a68b
+     ADD_ON_REPO1              66f7d451a68b (B) added locally
+     ADD_ON_REPO2                           (B) deleted locally, perhaps
+     ADV_ON_REPO1              fa942426a6fd (-) advanced locally
+     ADV_ON_REPO2              1ea73414a91b (B) advanced remotely
+     DIFF_ADV_ON_REPO1         6100d3090acf (-) advanced locally
+     DIFF_ADV_ON_REPO2         1ea73414a91b (B) changed
+     DIFF_DIVERGED             6100d3090acf (B) changed
+     DIVERGED                  66f7d451a68b (B) diverged
 
   $ hg -R repo2 incoming -B repo1 -v
   comparing with repo1
@@ -558,14 +558,14 @@  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_REPO1              1ea73414a91b
-     ADV_ON_REPO2              66f7d451a68b
-     DIFF_ADV_ON_REPO1         1ea73414a91b
-     DIFF_ADV_ON_REPO2         e7bd5218ca15
-     DIFF_DIVERGED             e7bd5218ca15
-     DIVERGED                  fa942426a6fd
+     ADD_ON_REPO1                           (B) deleted locally, perhaps
+     ADD_ON_REPO2              66f7d451a68b (B) added locally
+     ADV_ON_REPO1              1ea73414a91b (B) advanced remotely
+     ADV_ON_REPO2              66f7d451a68b (-) advanced locally
+     DIFF_ADV_ON_REPO1         1ea73414a91b (B) changed
+     DIFF_ADV_ON_REPO2         e7bd5218ca15 (-) advanced locally
+     DIFF_DIVERGED             e7bd5218ca15 (B) changed
+     DIVERGED                  fa942426a6fd (B) diverged
 
   $ cd ..