Patchwork [4,of,5,V7] bookmarks: show detailed status about incoming bookmarks

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 7, 2015, 6:04 p.m.
Message ID <403afd0068bbec4a0b64.1428429846@juju>
Download mbox | patch
Permalink /patch/8537/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - April 7, 2015, 6:04 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1428429379 -32400
#      Wed Apr 08 02:56:19 2015 +0900
# Node ID 403afd0068bbec4a0b6481bf5eff0cc68ccd70ab
# Parent  0dcf5ab4a564ffbf51a9636813b846a012d32dbd
bookmarks: show detailed status 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 detailed status about incoming bookmarks at "hg
incoming -B".

To avoid breaking backward compatibility with other tool chains, this
patch shows status, only if --verbose is specified,

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -456,16 +456,20 @@  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, st):
+            incomings.append("   %-25s %s %s\n" % (b, getid(id), st))
+    else:
+        def add(b, id, st):
+            incomings.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 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 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
@@ -4297,6 +4297,29 @@  def incoming(ui, repo, source="default",
 
     .. 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               1234567890ab advanced
+        BM3               234567890abc diverged
+        BM4               34567890abcd changed
+
+      Action on the local repository side at pulling depends on the
+      status of each bookmarks:
+
+      :``added``: will create it
+      :``advanced``: will update it
+      :``diverged``: will create diverged one
+      :``changed``: undefined (remote revision is unknown for local)
+
+      From the point of view of pulling behavior, the bookmark
+      existing only in the remote repository is treated as ``added``,
+      even if it is deleted locally in fact.
+
+    .. container:: verbose
+
       For remote repository, using --bundle avoids downloading the
       changesets twice if the incoming is followed by a pull.
 
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,11 +526,11 @@  be excahnged)
   $ hg -R repo1 incoming -B repo2 -v
   comparing with repo2
   searching for changed bookmarks
-     ADD_ON_REPO2              66f7d451a68b
-     ADV_ON_REPO2              66f7d451a68b
-     DIFF_ADV_ON_REPO2         e7bd5218ca15
-     DIFF_DIVERGED             e7bd5218ca15
-     DIVERGED                  fa942426a6fd
+     ADD_ON_REPO2              66f7d451a68b added
+     ADV_ON_REPO2              66f7d451a68b advanced
+     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
@@ -545,11 +545,11 @@  be excahnged)
   $ hg -R repo2 incoming -B repo1 -v
   comparing with repo1
   searching for changed bookmarks
-     ADD_ON_REPO1              66f7d451a68b
-     ADV_ON_REPO1              fa942426a6fd
-     DIFF_ADV_ON_REPO1         6100d3090acf
-     DIFF_DIVERGED             6100d3090acf
-     DIVERGED                  66f7d451a68b
+     ADD_ON_REPO1              66f7d451a68b added
+     ADV_ON_REPO1              fa942426a6fd advanced
+     DIFF_ADV_ON_REPO1         6100d3090acf changed
+     DIFF_DIVERGED             6100d3090acf changed
+     DIVERGED                  66f7d451a68b diverged
   $ hg -R repo2 outgoing -B repo1 -v
   comparing with repo1
   searching for changed bookmarks