--- a/hgext3rd/topic/__init__.py Fri Jul 14 03:14:27 2017 +0200
+++ b/hgext3rd/topic/__init__.py Fri Jul 14 00:54:48 2017 +0530
@@ -235,11 +235,6 @@
current = self.currenttopic
if current:
ctx.extra()[constants.extrakey] = current
- else:
- if ui.configbool('experimental', 'enforce-topic', False):
- # calling a function to raise an error as error variable
- # in this function does not refer to the error module
- panicforuntopicedcommit()
if (isinstance(ctx, context.memctx) and
ctx.extra().get('amend_source') and
ctx.topic() and
@@ -576,12 +571,6 @@
return topicstime
-def panicforuntopicedcommit():
- msg = _("no active topic")
- hint = _("set a current topic or use '--config " +
- "experimental.enforce-topic=no' to commit without a topic")
- raise error.Abort(msg, hint=hint)
-
def summaryhook(ui, repo):
t = repo.currenttopic
if not t:
@@ -591,10 +580,16 @@
def commitwrap(orig, ui, repo, *args, **opts):
with repo.wlock():
+ enforcetopic = ui.configbool('experimental', 'enforce-topic')
if opts.get('topic'):
t = opts['topic']
with repo.vfs.open('topic', 'w') as f:
f.write(t)
+ elif not repo.currenttopic and enforcetopic:
+ msg = _("no active topic")
+ hint = _("set a current topic or use '--config " +
+ "experimental.enforce-topic=no' to commit without a topic")
+ raise error.Abort(msg, hint=hint)
return orig(ui, repo, *args, **opts)
def committextwrap(orig, repo, ctx, subs, extramsg):