Mercurial > evolve
view hgext3rd/topic/compat.py @ 6376:5c8196a550b6
topic: make hg stack work for branches with double slashes in them
Other commands are likely affected as well.
Things to note: we're using FQBN-formatted branch instead of full
branch//namespace/topic in the workingctx.dirty() check because otherwise, if
you had no topic active and were trying to update to a topic, wdir would be
considered to be dirty and update would abort (same with unset topic namespace
and trying to update to a changeset with topic namespace set). With just a bare
branch, this doesn't happen, because you can't deactivate a branch. This is
caught by test-topic.t.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 15 Dec 2022 15:44:39 +0400 |
parents | f4ffe1e67a9b |
children | d13cfd9eb6c0 |
line wrap: on
line source
# Copyright 2017 FUJIWARA Katsunori <foozy@lares.dti.ne.jp> # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. """ Compatibility module """ from __future__ import absolute_import from mercurial.i18n import _ from mercurial import ( cmdutil, error, extensions, pycompat, util, ) if pycompat.ispy3: def branchmapitems(branchmap): return branchmap.items() else: # py3-transform: off def branchmapitems(branchmap): return branchmap.iteritems() # py3-transform: on def bcentries(branchcache): if util.safehasattr(branchcache, '_entries'): return branchcache._entries else: # hg <= 4.9 (624d6683c705+b137a6793c51) return branchcache # nodemap.get and index.[has_node|rev|get_rev] # hg <= 5.2 (02802fa87b74) def getgetrev(cl): """Returns index.get_rev or nodemap.get (for pre-5.3 Mercurial).""" if util.safehasattr(cl.index, 'get_rev'): return cl.index.get_rev return cl.nodemap.get # hg <= 5.4 (e2d17974a869) def nonpublicphaseroots(repo): if util.safehasattr(repo._phasecache, 'nonpublicphaseroots'): return repo._phasecache.nonpublicphaseroots(repo) return set().union( *[roots for roots in repo._phasecache.phaseroots[1:] if roots] ) def overridecommitstatus(overridefn): if r'tip' in cmdutil.commitstatus.__code__.co_varnames: extensions.wrapfunction(cmdutil, 'commitstatus', overridefn) else: # hg <= 5.6 (976b26bdd0d8) def _override(orig, repo, node, branch, bheads=None, opts=None): def _orig(repo, node, branch, bheads=None, tip=None, opts=None): return orig(repo, node, branch, bheads=bheads, opts=opts) return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, opts=opts) extensions.wrapfunction(cmdutil, 'commitstatus', _override) if util.safehasattr(error, 'InputError'): InputError = error.InputError else: # hg <= 5.6 (8d72e29ad1e0) InputError = error.Abort if util.safehasattr(error, 'StateError'): StateError = error.StateError else: # hg <= 5.6 (527ce85c2e60) StateError = error.Abort if util.safehasattr(error, 'CanceledError'): CanceledError = error.CanceledError else: # hg <= 5.6 (ac362d5a7893) CanceledError = error.Abort if util.safehasattr(cmdutil, 'check_at_most_one_arg'): def check_at_most_one_arg(opts, *args): return cmdutil.check_at_most_one_arg(opts, *args) else: # hg <= 5.2 (d587937600be) def check_at_most_one_arg(opts, *args): def to_display(name): return pycompat.sysbytes(name).replace(b'_', b'-') previous = None for x in args: if opts.get(x): if previous: raise InputError(_(b'cannot specify both --%s and --%s') % (to_display(previous), to_display(x))) previous = x return previous if util.safehasattr(cmdutil, 'check_incompatible_arguments'): code = cmdutil.check_incompatible_arguments.__code__ if r'others' in code.co_varnames[:code.co_argcount]: def check_incompatible_arguments(opts, first, others): return cmdutil.check_incompatible_arguments(opts, first, others) else: # hg <= 5.3 (d4c1501225c4) def check_incompatible_arguments(opts, first, others): return cmdutil.check_incompatible_arguments(opts, first, *others) else: # hg <= 5.2 (023ad45e2fd2) def check_incompatible_arguments(opts, first, others): for other in others: check_at_most_one_arg(opts, first, other)