##// END OF EJS Templates
idirstate: add missing get_entry() method...
Matt Harbison -
r49949:9ab62e1f default draft
parent child Browse files
Show More
@@ -1,207 +1,210
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 ):
15 ):
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 get_entry(path):
65 """return a DirstateItem for the associated path"""
66
64 def pathto(f, cwd=None):
67 def pathto(f, cwd=None):
65 pass
68 pass
66
69
67 def __contains__(key):
70 def __contains__(key):
68 """Check if bytestring `key` is known to the dirstate."""
71 """Check if bytestring `key` is known to the dirstate."""
69
72
70 def __iter__():
73 def __iter__():
71 """Iterate the dirstate's contained filenames as bytestrings."""
74 """Iterate the dirstate's contained filenames as bytestrings."""
72
75
73 def items():
76 def items():
74 """Iterate the dirstate's entries as (filename, DirstateItem.
77 """Iterate the dirstate's entries as (filename, DirstateItem.
75
78
76 As usual, filename is a bytestring.
79 As usual, filename is a bytestring.
77 """
80 """
78
81
79 iteritems = items
82 iteritems = items
80
83
81 def parents():
84 def parents():
82 pass
85 pass
83
86
84 def p1():
87 def p1():
85 pass
88 pass
86
89
87 def p2():
90 def p2():
88 pass
91 pass
89
92
90 def branch():
93 def branch():
91 pass
94 pass
92
95
93 def setparents(p1, p2=None):
96 def setparents(p1, p2=None):
94 """Set dirstate parents to p1 and p2.
97 """Set dirstate parents to p1 and p2.
95
98
96 When moving from two parents to one, 'm' merged entries a
99 When moving from two parents to one, 'm' merged entries a
97 adjusted to normal and previous copy records discarded and
100 adjusted to normal and previous copy records discarded and
98 returned by the call.
101 returned by the call.
99
102
100 See localrepo.setparents()
103 See localrepo.setparents()
101 """
104 """
102
105
103 def setbranch(branch):
106 def setbranch(branch):
104 pass
107 pass
105
108
106 def invalidate():
109 def invalidate():
107 """Causes the next access to reread the dirstate.
110 """Causes the next access to reread the dirstate.
108
111
109 This is different from localrepo.invalidatedirstate() because it always
112 This is different from localrepo.invalidatedirstate() because it always
110 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
113 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
111 check whether the dirstate has changed before rereading it."""
114 check whether the dirstate has changed before rereading it."""
112
115
113 def copy(source, dest):
116 def copy(source, dest):
114 """Mark dest as a copy of source. Unmark dest if source is None."""
117 """Mark dest as a copy of source. Unmark dest if source is None."""
115
118
116 def copied(file):
119 def copied(file):
117 pass
120 pass
118
121
119 def copies():
122 def copies():
120 pass
123 pass
121
124
122 def normalize(path, isknown=False, ignoremissing=False):
125 def normalize(path, isknown=False, ignoremissing=False):
123 """
126 """
124 normalize the case of a pathname when on a casefolding filesystem
127 normalize the case of a pathname when on a casefolding filesystem
125
128
126 isknown specifies whether the filename came from walking the
129 isknown specifies whether the filename came from walking the
127 disk, to avoid extra filesystem access.
130 disk, to avoid extra filesystem access.
128
131
129 If ignoremissing is True, missing path are returned
132 If ignoremissing is True, missing path are returned
130 unchanged. Otherwise, we try harder to normalize possibly
133 unchanged. Otherwise, we try harder to normalize possibly
131 existing path components.
134 existing path components.
132
135
133 The normalized case is determined based on the following precedence:
136 The normalized case is determined based on the following precedence:
134
137
135 - version of name already stored in the dirstate
138 - version of name already stored in the dirstate
136 - version of name stored on disk
139 - version of name stored on disk
137 - version provided via command arguments
140 - version provided via command arguments
138 """
141 """
139
142
140 def clear():
143 def clear():
141 pass
144 pass
142
145
143 def rebuild(parent, allfiles, changedfiles=None):
146 def rebuild(parent, allfiles, changedfiles=None):
144 pass
147 pass
145
148
146 def identity():
149 def identity():
147 """Return identity of dirstate it to detect changing in storage
150 """Return identity of dirstate it to detect changing in storage
148
151
149 If identity of previous dirstate is equal to this, writing
152 If identity of previous dirstate is equal to this, writing
150 changes based on the former dirstate out can keep consistency.
153 changes based on the former dirstate out can keep consistency.
151 """
154 """
152
155
153 def write(tr):
156 def write(tr):
154 pass
157 pass
155
158
156 def addparentchangecallback(category, callback):
159 def addparentchangecallback(category, callback):
157 """add a callback to be called when the wd parents are changed
160 """add a callback to be called when the wd parents are changed
158
161
159 Callback will be called with the following arguments:
162 Callback will be called with the following arguments:
160 dirstate, (oldp1, oldp2), (newp1, newp2)
163 dirstate, (oldp1, oldp2), (newp1, newp2)
161
164
162 Category is a unique identifier to allow overwriting an old callback
165 Category is a unique identifier to allow overwriting an old callback
163 with a newer callback.
166 with a newer callback.
164 """
167 """
165
168
166 def walk(match, subrepos, unknown, ignored, full=True):
169 def walk(match, subrepos, unknown, ignored, full=True):
167 """
170 """
168 Walk recursively through the directory tree, finding all files
171 Walk recursively through the directory tree, finding all files
169 matched by match.
172 matched by match.
170
173
171 If full is False, maybe skip some known-clean files.
174 If full is False, maybe skip some known-clean files.
172
175
173 Return a dict mapping filename to stat-like object (either
176 Return a dict mapping filename to stat-like object (either
174 mercurial.osutil.stat instance or return value of os.stat()).
177 mercurial.osutil.stat instance or return value of os.stat()).
175
178
176 """
179 """
177
180
178 def status(match, subrepos, ignored, clean, unknown):
181 def status(match, subrepos, ignored, clean, unknown):
179 """Determine the status of the working copy relative to the
182 """Determine the status of the working copy relative to the
180 dirstate and return a pair of (unsure, status), where status is of type
183 dirstate and return a pair of (unsure, status), where status is of type
181 scmutil.status and:
184 scmutil.status and:
182
185
183 unsure:
186 unsure:
184 files that might have been modified since the dirstate was
187 files that might have been modified since the dirstate was
185 written, but need to be read to be sure (size is the same
188 written, but need to be read to be sure (size is the same
186 but mtime differs)
189 but mtime differs)
187 status.modified:
190 status.modified:
188 files that have definitely been modified since the dirstate
191 files that have definitely been modified since the dirstate
189 was written (different size or mode)
192 was written (different size or mode)
190 status.clean:
193 status.clean:
191 files that have definitely not been modified since the
194 files that have definitely not been modified since the
192 dirstate was written
195 dirstate was written
193 """
196 """
194
197
195 def matches(match):
198 def matches(match):
196 """
199 """
197 return files in the dirstate (in whatever state) filtered by match
200 return files in the dirstate (in whatever state) filtered by match
198 """
201 """
199
202
200 def savebackup(tr, backupname):
203 def savebackup(tr, backupname):
201 '''Save current dirstate into backup file'''
204 '''Save current dirstate into backup file'''
202
205
203 def restorebackup(tr, backupname):
206 def restorebackup(tr, backupname):
204 '''Restore dirstate by backup file'''
207 '''Restore dirstate by backup file'''
205
208
206 def clearbackup(tr, backupname):
209 def clearbackup(tr, backupname):
207 '''Clear backup file'''
210 '''Clear backup file'''
General Comments 0
You need to be logged in to leave comments. Login now