Patchwork [15,of,15,V5] bookmarks: show also about changed bookmarks in output of summary command

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Nov. 8, 2013, 3:54 a.m.
Message ID <db2cbb2b70ca3ceff205.1383882865@juju>
Download mbox | patch
Permalink /patch/2885/
State Superseded
Headers show

Comments

Katsunori FUJIWARA - Nov. 8, 2013, 3:54 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1383882353 -32400
#      Fri Nov 08 12:45:53 2013 +0900
# Node ID db2cbb2b70ca3ceff205e7278ea8fc4e1f973057
# Parent  59cb9a813e264cb14ba1e26103c17307bdd14e3f
bookmarks: show also about changed bookmarks in output of summary command

Before this patch, "hg summary --remote" shows information only about
bookmarks newly added locally or remotely.

This patch shows also the number of bookmarks changed locally or
remotely, and this may lead users to compare bookmarks between
repositories by "hg incoming -B" and/or "hg outgoing -B".

This patch also changes output format of bookmark information to
prevent "remote:" line from being too long.

  old:
    remote: ...., N incoming bookmarks, M outgoing bookmarks

  new:
    remote: ...., bookmarks (N incoming, M outgoing, L changed)
Siddharth Agarwal - Nov. 19, 2013, 9:40 p.m.
On 11/07/2013 07:54 PM, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1383882353 -32400
> #      Fri Nov 08 12:45:53 2013 +0900
> # Node ID db2cbb2b70ca3ceff205e7278ea8fc4e1f973057
> # Parent  59cb9a813e264cb14ba1e26103c17307bdd14e3f
> bookmarks: show also about changed bookmarks in output of summary command

These patches look good, aside from my comments.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -483,7 +483,7 @@ 
     (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
      ) = compare(repo, other.listkeys('bookmarks'), repo._bookmarks,
                  dsthex=hex)
-    return (len(addsrc), len(adddst))
+    return (len(addsrc), len(adddst), len(advsrc + advdst + diverge + differ))
 
 def validdest(repo, old, new):
     """Is the new bookmark destination a valid update from the old one"""
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5591,10 +5591,15 @@ 
             t.append(_('%d outgoing') % len(o))
         if 'bookmarks' in other.listkeys('namespaces'):
             counts = bookmarks.summary(repo, other)
+            b = []
             if counts[0] > 0:
-                t.append(_('%d incoming bookmarks') % counts[0])
+                b.append(_('%d incoming') % counts[0])
             if counts[1] > 0:
-                t.append(_('%d outgoing bookmarks') % counts[1])
+                b.append(_('%d outgoing') % counts[1])
+            if counts[2] > 0:
+                b.append(_('%d changed') % counts[2])
+            if b:
+                t.append(_('bookmarks (%s)') % (', '.join(b)))
 
         if t:
             # i18n: column positioning for "hg summary"
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
@@ -464,7 +464,7 @@ 
   $ hg bookmarks -d X
   $ hg bookmarks -d Y
   $ hg summary --remote | grep '^remote:'
-  remote: *2 incoming bookmarks, 1 outgoing bookmarks (glob)
+  remote: 1 outgoing, bookmarks (2 incoming, 1 outgoing, 1 changed)
 
   $ cd ..
 
@@ -548,6 +548,9 @@ 
      DIFF_DIVERGED             6100d3090acf (B) changed
      DIVERGED                  66f7d451a68b (B) diverged
 
+  $ hg -R repo1 summary --remote --config paths.default=repo2 | grep '^remote:'
+  remote: 1 or more incoming, 1 outgoing, bookmarks (1 incoming, 1 outgoing, 6 changed)
+
   $ hg -R repo2 incoming -B repo1
   comparing with repo1
   searching for changed bookmarks