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

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 15, 2013, 3:25 p.m.
Message ID <11f692e4c620997fb5cd.1381850737@juju>
Download mbox | patch
Permalink /patch/2786/
State Superseded
Headers show

Comments

Katsunori FUJIWARA - Oct. 15, 2013, 3:25 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1381849966 -32400
#      Wed Oct 16 00:12:46 2013 +0900
# Node ID 11f692e4c620997fb5cd42a03d51311da907bd10
# Parent  6ab7b4f3013bc54016f6c0ecbad19b4e948b5c77
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
@@ -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
@@ -5585,10 +5585,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