Mercurial > evolve
changeset 3023:cc740c545776
topicmode: add new warning topicmode
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Sat, 30 Sep 2017 23:00:21 +0100 |
parents | 255e66783505 |
children | 89855920fb0f |
files | hgext3rd/topic/__init__.py tests/test-topic.t tests/test-topicmode.t |
diffstat | 3 files changed, 73 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Sun Oct 01 00:14:19 2017 +0100 +++ b/hgext3rd/topic/__init__.py Sat Sep 30 23:00:21 2017 +0100 @@ -58,6 +58,7 @@ [experimental] # behavior when commit is made without an active topic topic-mode = ignore # do nothing special (default) + topic-mode = warning # print a warning topic-mode = enforce # abort the commit """ @@ -888,6 +889,7 @@ _validmode = [ 'ignore', + 'warning', 'enforce', ] @@ -918,6 +920,8 @@ hint = _("set a current topic or use '--config " + "experimental.topic-mode=off' to commit without a topic") raise error.Abort(msg, hint=hint) + elif not repo.currenttopic and topicmode == 'warning': + ui.warn(_("warning: new draft commit without topic\n")) return orig(ui, repo, *args, **opts) def committextwrap(orig, repo, ctx, subs, extramsg):
--- a/tests/test-topic.t Sun Oct 01 00:14:19 2017 +0100 +++ b/tests/test-topic.t Sat Sep 30 23:00:21 2017 +0100 @@ -943,6 +943,7 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: added a + Testing the --age flag for `hg topics` ======================================
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-topicmode.t Sat Sep 30 23:00:21 2017 +0100 @@ -0,0 +1,68 @@ + $ . "$TESTDIR/testlib/topic_setup.sh" + +Testing the new config knob to forbid untopiced commit +====================================================== + + $ hg init $TESTTMP/untopic-commit + $ cd $TESTTMP/untopic-commit + $ cat <<EOF >> .hg/hgrc + > [phases] + > publish=false + > EOF + $ cat <<EOF >> $HGRCPATH + > [experimental] + > topic-mode = enforce + > EOF + $ touch a b c d + $ hg add a + $ hg ci -m "Added a" + abort: no active topic + (set a current topic or use '--config experimental.topic-mode=off' to commit without a topic) + [255] + +(same test, checking we abort before the editor) + + $ EDITOR=cat hg ci -m "Added a" --edit + abort: no active topic + (set a current topic or use '--config experimental.topic-mode=off' to commit without a topic) + [255] + $ hg ci -m "added a" --config experimental.topic-mode=off + $ hg log + changeset: 0:a154386e50d1 + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: added a + + +Testing the new config knob to warn about untopiced commit +========================================================== + + $ hg init $TESTTMP/untopic-warn-commit + $ cd $TESTTMP/untopic-warn-commit + $ cat <<EOF >> .hg/hgrc + > [phases] + > publish=false + > EOF + $ cat <<EOF >> $HGRCPATH + > [experimental] + > topic-mode = warning + > EOF + $ touch a b c d + $ hg add a + $ hg ci -m "Added a" + warning: new draft commit without topic + +(same test, checking we abort before the editor) + + $ EDITOR=cat hg ci --amend -m "Added a" --edit + warning: new draft commit without topic + $ hg ci --amend -m "added a'" --config experimental.topic-mode=off + $ hg log + changeset: 2:2e862d8b5eff + tag: tip + parent: -1:000000000000 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: added a' +