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

compat: ask pytype to ignore some warnings

It's expected to have a bunch of import and attribute errors in this module
because it's for compatibility with different versions of hg and Python.

Although it doesn't explain why a function wouldn't have __code__ attribute? So
far I think it's a quirk of pytype.
parent f583d9eedbce
......@@ -41,9 +41,9 @@ try:
changesetdiffer = logcmdutil.changesetdiffer
except (AttributeError, ImportError):
from mercurial import cmdutil
changesetdisplayer = cmdutil.show_changeset
changesetprinter = cmdutil.changeset_printer
displaygraph = cmdutil.displaygraph
changesetdisplayer = cmdutil.show_changeset # pytype: disable=module-attr
changesetprinter = cmdutil.changeset_printer # pytype: disable=module-attr
displaygraph = cmdutil.displaygraph # pytype: disable=module-attr
changesetdiffer = None
# hg <= 5.3 (c21aca51b392)
......@@ -51,7 +51,7 @@ try:
from mercurial import pathutil
dirs = pathutil.dirs
except (AttributeError, ImportError):
dirs = util.dirs
dirs = util.dirs # pytype: disable=module-attr
from . import (
exthelper,
......@@ -96,7 +96,7 @@ if r'predecessors' not in dir(obsolete.obsstore):
def memfilectx(repo, ctx, fctx, flags, copied, path):
# XXX Would it be better at the module level?
varnames = context.memfilectx.__init__.__code__.co_varnames
varnames = context.memfilectx.__init__.__code__.co_varnames # pytype: disable=attribute-error
if r"copysource" in varnames:
mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
......@@ -108,12 +108,12 @@ def memfilectx(repo, ctx, fctx, flags, copied, path):
mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
islink=b'l' in flags,
isexec=b'x' in flags,
copied=copied.get(path))
copied=copied.get(path)) # pytype: disable=wrong-keyword-args
else:
mctx = context.memfilectx(repo, fctx.path(), fctx.data(),
islink=b'l' in flags,
isexec=b'x' in flags,
copied=copied.get(path))
copied=copied.get(path)) # pytype: disable=wrong-keyword-args
return mctx
def strdiff(a, b, fn1, fn2):
......@@ -136,14 +136,15 @@ def strdiff(a, b, fn1, fn2):
# date related
# hg <= 4.5 (c6061cadb400)
try:
import mercurial.utils.dateutil
makedate = mercurial.utils.dateutil.makedate
parsedate = mercurial.utils.dateutil.parsedate
except ImportError:
import mercurial.util
makedate = mercurial.util.makedate
parsedate = mercurial.util.parsedate
makedate = mercurial.util.makedate # pytype: disable=module-attr
parsedate = mercurial.util.parsedate # pytype: disable=module-attr
def wireprotocommand(exthelper, name, args=b'', permission=b'pull'):
try:
......@@ -174,7 +175,7 @@ except (ImportError, AttributeError):
# scmutil.bookmarkrevs
# This change is a part of 4.7 cycle, so drop this when we drop support for 4.6
try:
bmrevset = repair.stripbmrevset
bmrevset = repair.stripbmrevset # pytype: disable=module-attr
except AttributeError:
bmrevset = scmutil.bookmarkrevs
......@@ -220,9 +221,9 @@ def fixedcopytracing(repo, c1, c2, base):
# hg < 4.8 compat (dc50121126ae)
try:
limit = copies._findlimit(repo, c1, c2)
limit = copies._findlimit(repo, c1, c2) # pytype: disable=module-attr
except (AttributeError, TypeError):
limit = copies._findlimit(repo, c1.rev(), c2.rev())
limit = copies._findlimit(repo, c1.rev(), c2.rev()) # pytype: disable=module-attr
if limit is None:
# no common ancestor, no copies
return {}, {}, {}, {}, {}
......@@ -263,11 +264,11 @@ def fixedcopytracing(repo, c1, c2, base):
bothnew = sorted(addedinm1 & addedinm2)
if tca == base:
# unmatched file from base
u1r, u2r = copies._computenonoverlap(repo, c1, c2, addedinm1, addedinm2)
u1r, u2r = copies._computenonoverlap(repo, c1, c2, addedinm1, addedinm2) # pytype: disable=module-attr
u1u, u2u = u1r, u2r
else:
# unmatched file from base (DAG rotation in the graft case)
u1r, u2r = copies._computenonoverlap(repo, c1, c2, addedinm1, addedinm2,
u1r, u2r = copies._computenonoverlap(repo, c1, c2, addedinm1, addedinm2, # pytype: disable=module-attr
baselabel=b'base')
# unmatched file from topological common ancestors (no DAG rotation)
# need to recompute this for directory move handling when grafting
......@@ -276,18 +277,18 @@ def fixedcopytracing(repo, c1, c2, base):
m1f = m1.filesnotin(mta, repo.narrowmatch())
m2f = m2.filesnotin(mta, repo.narrowmatch())
baselabel = b'topological common ancestor'
u1u, u2u = copies._computenonoverlap(repo, c1, c2, m1f, m2f,
u1u, u2u = copies._computenonoverlap(repo, c1, c2, m1f, m2f, # pytype: disable=module-attr
baselabel=baselabel)
else:
u1u, u2u = copies._computenonoverlap(repo, c1, c2, m1.filesnotin(mta),
u1u, u2u = copies._computenonoverlap(repo, c1, c2, m1.filesnotin(mta), # pytype: disable=module-attr
m2.filesnotin(mta),
baselabel=b'topological common ancestor')
for f in u1u:
copies._checkcopies(c1, c2, f, base, tca, dirtyc1, limit, data1)
copies._checkcopies(c1, c2, f, base, tca, dirtyc1, limit, data1) # pytype: disable=module-attr
for f in u2u:
copies._checkcopies(c2, c1, f, base, tca, dirtyc2, limit, data2)
copies._checkcopies(c2, c1, f, base, tca, dirtyc2, limit, data2) # pytype: disable=module-attr
copy = dict(data1[b'copy'])
copy.update(data2[b'copy'])
......@@ -295,10 +296,10 @@ def fixedcopytracing(repo, c1, c2, base):
fullcopy.update(data2[b'fullcopy'])
if dirtyc1:
copies._combinecopies(data2[b'incomplete'], data1[b'incomplete'], copy, diverge,
copies._combinecopies(data2[b'incomplete'], data1[b'incomplete'], copy, diverge, # pytype: disable=module-attr
incompletediverge)
else:
copies._combinecopies(data1[b'incomplete'], data2[b'incomplete'], copy, diverge,
copies._combinecopies(data1[b'incomplete'], data2[b'incomplete'], copy, diverge, # pytype: disable=module-attr
incompletediverge)
renamedelete = {}
......@@ -334,19 +335,19 @@ def fixedcopytracing(repo, c1, c2, base):
b'incompletediverge': bothincompletediverge
}
for f in bothnew:
copies._checkcopies(c1, c2, f, base, tca, dirtyc1, limit, both1)
copies._checkcopies(c2, c1, f, base, tca, dirtyc2, limit, both2)
copies._checkcopies(c1, c2, f, base, tca, dirtyc1, limit, both1) # pytype: disable=module-attr
copies._checkcopies(c2, c1, f, base, tca, dirtyc2, limit, both2) # pytype: disable=module-attr
if dirtyc1 and dirtyc2:
pass
elif dirtyc1:
# incomplete copies may only be found on the "dirty" side for bothnew
assert not both2[b'incomplete']
remainder = copies._combinecopies({}, both1[b'incomplete'], copy, bothdiverge,
remainder = copies._combinecopies({}, both1[b'incomplete'], copy, bothdiverge, # pytype: disable=module-attr
bothincompletediverge)
elif dirtyc2:
assert not both1[b'incomplete']
remainder = copies._combinecopies({}, both2[b'incomplete'], copy, bothdiverge,
remainder = copies._combinecopies({}, both2[b'incomplete'], copy, bothdiverge, # pytype: disable=module-attr
bothincompletediverge)
else:
# incomplete copies and divergences can't happen outside grafts
......
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