Mercurial > evolve
changeset 2711:8c938e9af113
topics: wrap the update function to check if either t0 or b0 is passed as rev
t0 or b0, seriously, what's that. Do they even exist? Hold on and look for the
next commits what we are trying to do.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Tue, 04 Jul 2017 00:15:36 +0530 |
parents | e22de367fc74 |
children | f19b314d8475 |
files | hgext3rd/topic/__init__.py |
diffstat | 1 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Fri Jul 07 00:42:18 2017 +0200 +++ b/hgext3rd/topic/__init__.py Tue Jul 04 00:15:36 2017 +0530 @@ -176,6 +176,11 @@ extensions.wrapfunction(cmdutil, 'buildcommittext', committextwrap) extensions.wrapfunction(merge, 'update', mergeupdatewrap) + # We need to check whether t0 or b0 is passed to override the default update + # behaviour of changing topic and I can't find a better way + # to do that as scmutil.revsingle returns the rev number and hence we can't + # plug into logic for this into mergemod.update(). + extensions.wrapcommand(commands.table, 'update', checkt0) try: evolve = extensions.find('evolve') @@ -491,6 +496,7 @@ partial = not (matcher is None or matcher.always()) wlock = repo.wlock() isrebase = False + ist0 = False try: ret = orig(repo, node, branchmerge, force, *args, **kwargs) # The mergeupdatewrap function makes the destination's topic as the @@ -500,7 +506,9 @@ # running. if repo.ui.hasconfig('experimental', 'topicrebase'): isrebase = True - if (not partial and not branchmerge) or isrebase: + if repo.ui.configbool('_internal', 'updating-to-t0'): + ist0 = True + if ((not partial and not branchmerge) or isrebase) and not ist0: ot = repo.currenttopic t = '' pctx = repo[node] @@ -510,10 +518,23 @@ f.write(t) if t and t != ot: repo.ui.status(_("switching to topic %s\n") % t) + elif ist0: + repo.ui.status(_("preserving the current topic '%s'\n") % + repo.currenttopic) return ret finally: wlock.release() +def checkt0(orig, ui, repo, node=None, rev=None, clean=False, date=None, + check=False, merge=None, tool=None): + + thezeros = set(['t0', 'b0']) + overrides = {} + if node in thezeros or rev in thezeros: + overrides[('_internal', 'updating-to-t0')] = 'yes' + with repo.ui.configoverride(overrides, source='topic-extension'): + return orig(ui, repo, node, rev, clean, date, check, merge, tool) + def _fixrebase(loaded): if not loaded: return