[PATCH 4 of 5 V6-3] bookmarks: show more detail about incoming bookmarks

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Apr 3 12:21:03 CDT 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1428081282 -32400
#      Sat Apr 04 02:14:42 2015 +0900
# Node ID 52464858f510461d6714d50d68bcc961c8097ebc
# Parent  1bbe353452c4e9df453e2bd37b5a5ccc7a2f218b
bookmarks: show more detail about incoming bookmarks

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

This patch shows more detail about incoming bookmarks for "hg incoming
-B" with --verbose as below:

    BM1                       01234567890a (-) advanced remotely
    BM2                       1234567890ab (B) advanced locally
    BM3                       234567890abc (@) diverged
    BM4                       34567890abcd (?) changed

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

"action at pulling" column shows about bookmark updating in the local
repository by marks below:

  - "-": updated or added implicitly
  - "B": not updated implicitly (use -B to update forcibly)
  - "@": same as "B" except for implicit creation of diverged one
  - "?": undefined, because remote revision is unknown for local

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

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -456,18 +456,23 @@ def incoming(ui, repo, other):
         getid = lambda id: id
     else:
         getid = lambda id: id[:12]
-    def add(b, id):
-        incomings.append("   %-25s %s\n" % (b, getid(id)))
+    if ui.verbose:
+        def add(b, id, act, msg):
+            incomings.append("   %-25s %s (%s) %s\n" %
+                             (b, getid(id), act, msg))
+    else:
+        def add(b, id, act, msg):
+            incomings.append("   %-25s %s\n" % (b, getid(id)))
     for b, scid, dcid in addsrc:
-        add(b, scid)
+        add(b, scid, '-', _('added remotely'))
     for b, scid, dcid in advsrc:
-        add(b, scid)
+        add(b, scid, '-', _('advanced remotely'))
     for b, scid, dcid in advdst:
-        add(b, scid)
+        add(b, scid, 'B', _('advanced locally'))
     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 incomings:
         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
@@ -4159,6 +4159,29 @@ def import_(ui, repo, patch1=None, *patc
 
     .. 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 remotely
+        BM2               1234567890ab (B) advanced locally
+        BM3               234567890abc (@) diverged
+        BM4               34567890abcd (?) changed
+
+      Each lines consist of four columns: "bookmark name", "remote
+      value", "action at pulling" and "detail of difference".
+
+      "action at pulling" column shows about bookmark updating in the
+      local repository by marks below:
+
+      :``-``: updated or added implicitly
+      :``B``: not updated implicitly (use -B to update forcibly)
+      :``@``: same as ``B`` except for implicit creation of diverged one
+      :``?``: undefined, because remote revision is unknown for local
+
+    .. container:: verbose
+
       Examples:
 
       - import a traditional patch from a website and detect renames::
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
@@ -526,13 +526,13 @@ be excahnged)
   $ hg -R repo1 incoming -B repo2 -v
   comparing with repo2
   searching for changed bookmarks
-     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_REPO2              66f7d451a68b (-) added remotely
+     ADV_ON_REPO1              1ea73414a91b (B) advanced locally
+     ADV_ON_REPO2              66f7d451a68b (-) advanced remotely
+     DIFF_ADV_ON_REPO1         1ea73414a91b (B) advanced locally
+     DIFF_ADV_ON_REPO2         e7bd5218ca15 (?) changed
+     DIFF_DIVERGED             e7bd5218ca15 (?) changed
+     DIVERGED                  fa942426a6fd (@) diverged
   $ hg -R repo1 outgoing -B repo2 -v
   comparing with repo2
   searching for changed bookmarks
@@ -548,13 +548,13 @@ be excahnged)
   $ hg -R repo2 incoming -B repo1 -v
   comparing with repo1
   searching for changed bookmarks
-     ADD_ON_REPO1              66f7d451a68b
-     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 (-) added remotely
+     ADV_ON_REPO1              fa942426a6fd (-) advanced remotely
+     ADV_ON_REPO2              1ea73414a91b (B) advanced locally
+     DIFF_ADV_ON_REPO1         6100d3090acf (?) changed
+     DIFF_ADV_ON_REPO2         1ea73414a91b (B) advanced locally
+     DIFF_DIVERGED             6100d3090acf (?) changed
+     DIVERGED                  66f7d451a68b (@) diverged
   $ hg -R repo2 outgoing -B repo1 -v
   comparing with repo1
   searching for changed bookmarks


More information about the Mercurial-devel mailing list