Mercurial > hg
annotate hgext/fsmonitor/state.py @ 39772:ae531f5e583c
testing: add interface unit tests for file storage
Our strategy for supporting alternate storage backends is to define
interfaces for everything then "code to the interface."
We already have interfaces for various primitives, including file
and manifest storage.
What we don't have is generic unit tests for those interfaces. Up
to this point we've been relying on high-level integration tests
(mainly in the form of existing .t tests) to test alternate storage
backends. And my experience with developing the "simple store" test
extension is that such testing is very tedious: it takes several
minutes to run all tests and when you find a failure, it is often
non-trivial to debug.
This commit starts to change that.
This commit introduces the mercurial.testing.storage module. It
contains testing code for storage. Currently, it defines some
unittest.TestCase classes for testing the file storage interfaces.
It also defines some factory functions that allow a caller to easily
spawn a custom TestCase "bound" to a specific file storage backend
implementation.
A new .py test has been added. It simply defines a callable to produce
filelog and transaction instances on demand and then "registers" the
various test classes so the filelog class can be tested with the
storage interface unit tests.
As part of writing the tests, I identified a couple of apparent
bugs in revlog.py and filelog.py! These are tracked with inline
TODO comments.
Writing the tests makes it more obvious where the storage interface
is lacking. For example, we raise either IndexError or
error.LookupError for missing revisions depending on whether we
use an integer revision or a node. Also, we raise error.RevlogError
in various places when we should be raising a storage-agnostic
error type.
The storage interfaces are currently far from perfect and there is much
work to be done to improve them. But at least with this commit we
finally have the start of unit tests that can be used to "qualify"
the behavior of a storage backend. And when implementing and debugging
new storage backends, we now have an obvious place to define new
tests and have obvious places to insert breakpoints to facilitate
debugging. This should be invaluable when implementing new storage
backends.
I added the mercurial.testing package because these interface
conformance tests are generic and need to be usable by all storage
backends. Having the code live in tests/ would make it difficult for
storage backends implemented in extensions to test their interface
conformance. First, it would require obtaining a copy of Mercurial's
storage test code in order to test. Second, it would make testing
against multiple Mercurial versions difficult, as you would need to
import N copies of the storage testing code in order to achieve test
coverage. By making the test code part of the Mercurial distribution
itself, extensions can `import mercurial.testing.*` to access and run
the test code. The test will run against whatever Mercurial version
is active.
FWIW I've always wanted to move parts of run-tests.py into the
mercurial.* package to make the testing story simpler (e.g. imagine an
`hg debugruntests` command that could invoke the test harness). While I
have no plans to do that in the near future, establishing the
mercurial.testing package does provide a natural home for that code
should someone do this in the future.
Differential Revision: https://phab.mercurial-scm.org/D4650
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 18 Sep 2018 16:52:11 -0700 |
parents | 718f7acd6d5e |
children | 2372284d9457 |
rev | line source |
---|---|
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
1 # state.py - fsmonitor persistent state |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
2 # |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
3 # Copyright 2013-2016 Facebook, Inc. |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
4 # |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
7 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
8 from __future__ import absolute_import |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
9 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
10 import errno |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
11 import os |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
12 import socket |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
13 import struct |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
14 |
29205
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28433
diff
changeset
|
15 from mercurial.i18n import _ |
32816
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
16 from mercurial import ( |
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
17 pathutil, |
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
18 util, |
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
19 ) |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
20 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
21 _version = 4 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
22 _versionformat = ">I" |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
23 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
24 class state(object): |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
25 def __init__(self, repo): |
31215
15c998528c36
fsmonitor: remove use of repo.opener
Durham Goode <durham@fb.com>
parents:
30539
diff
changeset
|
26 self._vfs = repo.vfs |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
27 self._ui = repo.ui |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
28 self._rootdir = pathutil.normasprefix(repo.root) |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
29 self._lastclock = None |
32816
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
30 self._identity = util.filestat(None) |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
31 |
34463
718f7acd6d5e
fsmonitor: use configitem
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32816
diff
changeset
|
32 self.mode = self._ui.config('fsmonitor', 'mode') |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
33 self.walk_on_invalidate = self._ui.configbool( |
34463
718f7acd6d5e
fsmonitor: use configitem
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32816
diff
changeset
|
34 'fsmonitor', 'walk_on_invalidate') |
718f7acd6d5e
fsmonitor: use configitem
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32816
diff
changeset
|
35 self.timeout = float(self._ui.config('fsmonitor', 'timeout')) |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
36 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
37 def get(self): |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
38 try: |
31215
15c998528c36
fsmonitor: remove use of repo.opener
Durham Goode <durham@fb.com>
parents:
30539
diff
changeset
|
39 file = self._vfs('fsmonitor.state', 'rb') |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
40 except IOError as inst: |
32816
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
41 self._identity = util.filestat(None) |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
42 if inst.errno != errno.ENOENT: |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
43 raise |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
44 return None, None, None |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
45 |
32816
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
46 self._identity = util.filestat.fromfp(file) |
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
47 |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
48 versionbytes = file.read(4) |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
49 if len(versionbytes) < 4: |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
50 self._ui.log( |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
51 'fsmonitor', 'fsmonitor: state file only has %d bytes, ' |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
52 'nuking state\n' % len(versionbytes)) |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
53 self.invalidate() |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
54 return None, None, None |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
55 try: |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
56 diskversion = struct.unpack(_versionformat, versionbytes)[0] |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
57 if diskversion != _version: |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
58 # different version, nuke state and start over |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
59 self._ui.log( |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
60 'fsmonitor', 'fsmonitor: version switch from %d to ' |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
61 '%d, nuking state\n' % (diskversion, _version)) |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
62 self.invalidate() |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
63 return None, None, None |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
64 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
65 state = file.read().split('\0') |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
66 # state = hostname\0clock\0ignorehash\0 + list of files, each |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
67 # followed by a \0 |
30539
29b35dac3b1f
fsmonitor: be robust in the face of bad state
Simon Farnsworth <simonfar@fb.com>
parents:
29205
diff
changeset
|
68 if len(state) < 3: |
29b35dac3b1f
fsmonitor: be robust in the face of bad state
Simon Farnsworth <simonfar@fb.com>
parents:
29205
diff
changeset
|
69 self._ui.log( |
29b35dac3b1f
fsmonitor: be robust in the face of bad state
Simon Farnsworth <simonfar@fb.com>
parents:
29205
diff
changeset
|
70 'fsmonitor', 'fsmonitor: state file truncated (expected ' |
29b35dac3b1f
fsmonitor: be robust in the face of bad state
Simon Farnsworth <simonfar@fb.com>
parents:
29205
diff
changeset
|
71 '3 chunks, found %d), nuking state\n', len(state)) |
29b35dac3b1f
fsmonitor: be robust in the face of bad state
Simon Farnsworth <simonfar@fb.com>
parents:
29205
diff
changeset
|
72 self.invalidate() |
29b35dac3b1f
fsmonitor: be robust in the face of bad state
Simon Farnsworth <simonfar@fb.com>
parents:
29205
diff
changeset
|
73 return None, None, None |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
74 diskhostname = state[0] |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
75 hostname = socket.gethostname() |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
76 if diskhostname != hostname: |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
77 # file got moved to a different host |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
78 self._ui.log('fsmonitor', 'fsmonitor: stored hostname "%s" ' |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
79 'different from current "%s", nuking state\n' % |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
80 (diskhostname, hostname)) |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
81 self.invalidate() |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
82 return None, None, None |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
83 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
84 clock = state[1] |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
85 ignorehash = state[2] |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
86 # discard the value after the last \0 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
87 notefiles = state[3:-1] |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
88 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
89 finally: |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
90 file.close() |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
91 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
92 return clock, ignorehash, notefiles |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
93 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
94 def set(self, clock, ignorehash, notefiles): |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
95 if clock is None: |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
96 self.invalidate() |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
97 return |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
98 |
32816
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
99 # Read the identity from the file on disk rather than from the open file |
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
100 # pointer below, because the latter is actually a brand new file. |
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
101 identity = util.filestat.frompath(self._vfs.join('fsmonitor.state')) |
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
102 if identity != self._identity: |
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
103 self._ui.debug('skip updating fsmonitor.state: identity mismatch\n') |
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
104 return |
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
105 |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
106 try: |
32816
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
107 file = self._vfs('fsmonitor.state', 'wb', atomictemp=True, |
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
108 checkambig=True) |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
109 except (IOError, OSError): |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
110 self._ui.warn(_("warning: unable to write out fsmonitor state\n")) |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
111 return |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
112 |
30539
29b35dac3b1f
fsmonitor: be robust in the face of bad state
Simon Farnsworth <simonfar@fb.com>
parents:
29205
diff
changeset
|
113 with file: |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
114 file.write(struct.pack(_versionformat, _version)) |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
115 file.write(socket.gethostname() + '\0') |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
116 file.write(clock + '\0') |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
117 file.write(ignorehash + '\0') |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
118 if notefiles: |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
119 file.write('\0'.join(notefiles)) |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
120 file.write('\0') |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
121 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
122 def invalidate(self): |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
123 try: |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
124 os.unlink(os.path.join(self._rootdir, '.hg', 'fsmonitor.state')) |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
125 except OSError as inst: |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
126 if inst.errno != errno.ENOENT: |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
127 raise |
32816
1b25c648d5b7
fsmonitor: don't write out state if identity has changed (issue5581)
Siddharth Agarwal <sid0@fb.com>
parents:
31215
diff
changeset
|
128 self._identity = util.filestat(None) |
28433
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
129 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
130 def setlastclock(self, clock): |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
131 self._lastclock = clock |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
132 |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
133 def getlastclock(self): |
3b67f27bb908
fsmonitor: new experimental extension
Martijn Pieters <mjpieters@fb.com>
parents:
diff
changeset
|
134 return self._lastclock |