##// END OF EJS Templates
dirstate: add missing methods and kwargs to idirstate interface
av6 -
r50777:8c7895db default
parent child Browse files
Show More
@@ -1,216 +1,222 b''
1 import contextlib
1 import contextlib
2
2
3 from . import util as interfaceutil
3 from . import util as interfaceutil
4
4
5
5
6 class idirstate(interfaceutil.Interface):
6 class idirstate(interfaceutil.Interface):
7 def __init__(
7 def __init__(
8 opener,
8 opener,
9 ui,
9 ui,
10 root,
10 root,
11 validate,
11 validate,
12 sparsematchfn,
12 sparsematchfn,
13 nodeconstants,
13 nodeconstants,
14 use_dirstate_v2,
14 use_dirstate_v2,
15 use_tracked_hint=False,
15 ):
16 ):
16 """Create a new dirstate object.
17 """Create a new dirstate object.
17
18
18 opener is an open()-like callable that can be used to open the
19 opener is an open()-like callable that can be used to open the
19 dirstate file; root is the root of the directory tracked by
20 dirstate file; root is the root of the directory tracked by
20 the dirstate.
21 the dirstate.
21 """
22 """
22
23
23 # TODO: all these private methods and attributes should be made
24 # TODO: all these private methods and attributes should be made
24 # public or removed from the interface.
25 # public or removed from the interface.
25 _ignore = interfaceutil.Attribute("""Matcher for ignored files.""")
26 _ignore = interfaceutil.Attribute("""Matcher for ignored files.""")
26
27
27 def _ignorefiles():
28 def _ignorefiles():
28 """Return a list of files containing patterns to ignore."""
29 """Return a list of files containing patterns to ignore."""
29
30
30 def _ignorefileandline(f):
31 def _ignorefileandline(f):
31 """Given a file `f`, return the ignore file and line that ignores it."""
32 """Given a file `f`, return the ignore file and line that ignores it."""
32
33
33 _checklink = interfaceutil.Attribute("""Callable for checking symlinks.""")
34 _checklink = interfaceutil.Attribute("""Callable for checking symlinks.""")
34 _checkexec = interfaceutil.Attribute("""Callable for checking exec bits.""")
35 _checkexec = interfaceutil.Attribute("""Callable for checking exec bits.""")
35
36
36 @contextlib.contextmanager
37 @contextlib.contextmanager
37 def parentchange():
38 def parentchange():
38 """Context manager for handling dirstate parents.
39 """Context manager for handling dirstate parents.
39
40
40 If an exception occurs in the scope of the context manager,
41 If an exception occurs in the scope of the context manager,
41 the incoherent dirstate won't be written when wlock is
42 the incoherent dirstate won't be written when wlock is
42 released.
43 released.
43 """
44 """
44
45
45 def pendingparentchange():
46 def pendingparentchange():
46 """Returns true if the dirstate is in the middle of a set of changes
47 """Returns true if the dirstate is in the middle of a set of changes
47 that modify the dirstate parent.
48 that modify the dirstate parent.
48 """
49 """
49
50
50 def hasdir(d):
51 def hasdir(d):
51 pass
52 pass
52
53
53 def flagfunc(buildfallback):
54 def flagfunc(buildfallback):
54 """build a callable that returns flags associated with a filename
55 """build a callable that returns flags associated with a filename
55
56
56 The information is extracted from three possible layers:
57 The information is extracted from three possible layers:
57 1. the file system if it supports the information
58 1. the file system if it supports the information
58 2. the "fallback" information stored in the dirstate if any
59 2. the "fallback" information stored in the dirstate if any
59 3. a more expensive mechanism inferring the flags from the parents.
60 3. a more expensive mechanism inferring the flags from the parents.
60 """
61 """
61
62
62 def getcwd():
63 def getcwd():
63 """Return the path from which a canonical path is calculated.
64 """Return the path from which a canonical path is calculated.
64
65
65 This path should be used to resolve file patterns or to convert
66 This path should be used to resolve file patterns or to convert
66 canonical paths back to file paths for display. It shouldn't be
67 canonical paths back to file paths for display. It shouldn't be
67 used to get real file paths. Use vfs functions instead.
68 used to get real file paths. Use vfs functions instead.
68 """
69 """
69
70
70 def pathto(f, cwd=None):
71 def pathto(f, cwd=None):
71 pass
72 pass
72
73
73 def get_entry(path):
74 def get_entry(path):
74 """return a DirstateItem for the associated path"""
75 """return a DirstateItem for the associated path"""
75
76
76 def __contains__(key):
77 def __contains__(key):
77 """Check if bytestring `key` is known to the dirstate."""
78 """Check if bytestring `key` is known to the dirstate."""
78
79
79 def __iter__():
80 def __iter__():
80 """Iterate the dirstate's contained filenames as bytestrings."""
81 """Iterate the dirstate's contained filenames as bytestrings."""
81
82
82 def items():
83 def items():
83 """Iterate the dirstate's entries as (filename, DirstateItem.
84 """Iterate the dirstate's entries as (filename, DirstateItem.
84
85
85 As usual, filename is a bytestring.
86 As usual, filename is a bytestring.
86 """
87 """
87
88
88 iteritems = items
89 iteritems = items
89
90
90 def parents():
91 def parents():
91 pass
92 pass
92
93
93 def p1():
94 def p1():
94 pass
95 pass
95
96
96 def p2():
97 def p2():
97 pass
98 pass
98
99
99 def branch():
100 def branch():
100 pass
101 pass
101
102
102 def setparents(p1, p2=None):
103 def setparents(p1, p2=None):
103 """Set dirstate parents to p1 and p2.
104 """Set dirstate parents to p1 and p2.
104
105
105 When moving from two parents to one, "merged" entries a
106 When moving from two parents to one, "merged" entries a
106 adjusted to normal and previous copy records discarded and
107 adjusted to normal and previous copy records discarded and
107 returned by the call.
108 returned by the call.
108
109
109 See localrepo.setparents()
110 See localrepo.setparents()
110 """
111 """
111
112
112 def setbranch(branch):
113 def setbranch(branch):
113 pass
114 pass
114
115
115 def invalidate():
116 def invalidate():
116 """Causes the next access to reread the dirstate.
117 """Causes the next access to reread the dirstate.
117
118
118 This is different from localrepo.invalidatedirstate() because it always
119 This is different from localrepo.invalidatedirstate() because it always
119 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
120 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
120 check whether the dirstate has changed before rereading it."""
121 check whether the dirstate has changed before rereading it."""
121
122
122 def copy(source, dest):
123 def copy(source, dest):
123 """Mark dest as a copy of source. Unmark dest if source is None."""
124 """Mark dest as a copy of source. Unmark dest if source is None."""
124
125
125 def copied(file):
126 def copied(file):
126 pass
127 pass
127
128
128 def copies():
129 def copies():
129 pass
130 pass
130
131
131 def normalize(path, isknown=False, ignoremissing=False):
132 def normalize(path, isknown=False, ignoremissing=False):
132 """
133 """
133 normalize the case of a pathname when on a casefolding filesystem
134 normalize the case of a pathname when on a casefolding filesystem
134
135
135 isknown specifies whether the filename came from walking the
136 isknown specifies whether the filename came from walking the
136 disk, to avoid extra filesystem access.
137 disk, to avoid extra filesystem access.
137
138
138 If ignoremissing is True, missing path are returned
139 If ignoremissing is True, missing path are returned
139 unchanged. Otherwise, we try harder to normalize possibly
140 unchanged. Otherwise, we try harder to normalize possibly
140 existing path components.
141 existing path components.
141
142
142 The normalized case is determined based on the following precedence:
143 The normalized case is determined based on the following precedence:
143
144
144 - version of name already stored in the dirstate
145 - version of name already stored in the dirstate
145 - version of name stored on disk
146 - version of name stored on disk
146 - version provided via command arguments
147 - version provided via command arguments
147 """
148 """
148
149
149 def clear():
150 def clear():
150 pass
151 pass
151
152
152 def rebuild(parent, allfiles, changedfiles=None):
153 def rebuild(parent, allfiles, changedfiles=None):
153 pass
154 pass
154
155
155 def identity():
156 def identity():
156 """Return identity of dirstate itself to detect changing in storage
157 """Return identity of dirstate itself to detect changing in storage
157
158
158 If identity of previous dirstate is equal to this, writing
159 If identity of previous dirstate is equal to this, writing
159 changes based on the former dirstate out can keep consistency.
160 changes based on the former dirstate out can keep consistency.
160 """
161 """
161
162
162 def write(tr):
163 def write(tr):
163 pass
164 pass
164
165
165 def addparentchangecallback(category, callback):
166 def addparentchangecallback(category, callback):
166 """add a callback to be called when the wd parents are changed
167 """add a callback to be called when the wd parents are changed
167
168
168 Callback will be called with the following arguments:
169 Callback will be called with the following arguments:
169 dirstate, (oldp1, oldp2), (newp1, newp2)
170 dirstate, (oldp1, oldp2), (newp1, newp2)
170
171
171 Category is a unique identifier to allow overwriting an old callback
172 Category is a unique identifier to allow overwriting an old callback
172 with a newer callback.
173 with a newer callback.
173 """
174 """
174
175
175 def walk(match, subrepos, unknown, ignored, full=True):
176 def walk(match, subrepos, unknown, ignored, full=True):
176 """
177 """
177 Walk recursively through the directory tree, finding all files
178 Walk recursively through the directory tree, finding all files
178 matched by match.
179 matched by match.
179
180
180 If full is False, maybe skip some known-clean files.
181 If full is False, maybe skip some known-clean files.
181
182
182 Return a dict mapping filename to stat-like object (either
183 Return a dict mapping filename to stat-like object (either
183 mercurial.osutil.stat instance or return value of os.stat()).
184 mercurial.osutil.stat instance or return value of os.stat()).
184
185
185 """
186 """
186
187
187 def status(match, subrepos, ignored, clean, unknown):
188 def status(match, subrepos, ignored, clean, unknown):
188 """Determine the status of the working copy relative to the
189 """Determine the status of the working copy relative to the
189 dirstate and return a pair of (unsure, status), where status is of type
190 dirstate and return a pair of (unsure, status), where status is of type
190 scmutil.status and:
191 scmutil.status and:
191
192
192 unsure:
193 unsure:
193 files that might have been modified since the dirstate was
194 files that might have been modified since the dirstate was
194 written, but need to be read to be sure (size is the same
195 written, but need to be read to be sure (size is the same
195 but mtime differs)
196 but mtime differs)
196 status.modified:
197 status.modified:
197 files that have definitely been modified since the dirstate
198 files that have definitely been modified since the dirstate
198 was written (different size or mode)
199 was written (different size or mode)
199 status.clean:
200 status.clean:
200 files that have definitely not been modified since the
201 files that have definitely not been modified since the
201 dirstate was written
202 dirstate was written
202 """
203 """
203
204
204 def matches(match):
205 def matches(match):
205 """
206 """
206 return files in the dirstate (in whatever state) filtered by match
207 return files in the dirstate (in whatever state) filtered by match
207 """
208 """
208
209
209 def savebackup(tr, backupname):
210 def savebackup(tr, backupname):
210 '''Save current dirstate into backup file'''
211 '''Save current dirstate into backup file'''
211
212
212 def restorebackup(tr, backupname):
213 def restorebackup(tr, backupname):
213 '''Restore dirstate by backup file'''
214 '''Restore dirstate by backup file'''
214
215
215 def clearbackup(tr, backupname):
216 def clearbackup(tr, backupname):
216 '''Clear backup file'''
217 '''Clear backup file'''
218
219 def verify(m1, m2, p1, narrow_matcher=None):
220 """
221 check the dirstate contents against the parent manifest and yield errors
222 """
General Comments 0
You need to be logged in to leave comments. Login now