author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Thu, 31 Aug 2023 01:54:48 +0200 | |
changeset 50945 | 0e6cea0c3113 |
parent 50256 | a6e0b7d4ae9d |
child 51293 | 79cd29d598af |
permissions | -rw-r--r-- |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 |
import contextlib |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43010
diff
changeset
|
3 |
from . import util as interfaceutil |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43010
diff
changeset
|
4 |
|
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 |
class idirstate(interfaceutil.Interface): |
47291
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
7 |
def __init__( |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
8 |
opener, |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
9 |
ui, |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
10 |
root, |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
11 |
validate, |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
12 |
sparsematchfn, |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
13 |
nodeconstants, |
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
14 |
use_dirstate_v2, |
49961
8c7895db8955
dirstate: add missing methods and kwargs to idirstate interface
Anton Shestakov <av6@dwimlabs.net>
parents:
49960
diff
changeset
|
15 |
use_tracked_hint=False, |
47291
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47055
diff
changeset
|
16 |
): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
17 |
"""Create a new dirstate object. |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 |
opener is an open()-like callable that can be used to open the |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 |
dirstate file; root is the root of the directory tracked by |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 |
the dirstate. |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
22 |
""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 |
|
42933
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
24 |
# TODO: all these private methods and attributes should be made |
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
25 |
# public or removed from the interface. |
43010
5f8b6617e962
interfaces: use triple quotes for Attribute value
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42933
diff
changeset
|
26 |
_ignore = interfaceutil.Attribute("""Matcher for ignored files.""") |
50079
e1cff85484e2
dirstate: introduce a `is_changing_any` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50078
diff
changeset
|
27 |
is_changing_any = interfaceutil.Attribute( |
e1cff85484e2
dirstate: introduce a `is_changing_any` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50078
diff
changeset
|
28 |
"""True if any changes in progress.""" |
e1cff85484e2
dirstate: introduce a `is_changing_any` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50078
diff
changeset
|
29 |
) |
50078
e333cc169c45
dirstate: rename `pendingparentchange` to `is_changing_parents`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50023
diff
changeset
|
30 |
is_changing_parents = interfaceutil.Attribute( |
e333cc169c45
dirstate: rename `pendingparentchange` to `is_changing_parents`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50023
diff
changeset
|
31 |
"""True if parents changes in progress.""" |
e333cc169c45
dirstate: rename `pendingparentchange` to `is_changing_parents`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50023
diff
changeset
|
32 |
) |
50082
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
33 |
is_changing_files = interfaceutil.Attribute( |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
34 |
"""True if file tracking changes in progress.""" |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
35 |
) |
42933
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
36 |
|
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
37 |
def _ignorefiles(): |
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
38 |
"""Return a list of files containing patterns to ignore.""" |
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
39 |
|
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
40 |
def _ignorefileandline(f): |
43807
be8552f25cab
cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents:
43077
diff
changeset
|
41 |
"""Given a file `f`, return the ignore file and line that ignores it.""" |
42933
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
42 |
|
43010
5f8b6617e962
interfaces: use triple quotes for Attribute value
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42933
diff
changeset
|
43 |
_checklink = interfaceutil.Attribute("""Callable for checking symlinks.""") |
5f8b6617e962
interfaces: use triple quotes for Attribute value
Gregory Szorc <gregory.szorc@gmail.com>
parents:
42933
diff
changeset
|
44 |
_checkexec = interfaceutil.Attribute("""Callable for checking exec bits.""") |
42933
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
45 |
|
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
46 |
@contextlib.contextmanager |
50023
7a8bfc05b691
dirstate: rename parentchange to changing_parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50022
diff
changeset
|
47 |
def changing_parents(repo): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
48 |
"""Context manager for handling dirstate parents. |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 |
If an exception occurs in the scope of the context manager, |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
51 |
the incoherent dirstate won't be written when wlock is |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
52 |
released. |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
53 |
""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
54 |
|
50082
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
55 |
@contextlib.contextmanager |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
56 |
def changing_files(repo): |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
57 |
"""Context manager for handling dirstate files. |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
58 |
|
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
59 |
If an exception occurs in the scope of the context manager, |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
60 |
the incoherent dirstate won't be written when wlock is |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
61 |
released. |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
62 |
""" |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
63 |
|
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
64 |
def hasdir(d): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
65 |
pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
66 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
67 |
def flagfunc(buildfallback): |
49959
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
68 |
"""build a callable that returns flags associated with a filename |
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
69 |
|
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
70 |
The information is extracted from three possible layers: |
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
71 |
1. the file system if it supports the information |
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
72 |
2. the "fallback" information stored in the dirstate if any |
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
73 |
3. a more expensive mechanism inferring the flags from the parents. |
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
74 |
""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
75 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
76 |
def getcwd(): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
77 |
"""Return the path from which a canonical path is calculated. |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
78 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
79 |
This path should be used to resolve file patterns or to convert |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
80 |
canonical paths back to file paths for display. It shouldn't be |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
81 |
used to get real file paths. Use vfs functions instead. |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
82 |
""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
83 |
|
49960
b3ae17037b54
dirstate: swap pathto() and get_entry() in idirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49959
diff
changeset
|
84 |
def pathto(f, cwd=None): |
b3ae17037b54
dirstate: swap pathto() and get_entry() in idirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49959
diff
changeset
|
85 |
pass |
b3ae17037b54
dirstate: swap pathto() and get_entry() in idirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49959
diff
changeset
|
86 |
|
49131
9c8d67a3af5e
idirstate: add missing get_entry() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
48966
diff
changeset
|
87 |
def get_entry(path): |
9c8d67a3af5e
idirstate: add missing get_entry() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
48966
diff
changeset
|
88 |
"""return a DirstateItem for the associated path""" |
9c8d67a3af5e
idirstate: add missing get_entry() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
48966
diff
changeset
|
89 |
|
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
90 |
def __contains__(key): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
91 |
"""Check if bytestring `key` is known to the dirstate.""" |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
92 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
93 |
def __iter__(): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
94 |
"""Iterate the dirstate's contained filenames as bytestrings.""" |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
95 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
96 |
def items(): |
47539
84391ddf4c78
dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47291
diff
changeset
|
97 |
"""Iterate the dirstate's entries as (filename, DirstateItem. |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
98 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
99 |
As usual, filename is a bytestring. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
100 |
""" |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
101 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
102 |
iteritems = items |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
103 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
104 |
def parents(): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
105 |
pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
106 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
107 |
def p1(): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
108 |
pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
109 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
110 |
def p2(): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
111 |
pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
112 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
113 |
def branch(): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
114 |
pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
115 |
|
47055
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46793
diff
changeset
|
116 |
def setparents(p1, p2=None): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
117 |
"""Set dirstate parents to p1 and p2. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
118 |
|
49959
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
119 |
When moving from two parents to one, "merged" entries a |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
120 |
adjusted to normal and previous copy records discarded and |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
121 |
returned by the call. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
122 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
123 |
See localrepo.setparents() |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
124 |
""" |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
125 |
|
50256
a6e0b7d4ae9d
dirstate: write the `branch` as part of the transaction if any
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50247
diff
changeset
|
126 |
def setbranch(branch, transaction=None): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
127 |
pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
128 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
129 |
def invalidate(): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
130 |
"""Causes the next access to reread the dirstate. |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
131 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
132 |
This is different from localrepo.invalidatedirstate() because it always |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
133 |
rereads the dirstate. Use localrepo.invalidatedirstate() if you want to |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
134 |
check whether the dirstate has changed before rereading it.""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
135 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
136 |
def copy(source, dest): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
137 |
"""Mark dest as a copy of source. Unmark dest if source is None.""" |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
138 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
139 |
def copied(file): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
140 |
pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
141 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
142 |
def copies(): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
143 |
pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
144 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
145 |
def normalize(path, isknown=False, ignoremissing=False): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
146 |
""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
147 |
normalize the case of a pathname when on a casefolding filesystem |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
148 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
149 |
isknown specifies whether the filename came from walking the |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
150 |
disk, to avoid extra filesystem access. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
151 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
152 |
If ignoremissing is True, missing path are returned |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
153 |
unchanged. Otherwise, we try harder to normalize possibly |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
154 |
existing path components. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
155 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
156 |
The normalized case is determined based on the following precedence: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
157 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
158 |
- version of name already stored in the dirstate |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
159 |
- version of name stored on disk |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
160 |
- version provided via command arguments |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
161 |
""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
162 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
163 |
def clear(): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
164 |
pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
165 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
166 |
def rebuild(parent, allfiles, changedfiles=None): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
167 |
pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
168 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
169 |
def write(tr): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
170 |
pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
171 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
172 |
def addparentchangecallback(category, callback): |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
173 |
"""add a callback to be called when the wd parents are changed |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
174 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
175 |
Callback will be called with the following arguments: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
176 |
dirstate, (oldp1, oldp2), (newp1, newp2) |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
177 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
178 |
Category is a unique identifier to allow overwriting an old callback |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
179 |
with a newer callback. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
180 |
""" |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
181 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
182 |
def walk(match, subrepos, unknown, ignored, full=True): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
183 |
""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
184 |
Walk recursively through the directory tree, finding all files |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
185 |
matched by match. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
186 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
187 |
If full is False, maybe skip some known-clean files. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
188 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
189 |
Return a dict mapping filename to stat-like object (either |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
190 |
mercurial.osutil.stat instance or return value of os.stat()). |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
191 |
|
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
192 |
""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
193 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
194 |
def status(match, subrepos, ignored, clean, unknown): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
195 |
"""Determine the status of the working copy relative to the |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
196 |
dirstate and return a pair of (unsure, status), where status is of type |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
197 |
scmutil.status and: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
198 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
199 |
unsure: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
200 |
files that might have been modified since the dirstate was |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
201 |
written, but need to be read to be sure (size is the same |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
202 |
but mtime differs) |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
203 |
status.modified: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
204 |
files that have definitely been modified since the dirstate |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
205 |
was written (different size or mode) |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
206 |
status.clean: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
207 |
files that have definitely not been modified since the |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
208 |
dirstate was written |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
209 |
""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
210 |
|
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
211 |
def matches(match): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
212 |
""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
213 |
return files in the dirstate (in whatever state) filtered by match |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
214 |
""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
215 |
|
49961
8c7895db8955
dirstate: add missing methods and kwargs to idirstate interface
Anton Shestakov <av6@dwimlabs.net>
parents:
49960
diff
changeset
|
216 |
def verify(m1, m2, p1, narrow_matcher=None): |
8c7895db8955
dirstate: add missing methods and kwargs to idirstate interface
Anton Shestakov <av6@dwimlabs.net>
parents:
49960
diff
changeset
|
217 |
""" |
8c7895db8955
dirstate: add missing methods and kwargs to idirstate interface
Anton Shestakov <av6@dwimlabs.net>
parents:
49960
diff
changeset
|
218 |
check the dirstate contents against the parent manifest and yield errors |
8c7895db8955
dirstate: add missing methods and kwargs to idirstate interface
Anton Shestakov <av6@dwimlabs.net>
parents:
49960
diff
changeset
|
219 |
""" |