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