Show More
@@ -27,6 +27,12 b' from . import (' | |||||
27 | util, |
|
27 | util, | |
28 | ) |
|
28 | ) | |
29 |
|
29 | |||
|
30 | try: | |||
|
31 | from . import rustext | |||
|
32 | rustext.__name__ # force actual import (see hgdemandimport) | |||
|
33 | except ImportError: | |||
|
34 | rustext = None | |||
|
35 | ||||
30 | parsers = policy.importmod(r'parsers') |
|
36 | parsers = policy.importmod(r'parsers') | |
31 |
|
37 | |||
32 | propertycache = util.propertycache |
|
38 | propertycache = util.propertycache | |
@@ -1465,7 +1471,12 b' class dirstatemap(object):' | |||||
1465 | # parsing the dirstate. |
|
1471 | # parsing the dirstate. | |
1466 | # |
|
1472 | # | |
1467 | # (we cannot decorate the function directly since it is in a C module) |
|
1473 | # (we cannot decorate the function directly since it is in a C module) | |
1468 | parse_dirstate = util.nogc(parsers.parse_dirstate) |
|
1474 | if rustext is not None: | |
|
1475 | parse_dirstate = rustext.dirstate.parse_dirstate | |||
|
1476 | else: | |||
|
1477 | parse_dirstate = parsers.parse_dirstate | |||
|
1478 | ||||
|
1479 | parse_dirstate = util.nogc(parse_dirstate) | |||
1469 | p = parse_dirstate(self._map, self.copymap, st) |
|
1480 | p = parse_dirstate(self._map, self.copymap, st) | |
1470 | if not self._dirtyparents: |
|
1481 | if not self._dirtyparents: | |
1471 | self.setparents(*p) |
|
1482 | self.setparents(*p) | |
@@ -1476,7 +1487,12 b' class dirstatemap(object):' | |||||
1476 | self.get = self._map.get |
|
1487 | self.get = self._map.get | |
1477 |
|
1488 | |||
1478 | def write(self, st, now): |
|
1489 | def write(self, st, now): | |
1479 | st.write(parsers.pack_dirstate(self._map, self.copymap, |
|
1490 | if rustext is not None: | |
|
1491 | pack_dirstate = rustext.dirstate.pack_dirstate | |||
|
1492 | else: | |||
|
1493 | pack_dirstate = parsers.pack_dirstate | |||
|
1494 | ||||
|
1495 | st.write(pack_dirstate(self._map, self.copymap, | |||
1480 | self.parents(), now)) |
|
1496 | self.parents(), now)) | |
1481 | st.close() |
|
1497 | st.close() | |
1482 | self._dirtyparents = False |
|
1498 | self._dirtyparents = False |
@@ -16,6 +16,12 b' from mercurial import (' | |||||
16 | ) |
|
16 | ) | |
17 | from mercurial.utils import dateutil |
|
17 | from mercurial.utils import dateutil | |
18 |
|
18 | |||
|
19 | try: | |||
|
20 | from mercurial import rustext | |||
|
21 | rustext.__name__ # force actual import (see hgdemandimport) | |||
|
22 | except ImportError: | |||
|
23 | rustext = None | |||
|
24 | ||||
19 | configtable = {} |
|
25 | configtable = {} | |
20 | configitem = registrar.configitem(configtable) |
|
26 | configitem = registrar.configitem(configtable) | |
21 |
|
27 | |||
@@ -51,16 +57,22 b' def fakewrite(ui, func):' | |||||
51 | # 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy |
|
57 | # 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy | |
52 | fakenow = dateutil.parsedate(fakenow, [b'%Y%m%d%H%M'])[0] |
|
58 | fakenow = dateutil.parsedate(fakenow, [b'%Y%m%d%H%M'])[0] | |
53 |
|
59 | |||
54 | orig_pack_dirstate = parsers.pack_dirstate |
|
60 | if rustext is not None: | |
|
61 | orig_module = rustext.dirstate | |||
|
62 | orig_pack_dirstate = rustext.dirstate.pack_dirstate | |||
|
63 | else: | |||
|
64 | orig_module = parsers | |||
|
65 | orig_pack_dirstate = parsers.pack_dirstate | |||
|
66 | ||||
55 | orig_dirstate_getfsnow = dirstate._getfsnow |
|
67 | orig_dirstate_getfsnow = dirstate._getfsnow | |
56 | wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args) |
|
68 | wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args) | |
57 |
|
69 | |||
58 |
|
|
70 | orig_module.pack_dirstate = wrapper | |
59 | dirstate._getfsnow = lambda *args: fakenow |
|
71 | dirstate._getfsnow = lambda *args: fakenow | |
60 | try: |
|
72 | try: | |
61 | return func() |
|
73 | return func() | |
62 | finally: |
|
74 | finally: | |
63 |
|
|
75 | orig_module.pack_dirstate = orig_pack_dirstate | |
64 | dirstate._getfsnow = orig_dirstate_getfsnow |
|
76 | dirstate._getfsnow = orig_dirstate_getfsnow | |
65 |
|
77 | |||
66 | def _poststatusfixup(orig, workingctx, status, fixup): |
|
78 | def _poststatusfixup(orig, workingctx, status, fixup): |
General Comments 0
You need to be logged in to leave comments.
Login now