topic: suggest using topic when user creates a new head on branch
This patch adds a message to use topics when user creates a new head on a
branch.
--- a/CHANGELOG Mon Jan 15 18:41:29 2018 +0100
+++ b/CHANGELOG Wed Dec 27 04:09:50 2017 +0530
@@ -19,6 +19,7 @@
* evolve: changes to the on disk format for interrupted evolve
* evolve: preserve phase information with --continue (issue5720)
* evolve: --continue now properly reports merges as evolve
+ * commit: suggest using topic on new heads
topic (0.7.1)
--- a/hgext3rd/topic/topicmap.py Mon Jan 15 18:41:29 2018 +0100
+++ b/hgext3rd/topic/topicmap.py Wed Dec 27 04:09:50 2017 +0530
@@ -1,6 +1,7 @@
import contextlib
import hashlib
+from mercurial.i18n import _
from mercurial.node import nullid
from mercurial import (
branchmap,
@@ -94,7 +95,23 @@
if ctx.topic() and ctx.branch() == branch:
subbranch = "%s:%s" % (branch, ctx.topic())
bheads = repo.branchheads("%s:%s" % (subbranch, ctx.topic()))
- return orig(repo, node, branch, bheads=bheads, opts=opts)
+
+ ret = orig(repo, node, branch, bheads=bheads, opts=opts)
+
+ # logic copy-pasted from cmdutil.commitstatus()
+ if opts is None:
+ opts = {}
+ ctx = repo[node]
+ if ctx.topic():
+ return ret
+ parents = ctx.parents()
+
+ if (not opts.get('amend') and bheads and node not in bheads and not
+ [x for x in parents if x.node() in bheads and x.branch() == branch]):
+ repo.ui.status(_("(consider using topic for lightweight branches."
+ " See 'hg help topic')\n"))
+
+ return ret
def _wrapbmcache(ui):
class topiccache(_topiccache, branchmap.branchcache):
--- a/tests/test-minitopic.t Mon Jan 15 18:41:29 2018 +0100
+++ b/tests/test-minitopic.t Wed Dec 27 04:09:50 2017 +0530
@@ -81,6 +81,7 @@
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ mkcommit c_C0
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
$ hg push enabled
pushing to http://localhost:$HGPORT/
searching for changes
--- a/tests/test-stack-branch.t Mon Jan 15 18:41:29 2018 +0100
+++ b/tests/test-stack-branch.t Wed Dec 27 04:09:50 2017 +0530
@@ -181,6 +181,7 @@
$ hg add ggg
$ hg commit -m c_g
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
$ echo aaa > hhh
$ hg add hhh
$ hg commit -m c_h
--- a/tests/test-topic-flow-publish-bare.t Mon Jan 15 18:41:29 2018 +0100
+++ b/tests/test-topic-flow-publish-bare.t Wed Dec 27 04:09:50 2017 +0530
@@ -52,10 +52,12 @@
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ mkcommit c_dC0
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
$ hg update 'desc("c_dA0")'
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ mkcommit c_dD0
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
$ hg push -f
pushing to $TESTTMP/bare-branch-server
searching for changes
--- a/tests/test-topic-flow-single-head.t Mon Jan 15 18:41:29 2018 +0100
+++ b/tests/test-topic-flow-single-head.t Wed Dec 27 04:09:50 2017 +0530
@@ -63,6 +63,7 @@
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ mkcommit c_dD0
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
$ hg push -f
pushing to $TESTTMP/single-head-server
searching for changes
--- a/tests/test-topic-fold.t Mon Jan 15 18:41:29 2018 +0100
+++ b/tests/test-topic-fold.t Wed Dec 27 04:09:50 2017 +0530
@@ -78,6 +78,7 @@
$ hg topic --clear
$ mkcommit feature3
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
$ hg topic myotherfeature
marked working directory as topic: myotherfeature
$ mkcommit feature4
--- a/tests/test-topic-push-concurrent-on.t Mon Jan 15 18:41:29 2018 +0100
+++ b/tests/test-topic-push-concurrent-on.t Wed Dec 27 04:09:50 2017 +0530
@@ -58,6 +58,7 @@
$ hg add ccc
$ hg commit -m 'CC'
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
$ hg outgoing -G
comparing with $TESTTMP/main (glob)
searching for changes
@@ -313,6 +314,7 @@
$ hg add ggg
$ hg commit -m 'CG'
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
$ hg up 'desc(CF)'
switching to topic babar
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
--- a/tests/test-topic-push.t Mon Jan 15 18:41:29 2018 +0100
+++ b/tests/test-topic-push.t Wed Dec 27 04:09:50 2017 +0530
@@ -54,6 +54,7 @@
$ hg add ccc
$ hg commit -m 'CC'
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
$ hg outgoing -G
comparing with $TESTTMP/main (glob)
searching for changes
@@ -364,6 +365,7 @@
$ hg add ggg
$ hg commit -m 'CG'
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
$ hg up 'desc(CF)'
switching to topic babar
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
--- a/tests/test-topic-rebase.t Mon Jan 15 18:41:29 2018 +0100
+++ b/tests/test-topic-rebase.t Wed Dec 27 04:09:50 2017 +0530
@@ -101,6 +101,7 @@
$ echo "A" > file
$ hg commit -A -m "default2" file
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
Update the common file in a topic
$ hg topic myotherfeature
--- a/tests/test-topic-stack-data.t Mon Jan 15 18:41:29 2018 +0100
+++ b/tests/test-topic-stack-data.t Wed Dec 27 04:09:50 2017 +0530
@@ -44,6 +44,7 @@
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ mkcommit lake_c
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
Add some topics
--- a/tests/test-topic.t Mon Jan 15 18:41:29 2018 +0100
+++ b/tests/test-topic.t Wed Dec 27 04:09:50 2017 +0530
@@ -612,6 +612,7 @@
$ echo fran? >> beta
$ hg ci -m 'fran?'
created new head
+ (consider using topic for lightweight branches. See 'hg help topic')
$ hg log -Gr 'draft()'
@ changeset: 10:4073470c35e1
| tag: tip