Mercurial > evolve
changeset 4044:c0fbe70f2e48
topic: check that repo.currenttopic is set before using it as an argument
repo.currenttopic can be an empty string, which means there's no current topic
set. This fact can be used to short-circuit some checks.
Also, this avoids passing an empty string as an argument to topic() revset.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Tue, 28 Aug 2018 21:28:41 +0800 |
parents | 503ae2689df8 |
children | 821e4be40c6c |
files | hgext3rd/topic/__init__.py hgext3rd/topic/destination.py |
diffstat | 2 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Wed Aug 29 18:59:07 2018 +0200 +++ b/hgext3rd/topic/__init__.py Tue Aug 28 21:28:41 2018 +0800 @@ -644,9 +644,9 @@ ct = repo.currenttopic if clear: - empty = stack.stack(repo, topic=ct).changesetcount == 0 - if empty: - if ct: + if ct: + empty = stack.stack(repo, topic=ct).changesetcount == 0 + if empty: ui.status(_('clearing empty topic "%s"\n') % ct) return _changecurrenttopic(repo, None) @@ -1149,7 +1149,6 @@ # rebased commit. We have explicitly stored in config if rebase is # running. ot = repo.currenttopic - empty = stack.stack(repo, topic=ot).changesetcount == 0 if repo.ui.hasconfig('experimental', 'topicrebase'): isrebase = True if repo.ui.configbool('_internal', 'keep-topic'): @@ -1163,8 +1162,10 @@ f.write(t) if t and t != ot: repo.ui.status(_("switching to topic %s\n") % t) - if ot and not t and empty: - repo.ui.status(_('clearing empty topic "%s"\n') % ot) + if ot and not t: + empty = stack.stack(repo, topic=ot).changesetcount == 0 + if empty: + repo.ui.status(_('clearing empty topic "%s"\n') % ot) elif ist0: repo.ui.status(_("preserving the current topic '%s'\n") % ot) return ret
--- a/hgext3rd/topic/destination.py Wed Aug 29 18:59:07 2018 +0200 +++ b/hgext3rd/topic/destination.py Tue Aug 28 21:28:41 2018 +0800 @@ -59,7 +59,10 @@ """decide on an update destination from current topic""" movemark = node = None topic = repo.currenttopic - revs = repo.revs('.::topic("%s")' % topic) + if topic: + revs = repo.revs('.::topic(%s)', topic) + else: + revs = [] if not revs: return None, None, None node = revs.last()