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