changeset 1953:bdc5bb223b50

commit: wrap "commitstatus" to take topic into account The "created new head" message was appearing for every single commit made on a topic. It should now properly only appears when a new head is actually created on a topic.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 30 Mar 2016 23:58:30 -0700
parents 665d6322994e
children 61f36480740f
files hgext3rd/topic/topicmap.py tests/test-topic-dest.t tests/test-topic-push.t tests/test-topic-stack.t tests/test-topic.t
diffstat 5 files changed, 9 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/topicmap.py	Wed Mar 30 23:55:31 2016 -0700
+++ b/hgext3rd/topic/topicmap.py	Wed Mar 30 23:58:30 2016 -0700
@@ -4,6 +4,7 @@
 from mercurial import (
     branchmap,
     changegroup,
+    cmdutil,
     encoding,
     error,
     extensions,
@@ -67,6 +68,13 @@
     with usetopicmap(repo):
         return orig(repo, *args, **kwargs)
 
+def commitstatus(orig, repo, node, branch, bheads=None, opts=None):
+    # wrap commit status use the topic branch heads
+    ctx = repo[node]
+    if ctx.topic() and ctx.branch() == branch:
+        bheads = repo.branchheads("%s:%s" % (branch, ctx.topic()))
+    return orig(repo, node, branch, bheads=bheads, opts=opts)
+
 class topiccache(oldbranchcache):
 
     def __init__(self, *args, **kwargs):
@@ -236,3 +244,4 @@
 def modsetup(ui):
     """call at uisetup time to install various wrappings"""
     extensions.wrapfunction(changegroup.cg1unpacker, 'apply', cgapply)
+    extensions.wrapfunction(cmdutil, 'commitstatus', commitstatus)
--- a/tests/test-topic-dest.t	Wed Mar 30 23:55:31 2016 -0700
+++ b/tests/test-topic-dest.t	Wed Mar 30 23:58:30 2016 -0700
@@ -53,7 +53,6 @@
   $ echo zephir >> jungle
   $ hg add jungle
   $ hg ci -t monkey -m zephir
-  created new head
   $ hg log -G
   @  5 (monkey) zephir
   |
@@ -152,7 +151,6 @@
   $ echo "General Huc" >> monkeyville
   $ hg add monkeyville
   $ hg ci -t monkey -m Huc
-  created new head
   $ hg log -G
   @  9 (monkey) Huc
   |
@@ -313,10 +311,8 @@
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ echo arthur >> jungle
   $ hg ci -m arthur
-  created new head
   $ echo pompadour >> jungle
   $ hg ci -m pompadour
-  created new head
   $ hg up 'roots(all())'
   0 files updated, 0 files merged, 6 files removed, 0 files unresolved
   $ hg log -G
--- a/tests/test-topic-push.t	Wed Mar 30 23:55:31 2016 -0700
+++ b/tests/test-topic-push.t	Wed Mar 30 23:58:30 2016 -0700
@@ -130,7 +130,6 @@
   $ echo aaa > ddd
   $ hg add ddd
   $ hg commit -m 'CD'
-  created new head
   $ hg log -G # keep track of phase because I saw some strange bug during developement
   @  5 default babar draft CD
   |
@@ -187,7 +186,6 @@
   $ echo aaa > eee
   $ hg add eee
   $ hg commit -m 'CE'
-  created new head
   $ hg log -G # keep track of phase because I saw some strange bug during developement
   @  6 default celeste draft CE
   |
--- a/tests/test-topic-stack.t	Wed Mar 30 23:55:31 2016 -0700
+++ b/tests/test-topic-stack.t	Wed Mar 30 23:58:30 2016 -0700
@@ -26,15 +26,12 @@
   $ echo aaa > ddd
   $ hg add ddd
   $ hg commit -m c_d
-  created new head
   $ echo aaa > eee
   $ hg add eee
   $ hg commit -m c_e
-  created new head
   $ echo aaa > fff
   $ hg add fff
   $ hg commit -m c_f
-  created new head
   $ hg log -G
   @  5 default {foo} draft c_f
   |
@@ -149,11 +146,9 @@
   $ echo aaa > ggg
   $ hg add ggg
   $ hg commit -m c_g
-  created new head
   $ echo aaa > hhh
   $ hg add hhh
   $ hg commit -m c_h
-  created new head
   $ hg log -G
   @  11 default {foo} draft c_h
   |
--- a/tests/test-topic.t	Wed Mar 30 23:55:31 2016 -0700
+++ b/tests/test-topic.t	Wed Mar 30 23:58:30 2016 -0700
@@ -91,7 +91,6 @@
   narf
   $ echo 'narf!!!' >> alpha
   $ hg ci -m 'narf!'
-  created new head
   $ hg log -G
   @  changeset:   6:7c34953036d6
   |  tag:         tip
@@ -293,7 +292,6 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo answer >> alpha
   $ hg ci -m 'Narf is like `zort` or `poit`!'
-  created new head
   $ hg merge narf
   merging alpha
   warning: conflicts while merging alpha! (edit, then use 'hg resolve --mark')
@@ -305,7 +303,6 @@
   (no more unresolved files)
   $ hg topic narf
   $ hg ci -m 'Finish narf'
-  created new head
   $ hg topics
      fran
    * narf