Patchwork [12,of,12,V2] bookmarks: show also about changed bookmarks in output of summary command

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Sept. 22, 2013, 2:05 p.m.
Message ID <7340fe0ad3df42910d09.1379858738@feefifofum>
Download mbox | patch
Permalink /patch/2609/
State Superseded
Headers show

Comments

Katsunori FUJIWARA - Sept. 22, 2013, 2:05 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1379858556 -32400
#      Sun Sep 22 23:02:36 2013 +0900
# Node ID 7340fe0ad3df42910d09581855599ac9ededc20e
# Parent  4e2e9a668f1437dbdbc4ac0baa0ace7c5d63df83
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)

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -487,13 +487,15 @@ 
 def summary(repo, other):
     results = compare(repo, other.listkeys('bookmarks'), repo._bookmarks,
                       dsthex=hex)
-    addsrc, adddst = 0, 0
+    addsrc, adddst, changed = 0, 0, 0
     for k, b, s, d in results:
         if k == 'addsrc':
             addsrc += 1
         elif k == 'adddst':
             adddst += 1
-    return (addsrc, adddst)
+        else:
+            changed += 1
+    return (addsrc, adddst, changed)
 
 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
@@ -5582,10 +5582,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
@@ -433,7 +433,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 ..
 
@@ -517,6 +517,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