Commit a4d08192 authored by Anton Shestakov's avatar Anton Shestakov
Browse files

compat: update hg-X.Y compat comments and test them

parent f5b366a31740
Pipeline #3969 passed with stage
in 5 minutes and 13 seconds
......@@ -1306,7 +1306,7 @@
statemod.addunfinished(b'pick', fname=b'pickstate', continueflag=True,
abortfunc=cmdrewrite.hgabortpick)
else:
# compat <= hg-5.0 (5f2f6912c9e6)
# hg <= 5.0 (5f2f6912c9e6)
estate = (b'evolvestate', False, False, _(b'evolve in progress'),
_(b"use 'hg evolve --continue' or 'hg evolve --abort' to abort"))
cmdutil.unfinishedstates.append(estate)
......
......@@ -520,7 +520,8 @@
try:
uipathfn = scmutil.getuipathfn(repo)
except AttributeError:
uipathfn = match.rel # <= 4.9
# hg <= 4.9 (e6ec0737b706)
uipathfn = match.rel
for f in sorted(badfiles):
if f in s.clean:
......
......@@ -28,7 +28,7 @@
arraytobytes = array.array.tostring
arrayfrombytes = array.array.fromstring
# hg <= 5.3 (c21aca51b392)
# hg <= 5.2 (c21aca51b392)
try:
from mercurial import pathutil
dirs = pathutil.dirs
......@@ -78,7 +78,7 @@
islink=b'l' in flags,
isexec=b'x' in flags,
copysource=copied.get(path))
# compat with hg <= 4.9
# hg <= 4.9 (550a172a603b)
elif varnames[2] == r"changectx":
mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
islink=b'l' in flags,
......@@ -86,7 +86,4 @@
copied=copied.get(path)) # pytype: disable=wrong-keyword-args
return mctx
# 46c2b19a1263f18a5829a21b7a5053019b0c5a31 in hg moved repair.stripbmrevset to
# scmutil.bookmarkrevs
# This change is a part of 4.7 cycle, so drop this when we drop support for hg <= 4.6
try:
......@@ -92,4 +89,5 @@
try:
# hg <= 4.6 (46c2b19a1263)
bmrevset = repair.stripbmrevset # pytype: disable=module-attr
except AttributeError:
bmrevset = scmutil.bookmarkrevs
......@@ -100,7 +98,7 @@
"""A complete copy-patse of copies._fullcopytrace with a one line fix to
handle when the base is not parent of both c1 and c2. This should be
converted in a compat function once https://phab.mercurial-scm.org/D3896
gets in and once we drop support for 4.7, this should be removed."""
gets in and once we drop support for 4.6, this should be removed."""
from mercurial import pathutil
......@@ -121,7 +119,7 @@
if util.safehasattr(base, 'isancestorof'):
dirtyc1 = not base.isancestorof(_c1)
dirtyc2 = not base.isancestorof(_c2)
else: # hg <= 4.6
else: # hg <= 4.6 (fbec9c0b32d3)
dirtyc1 = not base.descendant(_c1)
dirtyc2 = not base.descendant(_c2)
graft = dirtyc1 or dirtyc2
......@@ -129,7 +127,7 @@
if graft:
tca = _c1.ancestor(_c2)
# hg < 4.8 compat (dc50121126ae)
# hg <= 4.9 (dc50121126ae)
try:
limit = copies._findlimit(repo, c1, c2) # pytype: disable=module-attr
except (AttributeError, TypeError):
......@@ -350,7 +348,7 @@
return copy, movewithdir, diverge, renamedelete, dirmove
# hg <= 4.9 compat (7694b685bb10)
# hg <= 4.9 (7694b685bb10)
fixupstreamed = util.safehasattr(scmutil, 'movedirstate')
if not fixupstreamed:
copies._fullcopytracing = fixedcopytracing
......@@ -365,7 +363,7 @@
return {'helpcategory': category}
# nodemap.get and index.[has_node|rev|get_rev]
# hg <= 5.3 (02802fa87b74)
# 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'):
......
......@@ -781,7 +781,7 @@
try:
effectflag = obsutil.geteffectflag(prec, (succ,))
except TypeError:
# hg <= 4.7
# hg <= 4.7 (bae6f1418a95)
effectflag = obsutil.geteffectflag((prec, (succ,)))
metadata[obsutil.EFFECTFLAGFIELD] = b"%d" % effectflag
......
......@@ -153,7 +153,7 @@
super(obsmarker_printer, self).__init__(ui, repo, *args, **kwargs)
diffopts = kwargs.get('diffopts', {})
# Compat 4.6
# hg <= 4.6 (3fe1c9263024)
if not util.safehasattr(self, "_includediff"):
self._includediff = diffopts and diffopts.get(b'patch')
......
......@@ -19,7 +19,7 @@
eh = exthelper.exthelper()
# hg <= 4.8
# hg <= 4.8 (33d30fb1e4ae)
if b'auto-publish' not in configitems.coreitems.get(b'experimental', {}):
eh.configitem(b'experimental', b'auto-publish', b'publish')
......
......@@ -640,7 +640,7 @@
ui.progress(topic, pos, item, unit, total)
# nodemap.get and index.[has_node|rev|get_rev]
# hg <= 5.3 (02802fa87b74)
# 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'):
......
......@@ -158,7 +158,7 @@
if util.safehasattr(self, '_entries'):
_entries = self._entries
else:
# hg <= 4.9 (624d6683c705, b137a6793c51)
# hg <= 4.9 (624d6683c705+b137a6793c51)
_entries = self
new = self.__class__(_entries, self.tipnode, self.tiprev,
self.filteredhash, self._closednodes)
......@@ -232,6 +232,6 @@
def uisetup(ui):
wrapclass(branchmap, 'branchcache', _topiccache)
try:
# Mercurial 4.8 and older
# hg <= 4.9 (3461814417f3)
extensions.wrapfunction(branchmap, 'read', wrapread)
except AttributeError:
......@@ -236,6 +236,6 @@
extensions.wrapfunction(branchmap, 'read', wrapread)
except AttributeError:
# Mercurial 4.9; branchcache.fromfile now takes care of this
# Mercurial 5.0; branchcache.fromfile now takes care of this
# which is alredy defined on _topiccache
pass
extensions.wrapfunction(wireprotov1server, '_capabilities', wireprotocaps)
......
......@@ -481,7 +481,7 @@
reporef = weakref.ref(self)
if self.ui.configbool(b'experimental', b'enforce-single-head'):
if util.safehasattr(tr, 'validator'): # hg <= 4.7
if util.safehasattr(tr, 'validator'): # hg <= 4.7 (ebbba3ba3f66)
origvalidator = tr.validator
else:
origvalidator = tr._validator
......@@ -491,7 +491,7 @@
flow.enforcesinglehead(repo, tr2)
origvalidator(tr2)
if util.safehasattr(tr, 'validator'): # hg <= 4.7
if util.safehasattr(tr, 'validator'): # hg <= 4.7 (ebbba3ba3f66)
tr.validator = validator
else:
tr._validator = validator
......@@ -500,7 +500,7 @@
b'topic-mode.server', b'ignore')
ispush = (desc.startswith(b'push') or desc.startswith(b'serve'))
if (topicmodeserver != b'ignore' and ispush):
if util.safehasattr(tr, 'validator'): # hg <= 4.7
if util.safehasattr(tr, 'validator'): # hg <= 4.7 (ebbba3ba3f66)
origvalidator = tr.validator
else:
origvalidator = tr._validator
......@@ -509,7 +509,7 @@
repo = reporef()
flow.rejectuntopicedchangeset(repo, tr2)
return origvalidator(tr2)
if util.safehasattr(tr, 'validator'): # hg <= 4.7
if util.safehasattr(tr, 'validator'): # hg <= 4.7 (ebbba3ba3f66)
tr.validator = validator
else:
tr._validator = validator
......@@ -531,7 +531,7 @@
b'topic.allow-publish',
True)
if not allow_publish:
if util.safehasattr(tr, 'validator'): # hg <= 4.7
if util.safehasattr(tr, 'validator'): # hg <= 4.7 (ebbba3ba3f66)
origvalidator = tr.validator
else:
origvalidator = tr._validator
......@@ -540,7 +540,7 @@
repo = reporef()
flow.reject_publish(repo, tr2)
return origvalidator(tr2)
if util.safehasattr(tr, 'validator'): # hg <= 4.7
if util.safehasattr(tr, 'validator'): # hg <= 4.7 (ebbba3ba3f66)
tr.validator = validator
else:
tr._validator = validator
......
......@@ -32,7 +32,7 @@
return {'helpcategory': category}
# nodemap.get and index.[has_node|rev|get_rev]
# hg <= 5.3 (02802fa87b74)
# 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'):
......
......@@ -157,7 +157,7 @@
return
tr._prepushheads = _nbheads(op.repo)
reporef = weakref.ref(op.repo)
if util.safehasattr(tr, 'validator'): # hg <= 4.7
if util.safehasattr(tr, 'validator'): # hg <= 4.7 (ebbba3ba3f66)
oldvalidator = tr.validator
else:
oldvalidator = tr._validator
......@@ -178,7 +178,7 @@
% branch)
raise error.Abort(msg)
return oldvalidator(tr)
if util.safehasattr(tr, 'validator'): # hg <= 4.7
if util.safehasattr(tr, 'validator'): # hg <= 4.7 (ebbba3ba3f66)
tr.validator = validator
else:
tr._validator = validator
......
......@@ -101,7 +101,8 @@
def installpushflag(ui):
entry = extensions.wrapcommand(commands.table, b'push', wrappush)
if not any(opt for opt in entry[1] if opt[1] == b'publish'): # hg <= 4.9
if not any(opt for opt in entry[1] if opt[1] == b'publish'):
# hg <= 4.8 (9b8d1ad851f8)
entry[1].append((b'', b'publish', False,
_(b'push the changeset as public')))
extensions.wrapfunction(exchange.pushoperation, '__init__',
......
......@@ -124,6 +124,7 @@
b'relation subscript bounds must be integers',
None, None)
else:
# hg <= 4.9 (431cf2c8c839+13f7a6a4f0db)
a = b = z
s = revset.getset(repo, revset.fullreposet(repo), x)
......
......@@ -16,7 +16,7 @@
)
repoviewutil.subsettable
except (AttributeError, ImportError):
# hg <= 4.8
# hg <= 4.9 (caebe5e7f4bd)
from mercurial import branchmap as repoviewutil
from . import (
......
......@@ -125,7 +125,7 @@
branchmap.branchcache = topiccache
try:
# Mercurial 4.9
# Mercurial 5.0
class remotetopiccache(_topiccache, branchmap.remotebranchcache):
pass
branchmap.remotebranchcache = remotetopiccache
......@@ -135,7 +135,7 @@
return _wrapupdatebmcache(orig.__get__(self), repo)
extensions.wrapfunction(branchmap.BranchMapCache, 'updatecache', _wrapupdatebmcachemethod)
except AttributeError:
# Mercurial 4.8 and before
# hg <= 4.9 (3461814417f3)
extensions.wrapfunction(branchmap, 'updatecache', _wrapupdatebmcache)
......@@ -173,7 +173,7 @@
if util.safehasattr(self, '_entries'):
_entries = self._entries
else:
# hg <= 4.9 (624d6683c705, b137a6793c51)
# hg <= 4.9 (624d6683c705+b137a6793c51)
_entries = self
new = self.__class__(_entries, self.tipnode, self.tiprev,
self.filteredhash, self._closednodes)
......
Enable obsolescence to avoid the warning issue when obsmarkers are found
$ cat << EOF >> $HGRCPATH
> [experimental]
> evolution = all
> EOF
$ $TESTDIR/../contrib/check-compat-strings.sh "$TESTDIR/../hgext3rd/" "$RUNTESTDIR/.."
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment