D1970: contrib: fix dirstatenonnormalcheck to work in Python 3
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Thu Feb 1 18:48:48 EST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG786a70abb4d7: contrib: fix dirstatenonnormalcheck to work in Python 3 (authored by durin42, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D1970?vs=5115&id=5139
REVISION DETAIL
https://phab.mercurial-scm.org/D1970
AFFECTED FILES
contrib/dirstatenonnormalcheck.py
mercurial/dirstate.py
CHANGE DETAILS
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1237,9 +1237,12 @@
util.clearcachedproperty(self, "nonnormalset")
util.clearcachedproperty(self, "otherparentset")
- def iteritems(self):
+ def items(self):
return self._map.iteritems()
+ # forward for python2,3 compat
+ iteritems = items
+
def __len__(self):
return len(self._map)
diff --git a/contrib/dirstatenonnormalcheck.py b/contrib/dirstatenonnormalcheck.py
--- a/contrib/dirstatenonnormalcheck.py
+++ b/contrib/dirstatenonnormalcheck.py
@@ -17,32 +17,33 @@
"""Compute nonnormal entries from dirstate's dmap"""
res = set()
for f, e in dmap.iteritems():
- if e[0] != 'n' or e[3] == -1:
+ if e[0] != b'n' or e[3] == -1:
res.add(f)
return res
def checkconsistency(ui, orig, dmap, _nonnormalset, label):
"""Compute nonnormalset from dmap, check that it matches _nonnormalset"""
nonnormalcomputedmap = nonnormalentries(dmap)
if _nonnormalset != nonnormalcomputedmap:
- ui.develwarn("%s call to %s\n" % (label, orig), config='dirstate')
- ui.develwarn("inconsistency in nonnormalset\n", config='dirstate')
- ui.develwarn("[nonnormalset] %s\n" % _nonnormalset, config='dirstate')
- ui.develwarn("[map] %s\n" % nonnormalcomputedmap, config='dirstate')
+ ui.develwarn(b"%s call to %s\n" % (label, orig), config=b'dirstate')
+ ui.develwarn(b"inconsistency in nonnormalset\n", config=b'dirstate')
+ ui.develwarn(b"[nonnormalset] %s\n" % _nonnormalset, config=b'dirstate')
+ ui.develwarn(b"[map] %s\n" % nonnormalcomputedmap, config=b'dirstate')
def _checkdirstate(orig, self, arg):
"""Check nonnormal set consistency before and after the call to orig"""
checkconsistency(self._ui, orig, self._map, self._map.nonnormalset,
- "before")
+ b"before")
r = orig(self, arg)
- checkconsistency(self._ui, orig, self._map, self._map.nonnormalset, "after")
+ checkconsistency(self._ui, orig, self._map, self._map.nonnormalset,
+ b"after")
return r
def extsetup(ui):
"""Wrap functions modifying dirstate to check nonnormalset consistency"""
dirstatecl = dirstate.dirstate
- devel = ui.configbool('devel', 'all-warnings')
- paranoid = ui.configbool('experimental', 'nonnormalparanoidcheck')
+ devel = ui.configbool(b'devel', b'all-warnings')
+ paranoid = ui.configbool(b'experimental', b'nonnormalparanoidcheck')
if devel:
extensions.wrapfunction(dirstatecl, '_writedirstate', _checkdirstate)
if paranoid:
To: durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list