Mercurial > public > mercurial-scm > hg
diff mercurial/dirstate.py @ 42452:a3a8887e4426
rust: using policy.importrust from Python callers
This commit converts all current Python callers of
mercurial.rustext to the new policy.importrust system.
After this point, going through policy.importrust
or policy.importmod (in some more distant future)
is mandatory for callers of Rust code outside of
Python tests.
We felt it to be appropriate to keep Rust-specific tests
run inconditionally if the Rust extensions are present.
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Thu, 30 May 2019 09:14:41 +0200 |
parents | 448486e12c13 |
children | 87a34c767384 |
line wrap: on
line diff
--- a/mercurial/dirstate.py Wed May 29 13:27:56 2019 +0200 +++ b/mercurial/dirstate.py Thu May 30 09:14:41 2019 +0200 @@ -27,13 +27,8 @@ util, ) -try: - from . import rustext - rustext.__name__ # force actual import (see hgdemandimport) -except ImportError: - rustext = None - parsers = policy.importmod(r'parsers') +dirstatemod = policy.importrust(r'dirstate', default=parsers) propertycache = util.propertycache filecache = scmutil.filecache @@ -1468,12 +1463,7 @@ # parsing the dirstate. # # (we cannot decorate the function directly since it is in a C module) - if rustext is not None: - parse_dirstate = rustext.dirstate.parse_dirstate - else: - parse_dirstate = parsers.parse_dirstate - - parse_dirstate = util.nogc(parse_dirstate) + parse_dirstate = util.nogc(dirstatemod.parse_dirstate) p = parse_dirstate(self._map, self.copymap, st) if not self._dirtyparents: self.setparents(*p) @@ -1484,13 +1474,8 @@ self.get = self._map.get def write(self, st, now): - if rustext is not None: - pack_dirstate = rustext.dirstate.pack_dirstate - else: - pack_dirstate = parsers.pack_dirstate - - st.write(pack_dirstate(self._map, self.copymap, - self.parents(), now)) + st.write(dirstatemod.pack_dirstate(self._map, self.copymap, + self.parents(), now)) st.close() self._dirtyparents = False self.nonnormalset, self.otherparentset = self.nonnormalentries()