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