Mercurial > public > mercurial-scm > hg
diff contrib/dirstatenonnormalcheck.py @ 35878:6e7fae8f1c6c
contrib: fix dirstatenonnormalcheck to work in Python 3
This is a redo of D1963 that has the added benefit of not breaking
Python 2. Oops.
# skip-blame because this is bytes prefixes and a s/iteritems/items/
Differential Revision: https://phab.mercurial-scm.org/D1970
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 01 Feb 2018 16:01:43 -0500 |
parents | 60927b19ed65 |
children | 2372284d9457 |
line wrap: on
line diff
--- a/contrib/dirstatenonnormalcheck.py Thu Jan 18 13:12:09 2018 -0500 +++ b/contrib/dirstatenonnormalcheck.py Thu Feb 01 16:01:43 2018 -0500 @@ -17,7 +17,7 @@ """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 @@ -25,24 +25,25 @@ """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: