comparison hgext3rd/topic/__init__.py @ 3024:89855920fb0f

topicmode: 'enforce' topic mode, no longer warn about untopiced merge merging a topic back in a branch is common case, it seems sensible to not pester the user about it.
author Boris Feld <boris.feld@octobus.net>
date Sat, 30 Sep 2017 23:18:29 +0100
parents cc740c545776
children e814c553ef32
comparison
equal deleted inserted replaced
3023:cc740c545776 3024:89855920fb0f
57 57
58 [experimental] 58 [experimental]
59 # behavior when commit is made without an active topic 59 # behavior when commit is made without an active topic
60 topic-mode = ignore # do nothing special (default) 60 topic-mode = ignore # do nothing special (default)
61 topic-mode = warning # print a warning 61 topic-mode = warning # print a warning
62 topic-mode = enforce # abort the commit 62 topic-mode = enforce # abort the commit (except for merge)
63 """ 63 """
64 64
65 from __future__ import absolute_import 65 from __future__ import absolute_import
66 66
67 import re 67 import re
909 return topicmode 909 return topicmode
910 910
911 def commitwrap(orig, ui, repo, *args, **opts): 911 def commitwrap(orig, ui, repo, *args, **opts):
912 with repo.wlock(): 912 with repo.wlock():
913 topicmode = _configtopicmode(ui) 913 topicmode = _configtopicmode(ui)
914 ismergecommit = len(repo[None].parents()) == 2
915
916 notopic = not repo.currenttopic
917 mayabort = (topicmode == "enforce" and not ismergecommit)
918 maywarn = (topicmode == "warning"
919 or (topicmode == "enforce" and ismergecommit))
920
914 if opts.get('topic'): 921 if opts.get('topic'):
915 t = opts['topic'] 922 t = opts['topic']
916 with repo.vfs.open('topic', 'w') as f: 923 with repo.vfs.open('topic', 'w') as f:
917 f.write(t) 924 f.write(t)
918 elif not repo.currenttopic and topicmode == "enforce": 925 elif notopic and mayabort:
919 msg = _("no active topic") 926 msg = _("no active topic")
920 hint = _("set a current topic or use '--config " + 927 hint = _("set a current topic or use '--config " +
921 "experimental.topic-mode=off' to commit without a topic") 928 "experimental.topic-mode=off' to commit without a topic")
922 raise error.Abort(msg, hint=hint) 929 raise error.Abort(msg, hint=hint)
923 elif not repo.currenttopic and topicmode == 'warning': 930 elif notopic and maywarn:
924 ui.warn(_("warning: new draft commit without topic\n")) 931 ui.warn(_("warning: new draft commit without topic\n"))
925 return orig(ui, repo, *args, **opts) 932 return orig(ui, repo, *args, **opts)
926 933
927 def committextwrap(orig, repo, ctx, subs, extramsg): 934 def committextwrap(orig, repo, ctx, subs, extramsg):
928 ret = orig(repo, ctx, subs, extramsg) 935 ret = orig(repo, ctx, subs, extramsg)