test: add support for random-all topic mode
The 'random' mode no longer generate a random topic for merge.
--- a/hgext3rd/topic/__init__.py Sun Oct 01 10:44:23 2017 +0100
+++ b/hgext3rd/topic/__init__.py Sun Oct 01 11:13:38 2017 +0100
@@ -61,7 +61,8 @@
topic-mode = warning # print a warning
topic-mode = enforce # abort the commit (except for merge)
topic-mode = enforce-all # abort the commit (even for merge)
- topic-mode = random # use a randomized generated topic (even for merge)
+ topic-mode = random # use a randomized generated topic (except for merge)
+ topic-mode = random-all # use a randomized generated topic (even for merge)
"""
from __future__ import absolute_import
@@ -896,6 +897,7 @@
'enforce',
'enforce-all',
'random',
+ 'random-all',
]
def _configtopicmode(ui):
@@ -923,6 +925,12 @@
maywarn = (topicmode == "warning"
or (topicmode == "enforce" and ismergecommit))
+ mayrandom = False
+ if topicmode == "random":
+ mayrandom = not ismergecommit
+ elif topicmode == "random-all":
+ mayrandom = True
+
if topicmode == 'enforce-all':
ismergecommit = False
mayabort = True
@@ -940,7 +948,7 @@
ui.warn(_("warning: new draft commit without topic\n"))
if not ui.quiet:
ui.warn(("(%s)") % hint)
- elif notopic and topicmode == "random":
+ elif notopic and mayrandom:
with repo.vfs.open('topic', 'w') as f:
f.write(randomname.randomtopicname(ui))
return orig(ui, repo, *args, **opts)
--- a/tests/test-topic-mode.t Sun Oct 01 10:44:23 2017 +0100
+++ b/tests/test-topic-mode.t Sun Oct 01 11:13:38 2017 +0100
@@ -218,3 +218,96 @@
$ hg add B
$ hg commit -m "Add B" --config devel.randomseed=128
active topic 'various-dove' grew its first changeset
+
+Test a merge too
+
+ $ hg phase --public -r .
+ active topic 'various-dove' is now empty
+ $ hg up default
+ clearing empty topic "various-dove"
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg log -G
+ @ changeset: 2:2d2acb6efad5
+ | tag: tip
+ | parent: 0:ec1d2790416d
+ | user: test
+ | date: Thu Jan 01 00:00:00 1970 +0000
+ | summary: Add B
+ |
+ | o changeset: 1:d4b548f35972
+ |/ topic: panoramic-antelope
+ | user: test
+ | date: Thu Jan 01 00:00:00 1970 +0000
+ | summary: Add A
+ |
+ o changeset: 0:ec1d2790416d
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: ROOT
+
+ $ hg merge panoramic-antelope
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ (branch merge, don't forget to commit)
+ $ hg ci -m 'merge'
+Testing the config knob to use a random topic for untopic commit (even for merge)
+=================================================================================
+
+ $ hg init $TESTTMP/test-untopic-random-all
+ $ cd $TESTTMP/test-untopic-random-all
+ $ cat <<EOF >> .hg/hgrc
+ > [phases]
+ > publish=false
+ > EOF
+ $ cat <<EOF >> $HGRCPATH
+ > [experimental]
+ > topic-mode = random-all
+ > EOF
+
+ $ touch ROOT
+ $ hg commit -A -m "ROOT" --config experimental.topic-mode=off
+ adding ROOT
+
+ $ touch A
+ $ hg add A
+ $ hg commit -m "Add A" --config devel.randomseed=42
+ active topic 'panoramic-antelope' grew its first changeset
+
+ $ hg up -r "desc(ROOT)"
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+
+ $ touch B
+ $ hg add B
+ $ hg commit -m "Add B" --config devel.randomseed=128
+ active topic 'various-dove' grew its first changeset
+
+Test a merge too
+
+ $ hg phase --public -r .
+ active topic 'various-dove' is now empty
+ $ hg up default
+ clearing empty topic "various-dove"
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg log -G
+ @ changeset: 2:2d2acb6efad5
+ | tag: tip
+ | parent: 0:ec1d2790416d
+ | user: test
+ | date: Thu Jan 01 00:00:00 1970 +0000
+ | summary: Add B
+ |
+ | o changeset: 1:d4b548f35972
+ |/ topic: panoramic-antelope
+ | user: test
+ | date: Thu Jan 01 00:00:00 1970 +0000
+ | summary: Add A
+ |
+ o changeset: 0:ec1d2790416d
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: ROOT
+
+ $ hg merge panoramic-antelope
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ (branch merge, don't forget to commit)
+ $ hg ci -m 'merge' --config devel.randomseed=1337
+ active topic 'omniscient-locust' grew its first changeset