Mercurial > evolve
diff hgext3rd/topic/__init__.py @ 2733:adfbb984ebbb
topics: check for topic on commit before a user enters message
We have a enforce-topic cofig which can forbid user to commit without a topic on
it. We used to check topic on a commit after the user enters message, but we
should fail early.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 14 Jul 2017 00:54:48 +0530 |
parents | d39942773163 |
children | 51afc979d88d |
line wrap: on
line diff
--- 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):