Read about our upcoming Code of Conduct on this issue

Commit 8ae6d292 authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

python3: add raw prefix in cases harder to analyze at the token level

The `byteify-strings.py` script would be a lot more complicated if it had to
do backtracking and other more advanced static analysis to figure our those
cases, so we have to add the raw prefix to those cases manually.
parent 88472e743c64
......@@ -1291,7 +1291,7 @@ def _checkinvalidmarkers(orig, markers):
Exist as a separated function to allow the evolve extension for a more
subtle handling.
"""
if 'debugobsconvert' in sys.argv:
if r'debugobsconvert' in sys.argv:
return
for mark in markers:
if node.nullid in mark[1]:
......
......@@ -1015,9 +1015,9 @@ def cmdprune(ui, repo, *revs, **opts):
fold = opts.get('fold')
split = opts.get('split')
options = [o for o in ('pair', 'fold', 'split') if opts.get(o)]
options = [o for o in (r'pair', r'fold', r'split') if opts.get(o)]
if 1 < len(options):
_opts = pycompat.sysbytes(', '.join(options))
_opts = pycompat.sysbytes(r', '.join(options))
raise error.Abort(_("can only specify one of %s") % _opts)
if bookmarks:
......
......@@ -79,7 +79,7 @@ else:
ui.progress(topic, pos, item, unit, total)
# XXX: Better detection of property cache
if 'predecessors' not in dir(obsolete.obsstore):
if r'predecessors' not in dir(obsolete.obsstore):
@property
def predecessors(self):
return self.precursors
......@@ -90,13 +90,13 @@ def memfilectx(repo, ctx, fctx, flags, copied, path):
# XXX Would it be better at the module level?
varnames = context.memfilectx.__init__.__code__.co_varnames
if "copysource" in varnames:
if r"copysource" in varnames:
mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
islink='l' in flags,
isexec='x' in flags,
copysource=copied.get(path))
# compat with hg <- 4.9
elif varnames[2] == "changectx":
elif varnames[2] == r"changectx":
mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
islink='l' in flags,
isexec='x' in flags,
......@@ -116,10 +116,10 @@ def strdiff(a, b, fn1, fn2):
# hg < 4.6 compat 8b6dd3922f70
if util.safehasattr(inspect, 'signature'):
signature = inspect.signature(mdiff.unidiff)
needsbinary = 'binary' in signature.parameters
needsbinary = r'binary' in signature.parameters
else:
argspec = inspect.getargspec(mdiff.unidiff)
needsbinary = 'binary' in argspec.args
needsbinary = r'binary' in argspec.args
if needsbinary:
args.append(False)
......
......@@ -79,7 +79,7 @@ def setupcache(ui, repo):
@localrepo.unfilteredmethod
def destroyed(self):
if 'depthcache' in vars(self):
if r'depthcache' in vars(self):
self.depthcache.clear()
super(depthcacherepo, self).destroyed()
......
......@@ -1644,7 +1644,7 @@ def _performevolve(ui, repo, **opts):
elif len(specifiedcategories) == 1:
targetcat = specifiedcategories[0]
ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve')
ui.setconfig('ui', 'forcemerge', opts.get('tool', r''), 'evolve')
evolvestate = state.cmdstate(repo)
# Continuation handling
......
......@@ -41,7 +41,7 @@ def setupcache(ui, repo):
@localrepo.unfilteredmethod
def destroyed(self):
if 'firstmergecach' in vars(self):
if r'firstmergecach' in vars(self):
self.firstmergecache.clear()
super(firstmergecacherepo, self).destroyed()
......
......@@ -50,7 +50,7 @@ def reposetup(ui, repo):
evolveopts = 'all'
ui.setconfig('experimental', 'evolution', evolveopts)
for arg in sys.argv:
if 'debugc' in arg:
if r'debugc' in arg:
break
else:
data = repo.vfs.tryread('obsolete-relations')
......
......@@ -82,7 +82,7 @@ def obsstorewithcache(orig, repo):
def markersfrom(obsstore, byteoffset, firstmarker):
if not firstmarker:
return list(obsstore)
elif '_all' in vars(obsstore):
elif r'_all' in vars(obsstore):
# if the data are in memory, just use that
return obsstore._all[firstmarker:]
else:
......@@ -339,7 +339,7 @@ class obscache(dualsourcecache):
def _setdata(self, data):
"""set a new bytearray data, invalidating the 'get' shortcut if needed"""
self._data = data
if 'get' in vars(self):
if r'get' in vars(self):
del self.get
def clear(self, reset=False):
......@@ -476,7 +476,7 @@ def setupcache(ui, repo):
@localrepo.unfilteredmethod
def destroyed(self):
if 'obsstore' in vars(self):
if r'obsstore' in vars(self):
self.obsstore.obscache.clear()
super(obscacherepo, self).destroyed()
......
......@@ -353,7 +353,7 @@ class _obshashcache(obscache.dualsourcecache):
self._new.clear()
if reset:
self._valid = False
if '_con' in vars(self):
if r'_con' in vars(self):
del self._con
def get(self, rangeid):
......@@ -377,7 +377,7 @@ class _obshashcache(obscache.dualsourcecache):
except (sqlite3.DatabaseError, sqlite3.OperationalError):
# something is wrong with the sqlite db
# Since this is a cache, we ignore it.
if '_con' in vars(self):
if r'_con' in vars(self):
del self._con
self._new.clear()
return value
......@@ -528,7 +528,7 @@ class _obshashcache(obscache.dualsourcecache):
repo = repo.unfiltered()
try:
with repo.lock():
if 'stablerange' in vars(repo):
if r'stablerange' in vars(repo):
repo.stablerange.save(repo)
self._save(repo)
except error.LockError:
......@@ -548,7 +548,7 @@ class _obshashcache(obscache.dualsourcecache):
#
# operational error catch read-only and locked database
# IntegrityError catch Unique constraint error that may arise
if '_con' in vars(self):
if r'_con' in vars(self):
del self._con
self._new.clear()
repo.ui.log('evoext-cache', 'error while saving new data: %s' % exc)
......@@ -557,7 +557,7 @@ class _obshashcache(obscache.dualsourcecache):
def _trysave(self, repo):
if self._con is None:
util.unlinkpath(self._path, ignoremissing=True)
if '_con' in vars(self):
if r'_con' in vars(self):
del self._con
con = self._db()
......@@ -585,7 +585,7 @@ class _obshashcache(obscache.dualsourcecache):
repo.ui.warn(msg)
self._new.clear()
self._valid = False
if '_con' in vars(self):
if r'_con' in vars(self):
del self._con
self._valid = False
return
......@@ -618,7 +618,7 @@ def setupcache(ui, repo):
class obshashrepo(repo.__class__):
@localrepo.unfilteredmethod
def destroyed(self):
if 'obsstore' in vars(self):
if r'obsstore' in vars(self):
self.obsstore.rangeobshashcache.clear()
toplevel = not util.safehasattr(self, '_destroying')
if toplevel:
......
......@@ -83,12 +83,12 @@ def _addobscommontob2pull(orig, pullop, kwargs):
return ret
def _getbundleobsmarkerpart(orig, bundler, repo, source, **kwargs):
if not (set(['evo_obscommon', 'evo_missing_nodes']) & set(kwargs)):
if not (set([r'evo_obscommon', r'evo_missing_nodes']) & set(kwargs)):
return orig(bundler, repo, source, **kwargs)
if kwargs.get('obsmarkers', False):
heads = kwargs.get('heads')
if 'evo_obscommon' in kwargs:
if r'evo_obscommon' in kwargs:
if heads is None:
heads = repo.heads()
obscommon = kwargs.get('evo_obscommon', ())
......
......@@ -223,7 +223,7 @@ class stablerangesqlbase(stablerange.stablerangecached):
except (sqlite3.DatabaseError, sqlite3.OperationalError):
# something is wrong with the sqlite db
# Since this is a cache, we ignore it.
if '_con' in vars(self):
if r'_con' in vars(self):
del self._con
self._unsavedsubranges.clear()
......@@ -278,7 +278,7 @@ class stablerangesqlbase(stablerange.stablerangecached):
#
# operational error catch read-only and locked database
# IntegrityError catch Unique constraint error that may arise
if '_con' in vars(self):
if r'_con' in vars(self):
del self._con
self._unsavedsubranges.clear()
repo.ui.log('evoext-cache', 'error while saving new data: %s' % exc)
......@@ -294,7 +294,7 @@ class stablerangesqlbase(stablerange.stablerangecached):
if self._con is None:
util.unlinkpath(self._path, ignoremissing=True)
if '_con' in vars(self):
if r'_con' in vars(self):
del self._con
con = self._db()
......@@ -375,7 +375,7 @@ class stablerangesql(stablerangesqlbase, stablerangeondiskbase):
def clear(self, reset=False):
super(stablerangesql, self).clear(reset=reset)
if '_con' in vars(self):
if r'_con' in vars(self):
del self._con
self._subrangescache.clear()
......@@ -436,7 +436,7 @@ def setupcache(ui, repo):
@localrepo.unfilteredmethod
def destroyed(self):
if 'stablerange' in vars(self):
if r'stablerange' in vars(self):
self.stablerange.clear()
del self.stablerange
super(stablerangerepo, self).destroyed()
......
......@@ -669,7 +669,7 @@ def setupcache(ui, repo):
@localrepo.unfilteredmethod
def destroyed(self):
if 'stablesort' in vars(self):
if r'stablesort' in vars(self):
self.stablesort.clear()
super(stablesortrepo, self).destroyed()
......
......@@ -67,7 +67,7 @@ class revbranchcacheoverlay(object):
def _init__(self, *args, **kwargs):
super(revbranchcacheoverlay, self).__init__(*args, **kwargs)
if 'branchinfo' in vars(self):
if r'branchinfo' in vars(self):
del self.branchinfo
def branchinfo(self, rev, changelog=None):
......@@ -95,7 +95,7 @@ def reposetup(ui, repo):
class topicawarerbc(revbranchcacheoverlay, cache.__class__):
pass
cache.__class__ = topicawarerbc
if 'branchinfo' in vars(cache):
if r'branchinfo' in vars(cache):
del cache.branchinfo
self._revbranchcache = cache
return self._revbranchcache
......
......@@ -242,7 +242,7 @@ if util.safehasattr(registrar, 'configitem'):
# we need to do old style declaration for <= 4.5
templatekeyword = registrar.templatekeyword()
post45template = 'requires=' in templatekeyword.__doc__
post45template = r'requires=' in templatekeyword.__doc__
def _contexttopic(self, force=False):
if not (force or self.mutable()):
......
......@@ -117,7 +117,7 @@ def _headssummary(orig, pushop, *args, **kwargs):
summary[key] = ([value[1][0]], ) + value[1:]
return summary
finally:
if 'unfiltered' in vars(repo):
if r'unfiltered' in vars(repo):
del repo.unfiltered
repo.__class__ = oldrepocls
if remotebranchmap is not None:
......
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