##// END OF EJS Templates
annotate: always adjust linkrev before walking down to parents (issue4623)...
Yuya Nishihara -
r24862:c82d88df stable
parent child Browse files
Show More
@@ -1,1893 +1,1898 b''
1 # context.py - changeset and file context objects for mercurial
1 # context.py - changeset and file context objects for mercurial
2 #
2 #
3 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from node import nullid, nullrev, short, hex, bin
8 from node import nullid, nullrev, short, hex, bin
9 from i18n import _
9 from i18n import _
10 import mdiff, error, util, scmutil, subrepo, patch, encoding, phases
10 import mdiff, error, util, scmutil, subrepo, patch, encoding, phases
11 import match as matchmod
11 import match as matchmod
12 import os, errno, stat
12 import os, errno, stat
13 import obsolete as obsmod
13 import obsolete as obsmod
14 import repoview
14 import repoview
15 import fileset
15 import fileset
16 import revlog
16 import revlog
17
17
18 propertycache = util.propertycache
18 propertycache = util.propertycache
19
19
20 # Phony node value to stand-in for new files in some uses of
20 # Phony node value to stand-in for new files in some uses of
21 # manifests. Manifests support 21-byte hashes for nodes which are
21 # manifests. Manifests support 21-byte hashes for nodes which are
22 # dirty in the working copy.
22 # dirty in the working copy.
23 _newnode = '!' * 21
23 _newnode = '!' * 21
24
24
25 class basectx(object):
25 class basectx(object):
26 """A basectx object represents the common logic for its children:
26 """A basectx object represents the common logic for its children:
27 changectx: read-only context that is already present in the repo,
27 changectx: read-only context that is already present in the repo,
28 workingctx: a context that represents the working directory and can
28 workingctx: a context that represents the working directory and can
29 be committed,
29 be committed,
30 memctx: a context that represents changes in-memory and can also
30 memctx: a context that represents changes in-memory and can also
31 be committed."""
31 be committed."""
32 def __new__(cls, repo, changeid='', *args, **kwargs):
32 def __new__(cls, repo, changeid='', *args, **kwargs):
33 if isinstance(changeid, basectx):
33 if isinstance(changeid, basectx):
34 return changeid
34 return changeid
35
35
36 o = super(basectx, cls).__new__(cls)
36 o = super(basectx, cls).__new__(cls)
37
37
38 o._repo = repo
38 o._repo = repo
39 o._rev = nullrev
39 o._rev = nullrev
40 o._node = nullid
40 o._node = nullid
41
41
42 return o
42 return o
43
43
44 def __str__(self):
44 def __str__(self):
45 return short(self.node())
45 return short(self.node())
46
46
47 def __int__(self):
47 def __int__(self):
48 return self.rev()
48 return self.rev()
49
49
50 def __repr__(self):
50 def __repr__(self):
51 return "<%s %s>" % (type(self).__name__, str(self))
51 return "<%s %s>" % (type(self).__name__, str(self))
52
52
53 def __eq__(self, other):
53 def __eq__(self, other):
54 try:
54 try:
55 return type(self) == type(other) and self._rev == other._rev
55 return type(self) == type(other) and self._rev == other._rev
56 except AttributeError:
56 except AttributeError:
57 return False
57 return False
58
58
59 def __ne__(self, other):
59 def __ne__(self, other):
60 return not (self == other)
60 return not (self == other)
61
61
62 def __contains__(self, key):
62 def __contains__(self, key):
63 return key in self._manifest
63 return key in self._manifest
64
64
65 def __getitem__(self, key):
65 def __getitem__(self, key):
66 return self.filectx(key)
66 return self.filectx(key)
67
67
68 def __iter__(self):
68 def __iter__(self):
69 return iter(self._manifest)
69 return iter(self._manifest)
70
70
71 def _manifestmatches(self, match, s):
71 def _manifestmatches(self, match, s):
72 """generate a new manifest filtered by the match argument
72 """generate a new manifest filtered by the match argument
73
73
74 This method is for internal use only and mainly exists to provide an
74 This method is for internal use only and mainly exists to provide an
75 object oriented way for other contexts to customize the manifest
75 object oriented way for other contexts to customize the manifest
76 generation.
76 generation.
77 """
77 """
78 return self.manifest().matches(match)
78 return self.manifest().matches(match)
79
79
80 def _matchstatus(self, other, match):
80 def _matchstatus(self, other, match):
81 """return match.always if match is none
81 """return match.always if match is none
82
82
83 This internal method provides a way for child objects to override the
83 This internal method provides a way for child objects to override the
84 match operator.
84 match operator.
85 """
85 """
86 return match or matchmod.always(self._repo.root, self._repo.getcwd())
86 return match or matchmod.always(self._repo.root, self._repo.getcwd())
87
87
88 def _buildstatus(self, other, s, match, listignored, listclean,
88 def _buildstatus(self, other, s, match, listignored, listclean,
89 listunknown):
89 listunknown):
90 """build a status with respect to another context"""
90 """build a status with respect to another context"""
91 # Load earliest manifest first for caching reasons. More specifically,
91 # Load earliest manifest first for caching reasons. More specifically,
92 # if you have revisions 1000 and 1001, 1001 is probably stored as a
92 # if you have revisions 1000 and 1001, 1001 is probably stored as a
93 # delta against 1000. Thus, if you read 1000 first, we'll reconstruct
93 # delta against 1000. Thus, if you read 1000 first, we'll reconstruct
94 # 1000 and cache it so that when you read 1001, we just need to apply a
94 # 1000 and cache it so that when you read 1001, we just need to apply a
95 # delta to what's in the cache. So that's one full reconstruction + one
95 # delta to what's in the cache. So that's one full reconstruction + one
96 # delta application.
96 # delta application.
97 if self.rev() is not None and self.rev() < other.rev():
97 if self.rev() is not None and self.rev() < other.rev():
98 self.manifest()
98 self.manifest()
99 mf1 = other._manifestmatches(match, s)
99 mf1 = other._manifestmatches(match, s)
100 mf2 = self._manifestmatches(match, s)
100 mf2 = self._manifestmatches(match, s)
101
101
102 modified, added = [], []
102 modified, added = [], []
103 removed = []
103 removed = []
104 clean = []
104 clean = []
105 deleted, unknown, ignored = s.deleted, s.unknown, s.ignored
105 deleted, unknown, ignored = s.deleted, s.unknown, s.ignored
106 deletedset = set(deleted)
106 deletedset = set(deleted)
107 d = mf1.diff(mf2, clean=listclean)
107 d = mf1.diff(mf2, clean=listclean)
108 for fn, value in d.iteritems():
108 for fn, value in d.iteritems():
109 if fn in deletedset:
109 if fn in deletedset:
110 continue
110 continue
111 if value is None:
111 if value is None:
112 clean.append(fn)
112 clean.append(fn)
113 continue
113 continue
114 (node1, flag1), (node2, flag2) = value
114 (node1, flag1), (node2, flag2) = value
115 if node1 is None:
115 if node1 is None:
116 added.append(fn)
116 added.append(fn)
117 elif node2 is None:
117 elif node2 is None:
118 removed.append(fn)
118 removed.append(fn)
119 elif node2 != _newnode:
119 elif node2 != _newnode:
120 # The file was not a new file in mf2, so an entry
120 # The file was not a new file in mf2, so an entry
121 # from diff is really a difference.
121 # from diff is really a difference.
122 modified.append(fn)
122 modified.append(fn)
123 elif self[fn].cmp(other[fn]):
123 elif self[fn].cmp(other[fn]):
124 # node2 was newnode, but the working file doesn't
124 # node2 was newnode, but the working file doesn't
125 # match the one in mf1.
125 # match the one in mf1.
126 modified.append(fn)
126 modified.append(fn)
127 else:
127 else:
128 clean.append(fn)
128 clean.append(fn)
129
129
130 if removed:
130 if removed:
131 # need to filter files if they are already reported as removed
131 # need to filter files if they are already reported as removed
132 unknown = [fn for fn in unknown if fn not in mf1]
132 unknown = [fn for fn in unknown if fn not in mf1]
133 ignored = [fn for fn in ignored if fn not in mf1]
133 ignored = [fn for fn in ignored if fn not in mf1]
134 # if they're deleted, don't report them as removed
134 # if they're deleted, don't report them as removed
135 removed = [fn for fn in removed if fn not in deletedset]
135 removed = [fn for fn in removed if fn not in deletedset]
136
136
137 return scmutil.status(modified, added, removed, deleted, unknown,
137 return scmutil.status(modified, added, removed, deleted, unknown,
138 ignored, clean)
138 ignored, clean)
139
139
140 @propertycache
140 @propertycache
141 def substate(self):
141 def substate(self):
142 return subrepo.state(self, self._repo.ui)
142 return subrepo.state(self, self._repo.ui)
143
143
144 def subrev(self, subpath):
144 def subrev(self, subpath):
145 return self.substate[subpath][1]
145 return self.substate[subpath][1]
146
146
147 def rev(self):
147 def rev(self):
148 return self._rev
148 return self._rev
149 def node(self):
149 def node(self):
150 return self._node
150 return self._node
151 def hex(self):
151 def hex(self):
152 return hex(self.node())
152 return hex(self.node())
153 def manifest(self):
153 def manifest(self):
154 return self._manifest
154 return self._manifest
155 def repo(self):
155 def repo(self):
156 return self._repo
156 return self._repo
157 def phasestr(self):
157 def phasestr(self):
158 return phases.phasenames[self.phase()]
158 return phases.phasenames[self.phase()]
159 def mutable(self):
159 def mutable(self):
160 return self.phase() > phases.public
160 return self.phase() > phases.public
161
161
162 def getfileset(self, expr):
162 def getfileset(self, expr):
163 return fileset.getfileset(self, expr)
163 return fileset.getfileset(self, expr)
164
164
165 def obsolete(self):
165 def obsolete(self):
166 """True if the changeset is obsolete"""
166 """True if the changeset is obsolete"""
167 return self.rev() in obsmod.getrevs(self._repo, 'obsolete')
167 return self.rev() in obsmod.getrevs(self._repo, 'obsolete')
168
168
169 def extinct(self):
169 def extinct(self):
170 """True if the changeset is extinct"""
170 """True if the changeset is extinct"""
171 return self.rev() in obsmod.getrevs(self._repo, 'extinct')
171 return self.rev() in obsmod.getrevs(self._repo, 'extinct')
172
172
173 def unstable(self):
173 def unstable(self):
174 """True if the changeset is not obsolete but it's ancestor are"""
174 """True if the changeset is not obsolete but it's ancestor are"""
175 return self.rev() in obsmod.getrevs(self._repo, 'unstable')
175 return self.rev() in obsmod.getrevs(self._repo, 'unstable')
176
176
177 def bumped(self):
177 def bumped(self):
178 """True if the changeset try to be a successor of a public changeset
178 """True if the changeset try to be a successor of a public changeset
179
179
180 Only non-public and non-obsolete changesets may be bumped.
180 Only non-public and non-obsolete changesets may be bumped.
181 """
181 """
182 return self.rev() in obsmod.getrevs(self._repo, 'bumped')
182 return self.rev() in obsmod.getrevs(self._repo, 'bumped')
183
183
184 def divergent(self):
184 def divergent(self):
185 """Is a successors of a changeset with multiple possible successors set
185 """Is a successors of a changeset with multiple possible successors set
186
186
187 Only non-public and non-obsolete changesets may be divergent.
187 Only non-public and non-obsolete changesets may be divergent.
188 """
188 """
189 return self.rev() in obsmod.getrevs(self._repo, 'divergent')
189 return self.rev() in obsmod.getrevs(self._repo, 'divergent')
190
190
191 def troubled(self):
191 def troubled(self):
192 """True if the changeset is either unstable, bumped or divergent"""
192 """True if the changeset is either unstable, bumped or divergent"""
193 return self.unstable() or self.bumped() or self.divergent()
193 return self.unstable() or self.bumped() or self.divergent()
194
194
195 def troubles(self):
195 def troubles(self):
196 """return the list of troubles affecting this changesets.
196 """return the list of troubles affecting this changesets.
197
197
198 Troubles are returned as strings. possible values are:
198 Troubles are returned as strings. possible values are:
199 - unstable,
199 - unstable,
200 - bumped,
200 - bumped,
201 - divergent.
201 - divergent.
202 """
202 """
203 troubles = []
203 troubles = []
204 if self.unstable():
204 if self.unstable():
205 troubles.append('unstable')
205 troubles.append('unstable')
206 if self.bumped():
206 if self.bumped():
207 troubles.append('bumped')
207 troubles.append('bumped')
208 if self.divergent():
208 if self.divergent():
209 troubles.append('divergent')
209 troubles.append('divergent')
210 return troubles
210 return troubles
211
211
212 def parents(self):
212 def parents(self):
213 """return contexts for each parent changeset"""
213 """return contexts for each parent changeset"""
214 return self._parents
214 return self._parents
215
215
216 def p1(self):
216 def p1(self):
217 return self._parents[0]
217 return self._parents[0]
218
218
219 def p2(self):
219 def p2(self):
220 if len(self._parents) == 2:
220 if len(self._parents) == 2:
221 return self._parents[1]
221 return self._parents[1]
222 return changectx(self._repo, -1)
222 return changectx(self._repo, -1)
223
223
224 def _fileinfo(self, path):
224 def _fileinfo(self, path):
225 if '_manifest' in self.__dict__:
225 if '_manifest' in self.__dict__:
226 try:
226 try:
227 return self._manifest[path], self._manifest.flags(path)
227 return self._manifest[path], self._manifest.flags(path)
228 except KeyError:
228 except KeyError:
229 raise error.ManifestLookupError(self._node, path,
229 raise error.ManifestLookupError(self._node, path,
230 _('not found in manifest'))
230 _('not found in manifest'))
231 if '_manifestdelta' in self.__dict__ or path in self.files():
231 if '_manifestdelta' in self.__dict__ or path in self.files():
232 if path in self._manifestdelta:
232 if path in self._manifestdelta:
233 return (self._manifestdelta[path],
233 return (self._manifestdelta[path],
234 self._manifestdelta.flags(path))
234 self._manifestdelta.flags(path))
235 node, flag = self._repo.manifest.find(self._changeset[0], path)
235 node, flag = self._repo.manifest.find(self._changeset[0], path)
236 if not node:
236 if not node:
237 raise error.ManifestLookupError(self._node, path,
237 raise error.ManifestLookupError(self._node, path,
238 _('not found in manifest'))
238 _('not found in manifest'))
239
239
240 return node, flag
240 return node, flag
241
241
242 def filenode(self, path):
242 def filenode(self, path):
243 return self._fileinfo(path)[0]
243 return self._fileinfo(path)[0]
244
244
245 def flags(self, path):
245 def flags(self, path):
246 try:
246 try:
247 return self._fileinfo(path)[1]
247 return self._fileinfo(path)[1]
248 except error.LookupError:
248 except error.LookupError:
249 return ''
249 return ''
250
250
251 def sub(self, path):
251 def sub(self, path):
252 return subrepo.subrepo(self, path)
252 return subrepo.subrepo(self, path)
253
253
254 def match(self, pats=[], include=None, exclude=None, default='glob'):
254 def match(self, pats=[], include=None, exclude=None, default='glob'):
255 r = self._repo
255 r = self._repo
256 return matchmod.match(r.root, r.getcwd(), pats,
256 return matchmod.match(r.root, r.getcwd(), pats,
257 include, exclude, default,
257 include, exclude, default,
258 auditor=r.auditor, ctx=self)
258 auditor=r.auditor, ctx=self)
259
259
260 def diff(self, ctx2=None, match=None, **opts):
260 def diff(self, ctx2=None, match=None, **opts):
261 """Returns a diff generator for the given contexts and matcher"""
261 """Returns a diff generator for the given contexts and matcher"""
262 if ctx2 is None:
262 if ctx2 is None:
263 ctx2 = self.p1()
263 ctx2 = self.p1()
264 if ctx2 is not None:
264 if ctx2 is not None:
265 ctx2 = self._repo[ctx2]
265 ctx2 = self._repo[ctx2]
266 diffopts = patch.diffopts(self._repo.ui, opts)
266 diffopts = patch.diffopts(self._repo.ui, opts)
267 return patch.diff(self._repo, ctx2, self, match=match, opts=diffopts)
267 return patch.diff(self._repo, ctx2, self, match=match, opts=diffopts)
268
268
269 def dirs(self):
269 def dirs(self):
270 return self._manifest.dirs()
270 return self._manifest.dirs()
271
271
272 def hasdir(self, dir):
272 def hasdir(self, dir):
273 return self._manifest.hasdir(dir)
273 return self._manifest.hasdir(dir)
274
274
275 def dirty(self, missing=False, merge=True, branch=True):
275 def dirty(self, missing=False, merge=True, branch=True):
276 return False
276 return False
277
277
278 def status(self, other=None, match=None, listignored=False,
278 def status(self, other=None, match=None, listignored=False,
279 listclean=False, listunknown=False, listsubrepos=False):
279 listclean=False, listunknown=False, listsubrepos=False):
280 """return status of files between two nodes or node and working
280 """return status of files between two nodes or node and working
281 directory.
281 directory.
282
282
283 If other is None, compare this node with working directory.
283 If other is None, compare this node with working directory.
284
284
285 returns (modified, added, removed, deleted, unknown, ignored, clean)
285 returns (modified, added, removed, deleted, unknown, ignored, clean)
286 """
286 """
287
287
288 ctx1 = self
288 ctx1 = self
289 ctx2 = self._repo[other]
289 ctx2 = self._repo[other]
290
290
291 # This next code block is, admittedly, fragile logic that tests for
291 # This next code block is, admittedly, fragile logic that tests for
292 # reversing the contexts and wouldn't need to exist if it weren't for
292 # reversing the contexts and wouldn't need to exist if it weren't for
293 # the fast (and common) code path of comparing the working directory
293 # the fast (and common) code path of comparing the working directory
294 # with its first parent.
294 # with its first parent.
295 #
295 #
296 # What we're aiming for here is the ability to call:
296 # What we're aiming for here is the ability to call:
297 #
297 #
298 # workingctx.status(parentctx)
298 # workingctx.status(parentctx)
299 #
299 #
300 # If we always built the manifest for each context and compared those,
300 # If we always built the manifest for each context and compared those,
301 # then we'd be done. But the special case of the above call means we
301 # then we'd be done. But the special case of the above call means we
302 # just copy the manifest of the parent.
302 # just copy the manifest of the parent.
303 reversed = False
303 reversed = False
304 if (not isinstance(ctx1, changectx)
304 if (not isinstance(ctx1, changectx)
305 and isinstance(ctx2, changectx)):
305 and isinstance(ctx2, changectx)):
306 reversed = True
306 reversed = True
307 ctx1, ctx2 = ctx2, ctx1
307 ctx1, ctx2 = ctx2, ctx1
308
308
309 match = ctx2._matchstatus(ctx1, match)
309 match = ctx2._matchstatus(ctx1, match)
310 r = scmutil.status([], [], [], [], [], [], [])
310 r = scmutil.status([], [], [], [], [], [], [])
311 r = ctx2._buildstatus(ctx1, r, match, listignored, listclean,
311 r = ctx2._buildstatus(ctx1, r, match, listignored, listclean,
312 listunknown)
312 listunknown)
313
313
314 if reversed:
314 if reversed:
315 # Reverse added and removed. Clear deleted, unknown and ignored as
315 # Reverse added and removed. Clear deleted, unknown and ignored as
316 # these make no sense to reverse.
316 # these make no sense to reverse.
317 r = scmutil.status(r.modified, r.removed, r.added, [], [], [],
317 r = scmutil.status(r.modified, r.removed, r.added, [], [], [],
318 r.clean)
318 r.clean)
319
319
320 if listsubrepos:
320 if listsubrepos:
321 for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
321 for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
322 rev2 = ctx2.subrev(subpath)
322 rev2 = ctx2.subrev(subpath)
323 try:
323 try:
324 submatch = matchmod.narrowmatcher(subpath, match)
324 submatch = matchmod.narrowmatcher(subpath, match)
325 s = sub.status(rev2, match=submatch, ignored=listignored,
325 s = sub.status(rev2, match=submatch, ignored=listignored,
326 clean=listclean, unknown=listunknown,
326 clean=listclean, unknown=listunknown,
327 listsubrepos=True)
327 listsubrepos=True)
328 for rfiles, sfiles in zip(r, s):
328 for rfiles, sfiles in zip(r, s):
329 rfiles.extend("%s/%s" % (subpath, f) for f in sfiles)
329 rfiles.extend("%s/%s" % (subpath, f) for f in sfiles)
330 except error.LookupError:
330 except error.LookupError:
331 self._repo.ui.status(_("skipping missing "
331 self._repo.ui.status(_("skipping missing "
332 "subrepository: %s\n") % subpath)
332 "subrepository: %s\n") % subpath)
333
333
334 for l in r:
334 for l in r:
335 l.sort()
335 l.sort()
336
336
337 return r
337 return r
338
338
339
339
340 def makememctx(repo, parents, text, user, date, branch, files, store,
340 def makememctx(repo, parents, text, user, date, branch, files, store,
341 editor=None):
341 editor=None):
342 def getfilectx(repo, memctx, path):
342 def getfilectx(repo, memctx, path):
343 data, mode, copied = store.getfile(path)
343 data, mode, copied = store.getfile(path)
344 if data is None:
344 if data is None:
345 return None
345 return None
346 islink, isexec = mode
346 islink, isexec = mode
347 return memfilectx(repo, path, data, islink=islink, isexec=isexec,
347 return memfilectx(repo, path, data, islink=islink, isexec=isexec,
348 copied=copied, memctx=memctx)
348 copied=copied, memctx=memctx)
349 extra = {}
349 extra = {}
350 if branch:
350 if branch:
351 extra['branch'] = encoding.fromlocal(branch)
351 extra['branch'] = encoding.fromlocal(branch)
352 ctx = memctx(repo, parents, text, files, getfilectx, user,
352 ctx = memctx(repo, parents, text, files, getfilectx, user,
353 date, extra, editor)
353 date, extra, editor)
354 return ctx
354 return ctx
355
355
356 class changectx(basectx):
356 class changectx(basectx):
357 """A changecontext object makes access to data related to a particular
357 """A changecontext object makes access to data related to a particular
358 changeset convenient. It represents a read-only context already present in
358 changeset convenient. It represents a read-only context already present in
359 the repo."""
359 the repo."""
360 def __init__(self, repo, changeid=''):
360 def __init__(self, repo, changeid=''):
361 """changeid is a revision number, node, or tag"""
361 """changeid is a revision number, node, or tag"""
362
362
363 # since basectx.__new__ already took care of copying the object, we
363 # since basectx.__new__ already took care of copying the object, we
364 # don't need to do anything in __init__, so we just exit here
364 # don't need to do anything in __init__, so we just exit here
365 if isinstance(changeid, basectx):
365 if isinstance(changeid, basectx):
366 return
366 return
367
367
368 if changeid == '':
368 if changeid == '':
369 changeid = '.'
369 changeid = '.'
370 self._repo = repo
370 self._repo = repo
371
371
372 try:
372 try:
373 if isinstance(changeid, int):
373 if isinstance(changeid, int):
374 self._node = repo.changelog.node(changeid)
374 self._node = repo.changelog.node(changeid)
375 self._rev = changeid
375 self._rev = changeid
376 return
376 return
377 if isinstance(changeid, long):
377 if isinstance(changeid, long):
378 changeid = str(changeid)
378 changeid = str(changeid)
379 if changeid == 'null':
379 if changeid == 'null':
380 self._node = nullid
380 self._node = nullid
381 self._rev = nullrev
381 self._rev = nullrev
382 return
382 return
383 if changeid == 'tip':
383 if changeid == 'tip':
384 self._node = repo.changelog.tip()
384 self._node = repo.changelog.tip()
385 self._rev = repo.changelog.rev(self._node)
385 self._rev = repo.changelog.rev(self._node)
386 return
386 return
387 if changeid == '.' or changeid == repo.dirstate.p1():
387 if changeid == '.' or changeid == repo.dirstate.p1():
388 # this is a hack to delay/avoid loading obsmarkers
388 # this is a hack to delay/avoid loading obsmarkers
389 # when we know that '.' won't be hidden
389 # when we know that '.' won't be hidden
390 self._node = repo.dirstate.p1()
390 self._node = repo.dirstate.p1()
391 self._rev = repo.unfiltered().changelog.rev(self._node)
391 self._rev = repo.unfiltered().changelog.rev(self._node)
392 return
392 return
393 if len(changeid) == 20:
393 if len(changeid) == 20:
394 try:
394 try:
395 self._node = changeid
395 self._node = changeid
396 self._rev = repo.changelog.rev(changeid)
396 self._rev = repo.changelog.rev(changeid)
397 return
397 return
398 except error.FilteredRepoLookupError:
398 except error.FilteredRepoLookupError:
399 raise
399 raise
400 except LookupError:
400 except LookupError:
401 pass
401 pass
402
402
403 try:
403 try:
404 r = int(changeid)
404 r = int(changeid)
405 if str(r) != changeid:
405 if str(r) != changeid:
406 raise ValueError
406 raise ValueError
407 l = len(repo.changelog)
407 l = len(repo.changelog)
408 if r < 0:
408 if r < 0:
409 r += l
409 r += l
410 if r < 0 or r >= l:
410 if r < 0 or r >= l:
411 raise ValueError
411 raise ValueError
412 self._rev = r
412 self._rev = r
413 self._node = repo.changelog.node(r)
413 self._node = repo.changelog.node(r)
414 return
414 return
415 except error.FilteredIndexError:
415 except error.FilteredIndexError:
416 raise
416 raise
417 except (ValueError, OverflowError, IndexError):
417 except (ValueError, OverflowError, IndexError):
418 pass
418 pass
419
419
420 if len(changeid) == 40:
420 if len(changeid) == 40:
421 try:
421 try:
422 self._node = bin(changeid)
422 self._node = bin(changeid)
423 self._rev = repo.changelog.rev(self._node)
423 self._rev = repo.changelog.rev(self._node)
424 return
424 return
425 except error.FilteredLookupError:
425 except error.FilteredLookupError:
426 raise
426 raise
427 except (TypeError, LookupError):
427 except (TypeError, LookupError):
428 pass
428 pass
429
429
430 # lookup bookmarks through the name interface
430 # lookup bookmarks through the name interface
431 try:
431 try:
432 self._node = repo.names.singlenode(repo, changeid)
432 self._node = repo.names.singlenode(repo, changeid)
433 self._rev = repo.changelog.rev(self._node)
433 self._rev = repo.changelog.rev(self._node)
434 return
434 return
435 except KeyError:
435 except KeyError:
436 pass
436 pass
437 except error.FilteredRepoLookupError:
437 except error.FilteredRepoLookupError:
438 raise
438 raise
439 except error.RepoLookupError:
439 except error.RepoLookupError:
440 pass
440 pass
441
441
442 self._node = repo.unfiltered().changelog._partialmatch(changeid)
442 self._node = repo.unfiltered().changelog._partialmatch(changeid)
443 if self._node is not None:
443 if self._node is not None:
444 self._rev = repo.changelog.rev(self._node)
444 self._rev = repo.changelog.rev(self._node)
445 return
445 return
446
446
447 # lookup failed
447 # lookup failed
448 # check if it might have come from damaged dirstate
448 # check if it might have come from damaged dirstate
449 #
449 #
450 # XXX we could avoid the unfiltered if we had a recognizable
450 # XXX we could avoid the unfiltered if we had a recognizable
451 # exception for filtered changeset access
451 # exception for filtered changeset access
452 if changeid in repo.unfiltered().dirstate.parents():
452 if changeid in repo.unfiltered().dirstate.parents():
453 msg = _("working directory has unknown parent '%s'!")
453 msg = _("working directory has unknown parent '%s'!")
454 raise error.Abort(msg % short(changeid))
454 raise error.Abort(msg % short(changeid))
455 try:
455 try:
456 if len(changeid) == 20:
456 if len(changeid) == 20:
457 changeid = hex(changeid)
457 changeid = hex(changeid)
458 except TypeError:
458 except TypeError:
459 pass
459 pass
460 except (error.FilteredIndexError, error.FilteredLookupError,
460 except (error.FilteredIndexError, error.FilteredLookupError,
461 error.FilteredRepoLookupError):
461 error.FilteredRepoLookupError):
462 if repo.filtername == 'visible':
462 if repo.filtername == 'visible':
463 msg = _("hidden revision '%s'") % changeid
463 msg = _("hidden revision '%s'") % changeid
464 hint = _('use --hidden to access hidden revisions')
464 hint = _('use --hidden to access hidden revisions')
465 raise error.FilteredRepoLookupError(msg, hint=hint)
465 raise error.FilteredRepoLookupError(msg, hint=hint)
466 msg = _("filtered revision '%s' (not in '%s' subset)")
466 msg = _("filtered revision '%s' (not in '%s' subset)")
467 msg %= (changeid, repo.filtername)
467 msg %= (changeid, repo.filtername)
468 raise error.FilteredRepoLookupError(msg)
468 raise error.FilteredRepoLookupError(msg)
469 except IndexError:
469 except IndexError:
470 pass
470 pass
471 raise error.RepoLookupError(
471 raise error.RepoLookupError(
472 _("unknown revision '%s'") % changeid)
472 _("unknown revision '%s'") % changeid)
473
473
474 def __hash__(self):
474 def __hash__(self):
475 try:
475 try:
476 return hash(self._rev)
476 return hash(self._rev)
477 except AttributeError:
477 except AttributeError:
478 return id(self)
478 return id(self)
479
479
480 def __nonzero__(self):
480 def __nonzero__(self):
481 return self._rev != nullrev
481 return self._rev != nullrev
482
482
483 @propertycache
483 @propertycache
484 def _changeset(self):
484 def _changeset(self):
485 return self._repo.changelog.read(self.rev())
485 return self._repo.changelog.read(self.rev())
486
486
487 @propertycache
487 @propertycache
488 def _manifest(self):
488 def _manifest(self):
489 return self._repo.manifest.read(self._changeset[0])
489 return self._repo.manifest.read(self._changeset[0])
490
490
491 @propertycache
491 @propertycache
492 def _manifestdelta(self):
492 def _manifestdelta(self):
493 return self._repo.manifest.readdelta(self._changeset[0])
493 return self._repo.manifest.readdelta(self._changeset[0])
494
494
495 @propertycache
495 @propertycache
496 def _parents(self):
496 def _parents(self):
497 p = self._repo.changelog.parentrevs(self._rev)
497 p = self._repo.changelog.parentrevs(self._rev)
498 if p[1] == nullrev:
498 if p[1] == nullrev:
499 p = p[:-1]
499 p = p[:-1]
500 return [changectx(self._repo, x) for x in p]
500 return [changectx(self._repo, x) for x in p]
501
501
502 def changeset(self):
502 def changeset(self):
503 return self._changeset
503 return self._changeset
504 def manifestnode(self):
504 def manifestnode(self):
505 return self._changeset[0]
505 return self._changeset[0]
506
506
507 def user(self):
507 def user(self):
508 return self._changeset[1]
508 return self._changeset[1]
509 def date(self):
509 def date(self):
510 return self._changeset[2]
510 return self._changeset[2]
511 def files(self):
511 def files(self):
512 return self._changeset[3]
512 return self._changeset[3]
513 def description(self):
513 def description(self):
514 return self._changeset[4]
514 return self._changeset[4]
515 def branch(self):
515 def branch(self):
516 return encoding.tolocal(self._changeset[5].get("branch"))
516 return encoding.tolocal(self._changeset[5].get("branch"))
517 def closesbranch(self):
517 def closesbranch(self):
518 return 'close' in self._changeset[5]
518 return 'close' in self._changeset[5]
519 def extra(self):
519 def extra(self):
520 return self._changeset[5]
520 return self._changeset[5]
521 def tags(self):
521 def tags(self):
522 return self._repo.nodetags(self._node)
522 return self._repo.nodetags(self._node)
523 def bookmarks(self):
523 def bookmarks(self):
524 return self._repo.nodebookmarks(self._node)
524 return self._repo.nodebookmarks(self._node)
525 def phase(self):
525 def phase(self):
526 return self._repo._phasecache.phase(self._repo, self._rev)
526 return self._repo._phasecache.phase(self._repo, self._rev)
527 def hidden(self):
527 def hidden(self):
528 return self._rev in repoview.filterrevs(self._repo, 'visible')
528 return self._rev in repoview.filterrevs(self._repo, 'visible')
529
529
530 def children(self):
530 def children(self):
531 """return contexts for each child changeset"""
531 """return contexts for each child changeset"""
532 c = self._repo.changelog.children(self._node)
532 c = self._repo.changelog.children(self._node)
533 return [changectx(self._repo, x) for x in c]
533 return [changectx(self._repo, x) for x in c]
534
534
535 def ancestors(self):
535 def ancestors(self):
536 for a in self._repo.changelog.ancestors([self._rev]):
536 for a in self._repo.changelog.ancestors([self._rev]):
537 yield changectx(self._repo, a)
537 yield changectx(self._repo, a)
538
538
539 def descendants(self):
539 def descendants(self):
540 for d in self._repo.changelog.descendants([self._rev]):
540 for d in self._repo.changelog.descendants([self._rev]):
541 yield changectx(self._repo, d)
541 yield changectx(self._repo, d)
542
542
543 def filectx(self, path, fileid=None, filelog=None):
543 def filectx(self, path, fileid=None, filelog=None):
544 """get a file context from this changeset"""
544 """get a file context from this changeset"""
545 if fileid is None:
545 if fileid is None:
546 fileid = self.filenode(path)
546 fileid = self.filenode(path)
547 return filectx(self._repo, path, fileid=fileid,
547 return filectx(self._repo, path, fileid=fileid,
548 changectx=self, filelog=filelog)
548 changectx=self, filelog=filelog)
549
549
550 def ancestor(self, c2, warn=False):
550 def ancestor(self, c2, warn=False):
551 """return the "best" ancestor context of self and c2
551 """return the "best" ancestor context of self and c2
552
552
553 If there are multiple candidates, it will show a message and check
553 If there are multiple candidates, it will show a message and check
554 merge.preferancestor configuration before falling back to the
554 merge.preferancestor configuration before falling back to the
555 revlog ancestor."""
555 revlog ancestor."""
556 # deal with workingctxs
556 # deal with workingctxs
557 n2 = c2._node
557 n2 = c2._node
558 if n2 is None:
558 if n2 is None:
559 n2 = c2._parents[0]._node
559 n2 = c2._parents[0]._node
560 cahs = self._repo.changelog.commonancestorsheads(self._node, n2)
560 cahs = self._repo.changelog.commonancestorsheads(self._node, n2)
561 if not cahs:
561 if not cahs:
562 anc = nullid
562 anc = nullid
563 elif len(cahs) == 1:
563 elif len(cahs) == 1:
564 anc = cahs[0]
564 anc = cahs[0]
565 else:
565 else:
566 for r in self._repo.ui.configlist('merge', 'preferancestor'):
566 for r in self._repo.ui.configlist('merge', 'preferancestor'):
567 try:
567 try:
568 ctx = changectx(self._repo, r)
568 ctx = changectx(self._repo, r)
569 except error.RepoLookupError:
569 except error.RepoLookupError:
570 continue
570 continue
571 anc = ctx.node()
571 anc = ctx.node()
572 if anc in cahs:
572 if anc in cahs:
573 break
573 break
574 else:
574 else:
575 anc = self._repo.changelog.ancestor(self._node, n2)
575 anc = self._repo.changelog.ancestor(self._node, n2)
576 if warn:
576 if warn:
577 self._repo.ui.status(
577 self._repo.ui.status(
578 (_("note: using %s as ancestor of %s and %s\n") %
578 (_("note: using %s as ancestor of %s and %s\n") %
579 (short(anc), short(self._node), short(n2))) +
579 (short(anc), short(self._node), short(n2))) +
580 ''.join(_(" alternatively, use --config "
580 ''.join(_(" alternatively, use --config "
581 "merge.preferancestor=%s\n") %
581 "merge.preferancestor=%s\n") %
582 short(n) for n in sorted(cahs) if n != anc))
582 short(n) for n in sorted(cahs) if n != anc))
583 return changectx(self._repo, anc)
583 return changectx(self._repo, anc)
584
584
585 def descendant(self, other):
585 def descendant(self, other):
586 """True if other is descendant of this changeset"""
586 """True if other is descendant of this changeset"""
587 return self._repo.changelog.descendant(self._rev, other._rev)
587 return self._repo.changelog.descendant(self._rev, other._rev)
588
588
589 def walk(self, match):
589 def walk(self, match):
590 '''Generates matching file names.'''
590 '''Generates matching file names.'''
591
591
592 # Override match.bad method to have message with nodeid
592 # Override match.bad method to have message with nodeid
593 oldbad = match.bad
593 oldbad = match.bad
594 def bad(fn, msg):
594 def bad(fn, msg):
595 oldbad(fn, _('no such file in rev %s') % self)
595 oldbad(fn, _('no such file in rev %s') % self)
596 match.bad = bad
596 match.bad = bad
597
597
598 return self._manifest.walk(match)
598 return self._manifest.walk(match)
599
599
600 def matches(self, match):
600 def matches(self, match):
601 return self.walk(match)
601 return self.walk(match)
602
602
603 class basefilectx(object):
603 class basefilectx(object):
604 """A filecontext object represents the common logic for its children:
604 """A filecontext object represents the common logic for its children:
605 filectx: read-only access to a filerevision that is already present
605 filectx: read-only access to a filerevision that is already present
606 in the repo,
606 in the repo,
607 workingfilectx: a filecontext that represents files from the working
607 workingfilectx: a filecontext that represents files from the working
608 directory,
608 directory,
609 memfilectx: a filecontext that represents files in-memory."""
609 memfilectx: a filecontext that represents files in-memory."""
610 def __new__(cls, repo, path, *args, **kwargs):
610 def __new__(cls, repo, path, *args, **kwargs):
611 return super(basefilectx, cls).__new__(cls)
611 return super(basefilectx, cls).__new__(cls)
612
612
613 @propertycache
613 @propertycache
614 def _filelog(self):
614 def _filelog(self):
615 return self._repo.file(self._path)
615 return self._repo.file(self._path)
616
616
617 @propertycache
617 @propertycache
618 def _changeid(self):
618 def _changeid(self):
619 if '_changeid' in self.__dict__:
619 if '_changeid' in self.__dict__:
620 return self._changeid
620 return self._changeid
621 elif '_changectx' in self.__dict__:
621 elif '_changectx' in self.__dict__:
622 return self._changectx.rev()
622 return self._changectx.rev()
623 elif '_descendantrev' in self.__dict__:
623 elif '_descendantrev' in self.__dict__:
624 # this file context was created from a revision with a known
624 # this file context was created from a revision with a known
625 # descendant, we can (lazily) correct for linkrev aliases
625 # descendant, we can (lazily) correct for linkrev aliases
626 return self._adjustlinkrev(self._path, self._filelog,
626 return self._adjustlinkrev(self._path, self._filelog,
627 self._filenode, self._descendantrev)
627 self._filenode, self._descendantrev)
628 else:
628 else:
629 return self._filelog.linkrev(self._filerev)
629 return self._filelog.linkrev(self._filerev)
630
630
631 @propertycache
631 @propertycache
632 def _filenode(self):
632 def _filenode(self):
633 if '_fileid' in self.__dict__:
633 if '_fileid' in self.__dict__:
634 return self._filelog.lookup(self._fileid)
634 return self._filelog.lookup(self._fileid)
635 else:
635 else:
636 return self._changectx.filenode(self._path)
636 return self._changectx.filenode(self._path)
637
637
638 @propertycache
638 @propertycache
639 def _filerev(self):
639 def _filerev(self):
640 return self._filelog.rev(self._filenode)
640 return self._filelog.rev(self._filenode)
641
641
642 @propertycache
642 @propertycache
643 def _repopath(self):
643 def _repopath(self):
644 return self._path
644 return self._path
645
645
646 def __nonzero__(self):
646 def __nonzero__(self):
647 try:
647 try:
648 self._filenode
648 self._filenode
649 return True
649 return True
650 except error.LookupError:
650 except error.LookupError:
651 # file is missing
651 # file is missing
652 return False
652 return False
653
653
654 def __str__(self):
654 def __str__(self):
655 return "%s@%s" % (self.path(), self._changectx)
655 return "%s@%s" % (self.path(), self._changectx)
656
656
657 def __repr__(self):
657 def __repr__(self):
658 return "<%s %s>" % (type(self).__name__, str(self))
658 return "<%s %s>" % (type(self).__name__, str(self))
659
659
660 def __hash__(self):
660 def __hash__(self):
661 try:
661 try:
662 return hash((self._path, self._filenode))
662 return hash((self._path, self._filenode))
663 except AttributeError:
663 except AttributeError:
664 return id(self)
664 return id(self)
665
665
666 def __eq__(self, other):
666 def __eq__(self, other):
667 try:
667 try:
668 return (type(self) == type(other) and self._path == other._path
668 return (type(self) == type(other) and self._path == other._path
669 and self._filenode == other._filenode)
669 and self._filenode == other._filenode)
670 except AttributeError:
670 except AttributeError:
671 return False
671 return False
672
672
673 def __ne__(self, other):
673 def __ne__(self, other):
674 return not (self == other)
674 return not (self == other)
675
675
676 def filerev(self):
676 def filerev(self):
677 return self._filerev
677 return self._filerev
678 def filenode(self):
678 def filenode(self):
679 return self._filenode
679 return self._filenode
680 def flags(self):
680 def flags(self):
681 return self._changectx.flags(self._path)
681 return self._changectx.flags(self._path)
682 def filelog(self):
682 def filelog(self):
683 return self._filelog
683 return self._filelog
684 def rev(self):
684 def rev(self):
685 return self._changeid
685 return self._changeid
686 def linkrev(self):
686 def linkrev(self):
687 return self._filelog.linkrev(self._filerev)
687 return self._filelog.linkrev(self._filerev)
688 def node(self):
688 def node(self):
689 return self._changectx.node()
689 return self._changectx.node()
690 def hex(self):
690 def hex(self):
691 return self._changectx.hex()
691 return self._changectx.hex()
692 def user(self):
692 def user(self):
693 return self._changectx.user()
693 return self._changectx.user()
694 def date(self):
694 def date(self):
695 return self._changectx.date()
695 return self._changectx.date()
696 def files(self):
696 def files(self):
697 return self._changectx.files()
697 return self._changectx.files()
698 def description(self):
698 def description(self):
699 return self._changectx.description()
699 return self._changectx.description()
700 def branch(self):
700 def branch(self):
701 return self._changectx.branch()
701 return self._changectx.branch()
702 def extra(self):
702 def extra(self):
703 return self._changectx.extra()
703 return self._changectx.extra()
704 def phase(self):
704 def phase(self):
705 return self._changectx.phase()
705 return self._changectx.phase()
706 def phasestr(self):
706 def phasestr(self):
707 return self._changectx.phasestr()
707 return self._changectx.phasestr()
708 def manifest(self):
708 def manifest(self):
709 return self._changectx.manifest()
709 return self._changectx.manifest()
710 def changectx(self):
710 def changectx(self):
711 return self._changectx
711 return self._changectx
712 def repo(self):
712 def repo(self):
713 return self._repo
713 return self._repo
714
714
715 def path(self):
715 def path(self):
716 return self._path
716 return self._path
717
717
718 def isbinary(self):
718 def isbinary(self):
719 try:
719 try:
720 return util.binary(self.data())
720 return util.binary(self.data())
721 except IOError:
721 except IOError:
722 return False
722 return False
723 def isexec(self):
723 def isexec(self):
724 return 'x' in self.flags()
724 return 'x' in self.flags()
725 def islink(self):
725 def islink(self):
726 return 'l' in self.flags()
726 return 'l' in self.flags()
727
727
728 def cmp(self, fctx):
728 def cmp(self, fctx):
729 """compare with other file context
729 """compare with other file context
730
730
731 returns True if different than fctx.
731 returns True if different than fctx.
732 """
732 """
733 if (fctx._filerev is None
733 if (fctx._filerev is None
734 and (self._repo._encodefilterpats
734 and (self._repo._encodefilterpats
735 # if file data starts with '\1\n', empty metadata block is
735 # if file data starts with '\1\n', empty metadata block is
736 # prepended, which adds 4 bytes to filelog.size().
736 # prepended, which adds 4 bytes to filelog.size().
737 or self.size() - 4 == fctx.size())
737 or self.size() - 4 == fctx.size())
738 or self.size() == fctx.size()):
738 or self.size() == fctx.size()):
739 return self._filelog.cmp(self._filenode, fctx.data())
739 return self._filelog.cmp(self._filenode, fctx.data())
740
740
741 return True
741 return True
742
742
743 def _adjustlinkrev(self, path, filelog, fnode, srcrev, inclusive=False):
743 def _adjustlinkrev(self, path, filelog, fnode, srcrev, inclusive=False):
744 """return the first ancestor of <srcrev> introducing <fnode>
744 """return the first ancestor of <srcrev> introducing <fnode>
745
745
746 If the linkrev of the file revision does not point to an ancestor of
746 If the linkrev of the file revision does not point to an ancestor of
747 srcrev, we'll walk down the ancestors until we find one introducing
747 srcrev, we'll walk down the ancestors until we find one introducing
748 this file revision.
748 this file revision.
749
749
750 :repo: a localrepository object (used to access changelog and manifest)
750 :repo: a localrepository object (used to access changelog and manifest)
751 :path: the file path
751 :path: the file path
752 :fnode: the nodeid of the file revision
752 :fnode: the nodeid of the file revision
753 :filelog: the filelog of this path
753 :filelog: the filelog of this path
754 :srcrev: the changeset revision we search ancestors from
754 :srcrev: the changeset revision we search ancestors from
755 :inclusive: if true, the src revision will also be checked
755 :inclusive: if true, the src revision will also be checked
756 """
756 """
757 repo = self._repo
757 repo = self._repo
758 cl = repo.unfiltered().changelog
758 cl = repo.unfiltered().changelog
759 ma = repo.manifest
759 ma = repo.manifest
760 # fetch the linkrev
760 # fetch the linkrev
761 fr = filelog.rev(fnode)
761 fr = filelog.rev(fnode)
762 lkr = filelog.linkrev(fr)
762 lkr = filelog.linkrev(fr)
763 # hack to reuse ancestor computation when searching for renames
763 # hack to reuse ancestor computation when searching for renames
764 memberanc = getattr(self, '_ancestrycontext', None)
764 memberanc = getattr(self, '_ancestrycontext', None)
765 iteranc = None
765 iteranc = None
766 if srcrev is None:
766 if srcrev is None:
767 # wctx case, used by workingfilectx during mergecopy
767 # wctx case, used by workingfilectx during mergecopy
768 revs = [p.rev() for p in self._repo[None].parents()]
768 revs = [p.rev() for p in self._repo[None].parents()]
769 inclusive = True # we skipped the real (revless) source
769 inclusive = True # we skipped the real (revless) source
770 else:
770 else:
771 revs = [srcrev]
771 revs = [srcrev]
772 if memberanc is None:
772 if memberanc is None:
773 memberanc = iteranc = cl.ancestors(revs, lkr,
773 memberanc = iteranc = cl.ancestors(revs, lkr,
774 inclusive=inclusive)
774 inclusive=inclusive)
775 # check if this linkrev is an ancestor of srcrev
775 # check if this linkrev is an ancestor of srcrev
776 if lkr not in memberanc:
776 if lkr not in memberanc:
777 if iteranc is None:
777 if iteranc is None:
778 iteranc = cl.ancestors(revs, lkr, inclusive=inclusive)
778 iteranc = cl.ancestors(revs, lkr, inclusive=inclusive)
779 for a in iteranc:
779 for a in iteranc:
780 ac = cl.read(a) # get changeset data (we avoid object creation)
780 ac = cl.read(a) # get changeset data (we avoid object creation)
781 if path in ac[3]: # checking the 'files' field.
781 if path in ac[3]: # checking the 'files' field.
782 # The file has been touched, check if the content is
782 # The file has been touched, check if the content is
783 # similar to the one we search for.
783 # similar to the one we search for.
784 if fnode == ma.readfast(ac[0]).get(path):
784 if fnode == ma.readfast(ac[0]).get(path):
785 return a
785 return a
786 # In theory, we should never get out of that loop without a result.
786 # In theory, we should never get out of that loop without a result.
787 # But if manifest uses a buggy file revision (not children of the
787 # But if manifest uses a buggy file revision (not children of the
788 # one it replaces) we could. Such a buggy situation will likely
788 # one it replaces) we could. Such a buggy situation will likely
789 # result is crash somewhere else at to some point.
789 # result is crash somewhere else at to some point.
790 return lkr
790 return lkr
791
791
792 def introrev(self):
792 def introrev(self):
793 """return the rev of the changeset which introduced this file revision
793 """return the rev of the changeset which introduced this file revision
794
794
795 This method is different from linkrev because it take into account the
795 This method is different from linkrev because it take into account the
796 changeset the filectx was created from. It ensures the returned
796 changeset the filectx was created from. It ensures the returned
797 revision is one of its ancestors. This prevents bugs from
797 revision is one of its ancestors. This prevents bugs from
798 'linkrev-shadowing' when a file revision is used by multiple
798 'linkrev-shadowing' when a file revision is used by multiple
799 changesets.
799 changesets.
800 """
800 """
801 lkr = self.linkrev()
801 lkr = self.linkrev()
802 attrs = vars(self)
802 attrs = vars(self)
803 noctx = not ('_changeid' in attrs or '_changectx' in attrs)
803 noctx = not ('_changeid' in attrs or '_changectx' in attrs)
804 if noctx or self.rev() == lkr:
804 if noctx or self.rev() == lkr:
805 return self.linkrev()
805 return self.linkrev()
806 return self._adjustlinkrev(self._path, self._filelog, self._filenode,
806 return self._adjustlinkrev(self._path, self._filelog, self._filenode,
807 self.rev(), inclusive=True)
807 self.rev(), inclusive=True)
808
808
809 def _parentfilectx(self, path, fileid, filelog):
809 def _parentfilectx(self, path, fileid, filelog):
810 """create parent filectx keeping ancestry info for _adjustlinkrev()"""
810 """create parent filectx keeping ancestry info for _adjustlinkrev()"""
811 fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog)
811 fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog)
812 if '_changeid' in vars(self) or '_changectx' in vars(self):
812 if '_changeid' in vars(self) or '_changectx' in vars(self):
813 # If self is associated with a changeset (probably explicitly
813 # If self is associated with a changeset (probably explicitly
814 # fed), ensure the created filectx is associated with a
814 # fed), ensure the created filectx is associated with a
815 # changeset that is an ancestor of self.changectx.
815 # changeset that is an ancestor of self.changectx.
816 # This lets us later use _adjustlinkrev to get a correct link.
816 # This lets us later use _adjustlinkrev to get a correct link.
817 fctx._descendantrev = self.rev()
817 fctx._descendantrev = self.rev()
818 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None)
818 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None)
819 elif '_descendantrev' in vars(self):
819 elif '_descendantrev' in vars(self):
820 # Otherwise propagate _descendantrev if we have one associated.
820 # Otherwise propagate _descendantrev if we have one associated.
821 fctx._descendantrev = self._descendantrev
821 fctx._descendantrev = self._descendantrev
822 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None)
822 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None)
823 return fctx
823 return fctx
824
824
825 def parents(self):
825 def parents(self):
826 _path = self._path
826 _path = self._path
827 fl = self._filelog
827 fl = self._filelog
828 parents = self._filelog.parents(self._filenode)
828 parents = self._filelog.parents(self._filenode)
829 pl = [(_path, node, fl) for node in parents if node != nullid]
829 pl = [(_path, node, fl) for node in parents if node != nullid]
830
830
831 r = fl.renamed(self._filenode)
831 r = fl.renamed(self._filenode)
832 if r:
832 if r:
833 # - In the simple rename case, both parent are nullid, pl is empty.
833 # - In the simple rename case, both parent are nullid, pl is empty.
834 # - In case of merge, only one of the parent is null id and should
834 # - In case of merge, only one of the parent is null id and should
835 # be replaced with the rename information. This parent is -always-
835 # be replaced with the rename information. This parent is -always-
836 # the first one.
836 # the first one.
837 #
837 #
838 # As null id have always been filtered out in the previous list
838 # As null id have always been filtered out in the previous list
839 # comprehension, inserting to 0 will always result in "replacing
839 # comprehension, inserting to 0 will always result in "replacing
840 # first nullid parent with rename information.
840 # first nullid parent with rename information.
841 pl.insert(0, (r[0], r[1], self._repo.file(r[0])))
841 pl.insert(0, (r[0], r[1], self._repo.file(r[0])))
842
842
843 return [self._parentfilectx(path, fnode, l) for path, fnode, l in pl]
843 return [self._parentfilectx(path, fnode, l) for path, fnode, l in pl]
844
844
845 def p1(self):
845 def p1(self):
846 return self.parents()[0]
846 return self.parents()[0]
847
847
848 def p2(self):
848 def p2(self):
849 p = self.parents()
849 p = self.parents()
850 if len(p) == 2:
850 if len(p) == 2:
851 return p[1]
851 return p[1]
852 return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog)
852 return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog)
853
853
854 def annotate(self, follow=False, linenumber=None, diffopts=None):
854 def annotate(self, follow=False, linenumber=None, diffopts=None):
855 '''returns a list of tuples of (ctx, line) for each line
855 '''returns a list of tuples of (ctx, line) for each line
856 in the file, where ctx is the filectx of the node where
856 in the file, where ctx is the filectx of the node where
857 that line was last changed.
857 that line was last changed.
858 This returns tuples of ((ctx, linenumber), line) for each line,
858 This returns tuples of ((ctx, linenumber), line) for each line,
859 if "linenumber" parameter is NOT "None".
859 if "linenumber" parameter is NOT "None".
860 In such tuples, linenumber means one at the first appearance
860 In such tuples, linenumber means one at the first appearance
861 in the managed file.
861 in the managed file.
862 To reduce annotation cost,
862 To reduce annotation cost,
863 this returns fixed value(False is used) as linenumber,
863 this returns fixed value(False is used) as linenumber,
864 if "linenumber" parameter is "False".'''
864 if "linenumber" parameter is "False".'''
865
865
866 if linenumber is None:
866 if linenumber is None:
867 def decorate(text, rev):
867 def decorate(text, rev):
868 return ([rev] * len(text.splitlines()), text)
868 return ([rev] * len(text.splitlines()), text)
869 elif linenumber:
869 elif linenumber:
870 def decorate(text, rev):
870 def decorate(text, rev):
871 size = len(text.splitlines())
871 size = len(text.splitlines())
872 return ([(rev, i) for i in xrange(1, size + 1)], text)
872 return ([(rev, i) for i in xrange(1, size + 1)], text)
873 else:
873 else:
874 def decorate(text, rev):
874 def decorate(text, rev):
875 return ([(rev, False)] * len(text.splitlines()), text)
875 return ([(rev, False)] * len(text.splitlines()), text)
876
876
877 def pair(parent, child):
877 def pair(parent, child):
878 blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts,
878 blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts,
879 refine=True)
879 refine=True)
880 for (a1, a2, b1, b2), t in blocks:
880 for (a1, a2, b1, b2), t in blocks:
881 # Changed blocks ('!') or blocks made only of blank lines ('~')
881 # Changed blocks ('!') or blocks made only of blank lines ('~')
882 # belong to the child.
882 # belong to the child.
883 if t == '=':
883 if t == '=':
884 child[0][b1:b2] = parent[0][a1:a2]
884 child[0][b1:b2] = parent[0][a1:a2]
885 return child
885 return child
886
886
887 getlog = util.lrucachefunc(lambda x: self._repo.file(x))
887 getlog = util.lrucachefunc(lambda x: self._repo.file(x))
888
888
889 def parents(f):
889 def parents(f):
890 # Cut _descendantrev here to mitigate the penalty of lazy linkrev
891 # adjustment. Otherwise, p._adjustlinkrev() would walk changelog
892 # from the topmost introrev (= srcrev) down to p.linkrev() if it
893 # isn't an ancestor of the srcrev.
894 f._changeid
890 pl = f.parents()
895 pl = f.parents()
891
896
892 # Don't return renamed parents if we aren't following.
897 # Don't return renamed parents if we aren't following.
893 if not follow:
898 if not follow:
894 pl = [p for p in pl if p.path() == f.path()]
899 pl = [p for p in pl if p.path() == f.path()]
895
900
896 # renamed filectx won't have a filelog yet, so set it
901 # renamed filectx won't have a filelog yet, so set it
897 # from the cache to save time
902 # from the cache to save time
898 for p in pl:
903 for p in pl:
899 if not '_filelog' in p.__dict__:
904 if not '_filelog' in p.__dict__:
900 p._filelog = getlog(p.path())
905 p._filelog = getlog(p.path())
901
906
902 return pl
907 return pl
903
908
904 # use linkrev to find the first changeset where self appeared
909 # use linkrev to find the first changeset where self appeared
905 base = self
910 base = self
906 introrev = self.introrev()
911 introrev = self.introrev()
907 if self.rev() != introrev:
912 if self.rev() != introrev:
908 base = self.filectx(self.filenode(), changeid=introrev)
913 base = self.filectx(self.filenode(), changeid=introrev)
909 if getattr(base, '_ancestrycontext', None) is None:
914 if getattr(base, '_ancestrycontext', None) is None:
910 cl = self._repo.changelog
915 cl = self._repo.changelog
911 if introrev is None:
916 if introrev is None:
912 # wctx is not inclusive, but works because _ancestrycontext
917 # wctx is not inclusive, but works because _ancestrycontext
913 # is used to test filelog revisions
918 # is used to test filelog revisions
914 ac = cl.ancestors([p.rev() for p in base.parents()],
919 ac = cl.ancestors([p.rev() for p in base.parents()],
915 inclusive=True)
920 inclusive=True)
916 else:
921 else:
917 ac = cl.ancestors([introrev], inclusive=True)
922 ac = cl.ancestors([introrev], inclusive=True)
918 base._ancestrycontext = ac
923 base._ancestrycontext = ac
919
924
920 # This algorithm would prefer to be recursive, but Python is a
925 # This algorithm would prefer to be recursive, but Python is a
921 # bit recursion-hostile. Instead we do an iterative
926 # bit recursion-hostile. Instead we do an iterative
922 # depth-first search.
927 # depth-first search.
923
928
924 visit = [base]
929 visit = [base]
925 hist = {}
930 hist = {}
926 pcache = {}
931 pcache = {}
927 needed = {base: 1}
932 needed = {base: 1}
928 while visit:
933 while visit:
929 f = visit[-1]
934 f = visit[-1]
930 pcached = f in pcache
935 pcached = f in pcache
931 if not pcached:
936 if not pcached:
932 pcache[f] = parents(f)
937 pcache[f] = parents(f)
933
938
934 ready = True
939 ready = True
935 pl = pcache[f]
940 pl = pcache[f]
936 for p in pl:
941 for p in pl:
937 if p not in hist:
942 if p not in hist:
938 ready = False
943 ready = False
939 visit.append(p)
944 visit.append(p)
940 if not pcached:
945 if not pcached:
941 needed[p] = needed.get(p, 0) + 1
946 needed[p] = needed.get(p, 0) + 1
942 if ready:
947 if ready:
943 visit.pop()
948 visit.pop()
944 reusable = f in hist
949 reusable = f in hist
945 if reusable:
950 if reusable:
946 curr = hist[f]
951 curr = hist[f]
947 else:
952 else:
948 curr = decorate(f.data(), f)
953 curr = decorate(f.data(), f)
949 for p in pl:
954 for p in pl:
950 if not reusable:
955 if not reusable:
951 curr = pair(hist[p], curr)
956 curr = pair(hist[p], curr)
952 if needed[p] == 1:
957 if needed[p] == 1:
953 del hist[p]
958 del hist[p]
954 del needed[p]
959 del needed[p]
955 else:
960 else:
956 needed[p] -= 1
961 needed[p] -= 1
957
962
958 hist[f] = curr
963 hist[f] = curr
959 pcache[f] = []
964 pcache[f] = []
960
965
961 return zip(hist[base][0], hist[base][1].splitlines(True))
966 return zip(hist[base][0], hist[base][1].splitlines(True))
962
967
963 def ancestors(self, followfirst=False):
968 def ancestors(self, followfirst=False):
964 visit = {}
969 visit = {}
965 c = self
970 c = self
966 if followfirst:
971 if followfirst:
967 cut = 1
972 cut = 1
968 else:
973 else:
969 cut = None
974 cut = None
970
975
971 while True:
976 while True:
972 for parent in c.parents()[:cut]:
977 for parent in c.parents()[:cut]:
973 visit[(parent.linkrev(), parent.filenode())] = parent
978 visit[(parent.linkrev(), parent.filenode())] = parent
974 if not visit:
979 if not visit:
975 break
980 break
976 c = visit.pop(max(visit))
981 c = visit.pop(max(visit))
977 yield c
982 yield c
978
983
979 class filectx(basefilectx):
984 class filectx(basefilectx):
980 """A filecontext object makes access to data related to a particular
985 """A filecontext object makes access to data related to a particular
981 filerevision convenient."""
986 filerevision convenient."""
982 def __init__(self, repo, path, changeid=None, fileid=None,
987 def __init__(self, repo, path, changeid=None, fileid=None,
983 filelog=None, changectx=None):
988 filelog=None, changectx=None):
984 """changeid can be a changeset revision, node, or tag.
989 """changeid can be a changeset revision, node, or tag.
985 fileid can be a file revision or node."""
990 fileid can be a file revision or node."""
986 self._repo = repo
991 self._repo = repo
987 self._path = path
992 self._path = path
988
993
989 assert (changeid is not None
994 assert (changeid is not None
990 or fileid is not None
995 or fileid is not None
991 or changectx is not None), \
996 or changectx is not None), \
992 ("bad args: changeid=%r, fileid=%r, changectx=%r"
997 ("bad args: changeid=%r, fileid=%r, changectx=%r"
993 % (changeid, fileid, changectx))
998 % (changeid, fileid, changectx))
994
999
995 if filelog is not None:
1000 if filelog is not None:
996 self._filelog = filelog
1001 self._filelog = filelog
997
1002
998 if changeid is not None:
1003 if changeid is not None:
999 self._changeid = changeid
1004 self._changeid = changeid
1000 if changectx is not None:
1005 if changectx is not None:
1001 self._changectx = changectx
1006 self._changectx = changectx
1002 if fileid is not None:
1007 if fileid is not None:
1003 self._fileid = fileid
1008 self._fileid = fileid
1004
1009
1005 @propertycache
1010 @propertycache
1006 def _changectx(self):
1011 def _changectx(self):
1007 try:
1012 try:
1008 return changectx(self._repo, self._changeid)
1013 return changectx(self._repo, self._changeid)
1009 except error.FilteredRepoLookupError:
1014 except error.FilteredRepoLookupError:
1010 # Linkrev may point to any revision in the repository. When the
1015 # Linkrev may point to any revision in the repository. When the
1011 # repository is filtered this may lead to `filectx` trying to build
1016 # repository is filtered this may lead to `filectx` trying to build
1012 # `changectx` for filtered revision. In such case we fallback to
1017 # `changectx` for filtered revision. In such case we fallback to
1013 # creating `changectx` on the unfiltered version of the reposition.
1018 # creating `changectx` on the unfiltered version of the reposition.
1014 # This fallback should not be an issue because `changectx` from
1019 # This fallback should not be an issue because `changectx` from
1015 # `filectx` are not used in complex operations that care about
1020 # `filectx` are not used in complex operations that care about
1016 # filtering.
1021 # filtering.
1017 #
1022 #
1018 # This fallback is a cheap and dirty fix that prevent several
1023 # This fallback is a cheap and dirty fix that prevent several
1019 # crashes. It does not ensure the behavior is correct. However the
1024 # crashes. It does not ensure the behavior is correct. However the
1020 # behavior was not correct before filtering either and "incorrect
1025 # behavior was not correct before filtering either and "incorrect
1021 # behavior" is seen as better as "crash"
1026 # behavior" is seen as better as "crash"
1022 #
1027 #
1023 # Linkrevs have several serious troubles with filtering that are
1028 # Linkrevs have several serious troubles with filtering that are
1024 # complicated to solve. Proper handling of the issue here should be
1029 # complicated to solve. Proper handling of the issue here should be
1025 # considered when solving linkrev issue are on the table.
1030 # considered when solving linkrev issue are on the table.
1026 return changectx(self._repo.unfiltered(), self._changeid)
1031 return changectx(self._repo.unfiltered(), self._changeid)
1027
1032
1028 def filectx(self, fileid, changeid=None):
1033 def filectx(self, fileid, changeid=None):
1029 '''opens an arbitrary revision of the file without
1034 '''opens an arbitrary revision of the file without
1030 opening a new filelog'''
1035 opening a new filelog'''
1031 return filectx(self._repo, self._path, fileid=fileid,
1036 return filectx(self._repo, self._path, fileid=fileid,
1032 filelog=self._filelog, changeid=changeid)
1037 filelog=self._filelog, changeid=changeid)
1033
1038
1034 def data(self):
1039 def data(self):
1035 try:
1040 try:
1036 return self._filelog.read(self._filenode)
1041 return self._filelog.read(self._filenode)
1037 except error.CensoredNodeError:
1042 except error.CensoredNodeError:
1038 if self._repo.ui.config("censor", "policy", "abort") == "ignore":
1043 if self._repo.ui.config("censor", "policy", "abort") == "ignore":
1039 return ""
1044 return ""
1040 raise util.Abort(_("censored node: %s") % short(self._filenode),
1045 raise util.Abort(_("censored node: %s") % short(self._filenode),
1041 hint=_("set censor.policy to ignore errors"))
1046 hint=_("set censor.policy to ignore errors"))
1042
1047
1043 def size(self):
1048 def size(self):
1044 return self._filelog.size(self._filerev)
1049 return self._filelog.size(self._filerev)
1045
1050
1046 def renamed(self):
1051 def renamed(self):
1047 """check if file was actually renamed in this changeset revision
1052 """check if file was actually renamed in this changeset revision
1048
1053
1049 If rename logged in file revision, we report copy for changeset only
1054 If rename logged in file revision, we report copy for changeset only
1050 if file revisions linkrev points back to the changeset in question
1055 if file revisions linkrev points back to the changeset in question
1051 or both changeset parents contain different file revisions.
1056 or both changeset parents contain different file revisions.
1052 """
1057 """
1053
1058
1054 renamed = self._filelog.renamed(self._filenode)
1059 renamed = self._filelog.renamed(self._filenode)
1055 if not renamed:
1060 if not renamed:
1056 return renamed
1061 return renamed
1057
1062
1058 if self.rev() == self.linkrev():
1063 if self.rev() == self.linkrev():
1059 return renamed
1064 return renamed
1060
1065
1061 name = self.path()
1066 name = self.path()
1062 fnode = self._filenode
1067 fnode = self._filenode
1063 for p in self._changectx.parents():
1068 for p in self._changectx.parents():
1064 try:
1069 try:
1065 if fnode == p.filenode(name):
1070 if fnode == p.filenode(name):
1066 return None
1071 return None
1067 except error.LookupError:
1072 except error.LookupError:
1068 pass
1073 pass
1069 return renamed
1074 return renamed
1070
1075
1071 def children(self):
1076 def children(self):
1072 # hard for renames
1077 # hard for renames
1073 c = self._filelog.children(self._filenode)
1078 c = self._filelog.children(self._filenode)
1074 return [filectx(self._repo, self._path, fileid=x,
1079 return [filectx(self._repo, self._path, fileid=x,
1075 filelog=self._filelog) for x in c]
1080 filelog=self._filelog) for x in c]
1076
1081
1077 class committablectx(basectx):
1082 class committablectx(basectx):
1078 """A committablectx object provides common functionality for a context that
1083 """A committablectx object provides common functionality for a context that
1079 wants the ability to commit, e.g. workingctx or memctx."""
1084 wants the ability to commit, e.g. workingctx or memctx."""
1080 def __init__(self, repo, text="", user=None, date=None, extra=None,
1085 def __init__(self, repo, text="", user=None, date=None, extra=None,
1081 changes=None):
1086 changes=None):
1082 self._repo = repo
1087 self._repo = repo
1083 self._rev = None
1088 self._rev = None
1084 self._node = None
1089 self._node = None
1085 self._text = text
1090 self._text = text
1086 if date:
1091 if date:
1087 self._date = util.parsedate(date)
1092 self._date = util.parsedate(date)
1088 if user:
1093 if user:
1089 self._user = user
1094 self._user = user
1090 if changes:
1095 if changes:
1091 self._status = changes
1096 self._status = changes
1092
1097
1093 self._extra = {}
1098 self._extra = {}
1094 if extra:
1099 if extra:
1095 self._extra = extra.copy()
1100 self._extra = extra.copy()
1096 if 'branch' not in self._extra:
1101 if 'branch' not in self._extra:
1097 try:
1102 try:
1098 branch = encoding.fromlocal(self._repo.dirstate.branch())
1103 branch = encoding.fromlocal(self._repo.dirstate.branch())
1099 except UnicodeDecodeError:
1104 except UnicodeDecodeError:
1100 raise util.Abort(_('branch name not in UTF-8!'))
1105 raise util.Abort(_('branch name not in UTF-8!'))
1101 self._extra['branch'] = branch
1106 self._extra['branch'] = branch
1102 if self._extra['branch'] == '':
1107 if self._extra['branch'] == '':
1103 self._extra['branch'] = 'default'
1108 self._extra['branch'] = 'default'
1104
1109
1105 def __str__(self):
1110 def __str__(self):
1106 return str(self._parents[0]) + "+"
1111 return str(self._parents[0]) + "+"
1107
1112
1108 def __nonzero__(self):
1113 def __nonzero__(self):
1109 return True
1114 return True
1110
1115
1111 def _buildflagfunc(self):
1116 def _buildflagfunc(self):
1112 # Create a fallback function for getting file flags when the
1117 # Create a fallback function for getting file flags when the
1113 # filesystem doesn't support them
1118 # filesystem doesn't support them
1114
1119
1115 copiesget = self._repo.dirstate.copies().get
1120 copiesget = self._repo.dirstate.copies().get
1116
1121
1117 if len(self._parents) < 2:
1122 if len(self._parents) < 2:
1118 # when we have one parent, it's easy: copy from parent
1123 # when we have one parent, it's easy: copy from parent
1119 man = self._parents[0].manifest()
1124 man = self._parents[0].manifest()
1120 def func(f):
1125 def func(f):
1121 f = copiesget(f, f)
1126 f = copiesget(f, f)
1122 return man.flags(f)
1127 return man.flags(f)
1123 else:
1128 else:
1124 # merges are tricky: we try to reconstruct the unstored
1129 # merges are tricky: we try to reconstruct the unstored
1125 # result from the merge (issue1802)
1130 # result from the merge (issue1802)
1126 p1, p2 = self._parents
1131 p1, p2 = self._parents
1127 pa = p1.ancestor(p2)
1132 pa = p1.ancestor(p2)
1128 m1, m2, ma = p1.manifest(), p2.manifest(), pa.manifest()
1133 m1, m2, ma = p1.manifest(), p2.manifest(), pa.manifest()
1129
1134
1130 def func(f):
1135 def func(f):
1131 f = copiesget(f, f) # may be wrong for merges with copies
1136 f = copiesget(f, f) # may be wrong for merges with copies
1132 fl1, fl2, fla = m1.flags(f), m2.flags(f), ma.flags(f)
1137 fl1, fl2, fla = m1.flags(f), m2.flags(f), ma.flags(f)
1133 if fl1 == fl2:
1138 if fl1 == fl2:
1134 return fl1
1139 return fl1
1135 if fl1 == fla:
1140 if fl1 == fla:
1136 return fl2
1141 return fl2
1137 if fl2 == fla:
1142 if fl2 == fla:
1138 return fl1
1143 return fl1
1139 return '' # punt for conflicts
1144 return '' # punt for conflicts
1140
1145
1141 return func
1146 return func
1142
1147
1143 @propertycache
1148 @propertycache
1144 def _flagfunc(self):
1149 def _flagfunc(self):
1145 return self._repo.dirstate.flagfunc(self._buildflagfunc)
1150 return self._repo.dirstate.flagfunc(self._buildflagfunc)
1146
1151
1147 @propertycache
1152 @propertycache
1148 def _manifest(self):
1153 def _manifest(self):
1149 """generate a manifest corresponding to the values in self._status
1154 """generate a manifest corresponding to the values in self._status
1150
1155
1151 This reuse the file nodeid from parent, but we append an extra letter
1156 This reuse the file nodeid from parent, but we append an extra letter
1152 when modified. Modified files get an extra 'm' while added files get
1157 when modified. Modified files get an extra 'm' while added files get
1153 an extra 'a'. This is used by manifests merge to see that files
1158 an extra 'a'. This is used by manifests merge to see that files
1154 are different and by update logic to avoid deleting newly added files.
1159 are different and by update logic to avoid deleting newly added files.
1155 """
1160 """
1156
1161
1157 man1 = self._parents[0].manifest()
1162 man1 = self._parents[0].manifest()
1158 man = man1.copy()
1163 man = man1.copy()
1159 if len(self._parents) > 1:
1164 if len(self._parents) > 1:
1160 man2 = self.p2().manifest()
1165 man2 = self.p2().manifest()
1161 def getman(f):
1166 def getman(f):
1162 if f in man1:
1167 if f in man1:
1163 return man1
1168 return man1
1164 return man2
1169 return man2
1165 else:
1170 else:
1166 getman = lambda f: man1
1171 getman = lambda f: man1
1167
1172
1168 copied = self._repo.dirstate.copies()
1173 copied = self._repo.dirstate.copies()
1169 ff = self._flagfunc
1174 ff = self._flagfunc
1170 for i, l in (("a", self._status.added), ("m", self._status.modified)):
1175 for i, l in (("a", self._status.added), ("m", self._status.modified)):
1171 for f in l:
1176 for f in l:
1172 orig = copied.get(f, f)
1177 orig = copied.get(f, f)
1173 man[f] = getman(orig).get(orig, nullid) + i
1178 man[f] = getman(orig).get(orig, nullid) + i
1174 try:
1179 try:
1175 man.setflag(f, ff(f))
1180 man.setflag(f, ff(f))
1176 except OSError:
1181 except OSError:
1177 pass
1182 pass
1178
1183
1179 for f in self._status.deleted + self._status.removed:
1184 for f in self._status.deleted + self._status.removed:
1180 if f in man:
1185 if f in man:
1181 del man[f]
1186 del man[f]
1182
1187
1183 return man
1188 return man
1184
1189
1185 @propertycache
1190 @propertycache
1186 def _status(self):
1191 def _status(self):
1187 return self._repo.status()
1192 return self._repo.status()
1188
1193
1189 @propertycache
1194 @propertycache
1190 def _user(self):
1195 def _user(self):
1191 return self._repo.ui.username()
1196 return self._repo.ui.username()
1192
1197
1193 @propertycache
1198 @propertycache
1194 def _date(self):
1199 def _date(self):
1195 return util.makedate()
1200 return util.makedate()
1196
1201
1197 def subrev(self, subpath):
1202 def subrev(self, subpath):
1198 return None
1203 return None
1199
1204
1200 def manifestnode(self):
1205 def manifestnode(self):
1201 return None
1206 return None
1202 def user(self):
1207 def user(self):
1203 return self._user or self._repo.ui.username()
1208 return self._user or self._repo.ui.username()
1204 def date(self):
1209 def date(self):
1205 return self._date
1210 return self._date
1206 def description(self):
1211 def description(self):
1207 return self._text
1212 return self._text
1208 def files(self):
1213 def files(self):
1209 return sorted(self._status.modified + self._status.added +
1214 return sorted(self._status.modified + self._status.added +
1210 self._status.removed)
1215 self._status.removed)
1211
1216
1212 def modified(self):
1217 def modified(self):
1213 return self._status.modified
1218 return self._status.modified
1214 def added(self):
1219 def added(self):
1215 return self._status.added
1220 return self._status.added
1216 def removed(self):
1221 def removed(self):
1217 return self._status.removed
1222 return self._status.removed
1218 def deleted(self):
1223 def deleted(self):
1219 return self._status.deleted
1224 return self._status.deleted
1220 def branch(self):
1225 def branch(self):
1221 return encoding.tolocal(self._extra['branch'])
1226 return encoding.tolocal(self._extra['branch'])
1222 def closesbranch(self):
1227 def closesbranch(self):
1223 return 'close' in self._extra
1228 return 'close' in self._extra
1224 def extra(self):
1229 def extra(self):
1225 return self._extra
1230 return self._extra
1226
1231
1227 def tags(self):
1232 def tags(self):
1228 t = []
1233 t = []
1229 for p in self.parents():
1234 for p in self.parents():
1230 t.extend(p.tags())
1235 t.extend(p.tags())
1231 return t
1236 return t
1232
1237
1233 def bookmarks(self):
1238 def bookmarks(self):
1234 b = []
1239 b = []
1235 for p in self.parents():
1240 for p in self.parents():
1236 b.extend(p.bookmarks())
1241 b.extend(p.bookmarks())
1237 return b
1242 return b
1238
1243
1239 def phase(self):
1244 def phase(self):
1240 phase = phases.draft # default phase to draft
1245 phase = phases.draft # default phase to draft
1241 for p in self.parents():
1246 for p in self.parents():
1242 phase = max(phase, p.phase())
1247 phase = max(phase, p.phase())
1243 return phase
1248 return phase
1244
1249
1245 def hidden(self):
1250 def hidden(self):
1246 return False
1251 return False
1247
1252
1248 def children(self):
1253 def children(self):
1249 return []
1254 return []
1250
1255
1251 def flags(self, path):
1256 def flags(self, path):
1252 if '_manifest' in self.__dict__:
1257 if '_manifest' in self.__dict__:
1253 try:
1258 try:
1254 return self._manifest.flags(path)
1259 return self._manifest.flags(path)
1255 except KeyError:
1260 except KeyError:
1256 return ''
1261 return ''
1257
1262
1258 try:
1263 try:
1259 return self._flagfunc(path)
1264 return self._flagfunc(path)
1260 except OSError:
1265 except OSError:
1261 return ''
1266 return ''
1262
1267
1263 def ancestor(self, c2):
1268 def ancestor(self, c2):
1264 """return the "best" ancestor context of self and c2"""
1269 """return the "best" ancestor context of self and c2"""
1265 return self._parents[0].ancestor(c2) # punt on two parents for now
1270 return self._parents[0].ancestor(c2) # punt on two parents for now
1266
1271
1267 def walk(self, match):
1272 def walk(self, match):
1268 '''Generates matching file names.'''
1273 '''Generates matching file names.'''
1269 return sorted(self._repo.dirstate.walk(match, sorted(self.substate),
1274 return sorted(self._repo.dirstate.walk(match, sorted(self.substate),
1270 True, False))
1275 True, False))
1271
1276
1272 def matches(self, match):
1277 def matches(self, match):
1273 return sorted(self._repo.dirstate.matches(match))
1278 return sorted(self._repo.dirstate.matches(match))
1274
1279
1275 def ancestors(self):
1280 def ancestors(self):
1276 for p in self._parents:
1281 for p in self._parents:
1277 yield p
1282 yield p
1278 for a in self._repo.changelog.ancestors(
1283 for a in self._repo.changelog.ancestors(
1279 [p.rev() for p in self._parents]):
1284 [p.rev() for p in self._parents]):
1280 yield changectx(self._repo, a)
1285 yield changectx(self._repo, a)
1281
1286
1282 def markcommitted(self, node):
1287 def markcommitted(self, node):
1283 """Perform post-commit cleanup necessary after committing this ctx
1288 """Perform post-commit cleanup necessary after committing this ctx
1284
1289
1285 Specifically, this updates backing stores this working context
1290 Specifically, this updates backing stores this working context
1286 wraps to reflect the fact that the changes reflected by this
1291 wraps to reflect the fact that the changes reflected by this
1287 workingctx have been committed. For example, it marks
1292 workingctx have been committed. For example, it marks
1288 modified and added files as normal in the dirstate.
1293 modified and added files as normal in the dirstate.
1289
1294
1290 """
1295 """
1291
1296
1292 self._repo.dirstate.beginparentchange()
1297 self._repo.dirstate.beginparentchange()
1293 for f in self.modified() + self.added():
1298 for f in self.modified() + self.added():
1294 self._repo.dirstate.normal(f)
1299 self._repo.dirstate.normal(f)
1295 for f in self.removed():
1300 for f in self.removed():
1296 self._repo.dirstate.drop(f)
1301 self._repo.dirstate.drop(f)
1297 self._repo.dirstate.setparents(node)
1302 self._repo.dirstate.setparents(node)
1298 self._repo.dirstate.endparentchange()
1303 self._repo.dirstate.endparentchange()
1299
1304
1300 class workingctx(committablectx):
1305 class workingctx(committablectx):
1301 """A workingctx object makes access to data related to
1306 """A workingctx object makes access to data related to
1302 the current working directory convenient.
1307 the current working directory convenient.
1303 date - any valid date string or (unixtime, offset), or None.
1308 date - any valid date string or (unixtime, offset), or None.
1304 user - username string, or None.
1309 user - username string, or None.
1305 extra - a dictionary of extra values, or None.
1310 extra - a dictionary of extra values, or None.
1306 changes - a list of file lists as returned by localrepo.status()
1311 changes - a list of file lists as returned by localrepo.status()
1307 or None to use the repository status.
1312 or None to use the repository status.
1308 """
1313 """
1309 def __init__(self, repo, text="", user=None, date=None, extra=None,
1314 def __init__(self, repo, text="", user=None, date=None, extra=None,
1310 changes=None):
1315 changes=None):
1311 super(workingctx, self).__init__(repo, text, user, date, extra, changes)
1316 super(workingctx, self).__init__(repo, text, user, date, extra, changes)
1312
1317
1313 def __iter__(self):
1318 def __iter__(self):
1314 d = self._repo.dirstate
1319 d = self._repo.dirstate
1315 for f in d:
1320 for f in d:
1316 if d[f] != 'r':
1321 if d[f] != 'r':
1317 yield f
1322 yield f
1318
1323
1319 def __contains__(self, key):
1324 def __contains__(self, key):
1320 return self._repo.dirstate[key] not in "?r"
1325 return self._repo.dirstate[key] not in "?r"
1321
1326
1322 @propertycache
1327 @propertycache
1323 def _parents(self):
1328 def _parents(self):
1324 p = self._repo.dirstate.parents()
1329 p = self._repo.dirstate.parents()
1325 if p[1] == nullid:
1330 if p[1] == nullid:
1326 p = p[:-1]
1331 p = p[:-1]
1327 return [changectx(self._repo, x) for x in p]
1332 return [changectx(self._repo, x) for x in p]
1328
1333
1329 def filectx(self, path, filelog=None):
1334 def filectx(self, path, filelog=None):
1330 """get a file context from the working directory"""
1335 """get a file context from the working directory"""
1331 return workingfilectx(self._repo, path, workingctx=self,
1336 return workingfilectx(self._repo, path, workingctx=self,
1332 filelog=filelog)
1337 filelog=filelog)
1333
1338
1334 def dirty(self, missing=False, merge=True, branch=True):
1339 def dirty(self, missing=False, merge=True, branch=True):
1335 "check whether a working directory is modified"
1340 "check whether a working directory is modified"
1336 # check subrepos first
1341 # check subrepos first
1337 for s in sorted(self.substate):
1342 for s in sorted(self.substate):
1338 if self.sub(s).dirty():
1343 if self.sub(s).dirty():
1339 return True
1344 return True
1340 # check current working dir
1345 # check current working dir
1341 return ((merge and self.p2()) or
1346 return ((merge and self.p2()) or
1342 (branch and self.branch() != self.p1().branch()) or
1347 (branch and self.branch() != self.p1().branch()) or
1343 self.modified() or self.added() or self.removed() or
1348 self.modified() or self.added() or self.removed() or
1344 (missing and self.deleted()))
1349 (missing and self.deleted()))
1345
1350
1346 def add(self, list, prefix=""):
1351 def add(self, list, prefix=""):
1347 join = lambda f: os.path.join(prefix, f)
1352 join = lambda f: os.path.join(prefix, f)
1348 wlock = self._repo.wlock()
1353 wlock = self._repo.wlock()
1349 ui, ds = self._repo.ui, self._repo.dirstate
1354 ui, ds = self._repo.ui, self._repo.dirstate
1350 try:
1355 try:
1351 rejected = []
1356 rejected = []
1352 lstat = self._repo.wvfs.lstat
1357 lstat = self._repo.wvfs.lstat
1353 for f in list:
1358 for f in list:
1354 scmutil.checkportable(ui, join(f))
1359 scmutil.checkportable(ui, join(f))
1355 try:
1360 try:
1356 st = lstat(f)
1361 st = lstat(f)
1357 except OSError:
1362 except OSError:
1358 ui.warn(_("%s does not exist!\n") % join(f))
1363 ui.warn(_("%s does not exist!\n") % join(f))
1359 rejected.append(f)
1364 rejected.append(f)
1360 continue
1365 continue
1361 if st.st_size > 10000000:
1366 if st.st_size > 10000000:
1362 ui.warn(_("%s: up to %d MB of RAM may be required "
1367 ui.warn(_("%s: up to %d MB of RAM may be required "
1363 "to manage this file\n"
1368 "to manage this file\n"
1364 "(use 'hg revert %s' to cancel the "
1369 "(use 'hg revert %s' to cancel the "
1365 "pending addition)\n")
1370 "pending addition)\n")
1366 % (f, 3 * st.st_size // 1000000, join(f)))
1371 % (f, 3 * st.st_size // 1000000, join(f)))
1367 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1372 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1368 ui.warn(_("%s not added: only files and symlinks "
1373 ui.warn(_("%s not added: only files and symlinks "
1369 "supported currently\n") % join(f))
1374 "supported currently\n") % join(f))
1370 rejected.append(f)
1375 rejected.append(f)
1371 elif ds[f] in 'amn':
1376 elif ds[f] in 'amn':
1372 ui.warn(_("%s already tracked!\n") % join(f))
1377 ui.warn(_("%s already tracked!\n") % join(f))
1373 elif ds[f] == 'r':
1378 elif ds[f] == 'r':
1374 ds.normallookup(f)
1379 ds.normallookup(f)
1375 else:
1380 else:
1376 ds.add(f)
1381 ds.add(f)
1377 return rejected
1382 return rejected
1378 finally:
1383 finally:
1379 wlock.release()
1384 wlock.release()
1380
1385
1381 def forget(self, files, prefix=""):
1386 def forget(self, files, prefix=""):
1382 join = lambda f: os.path.join(prefix, f)
1387 join = lambda f: os.path.join(prefix, f)
1383 wlock = self._repo.wlock()
1388 wlock = self._repo.wlock()
1384 try:
1389 try:
1385 rejected = []
1390 rejected = []
1386 for f in files:
1391 for f in files:
1387 if f not in self._repo.dirstate:
1392 if f not in self._repo.dirstate:
1388 self._repo.ui.warn(_("%s not tracked!\n") % join(f))
1393 self._repo.ui.warn(_("%s not tracked!\n") % join(f))
1389 rejected.append(f)
1394 rejected.append(f)
1390 elif self._repo.dirstate[f] != 'a':
1395 elif self._repo.dirstate[f] != 'a':
1391 self._repo.dirstate.remove(f)
1396 self._repo.dirstate.remove(f)
1392 else:
1397 else:
1393 self._repo.dirstate.drop(f)
1398 self._repo.dirstate.drop(f)
1394 return rejected
1399 return rejected
1395 finally:
1400 finally:
1396 wlock.release()
1401 wlock.release()
1397
1402
1398 def undelete(self, list):
1403 def undelete(self, list):
1399 pctxs = self.parents()
1404 pctxs = self.parents()
1400 wlock = self._repo.wlock()
1405 wlock = self._repo.wlock()
1401 try:
1406 try:
1402 for f in list:
1407 for f in list:
1403 if self._repo.dirstate[f] != 'r':
1408 if self._repo.dirstate[f] != 'r':
1404 self._repo.ui.warn(_("%s not removed!\n") % f)
1409 self._repo.ui.warn(_("%s not removed!\n") % f)
1405 else:
1410 else:
1406 fctx = f in pctxs[0] and pctxs[0][f] or pctxs[1][f]
1411 fctx = f in pctxs[0] and pctxs[0][f] or pctxs[1][f]
1407 t = fctx.data()
1412 t = fctx.data()
1408 self._repo.wwrite(f, t, fctx.flags())
1413 self._repo.wwrite(f, t, fctx.flags())
1409 self._repo.dirstate.normal(f)
1414 self._repo.dirstate.normal(f)
1410 finally:
1415 finally:
1411 wlock.release()
1416 wlock.release()
1412
1417
1413 def copy(self, source, dest):
1418 def copy(self, source, dest):
1414 try:
1419 try:
1415 st = self._repo.wvfs.lstat(dest)
1420 st = self._repo.wvfs.lstat(dest)
1416 except OSError, err:
1421 except OSError, err:
1417 if err.errno != errno.ENOENT:
1422 if err.errno != errno.ENOENT:
1418 raise
1423 raise
1419 self._repo.ui.warn(_("%s does not exist!\n") % dest)
1424 self._repo.ui.warn(_("%s does not exist!\n") % dest)
1420 return
1425 return
1421 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1426 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1422 self._repo.ui.warn(_("copy failed: %s is not a file or a "
1427 self._repo.ui.warn(_("copy failed: %s is not a file or a "
1423 "symbolic link\n") % dest)
1428 "symbolic link\n") % dest)
1424 else:
1429 else:
1425 wlock = self._repo.wlock()
1430 wlock = self._repo.wlock()
1426 try:
1431 try:
1427 if self._repo.dirstate[dest] in '?':
1432 if self._repo.dirstate[dest] in '?':
1428 self._repo.dirstate.add(dest)
1433 self._repo.dirstate.add(dest)
1429 elif self._repo.dirstate[dest] in 'r':
1434 elif self._repo.dirstate[dest] in 'r':
1430 self._repo.dirstate.normallookup(dest)
1435 self._repo.dirstate.normallookup(dest)
1431 self._repo.dirstate.copy(source, dest)
1436 self._repo.dirstate.copy(source, dest)
1432 finally:
1437 finally:
1433 wlock.release()
1438 wlock.release()
1434
1439
1435 def match(self, pats=[], include=None, exclude=None, default='glob'):
1440 def match(self, pats=[], include=None, exclude=None, default='glob'):
1436 r = self._repo
1441 r = self._repo
1437
1442
1438 # Only a case insensitive filesystem needs magic to translate user input
1443 # Only a case insensitive filesystem needs magic to translate user input
1439 # to actual case in the filesystem.
1444 # to actual case in the filesystem.
1440 if not util.checkcase(r.root):
1445 if not util.checkcase(r.root):
1441 return matchmod.icasefsmatcher(r.root, r.getcwd(), pats, include,
1446 return matchmod.icasefsmatcher(r.root, r.getcwd(), pats, include,
1442 exclude, default, r.auditor, self)
1447 exclude, default, r.auditor, self)
1443 return matchmod.match(r.root, r.getcwd(), pats,
1448 return matchmod.match(r.root, r.getcwd(), pats,
1444 include, exclude, default,
1449 include, exclude, default,
1445 auditor=r.auditor, ctx=self)
1450 auditor=r.auditor, ctx=self)
1446
1451
1447 def _filtersuspectsymlink(self, files):
1452 def _filtersuspectsymlink(self, files):
1448 if not files or self._repo.dirstate._checklink:
1453 if not files or self._repo.dirstate._checklink:
1449 return files
1454 return files
1450
1455
1451 # Symlink placeholders may get non-symlink-like contents
1456 # Symlink placeholders may get non-symlink-like contents
1452 # via user error or dereferencing by NFS or Samba servers,
1457 # via user error or dereferencing by NFS or Samba servers,
1453 # so we filter out any placeholders that don't look like a
1458 # so we filter out any placeholders that don't look like a
1454 # symlink
1459 # symlink
1455 sane = []
1460 sane = []
1456 for f in files:
1461 for f in files:
1457 if self.flags(f) == 'l':
1462 if self.flags(f) == 'l':
1458 d = self[f].data()
1463 d = self[f].data()
1459 if d == '' or len(d) >= 1024 or '\n' in d or util.binary(d):
1464 if d == '' or len(d) >= 1024 or '\n' in d or util.binary(d):
1460 self._repo.ui.debug('ignoring suspect symlink placeholder'
1465 self._repo.ui.debug('ignoring suspect symlink placeholder'
1461 ' "%s"\n' % f)
1466 ' "%s"\n' % f)
1462 continue
1467 continue
1463 sane.append(f)
1468 sane.append(f)
1464 return sane
1469 return sane
1465
1470
1466 def _checklookup(self, files):
1471 def _checklookup(self, files):
1467 # check for any possibly clean files
1472 # check for any possibly clean files
1468 if not files:
1473 if not files:
1469 return [], []
1474 return [], []
1470
1475
1471 modified = []
1476 modified = []
1472 fixup = []
1477 fixup = []
1473 pctx = self._parents[0]
1478 pctx = self._parents[0]
1474 # do a full compare of any files that might have changed
1479 # do a full compare of any files that might have changed
1475 for f in sorted(files):
1480 for f in sorted(files):
1476 if (f not in pctx or self.flags(f) != pctx.flags(f)
1481 if (f not in pctx or self.flags(f) != pctx.flags(f)
1477 or pctx[f].cmp(self[f])):
1482 or pctx[f].cmp(self[f])):
1478 modified.append(f)
1483 modified.append(f)
1479 else:
1484 else:
1480 fixup.append(f)
1485 fixup.append(f)
1481
1486
1482 # update dirstate for files that are actually clean
1487 # update dirstate for files that are actually clean
1483 if fixup:
1488 if fixup:
1484 try:
1489 try:
1485 # updating the dirstate is optional
1490 # updating the dirstate is optional
1486 # so we don't wait on the lock
1491 # so we don't wait on the lock
1487 # wlock can invalidate the dirstate, so cache normal _after_
1492 # wlock can invalidate the dirstate, so cache normal _after_
1488 # taking the lock
1493 # taking the lock
1489 wlock = self._repo.wlock(False)
1494 wlock = self._repo.wlock(False)
1490 normal = self._repo.dirstate.normal
1495 normal = self._repo.dirstate.normal
1491 try:
1496 try:
1492 for f in fixup:
1497 for f in fixup:
1493 normal(f)
1498 normal(f)
1494 finally:
1499 finally:
1495 wlock.release()
1500 wlock.release()
1496 except error.LockError:
1501 except error.LockError:
1497 pass
1502 pass
1498 return modified, fixup
1503 return modified, fixup
1499
1504
1500 def _manifestmatches(self, match, s):
1505 def _manifestmatches(self, match, s):
1501 """Slow path for workingctx
1506 """Slow path for workingctx
1502
1507
1503 The fast path is when we compare the working directory to its parent
1508 The fast path is when we compare the working directory to its parent
1504 which means this function is comparing with a non-parent; therefore we
1509 which means this function is comparing with a non-parent; therefore we
1505 need to build a manifest and return what matches.
1510 need to build a manifest and return what matches.
1506 """
1511 """
1507 mf = self._repo['.']._manifestmatches(match, s)
1512 mf = self._repo['.']._manifestmatches(match, s)
1508 for f in s.modified + s.added:
1513 for f in s.modified + s.added:
1509 mf[f] = _newnode
1514 mf[f] = _newnode
1510 mf.setflag(f, self.flags(f))
1515 mf.setflag(f, self.flags(f))
1511 for f in s.removed:
1516 for f in s.removed:
1512 if f in mf:
1517 if f in mf:
1513 del mf[f]
1518 del mf[f]
1514 return mf
1519 return mf
1515
1520
1516 def _dirstatestatus(self, match=None, ignored=False, clean=False,
1521 def _dirstatestatus(self, match=None, ignored=False, clean=False,
1517 unknown=False):
1522 unknown=False):
1518 '''Gets the status from the dirstate -- internal use only.'''
1523 '''Gets the status from the dirstate -- internal use only.'''
1519 listignored, listclean, listunknown = ignored, clean, unknown
1524 listignored, listclean, listunknown = ignored, clean, unknown
1520 match = match or matchmod.always(self._repo.root, self._repo.getcwd())
1525 match = match or matchmod.always(self._repo.root, self._repo.getcwd())
1521 subrepos = []
1526 subrepos = []
1522 if '.hgsub' in self:
1527 if '.hgsub' in self:
1523 subrepos = sorted(self.substate)
1528 subrepos = sorted(self.substate)
1524 cmp, s = self._repo.dirstate.status(match, subrepos, listignored,
1529 cmp, s = self._repo.dirstate.status(match, subrepos, listignored,
1525 listclean, listunknown)
1530 listclean, listunknown)
1526
1531
1527 # check for any possibly clean files
1532 # check for any possibly clean files
1528 if cmp:
1533 if cmp:
1529 modified2, fixup = self._checklookup(cmp)
1534 modified2, fixup = self._checklookup(cmp)
1530 s.modified.extend(modified2)
1535 s.modified.extend(modified2)
1531
1536
1532 # update dirstate for files that are actually clean
1537 # update dirstate for files that are actually clean
1533 if fixup and listclean:
1538 if fixup and listclean:
1534 s.clean.extend(fixup)
1539 s.clean.extend(fixup)
1535
1540
1536 if match.always():
1541 if match.always():
1537 # cache for performance
1542 # cache for performance
1538 if s.unknown or s.ignored or s.clean:
1543 if s.unknown or s.ignored or s.clean:
1539 # "_status" is cached with list*=False in the normal route
1544 # "_status" is cached with list*=False in the normal route
1540 self._status = scmutil.status(s.modified, s.added, s.removed,
1545 self._status = scmutil.status(s.modified, s.added, s.removed,
1541 s.deleted, [], [], [])
1546 s.deleted, [], [], [])
1542 else:
1547 else:
1543 self._status = s
1548 self._status = s
1544
1549
1545 return s
1550 return s
1546
1551
1547 def _buildstatus(self, other, s, match, listignored, listclean,
1552 def _buildstatus(self, other, s, match, listignored, listclean,
1548 listunknown):
1553 listunknown):
1549 """build a status with respect to another context
1554 """build a status with respect to another context
1550
1555
1551 This includes logic for maintaining the fast path of status when
1556 This includes logic for maintaining the fast path of status when
1552 comparing the working directory against its parent, which is to skip
1557 comparing the working directory against its parent, which is to skip
1553 building a new manifest if self (working directory) is not comparing
1558 building a new manifest if self (working directory) is not comparing
1554 against its parent (repo['.']).
1559 against its parent (repo['.']).
1555 """
1560 """
1556 s = self._dirstatestatus(match, listignored, listclean, listunknown)
1561 s = self._dirstatestatus(match, listignored, listclean, listunknown)
1557 # Filter out symlinks that, in the case of FAT32 and NTFS filesystems,
1562 # Filter out symlinks that, in the case of FAT32 and NTFS filesystems,
1558 # might have accidentally ended up with the entire contents of the file
1563 # might have accidentally ended up with the entire contents of the file
1559 # they are supposed to be linking to.
1564 # they are supposed to be linking to.
1560 s.modified[:] = self._filtersuspectsymlink(s.modified)
1565 s.modified[:] = self._filtersuspectsymlink(s.modified)
1561 if other != self._repo['.']:
1566 if other != self._repo['.']:
1562 s = super(workingctx, self)._buildstatus(other, s, match,
1567 s = super(workingctx, self)._buildstatus(other, s, match,
1563 listignored, listclean,
1568 listignored, listclean,
1564 listunknown)
1569 listunknown)
1565 return s
1570 return s
1566
1571
1567 def _matchstatus(self, other, match):
1572 def _matchstatus(self, other, match):
1568 """override the match method with a filter for directory patterns
1573 """override the match method with a filter for directory patterns
1569
1574
1570 We use inheritance to customize the match.bad method only in cases of
1575 We use inheritance to customize the match.bad method only in cases of
1571 workingctx since it belongs only to the working directory when
1576 workingctx since it belongs only to the working directory when
1572 comparing against the parent changeset.
1577 comparing against the parent changeset.
1573
1578
1574 If we aren't comparing against the working directory's parent, then we
1579 If we aren't comparing against the working directory's parent, then we
1575 just use the default match object sent to us.
1580 just use the default match object sent to us.
1576 """
1581 """
1577 superself = super(workingctx, self)
1582 superself = super(workingctx, self)
1578 match = superself._matchstatus(other, match)
1583 match = superself._matchstatus(other, match)
1579 if other != self._repo['.']:
1584 if other != self._repo['.']:
1580 def bad(f, msg):
1585 def bad(f, msg):
1581 # 'f' may be a directory pattern from 'match.files()',
1586 # 'f' may be a directory pattern from 'match.files()',
1582 # so 'f not in ctx1' is not enough
1587 # so 'f not in ctx1' is not enough
1583 if f not in other and not other.hasdir(f):
1588 if f not in other and not other.hasdir(f):
1584 self._repo.ui.warn('%s: %s\n' %
1589 self._repo.ui.warn('%s: %s\n' %
1585 (self._repo.dirstate.pathto(f), msg))
1590 (self._repo.dirstate.pathto(f), msg))
1586 match.bad = bad
1591 match.bad = bad
1587 return match
1592 return match
1588
1593
1589 class committablefilectx(basefilectx):
1594 class committablefilectx(basefilectx):
1590 """A committablefilectx provides common functionality for a file context
1595 """A committablefilectx provides common functionality for a file context
1591 that wants the ability to commit, e.g. workingfilectx or memfilectx."""
1596 that wants the ability to commit, e.g. workingfilectx or memfilectx."""
1592 def __init__(self, repo, path, filelog=None, ctx=None):
1597 def __init__(self, repo, path, filelog=None, ctx=None):
1593 self._repo = repo
1598 self._repo = repo
1594 self._path = path
1599 self._path = path
1595 self._changeid = None
1600 self._changeid = None
1596 self._filerev = self._filenode = None
1601 self._filerev = self._filenode = None
1597
1602
1598 if filelog is not None:
1603 if filelog is not None:
1599 self._filelog = filelog
1604 self._filelog = filelog
1600 if ctx:
1605 if ctx:
1601 self._changectx = ctx
1606 self._changectx = ctx
1602
1607
1603 def __nonzero__(self):
1608 def __nonzero__(self):
1604 return True
1609 return True
1605
1610
1606 def linkrev(self):
1611 def linkrev(self):
1607 # linked to self._changectx no matter if file is modified or not
1612 # linked to self._changectx no matter if file is modified or not
1608 return self.rev()
1613 return self.rev()
1609
1614
1610 def parents(self):
1615 def parents(self):
1611 '''return parent filectxs, following copies if necessary'''
1616 '''return parent filectxs, following copies if necessary'''
1612 def filenode(ctx, path):
1617 def filenode(ctx, path):
1613 return ctx._manifest.get(path, nullid)
1618 return ctx._manifest.get(path, nullid)
1614
1619
1615 path = self._path
1620 path = self._path
1616 fl = self._filelog
1621 fl = self._filelog
1617 pcl = self._changectx._parents
1622 pcl = self._changectx._parents
1618 renamed = self.renamed()
1623 renamed = self.renamed()
1619
1624
1620 if renamed:
1625 if renamed:
1621 pl = [renamed + (None,)]
1626 pl = [renamed + (None,)]
1622 else:
1627 else:
1623 pl = [(path, filenode(pcl[0], path), fl)]
1628 pl = [(path, filenode(pcl[0], path), fl)]
1624
1629
1625 for pc in pcl[1:]:
1630 for pc in pcl[1:]:
1626 pl.append((path, filenode(pc, path), fl))
1631 pl.append((path, filenode(pc, path), fl))
1627
1632
1628 return [self._parentfilectx(p, fileid=n, filelog=l)
1633 return [self._parentfilectx(p, fileid=n, filelog=l)
1629 for p, n, l in pl if n != nullid]
1634 for p, n, l in pl if n != nullid]
1630
1635
1631 def children(self):
1636 def children(self):
1632 return []
1637 return []
1633
1638
1634 class workingfilectx(committablefilectx):
1639 class workingfilectx(committablefilectx):
1635 """A workingfilectx object makes access to data related to a particular
1640 """A workingfilectx object makes access to data related to a particular
1636 file in the working directory convenient."""
1641 file in the working directory convenient."""
1637 def __init__(self, repo, path, filelog=None, workingctx=None):
1642 def __init__(self, repo, path, filelog=None, workingctx=None):
1638 super(workingfilectx, self).__init__(repo, path, filelog, workingctx)
1643 super(workingfilectx, self).__init__(repo, path, filelog, workingctx)
1639
1644
1640 @propertycache
1645 @propertycache
1641 def _changectx(self):
1646 def _changectx(self):
1642 return workingctx(self._repo)
1647 return workingctx(self._repo)
1643
1648
1644 def data(self):
1649 def data(self):
1645 return self._repo.wread(self._path)
1650 return self._repo.wread(self._path)
1646 def renamed(self):
1651 def renamed(self):
1647 rp = self._repo.dirstate.copied(self._path)
1652 rp = self._repo.dirstate.copied(self._path)
1648 if not rp:
1653 if not rp:
1649 return None
1654 return None
1650 return rp, self._changectx._parents[0]._manifest.get(rp, nullid)
1655 return rp, self._changectx._parents[0]._manifest.get(rp, nullid)
1651
1656
1652 def size(self):
1657 def size(self):
1653 return self._repo.wvfs.lstat(self._path).st_size
1658 return self._repo.wvfs.lstat(self._path).st_size
1654 def date(self):
1659 def date(self):
1655 t, tz = self._changectx.date()
1660 t, tz = self._changectx.date()
1656 try:
1661 try:
1657 return (int(self._repo.wvfs.lstat(self._path).st_mtime), tz)
1662 return (int(self._repo.wvfs.lstat(self._path).st_mtime), tz)
1658 except OSError, err:
1663 except OSError, err:
1659 if err.errno != errno.ENOENT:
1664 if err.errno != errno.ENOENT:
1660 raise
1665 raise
1661 return (t, tz)
1666 return (t, tz)
1662
1667
1663 def cmp(self, fctx):
1668 def cmp(self, fctx):
1664 """compare with other file context
1669 """compare with other file context
1665
1670
1666 returns True if different than fctx.
1671 returns True if different than fctx.
1667 """
1672 """
1668 # fctx should be a filectx (not a workingfilectx)
1673 # fctx should be a filectx (not a workingfilectx)
1669 # invert comparison to reuse the same code path
1674 # invert comparison to reuse the same code path
1670 return fctx.cmp(self)
1675 return fctx.cmp(self)
1671
1676
1672 def remove(self, ignoremissing=False):
1677 def remove(self, ignoremissing=False):
1673 """wraps unlink for a repo's working directory"""
1678 """wraps unlink for a repo's working directory"""
1674 util.unlinkpath(self._repo.wjoin(self._path), ignoremissing)
1679 util.unlinkpath(self._repo.wjoin(self._path), ignoremissing)
1675
1680
1676 def write(self, data, flags):
1681 def write(self, data, flags):
1677 """wraps repo.wwrite"""
1682 """wraps repo.wwrite"""
1678 self._repo.wwrite(self._path, data, flags)
1683 self._repo.wwrite(self._path, data, flags)
1679
1684
1680 class workingcommitctx(workingctx):
1685 class workingcommitctx(workingctx):
1681 """A workingcommitctx object makes access to data related to
1686 """A workingcommitctx object makes access to data related to
1682 the revision being committed convenient.
1687 the revision being committed convenient.
1683
1688
1684 This hides changes in the working directory, if they aren't
1689 This hides changes in the working directory, if they aren't
1685 committed in this context.
1690 committed in this context.
1686 """
1691 """
1687 def __init__(self, repo, changes,
1692 def __init__(self, repo, changes,
1688 text="", user=None, date=None, extra=None):
1693 text="", user=None, date=None, extra=None):
1689 super(workingctx, self).__init__(repo, text, user, date, extra,
1694 super(workingctx, self).__init__(repo, text, user, date, extra,
1690 changes)
1695 changes)
1691
1696
1692 def _dirstatestatus(self, match=None, ignored=False, clean=False,
1697 def _dirstatestatus(self, match=None, ignored=False, clean=False,
1693 unknown=False):
1698 unknown=False):
1694 """Return matched files only in ``self._status``
1699 """Return matched files only in ``self._status``
1695
1700
1696 Uncommitted files appear "clean" via this context, even if
1701 Uncommitted files appear "clean" via this context, even if
1697 they aren't actually so in the working directory.
1702 they aren't actually so in the working directory.
1698 """
1703 """
1699 match = match or matchmod.always(self._repo.root, self._repo.getcwd())
1704 match = match or matchmod.always(self._repo.root, self._repo.getcwd())
1700 if clean:
1705 if clean:
1701 clean = [f for f in self._manifest if f not in self._changedset]
1706 clean = [f for f in self._manifest if f not in self._changedset]
1702 else:
1707 else:
1703 clean = []
1708 clean = []
1704 return scmutil.status([f for f in self._status.modified if match(f)],
1709 return scmutil.status([f for f in self._status.modified if match(f)],
1705 [f for f in self._status.added if match(f)],
1710 [f for f in self._status.added if match(f)],
1706 [f for f in self._status.removed if match(f)],
1711 [f for f in self._status.removed if match(f)],
1707 [], [], [], clean)
1712 [], [], [], clean)
1708
1713
1709 @propertycache
1714 @propertycache
1710 def _changedset(self):
1715 def _changedset(self):
1711 """Return the set of files changed in this context
1716 """Return the set of files changed in this context
1712 """
1717 """
1713 changed = set(self._status.modified)
1718 changed = set(self._status.modified)
1714 changed.update(self._status.added)
1719 changed.update(self._status.added)
1715 changed.update(self._status.removed)
1720 changed.update(self._status.removed)
1716 return changed
1721 return changed
1717
1722
1718 class memctx(committablectx):
1723 class memctx(committablectx):
1719 """Use memctx to perform in-memory commits via localrepo.commitctx().
1724 """Use memctx to perform in-memory commits via localrepo.commitctx().
1720
1725
1721 Revision information is supplied at initialization time while
1726 Revision information is supplied at initialization time while
1722 related files data and is made available through a callback
1727 related files data and is made available through a callback
1723 mechanism. 'repo' is the current localrepo, 'parents' is a
1728 mechanism. 'repo' is the current localrepo, 'parents' is a
1724 sequence of two parent revisions identifiers (pass None for every
1729 sequence of two parent revisions identifiers (pass None for every
1725 missing parent), 'text' is the commit message and 'files' lists
1730 missing parent), 'text' is the commit message and 'files' lists
1726 names of files touched by the revision (normalized and relative to
1731 names of files touched by the revision (normalized and relative to
1727 repository root).
1732 repository root).
1728
1733
1729 filectxfn(repo, memctx, path) is a callable receiving the
1734 filectxfn(repo, memctx, path) is a callable receiving the
1730 repository, the current memctx object and the normalized path of
1735 repository, the current memctx object and the normalized path of
1731 requested file, relative to repository root. It is fired by the
1736 requested file, relative to repository root. It is fired by the
1732 commit function for every file in 'files', but calls order is
1737 commit function for every file in 'files', but calls order is
1733 undefined. If the file is available in the revision being
1738 undefined. If the file is available in the revision being
1734 committed (updated or added), filectxfn returns a memfilectx
1739 committed (updated or added), filectxfn returns a memfilectx
1735 object. If the file was removed, filectxfn raises an
1740 object. If the file was removed, filectxfn raises an
1736 IOError. Moved files are represented by marking the source file
1741 IOError. Moved files are represented by marking the source file
1737 removed and the new file added with copy information (see
1742 removed and the new file added with copy information (see
1738 memfilectx).
1743 memfilectx).
1739
1744
1740 user receives the committer name and defaults to current
1745 user receives the committer name and defaults to current
1741 repository username, date is the commit date in any format
1746 repository username, date is the commit date in any format
1742 supported by util.parsedate() and defaults to current date, extra
1747 supported by util.parsedate() and defaults to current date, extra
1743 is a dictionary of metadata or is left empty.
1748 is a dictionary of metadata or is left empty.
1744 """
1749 """
1745
1750
1746 # Mercurial <= 3.1 expects the filectxfn to raise IOError for missing files.
1751 # Mercurial <= 3.1 expects the filectxfn to raise IOError for missing files.
1747 # Extensions that need to retain compatibility across Mercurial 3.1 can use
1752 # Extensions that need to retain compatibility across Mercurial 3.1 can use
1748 # this field to determine what to do in filectxfn.
1753 # this field to determine what to do in filectxfn.
1749 _returnnoneformissingfiles = True
1754 _returnnoneformissingfiles = True
1750
1755
1751 def __init__(self, repo, parents, text, files, filectxfn, user=None,
1756 def __init__(self, repo, parents, text, files, filectxfn, user=None,
1752 date=None, extra=None, editor=False):
1757 date=None, extra=None, editor=False):
1753 super(memctx, self).__init__(repo, text, user, date, extra)
1758 super(memctx, self).__init__(repo, text, user, date, extra)
1754 self._rev = None
1759 self._rev = None
1755 self._node = None
1760 self._node = None
1756 parents = [(p or nullid) for p in parents]
1761 parents = [(p or nullid) for p in parents]
1757 p1, p2 = parents
1762 p1, p2 = parents
1758 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
1763 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
1759 files = sorted(set(files))
1764 files = sorted(set(files))
1760 self._files = files
1765 self._files = files
1761 self.substate = {}
1766 self.substate = {}
1762
1767
1763 # if store is not callable, wrap it in a function
1768 # if store is not callable, wrap it in a function
1764 if not callable(filectxfn):
1769 if not callable(filectxfn):
1765 def getfilectx(repo, memctx, path):
1770 def getfilectx(repo, memctx, path):
1766 fctx = filectxfn[path]
1771 fctx = filectxfn[path]
1767 # this is weird but apparently we only keep track of one parent
1772 # this is weird but apparently we only keep track of one parent
1768 # (why not only store that instead of a tuple?)
1773 # (why not only store that instead of a tuple?)
1769 copied = fctx.renamed()
1774 copied = fctx.renamed()
1770 if copied:
1775 if copied:
1771 copied = copied[0]
1776 copied = copied[0]
1772 return memfilectx(repo, path, fctx.data(),
1777 return memfilectx(repo, path, fctx.data(),
1773 islink=fctx.islink(), isexec=fctx.isexec(),
1778 islink=fctx.islink(), isexec=fctx.isexec(),
1774 copied=copied, memctx=memctx)
1779 copied=copied, memctx=memctx)
1775 self._filectxfn = getfilectx
1780 self._filectxfn = getfilectx
1776 else:
1781 else:
1777 # "util.cachefunc" reduces invocation of possibly expensive
1782 # "util.cachefunc" reduces invocation of possibly expensive
1778 # "filectxfn" for performance (e.g. converting from another VCS)
1783 # "filectxfn" for performance (e.g. converting from another VCS)
1779 self._filectxfn = util.cachefunc(filectxfn)
1784 self._filectxfn = util.cachefunc(filectxfn)
1780
1785
1781 if extra:
1786 if extra:
1782 self._extra = extra.copy()
1787 self._extra = extra.copy()
1783 else:
1788 else:
1784 self._extra = {}
1789 self._extra = {}
1785
1790
1786 if self._extra.get('branch', '') == '':
1791 if self._extra.get('branch', '') == '':
1787 self._extra['branch'] = 'default'
1792 self._extra['branch'] = 'default'
1788
1793
1789 if editor:
1794 if editor:
1790 self._text = editor(self._repo, self, [])
1795 self._text = editor(self._repo, self, [])
1791 self._repo.savecommitmessage(self._text)
1796 self._repo.savecommitmessage(self._text)
1792
1797
1793 def filectx(self, path, filelog=None):
1798 def filectx(self, path, filelog=None):
1794 """get a file context from the working directory
1799 """get a file context from the working directory
1795
1800
1796 Returns None if file doesn't exist and should be removed."""
1801 Returns None if file doesn't exist and should be removed."""
1797 return self._filectxfn(self._repo, self, path)
1802 return self._filectxfn(self._repo, self, path)
1798
1803
1799 def commit(self):
1804 def commit(self):
1800 """commit context to the repo"""
1805 """commit context to the repo"""
1801 return self._repo.commitctx(self)
1806 return self._repo.commitctx(self)
1802
1807
1803 @propertycache
1808 @propertycache
1804 def _manifest(self):
1809 def _manifest(self):
1805 """generate a manifest based on the return values of filectxfn"""
1810 """generate a manifest based on the return values of filectxfn"""
1806
1811
1807 # keep this simple for now; just worry about p1
1812 # keep this simple for now; just worry about p1
1808 pctx = self._parents[0]
1813 pctx = self._parents[0]
1809 man = pctx.manifest().copy()
1814 man = pctx.manifest().copy()
1810
1815
1811 for f in self._status.modified:
1816 for f in self._status.modified:
1812 p1node = nullid
1817 p1node = nullid
1813 p2node = nullid
1818 p2node = nullid
1814 p = pctx[f].parents() # if file isn't in pctx, check p2?
1819 p = pctx[f].parents() # if file isn't in pctx, check p2?
1815 if len(p) > 0:
1820 if len(p) > 0:
1816 p1node = p[0].node()
1821 p1node = p[0].node()
1817 if len(p) > 1:
1822 if len(p) > 1:
1818 p2node = p[1].node()
1823 p2node = p[1].node()
1819 man[f] = revlog.hash(self[f].data(), p1node, p2node)
1824 man[f] = revlog.hash(self[f].data(), p1node, p2node)
1820
1825
1821 for f in self._status.added:
1826 for f in self._status.added:
1822 man[f] = revlog.hash(self[f].data(), nullid, nullid)
1827 man[f] = revlog.hash(self[f].data(), nullid, nullid)
1823
1828
1824 for f in self._status.removed:
1829 for f in self._status.removed:
1825 if f in man:
1830 if f in man:
1826 del man[f]
1831 del man[f]
1827
1832
1828 return man
1833 return man
1829
1834
1830 @propertycache
1835 @propertycache
1831 def _status(self):
1836 def _status(self):
1832 """Calculate exact status from ``files`` specified at construction
1837 """Calculate exact status from ``files`` specified at construction
1833 """
1838 """
1834 man1 = self.p1().manifest()
1839 man1 = self.p1().manifest()
1835 p2 = self._parents[1]
1840 p2 = self._parents[1]
1836 # "1 < len(self._parents)" can't be used for checking
1841 # "1 < len(self._parents)" can't be used for checking
1837 # existence of the 2nd parent, because "memctx._parents" is
1842 # existence of the 2nd parent, because "memctx._parents" is
1838 # explicitly initialized by the list, of which length is 2.
1843 # explicitly initialized by the list, of which length is 2.
1839 if p2.node() != nullid:
1844 if p2.node() != nullid:
1840 man2 = p2.manifest()
1845 man2 = p2.manifest()
1841 managing = lambda f: f in man1 or f in man2
1846 managing = lambda f: f in man1 or f in man2
1842 else:
1847 else:
1843 managing = lambda f: f in man1
1848 managing = lambda f: f in man1
1844
1849
1845 modified, added, removed = [], [], []
1850 modified, added, removed = [], [], []
1846 for f in self._files:
1851 for f in self._files:
1847 if not managing(f):
1852 if not managing(f):
1848 added.append(f)
1853 added.append(f)
1849 elif self[f]:
1854 elif self[f]:
1850 modified.append(f)
1855 modified.append(f)
1851 else:
1856 else:
1852 removed.append(f)
1857 removed.append(f)
1853
1858
1854 return scmutil.status(modified, added, removed, [], [], [], [])
1859 return scmutil.status(modified, added, removed, [], [], [], [])
1855
1860
1856 class memfilectx(committablefilectx):
1861 class memfilectx(committablefilectx):
1857 """memfilectx represents an in-memory file to commit.
1862 """memfilectx represents an in-memory file to commit.
1858
1863
1859 See memctx and committablefilectx for more details.
1864 See memctx and committablefilectx for more details.
1860 """
1865 """
1861 def __init__(self, repo, path, data, islink=False,
1866 def __init__(self, repo, path, data, islink=False,
1862 isexec=False, copied=None, memctx=None):
1867 isexec=False, copied=None, memctx=None):
1863 """
1868 """
1864 path is the normalized file path relative to repository root.
1869 path is the normalized file path relative to repository root.
1865 data is the file content as a string.
1870 data is the file content as a string.
1866 islink is True if the file is a symbolic link.
1871 islink is True if the file is a symbolic link.
1867 isexec is True if the file is executable.
1872 isexec is True if the file is executable.
1868 copied is the source file path if current file was copied in the
1873 copied is the source file path if current file was copied in the
1869 revision being committed, or None."""
1874 revision being committed, or None."""
1870 super(memfilectx, self).__init__(repo, path, None, memctx)
1875 super(memfilectx, self).__init__(repo, path, None, memctx)
1871 self._data = data
1876 self._data = data
1872 self._flags = (islink and 'l' or '') + (isexec and 'x' or '')
1877 self._flags = (islink and 'l' or '') + (isexec and 'x' or '')
1873 self._copied = None
1878 self._copied = None
1874 if copied:
1879 if copied:
1875 self._copied = (copied, nullid)
1880 self._copied = (copied, nullid)
1876
1881
1877 def data(self):
1882 def data(self):
1878 return self._data
1883 return self._data
1879 def size(self):
1884 def size(self):
1880 return len(self.data())
1885 return len(self.data())
1881 def flags(self):
1886 def flags(self):
1882 return self._flags
1887 return self._flags
1883 def renamed(self):
1888 def renamed(self):
1884 return self._copied
1889 return self._copied
1885
1890
1886 def remove(self, ignoremissing=False):
1891 def remove(self, ignoremissing=False):
1887 """wraps unlink for a repo's working directory"""
1892 """wraps unlink for a repo's working directory"""
1888 # need to figure out what to do here
1893 # need to figure out what to do here
1889 del self._changectx[self._path]
1894 del self._changectx[self._path]
1890
1895
1891 def write(self, data, flags):
1896 def write(self, data, flags):
1892 """wraps repo.wwrite"""
1897 """wraps repo.wwrite"""
1893 self._data = data
1898 self._data = data
General Comments 0
You need to be logged in to leave comments. Login now