Show More
@@ -66,16 +66,6 b' class rootcache(filecache):' | |||||
66 | return obj._join(fname) |
|
66 | return obj._join(fname) | |
67 |
|
67 | |||
68 |
|
68 | |||
69 | def _getfsnow(vfs): |
|
|||
70 | '''Get "now" timestamp on filesystem''' |
|
|||
71 | tmpfd, tmpname = vfs.mkstemp() |
|
|||
72 | try: |
|
|||
73 | return timestamp.mtime_of(os.fstat(tmpfd)) |
|
|||
74 | finally: |
|
|||
75 | os.close(tmpfd) |
|
|||
76 | vfs.unlink(tmpname) |
|
|||
77 |
|
||||
78 |
|
||||
79 | def requires_parents_change(func): |
|
69 | def requires_parents_change(func): | |
80 | def wrap(self, *args, **kwargs): |
|
70 | def wrap(self, *args, **kwargs): | |
81 | if not self.pendingparentchange(): |
|
71 | if not self.pendingparentchange(): | |
@@ -787,7 +777,7 b' class dirstate(object):' | |||||
787 | # https://www.mercurial-scm.org/wiki/DirstateTransactionPlan |
|
777 | # https://www.mercurial-scm.org/wiki/DirstateTransactionPlan | |
788 |
|
778 | |||
789 | # record when mtime start to be ambiguous |
|
779 | # record when mtime start to be ambiguous | |
790 |
now = |
|
780 | now = timestamp.get_fs_now(self._opener) | |
791 |
|
781 | |||
792 | # delay writing in-memory changes out |
|
782 | # delay writing in-memory changes out | |
793 | tr.addfilegenerator( |
|
783 | tr.addfilegenerator( |
@@ -6,6 +6,7 b'' | |||||
6 | from __future__ import absolute_import |
|
6 | from __future__ import absolute_import | |
7 |
|
7 | |||
8 | import functools |
|
8 | import functools | |
|
9 | import os | |||
9 | import stat |
|
10 | import stat | |
10 |
|
11 | |||
11 |
|
12 | |||
@@ -54,6 +55,19 b' class timestamp(tuple):' | |||||
54 | return self_subsec_nanos > other_subsec_nanos |
|
55 | return self_subsec_nanos > other_subsec_nanos | |
55 |
|
56 | |||
56 |
|
57 | |||
|
58 | def get_fs_now(vfs): | |||
|
59 | """return a timestamp for "now" in the current vfs | |||
|
60 | ||||
|
61 | This will raise an exception if no temporary files could be created. | |||
|
62 | """ | |||
|
63 | tmpfd, tmpname = vfs.mkstemp() | |||
|
64 | try: | |||
|
65 | return mtime_of(os.fstat(tmpfd)) | |||
|
66 | finally: | |||
|
67 | os.close(tmpfd) | |||
|
68 | vfs.unlink(tmpname) | |||
|
69 | ||||
|
70 | ||||
57 | def zero(): |
|
71 | def zero(): | |
58 | """ |
|
72 | """ | |
59 | Returns the `timestamp` at the Unix epoch. |
|
73 | Returns the `timestamp` at the Unix epoch. |
@@ -9,7 +9,6 b' from __future__ import absolute_import' | |||||
9 |
|
9 | |||
10 | from mercurial import ( |
|
10 | from mercurial import ( | |
11 | context, |
|
11 | context, | |
12 | dirstate, |
|
|||
13 | dirstatemap as dirstatemapmod, |
|
12 | dirstatemap as dirstatemapmod, | |
14 | extensions, |
|
13 | extensions, | |
15 | policy, |
|
14 | policy, | |
@@ -73,19 +72,19 b' def fakewrite(ui, func):' | |||||
73 | ) |
|
72 | ) | |
74 | dirstatemapmod.dirstatemap.write = wrapper |
|
73 | dirstatemapmod.dirstatemap.write = wrapper | |
75 |
|
74 | |||
76 |
orig_ |
|
75 | orig_get_fs_now = timestamp.get_fs_now | |
77 | wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args) |
|
76 | wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args) | |
78 |
|
77 | |||
79 | orig_module = parsers |
|
78 | orig_module = parsers | |
80 | orig_pack_dirstate = parsers.pack_dirstate |
|
79 | orig_pack_dirstate = parsers.pack_dirstate | |
81 |
|
80 | |||
82 | orig_module.pack_dirstate = wrapper |
|
81 | orig_module.pack_dirstate = wrapper | |
83 |
|
|
82 | timestamp.get_fs_now = lambda *args: fakenow | |
84 | try: |
|
83 | try: | |
85 | return func() |
|
84 | return func() | |
86 | finally: |
|
85 | finally: | |
87 | orig_module.pack_dirstate = orig_pack_dirstate |
|
86 | orig_module.pack_dirstate = orig_pack_dirstate | |
88 |
|
|
87 | timestamp.get_fs_now = orig_get_fs_now | |
89 | if has_rust_dirstate: |
|
88 | if has_rust_dirstate: | |
90 | dirstatemapmod.dirstatemap.write = orig_dirstatemap_write |
|
89 | dirstatemapmod.dirstatemap.write = orig_dirstatemap_write | |
91 |
|
90 |
General Comments 0
You need to be logged in to leave comments.
Login now