[PATCH 1 of 2 V2] destutil: show branch head information even if parent is at active bookmark

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Feb 28 17:27:24 UTC 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1456680134 -32400
#      Mon Feb 29 02:22:14 2016 +0900
# Node ID a694cb0ea3a9ca64ac729c8fb2d507fb188eae97
# Parent  10eaae94523c790d7b77c52a4cb4bfcf406021ef
destutil: show branch head information even if parent is at active bookmark

Before this patch, active bookmark at parent always causes omission of
the message 'N other heads for branch "BRANCH"', even if there are
other branch heads.

If there are divergent bookmarks, this behavior is reasonable, because
this omission makes user focus on resolving divergence of
bookmark. But otherwise, this might make user overlook other branch
heads.

This patch makes _statusotherbook() return whether any message is
displayed or not, and invokes _statusotherbranchheads() if not.

diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -347,6 +347,10 @@ def desthistedit(ui, repo):
     return None
 
 def _statusotherbook(ui, repo):
+    """Show important message for other bookmarks, if needed
+
+    Return whether message is displayed or not
+    """
     bmheads = repo.bookmarkheads(repo._activebookmark)
     curhead = repo[repo._activebookmark].node()
     if repo.revs('%n and parents()', curhead):
@@ -355,6 +359,7 @@ def _statusotherbook(ui, repo):
         if bmheads:
             msg = _('%i other divergent bookmarks for "%s"\n')
             ui.status(msg % (len(bmheads), repo._activebookmark))
+            return True
 
 def _statusotherbranchheads(ui, repo):
     currentbranch = repo.dirstate.branch()
@@ -372,7 +377,5 @@ def statusotherdests(ui, repo):
     # XXX we should probably include a hint:
     # - about what to do
     # - how to see such heads
-    if repo._activebookmark:
-        _statusotherbook(ui, repo)
-    else:
+    if not repo._activebookmark or not _statusotherbook(ui, repo):
         _statusotherbranchheads(ui, repo)
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -562,11 +562,15 @@ update to active bookmark if it's not th
   $ hg update
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   updating bookmark Z
+  1 other heads for branch "default"
   $ hg bookmarks
      X2                        1:925d80f479bb
      Y                         2:db815d6d32e6
    * Z                         3:125c9a1d6df6
      x  y                      2:db815d6d32e6
+  $ hg heads -q .
+  3:125c9a1d6df6
+  1:925d80f479bb
 
 pull --update works the same as pull && update
 
@@ -600,6 +604,12 @@ pull --update works the same as pull && 
   updating to active bookmark Y
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (activating bookmark Y)
+  1 other heads for branch "default"
+  $ hg parents -q
+  3:125c9a1d6df6
+  $ hg heads -q .
+  3:125c9a1d6df6
+  1:925d80f479bb
 
 (all in one version)
 
@@ -617,6 +627,12 @@ pull --update works the same as pull && 
   updating bookmark Z
   updating to active bookmark Y
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 other heads for branch "default"
+  $ hg parents -q
+  3:125c9a1d6df6
+  $ hg heads -q .
+  3:125c9a1d6df6
+  1:925d80f479bb
 
 We warn about divergent during bare update to the active bookmark
 
@@ -818,8 +834,12 @@ case)
   adding remote bookmark four
   adding remote bookmark should-end-on-two
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 other heads for branch "default"
   $ hg -R ../cloned-bookmarks-update parents -T "{rev}:{node|short}\n"
   3:125c9a1d6df6
+  $ hg -R ../cloned-bookmarks-update heads -q .
+  3:125c9a1d6df6
+  1:925d80f479bb
   $ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y '
    * Y                         3:125c9a1d6df6
 
@@ -841,8 +861,12 @@ updates the working directory and curren
   added 1 changesets with 1 changes to 1 files
   divergent bookmark Z stored as Z at default
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 other heads for branch "default"
   updating bookmark Y
   $ hg -R ../cloned-bookmarks-update parents -T "{rev}:{node|short}\n"
   6:81dcce76aa0b
+  $ hg -R ../cloned-bookmarks-update heads -q .
+  6:81dcce76aa0b
+  1:925d80f479bb
   $ hg -R ../cloned-bookmarks-update bookmarks | grep ' Y '
    * Y                         6:81dcce76aa0b


More information about the Mercurial-devel mailing list