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