##// END OF EJS Templates
log: use namespace logname and colorname...
Sean Farley -
r23876:48fd1dfb default
parent child Browse files
Show More
@@ -1,2979 +1,2979 b''
1 # cmdutil.py - help for command processing in mercurial
1 # cmdutil.py - help for command processing in mercurial
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-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 hex, nullid, nullrev, short
8 from node import hex, nullid, nullrev, short
9 from i18n import _
9 from i18n import _
10 import os, sys, errno, re, tempfile
10 import os, sys, errno, re, tempfile
11 import util, scmutil, templater, patch, error, templatekw, revlog, copies
11 import util, scmutil, templater, patch, error, templatekw, revlog, copies
12 import match as matchmod
12 import match as matchmod
13 import context, repair, graphmod, revset, phases, obsolete, pathutil
13 import context, repair, graphmod, revset, phases, obsolete, pathutil
14 import changelog
14 import changelog
15 import bookmarks
15 import bookmarks
16 import encoding
16 import encoding
17 import lock as lockmod
17 import lock as lockmod
18
18
19 def parsealiases(cmd):
19 def parsealiases(cmd):
20 return cmd.lstrip("^").split("|")
20 return cmd.lstrip("^").split("|")
21
21
22 def findpossible(cmd, table, strict=False):
22 def findpossible(cmd, table, strict=False):
23 """
23 """
24 Return cmd -> (aliases, command table entry)
24 Return cmd -> (aliases, command table entry)
25 for each matching command.
25 for each matching command.
26 Return debug commands (or their aliases) only if no normal command matches.
26 Return debug commands (or their aliases) only if no normal command matches.
27 """
27 """
28 choice = {}
28 choice = {}
29 debugchoice = {}
29 debugchoice = {}
30
30
31 if cmd in table:
31 if cmd in table:
32 # short-circuit exact matches, "log" alias beats "^log|history"
32 # short-circuit exact matches, "log" alias beats "^log|history"
33 keys = [cmd]
33 keys = [cmd]
34 else:
34 else:
35 keys = table.keys()
35 keys = table.keys()
36
36
37 for e in keys:
37 for e in keys:
38 aliases = parsealiases(e)
38 aliases = parsealiases(e)
39 found = None
39 found = None
40 if cmd in aliases:
40 if cmd in aliases:
41 found = cmd
41 found = cmd
42 elif not strict:
42 elif not strict:
43 for a in aliases:
43 for a in aliases:
44 if a.startswith(cmd):
44 if a.startswith(cmd):
45 found = a
45 found = a
46 break
46 break
47 if found is not None:
47 if found is not None:
48 if aliases[0].startswith("debug") or found.startswith("debug"):
48 if aliases[0].startswith("debug") or found.startswith("debug"):
49 debugchoice[found] = (aliases, table[e])
49 debugchoice[found] = (aliases, table[e])
50 else:
50 else:
51 choice[found] = (aliases, table[e])
51 choice[found] = (aliases, table[e])
52
52
53 if not choice and debugchoice:
53 if not choice and debugchoice:
54 choice = debugchoice
54 choice = debugchoice
55
55
56 return choice
56 return choice
57
57
58 def findcmd(cmd, table, strict=True):
58 def findcmd(cmd, table, strict=True):
59 """Return (aliases, command table entry) for command string."""
59 """Return (aliases, command table entry) for command string."""
60 choice = findpossible(cmd, table, strict)
60 choice = findpossible(cmd, table, strict)
61
61
62 if cmd in choice:
62 if cmd in choice:
63 return choice[cmd]
63 return choice[cmd]
64
64
65 if len(choice) > 1:
65 if len(choice) > 1:
66 clist = choice.keys()
66 clist = choice.keys()
67 clist.sort()
67 clist.sort()
68 raise error.AmbiguousCommand(cmd, clist)
68 raise error.AmbiguousCommand(cmd, clist)
69
69
70 if choice:
70 if choice:
71 return choice.values()[0]
71 return choice.values()[0]
72
72
73 raise error.UnknownCommand(cmd)
73 raise error.UnknownCommand(cmd)
74
74
75 def findrepo(p):
75 def findrepo(p):
76 while not os.path.isdir(os.path.join(p, ".hg")):
76 while not os.path.isdir(os.path.join(p, ".hg")):
77 oldp, p = p, os.path.dirname(p)
77 oldp, p = p, os.path.dirname(p)
78 if p == oldp:
78 if p == oldp:
79 return None
79 return None
80
80
81 return p
81 return p
82
82
83 def bailifchanged(repo):
83 def bailifchanged(repo):
84 if repo.dirstate.p2() != nullid:
84 if repo.dirstate.p2() != nullid:
85 raise util.Abort(_('outstanding uncommitted merge'))
85 raise util.Abort(_('outstanding uncommitted merge'))
86 modified, added, removed, deleted = repo.status()[:4]
86 modified, added, removed, deleted = repo.status()[:4]
87 if modified or added or removed or deleted:
87 if modified or added or removed or deleted:
88 raise util.Abort(_('uncommitted changes'))
88 raise util.Abort(_('uncommitted changes'))
89 ctx = repo[None]
89 ctx = repo[None]
90 for s in sorted(ctx.substate):
90 for s in sorted(ctx.substate):
91 if ctx.sub(s).dirty():
91 if ctx.sub(s).dirty():
92 raise util.Abort(_("uncommitted changes in subrepo %s") % s)
92 raise util.Abort(_("uncommitted changes in subrepo %s") % s)
93
93
94 def logmessage(ui, opts):
94 def logmessage(ui, opts):
95 """ get the log message according to -m and -l option """
95 """ get the log message according to -m and -l option """
96 message = opts.get('message')
96 message = opts.get('message')
97 logfile = opts.get('logfile')
97 logfile = opts.get('logfile')
98
98
99 if message and logfile:
99 if message and logfile:
100 raise util.Abort(_('options --message and --logfile are mutually '
100 raise util.Abort(_('options --message and --logfile are mutually '
101 'exclusive'))
101 'exclusive'))
102 if not message and logfile:
102 if not message and logfile:
103 try:
103 try:
104 if logfile == '-':
104 if logfile == '-':
105 message = ui.fin.read()
105 message = ui.fin.read()
106 else:
106 else:
107 message = '\n'.join(util.readfile(logfile).splitlines())
107 message = '\n'.join(util.readfile(logfile).splitlines())
108 except IOError, inst:
108 except IOError, inst:
109 raise util.Abort(_("can't read commit message '%s': %s") %
109 raise util.Abort(_("can't read commit message '%s': %s") %
110 (logfile, inst.strerror))
110 (logfile, inst.strerror))
111 return message
111 return message
112
112
113 def mergeeditform(ctxorbool, baseform):
113 def mergeeditform(ctxorbool, baseform):
114 """build appropriate editform from ctxorbool and baseform
114 """build appropriate editform from ctxorbool and baseform
115
115
116 'ctxorbool' is one of a ctx to be committed, or a bool whether
116 'ctxorbool' is one of a ctx to be committed, or a bool whether
117 merging is committed.
117 merging is committed.
118
118
119 This returns editform 'baseform' with '.merge' if merging is
119 This returns editform 'baseform' with '.merge' if merging is
120 committed, or one with '.normal' suffix otherwise.
120 committed, or one with '.normal' suffix otherwise.
121 """
121 """
122 if isinstance(ctxorbool, bool):
122 if isinstance(ctxorbool, bool):
123 if ctxorbool:
123 if ctxorbool:
124 return baseform + ".merge"
124 return baseform + ".merge"
125 elif 1 < len(ctxorbool.parents()):
125 elif 1 < len(ctxorbool.parents()):
126 return baseform + ".merge"
126 return baseform + ".merge"
127
127
128 return baseform + ".normal"
128 return baseform + ".normal"
129
129
130 def getcommiteditor(edit=False, finishdesc=None, extramsg=None,
130 def getcommiteditor(edit=False, finishdesc=None, extramsg=None,
131 editform='', **opts):
131 editform='', **opts):
132 """get appropriate commit message editor according to '--edit' option
132 """get appropriate commit message editor according to '--edit' option
133
133
134 'finishdesc' is a function to be called with edited commit message
134 'finishdesc' is a function to be called with edited commit message
135 (= 'description' of the new changeset) just after editing, but
135 (= 'description' of the new changeset) just after editing, but
136 before checking empty-ness. It should return actual text to be
136 before checking empty-ness. It should return actual text to be
137 stored into history. This allows to change description before
137 stored into history. This allows to change description before
138 storing.
138 storing.
139
139
140 'extramsg' is a extra message to be shown in the editor instead of
140 'extramsg' is a extra message to be shown in the editor instead of
141 'Leave message empty to abort commit' line. 'HG: ' prefix and EOL
141 'Leave message empty to abort commit' line. 'HG: ' prefix and EOL
142 is automatically added.
142 is automatically added.
143
143
144 'editform' is a dot-separated list of names, to distinguish
144 'editform' is a dot-separated list of names, to distinguish
145 the purpose of commit text editing.
145 the purpose of commit text editing.
146
146
147 'getcommiteditor' returns 'commitforceeditor' regardless of
147 'getcommiteditor' returns 'commitforceeditor' regardless of
148 'edit', if one of 'finishdesc' or 'extramsg' is specified, because
148 'edit', if one of 'finishdesc' or 'extramsg' is specified, because
149 they are specific for usage in MQ.
149 they are specific for usage in MQ.
150 """
150 """
151 if edit or finishdesc or extramsg:
151 if edit or finishdesc or extramsg:
152 return lambda r, c, s: commitforceeditor(r, c, s,
152 return lambda r, c, s: commitforceeditor(r, c, s,
153 finishdesc=finishdesc,
153 finishdesc=finishdesc,
154 extramsg=extramsg,
154 extramsg=extramsg,
155 editform=editform)
155 editform=editform)
156 elif editform:
156 elif editform:
157 return lambda r, c, s: commiteditor(r, c, s, editform=editform)
157 return lambda r, c, s: commiteditor(r, c, s, editform=editform)
158 else:
158 else:
159 return commiteditor
159 return commiteditor
160
160
161 def loglimit(opts):
161 def loglimit(opts):
162 """get the log limit according to option -l/--limit"""
162 """get the log limit according to option -l/--limit"""
163 limit = opts.get('limit')
163 limit = opts.get('limit')
164 if limit:
164 if limit:
165 try:
165 try:
166 limit = int(limit)
166 limit = int(limit)
167 except ValueError:
167 except ValueError:
168 raise util.Abort(_('limit must be a positive integer'))
168 raise util.Abort(_('limit must be a positive integer'))
169 if limit <= 0:
169 if limit <= 0:
170 raise util.Abort(_('limit must be positive'))
170 raise util.Abort(_('limit must be positive'))
171 else:
171 else:
172 limit = None
172 limit = None
173 return limit
173 return limit
174
174
175 def makefilename(repo, pat, node, desc=None,
175 def makefilename(repo, pat, node, desc=None,
176 total=None, seqno=None, revwidth=None, pathname=None):
176 total=None, seqno=None, revwidth=None, pathname=None):
177 node_expander = {
177 node_expander = {
178 'H': lambda: hex(node),
178 'H': lambda: hex(node),
179 'R': lambda: str(repo.changelog.rev(node)),
179 'R': lambda: str(repo.changelog.rev(node)),
180 'h': lambda: short(node),
180 'h': lambda: short(node),
181 'm': lambda: re.sub('[^\w]', '_', str(desc))
181 'm': lambda: re.sub('[^\w]', '_', str(desc))
182 }
182 }
183 expander = {
183 expander = {
184 '%': lambda: '%',
184 '%': lambda: '%',
185 'b': lambda: os.path.basename(repo.root),
185 'b': lambda: os.path.basename(repo.root),
186 }
186 }
187
187
188 try:
188 try:
189 if node:
189 if node:
190 expander.update(node_expander)
190 expander.update(node_expander)
191 if node:
191 if node:
192 expander['r'] = (lambda:
192 expander['r'] = (lambda:
193 str(repo.changelog.rev(node)).zfill(revwidth or 0))
193 str(repo.changelog.rev(node)).zfill(revwidth or 0))
194 if total is not None:
194 if total is not None:
195 expander['N'] = lambda: str(total)
195 expander['N'] = lambda: str(total)
196 if seqno is not None:
196 if seqno is not None:
197 expander['n'] = lambda: str(seqno)
197 expander['n'] = lambda: str(seqno)
198 if total is not None and seqno is not None:
198 if total is not None and seqno is not None:
199 expander['n'] = lambda: str(seqno).zfill(len(str(total)))
199 expander['n'] = lambda: str(seqno).zfill(len(str(total)))
200 if pathname is not None:
200 if pathname is not None:
201 expander['s'] = lambda: os.path.basename(pathname)
201 expander['s'] = lambda: os.path.basename(pathname)
202 expander['d'] = lambda: os.path.dirname(pathname) or '.'
202 expander['d'] = lambda: os.path.dirname(pathname) or '.'
203 expander['p'] = lambda: pathname
203 expander['p'] = lambda: pathname
204
204
205 newname = []
205 newname = []
206 patlen = len(pat)
206 patlen = len(pat)
207 i = 0
207 i = 0
208 while i < patlen:
208 while i < patlen:
209 c = pat[i]
209 c = pat[i]
210 if c == '%':
210 if c == '%':
211 i += 1
211 i += 1
212 c = pat[i]
212 c = pat[i]
213 c = expander[c]()
213 c = expander[c]()
214 newname.append(c)
214 newname.append(c)
215 i += 1
215 i += 1
216 return ''.join(newname)
216 return ''.join(newname)
217 except KeyError, inst:
217 except KeyError, inst:
218 raise util.Abort(_("invalid format spec '%%%s' in output filename") %
218 raise util.Abort(_("invalid format spec '%%%s' in output filename") %
219 inst.args[0])
219 inst.args[0])
220
220
221 def makefileobj(repo, pat, node=None, desc=None, total=None,
221 def makefileobj(repo, pat, node=None, desc=None, total=None,
222 seqno=None, revwidth=None, mode='wb', modemap=None,
222 seqno=None, revwidth=None, mode='wb', modemap=None,
223 pathname=None):
223 pathname=None):
224
224
225 writable = mode not in ('r', 'rb')
225 writable = mode not in ('r', 'rb')
226
226
227 if not pat or pat == '-':
227 if not pat or pat == '-':
228 fp = writable and repo.ui.fout or repo.ui.fin
228 fp = writable and repo.ui.fout or repo.ui.fin
229 if util.safehasattr(fp, 'fileno'):
229 if util.safehasattr(fp, 'fileno'):
230 return os.fdopen(os.dup(fp.fileno()), mode)
230 return os.fdopen(os.dup(fp.fileno()), mode)
231 else:
231 else:
232 # if this fp can't be duped properly, return
232 # if this fp can't be duped properly, return
233 # a dummy object that can be closed
233 # a dummy object that can be closed
234 class wrappedfileobj(object):
234 class wrappedfileobj(object):
235 noop = lambda x: None
235 noop = lambda x: None
236 def __init__(self, f):
236 def __init__(self, f):
237 self.f = f
237 self.f = f
238 def __getattr__(self, attr):
238 def __getattr__(self, attr):
239 if attr == 'close':
239 if attr == 'close':
240 return self.noop
240 return self.noop
241 else:
241 else:
242 return getattr(self.f, attr)
242 return getattr(self.f, attr)
243
243
244 return wrappedfileobj(fp)
244 return wrappedfileobj(fp)
245 if util.safehasattr(pat, 'write') and writable:
245 if util.safehasattr(pat, 'write') and writable:
246 return pat
246 return pat
247 if util.safehasattr(pat, 'read') and 'r' in mode:
247 if util.safehasattr(pat, 'read') and 'r' in mode:
248 return pat
248 return pat
249 fn = makefilename(repo, pat, node, desc, total, seqno, revwidth, pathname)
249 fn = makefilename(repo, pat, node, desc, total, seqno, revwidth, pathname)
250 if modemap is not None:
250 if modemap is not None:
251 mode = modemap.get(fn, mode)
251 mode = modemap.get(fn, mode)
252 if mode == 'wb':
252 if mode == 'wb':
253 modemap[fn] = 'ab'
253 modemap[fn] = 'ab'
254 return open(fn, mode)
254 return open(fn, mode)
255
255
256 def openrevlog(repo, cmd, file_, opts):
256 def openrevlog(repo, cmd, file_, opts):
257 """opens the changelog, manifest, a filelog or a given revlog"""
257 """opens the changelog, manifest, a filelog or a given revlog"""
258 cl = opts['changelog']
258 cl = opts['changelog']
259 mf = opts['manifest']
259 mf = opts['manifest']
260 msg = None
260 msg = None
261 if cl and mf:
261 if cl and mf:
262 msg = _('cannot specify --changelog and --manifest at the same time')
262 msg = _('cannot specify --changelog and --manifest at the same time')
263 elif cl or mf:
263 elif cl or mf:
264 if file_:
264 if file_:
265 msg = _('cannot specify filename with --changelog or --manifest')
265 msg = _('cannot specify filename with --changelog or --manifest')
266 elif not repo:
266 elif not repo:
267 msg = _('cannot specify --changelog or --manifest '
267 msg = _('cannot specify --changelog or --manifest '
268 'without a repository')
268 'without a repository')
269 if msg:
269 if msg:
270 raise util.Abort(msg)
270 raise util.Abort(msg)
271
271
272 r = None
272 r = None
273 if repo:
273 if repo:
274 if cl:
274 if cl:
275 r = repo.unfiltered().changelog
275 r = repo.unfiltered().changelog
276 elif mf:
276 elif mf:
277 r = repo.manifest
277 r = repo.manifest
278 elif file_:
278 elif file_:
279 filelog = repo.file(file_)
279 filelog = repo.file(file_)
280 if len(filelog):
280 if len(filelog):
281 r = filelog
281 r = filelog
282 if not r:
282 if not r:
283 if not file_:
283 if not file_:
284 raise error.CommandError(cmd, _('invalid arguments'))
284 raise error.CommandError(cmd, _('invalid arguments'))
285 if not os.path.isfile(file_):
285 if not os.path.isfile(file_):
286 raise util.Abort(_("revlog '%s' not found") % file_)
286 raise util.Abort(_("revlog '%s' not found") % file_)
287 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
287 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
288 file_[:-2] + ".i")
288 file_[:-2] + ".i")
289 return r
289 return r
290
290
291 def copy(ui, repo, pats, opts, rename=False):
291 def copy(ui, repo, pats, opts, rename=False):
292 # called with the repo lock held
292 # called with the repo lock held
293 #
293 #
294 # hgsep => pathname that uses "/" to separate directories
294 # hgsep => pathname that uses "/" to separate directories
295 # ossep => pathname that uses os.sep to separate directories
295 # ossep => pathname that uses os.sep to separate directories
296 cwd = repo.getcwd()
296 cwd = repo.getcwd()
297 targets = {}
297 targets = {}
298 after = opts.get("after")
298 after = opts.get("after")
299 dryrun = opts.get("dry_run")
299 dryrun = opts.get("dry_run")
300 wctx = repo[None]
300 wctx = repo[None]
301
301
302 def walkpat(pat):
302 def walkpat(pat):
303 srcs = []
303 srcs = []
304 badstates = after and '?' or '?r'
304 badstates = after and '?' or '?r'
305 m = scmutil.match(repo[None], [pat], opts, globbed=True)
305 m = scmutil.match(repo[None], [pat], opts, globbed=True)
306 for abs in repo.walk(m):
306 for abs in repo.walk(m):
307 state = repo.dirstate[abs]
307 state = repo.dirstate[abs]
308 rel = m.rel(abs)
308 rel = m.rel(abs)
309 exact = m.exact(abs)
309 exact = m.exact(abs)
310 if state in badstates:
310 if state in badstates:
311 if exact and state == '?':
311 if exact and state == '?':
312 ui.warn(_('%s: not copying - file is not managed\n') % rel)
312 ui.warn(_('%s: not copying - file is not managed\n') % rel)
313 if exact and state == 'r':
313 if exact and state == 'r':
314 ui.warn(_('%s: not copying - file has been marked for'
314 ui.warn(_('%s: not copying - file has been marked for'
315 ' remove\n') % rel)
315 ' remove\n') % rel)
316 continue
316 continue
317 # abs: hgsep
317 # abs: hgsep
318 # rel: ossep
318 # rel: ossep
319 srcs.append((abs, rel, exact))
319 srcs.append((abs, rel, exact))
320 return srcs
320 return srcs
321
321
322 # abssrc: hgsep
322 # abssrc: hgsep
323 # relsrc: ossep
323 # relsrc: ossep
324 # otarget: ossep
324 # otarget: ossep
325 def copyfile(abssrc, relsrc, otarget, exact):
325 def copyfile(abssrc, relsrc, otarget, exact):
326 abstarget = pathutil.canonpath(repo.root, cwd, otarget)
326 abstarget = pathutil.canonpath(repo.root, cwd, otarget)
327 if '/' in abstarget:
327 if '/' in abstarget:
328 # We cannot normalize abstarget itself, this would prevent
328 # We cannot normalize abstarget itself, this would prevent
329 # case only renames, like a => A.
329 # case only renames, like a => A.
330 abspath, absname = abstarget.rsplit('/', 1)
330 abspath, absname = abstarget.rsplit('/', 1)
331 abstarget = repo.dirstate.normalize(abspath) + '/' + absname
331 abstarget = repo.dirstate.normalize(abspath) + '/' + absname
332 reltarget = repo.pathto(abstarget, cwd)
332 reltarget = repo.pathto(abstarget, cwd)
333 target = repo.wjoin(abstarget)
333 target = repo.wjoin(abstarget)
334 src = repo.wjoin(abssrc)
334 src = repo.wjoin(abssrc)
335 state = repo.dirstate[abstarget]
335 state = repo.dirstate[abstarget]
336
336
337 scmutil.checkportable(ui, abstarget)
337 scmutil.checkportable(ui, abstarget)
338
338
339 # check for collisions
339 # check for collisions
340 prevsrc = targets.get(abstarget)
340 prevsrc = targets.get(abstarget)
341 if prevsrc is not None:
341 if prevsrc is not None:
342 ui.warn(_('%s: not overwriting - %s collides with %s\n') %
342 ui.warn(_('%s: not overwriting - %s collides with %s\n') %
343 (reltarget, repo.pathto(abssrc, cwd),
343 (reltarget, repo.pathto(abssrc, cwd),
344 repo.pathto(prevsrc, cwd)))
344 repo.pathto(prevsrc, cwd)))
345 return
345 return
346
346
347 # check for overwrites
347 # check for overwrites
348 exists = os.path.lexists(target)
348 exists = os.path.lexists(target)
349 samefile = False
349 samefile = False
350 if exists and abssrc != abstarget:
350 if exists and abssrc != abstarget:
351 if (repo.dirstate.normalize(abssrc) ==
351 if (repo.dirstate.normalize(abssrc) ==
352 repo.dirstate.normalize(abstarget)):
352 repo.dirstate.normalize(abstarget)):
353 if not rename:
353 if not rename:
354 ui.warn(_("%s: can't copy - same file\n") % reltarget)
354 ui.warn(_("%s: can't copy - same file\n") % reltarget)
355 return
355 return
356 exists = False
356 exists = False
357 samefile = True
357 samefile = True
358
358
359 if not after and exists or after and state in 'mn':
359 if not after and exists or after and state in 'mn':
360 if not opts['force']:
360 if not opts['force']:
361 ui.warn(_('%s: not overwriting - file exists\n') %
361 ui.warn(_('%s: not overwriting - file exists\n') %
362 reltarget)
362 reltarget)
363 return
363 return
364
364
365 if after:
365 if after:
366 if not exists:
366 if not exists:
367 if rename:
367 if rename:
368 ui.warn(_('%s: not recording move - %s does not exist\n') %
368 ui.warn(_('%s: not recording move - %s does not exist\n') %
369 (relsrc, reltarget))
369 (relsrc, reltarget))
370 else:
370 else:
371 ui.warn(_('%s: not recording copy - %s does not exist\n') %
371 ui.warn(_('%s: not recording copy - %s does not exist\n') %
372 (relsrc, reltarget))
372 (relsrc, reltarget))
373 return
373 return
374 elif not dryrun:
374 elif not dryrun:
375 try:
375 try:
376 if exists:
376 if exists:
377 os.unlink(target)
377 os.unlink(target)
378 targetdir = os.path.dirname(target) or '.'
378 targetdir = os.path.dirname(target) or '.'
379 if not os.path.isdir(targetdir):
379 if not os.path.isdir(targetdir):
380 os.makedirs(targetdir)
380 os.makedirs(targetdir)
381 if samefile:
381 if samefile:
382 tmp = target + "~hgrename"
382 tmp = target + "~hgrename"
383 os.rename(src, tmp)
383 os.rename(src, tmp)
384 os.rename(tmp, target)
384 os.rename(tmp, target)
385 else:
385 else:
386 util.copyfile(src, target)
386 util.copyfile(src, target)
387 srcexists = True
387 srcexists = True
388 except IOError, inst:
388 except IOError, inst:
389 if inst.errno == errno.ENOENT:
389 if inst.errno == errno.ENOENT:
390 ui.warn(_('%s: deleted in working copy\n') % relsrc)
390 ui.warn(_('%s: deleted in working copy\n') % relsrc)
391 srcexists = False
391 srcexists = False
392 else:
392 else:
393 ui.warn(_('%s: cannot copy - %s\n') %
393 ui.warn(_('%s: cannot copy - %s\n') %
394 (relsrc, inst.strerror))
394 (relsrc, inst.strerror))
395 return True # report a failure
395 return True # report a failure
396
396
397 if ui.verbose or not exact:
397 if ui.verbose or not exact:
398 if rename:
398 if rename:
399 ui.status(_('moving %s to %s\n') % (relsrc, reltarget))
399 ui.status(_('moving %s to %s\n') % (relsrc, reltarget))
400 else:
400 else:
401 ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
401 ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
402
402
403 targets[abstarget] = abssrc
403 targets[abstarget] = abssrc
404
404
405 # fix up dirstate
405 # fix up dirstate
406 scmutil.dirstatecopy(ui, repo, wctx, abssrc, abstarget,
406 scmutil.dirstatecopy(ui, repo, wctx, abssrc, abstarget,
407 dryrun=dryrun, cwd=cwd)
407 dryrun=dryrun, cwd=cwd)
408 if rename and not dryrun:
408 if rename and not dryrun:
409 if not after and srcexists and not samefile:
409 if not after and srcexists and not samefile:
410 util.unlinkpath(repo.wjoin(abssrc))
410 util.unlinkpath(repo.wjoin(abssrc))
411 wctx.forget([abssrc])
411 wctx.forget([abssrc])
412
412
413 # pat: ossep
413 # pat: ossep
414 # dest ossep
414 # dest ossep
415 # srcs: list of (hgsep, hgsep, ossep, bool)
415 # srcs: list of (hgsep, hgsep, ossep, bool)
416 # return: function that takes hgsep and returns ossep
416 # return: function that takes hgsep and returns ossep
417 def targetpathfn(pat, dest, srcs):
417 def targetpathfn(pat, dest, srcs):
418 if os.path.isdir(pat):
418 if os.path.isdir(pat):
419 abspfx = pathutil.canonpath(repo.root, cwd, pat)
419 abspfx = pathutil.canonpath(repo.root, cwd, pat)
420 abspfx = util.localpath(abspfx)
420 abspfx = util.localpath(abspfx)
421 if destdirexists:
421 if destdirexists:
422 striplen = len(os.path.split(abspfx)[0])
422 striplen = len(os.path.split(abspfx)[0])
423 else:
423 else:
424 striplen = len(abspfx)
424 striplen = len(abspfx)
425 if striplen:
425 if striplen:
426 striplen += len(os.sep)
426 striplen += len(os.sep)
427 res = lambda p: os.path.join(dest, util.localpath(p)[striplen:])
427 res = lambda p: os.path.join(dest, util.localpath(p)[striplen:])
428 elif destdirexists:
428 elif destdirexists:
429 res = lambda p: os.path.join(dest,
429 res = lambda p: os.path.join(dest,
430 os.path.basename(util.localpath(p)))
430 os.path.basename(util.localpath(p)))
431 else:
431 else:
432 res = lambda p: dest
432 res = lambda p: dest
433 return res
433 return res
434
434
435 # pat: ossep
435 # pat: ossep
436 # dest ossep
436 # dest ossep
437 # srcs: list of (hgsep, hgsep, ossep, bool)
437 # srcs: list of (hgsep, hgsep, ossep, bool)
438 # return: function that takes hgsep and returns ossep
438 # return: function that takes hgsep and returns ossep
439 def targetpathafterfn(pat, dest, srcs):
439 def targetpathafterfn(pat, dest, srcs):
440 if matchmod.patkind(pat):
440 if matchmod.patkind(pat):
441 # a mercurial pattern
441 # a mercurial pattern
442 res = lambda p: os.path.join(dest,
442 res = lambda p: os.path.join(dest,
443 os.path.basename(util.localpath(p)))
443 os.path.basename(util.localpath(p)))
444 else:
444 else:
445 abspfx = pathutil.canonpath(repo.root, cwd, pat)
445 abspfx = pathutil.canonpath(repo.root, cwd, pat)
446 if len(abspfx) < len(srcs[0][0]):
446 if len(abspfx) < len(srcs[0][0]):
447 # A directory. Either the target path contains the last
447 # A directory. Either the target path contains the last
448 # component of the source path or it does not.
448 # component of the source path or it does not.
449 def evalpath(striplen):
449 def evalpath(striplen):
450 score = 0
450 score = 0
451 for s in srcs:
451 for s in srcs:
452 t = os.path.join(dest, util.localpath(s[0])[striplen:])
452 t = os.path.join(dest, util.localpath(s[0])[striplen:])
453 if os.path.lexists(t):
453 if os.path.lexists(t):
454 score += 1
454 score += 1
455 return score
455 return score
456
456
457 abspfx = util.localpath(abspfx)
457 abspfx = util.localpath(abspfx)
458 striplen = len(abspfx)
458 striplen = len(abspfx)
459 if striplen:
459 if striplen:
460 striplen += len(os.sep)
460 striplen += len(os.sep)
461 if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])):
461 if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])):
462 score = evalpath(striplen)
462 score = evalpath(striplen)
463 striplen1 = len(os.path.split(abspfx)[0])
463 striplen1 = len(os.path.split(abspfx)[0])
464 if striplen1:
464 if striplen1:
465 striplen1 += len(os.sep)
465 striplen1 += len(os.sep)
466 if evalpath(striplen1) > score:
466 if evalpath(striplen1) > score:
467 striplen = striplen1
467 striplen = striplen1
468 res = lambda p: os.path.join(dest,
468 res = lambda p: os.path.join(dest,
469 util.localpath(p)[striplen:])
469 util.localpath(p)[striplen:])
470 else:
470 else:
471 # a file
471 # a file
472 if destdirexists:
472 if destdirexists:
473 res = lambda p: os.path.join(dest,
473 res = lambda p: os.path.join(dest,
474 os.path.basename(util.localpath(p)))
474 os.path.basename(util.localpath(p)))
475 else:
475 else:
476 res = lambda p: dest
476 res = lambda p: dest
477 return res
477 return res
478
478
479
479
480 pats = scmutil.expandpats(pats)
480 pats = scmutil.expandpats(pats)
481 if not pats:
481 if not pats:
482 raise util.Abort(_('no source or destination specified'))
482 raise util.Abort(_('no source or destination specified'))
483 if len(pats) == 1:
483 if len(pats) == 1:
484 raise util.Abort(_('no destination specified'))
484 raise util.Abort(_('no destination specified'))
485 dest = pats.pop()
485 dest = pats.pop()
486 destdirexists = os.path.isdir(dest) and not os.path.islink(dest)
486 destdirexists = os.path.isdir(dest) and not os.path.islink(dest)
487 if not destdirexists:
487 if not destdirexists:
488 if len(pats) > 1 or matchmod.patkind(pats[0]):
488 if len(pats) > 1 or matchmod.patkind(pats[0]):
489 raise util.Abort(_('with multiple sources, destination must be an '
489 raise util.Abort(_('with multiple sources, destination must be an '
490 'existing directory'))
490 'existing directory'))
491 if util.endswithsep(dest):
491 if util.endswithsep(dest):
492 raise util.Abort(_('destination %s is not a directory') % dest)
492 raise util.Abort(_('destination %s is not a directory') % dest)
493
493
494 tfn = targetpathfn
494 tfn = targetpathfn
495 if after:
495 if after:
496 tfn = targetpathafterfn
496 tfn = targetpathafterfn
497 copylist = []
497 copylist = []
498 for pat in pats:
498 for pat in pats:
499 srcs = walkpat(pat)
499 srcs = walkpat(pat)
500 if not srcs:
500 if not srcs:
501 continue
501 continue
502 copylist.append((tfn(pat, dest, srcs), srcs))
502 copylist.append((tfn(pat, dest, srcs), srcs))
503 if not copylist:
503 if not copylist:
504 raise util.Abort(_('no files to copy'))
504 raise util.Abort(_('no files to copy'))
505
505
506 errors = 0
506 errors = 0
507 for targetpath, srcs in copylist:
507 for targetpath, srcs in copylist:
508 for abssrc, relsrc, exact in srcs:
508 for abssrc, relsrc, exact in srcs:
509 if copyfile(abssrc, relsrc, targetpath(abssrc), exact):
509 if copyfile(abssrc, relsrc, targetpath(abssrc), exact):
510 errors += 1
510 errors += 1
511
511
512 if errors:
512 if errors:
513 ui.warn(_('(consider using --after)\n'))
513 ui.warn(_('(consider using --after)\n'))
514
514
515 return errors != 0
515 return errors != 0
516
516
517 def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None,
517 def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None,
518 runargs=None, appendpid=False):
518 runargs=None, appendpid=False):
519 '''Run a command as a service.'''
519 '''Run a command as a service.'''
520
520
521 def writepid(pid):
521 def writepid(pid):
522 if opts['pid_file']:
522 if opts['pid_file']:
523 mode = appendpid and 'a' or 'w'
523 mode = appendpid and 'a' or 'w'
524 fp = open(opts['pid_file'], mode)
524 fp = open(opts['pid_file'], mode)
525 fp.write(str(pid) + '\n')
525 fp.write(str(pid) + '\n')
526 fp.close()
526 fp.close()
527
527
528 if opts['daemon'] and not opts['daemon_pipefds']:
528 if opts['daemon'] and not opts['daemon_pipefds']:
529 # Signal child process startup with file removal
529 # Signal child process startup with file removal
530 lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-')
530 lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-')
531 os.close(lockfd)
531 os.close(lockfd)
532 try:
532 try:
533 if not runargs:
533 if not runargs:
534 runargs = util.hgcmd() + sys.argv[1:]
534 runargs = util.hgcmd() + sys.argv[1:]
535 runargs.append('--daemon-pipefds=%s' % lockpath)
535 runargs.append('--daemon-pipefds=%s' % lockpath)
536 # Don't pass --cwd to the child process, because we've already
536 # Don't pass --cwd to the child process, because we've already
537 # changed directory.
537 # changed directory.
538 for i in xrange(1, len(runargs)):
538 for i in xrange(1, len(runargs)):
539 if runargs[i].startswith('--cwd='):
539 if runargs[i].startswith('--cwd='):
540 del runargs[i]
540 del runargs[i]
541 break
541 break
542 elif runargs[i].startswith('--cwd'):
542 elif runargs[i].startswith('--cwd'):
543 del runargs[i:i + 2]
543 del runargs[i:i + 2]
544 break
544 break
545 def condfn():
545 def condfn():
546 return not os.path.exists(lockpath)
546 return not os.path.exists(lockpath)
547 pid = util.rundetached(runargs, condfn)
547 pid = util.rundetached(runargs, condfn)
548 if pid < 0:
548 if pid < 0:
549 raise util.Abort(_('child process failed to start'))
549 raise util.Abort(_('child process failed to start'))
550 writepid(pid)
550 writepid(pid)
551 finally:
551 finally:
552 try:
552 try:
553 os.unlink(lockpath)
553 os.unlink(lockpath)
554 except OSError, e:
554 except OSError, e:
555 if e.errno != errno.ENOENT:
555 if e.errno != errno.ENOENT:
556 raise
556 raise
557 if parentfn:
557 if parentfn:
558 return parentfn(pid)
558 return parentfn(pid)
559 else:
559 else:
560 return
560 return
561
561
562 if initfn:
562 if initfn:
563 initfn()
563 initfn()
564
564
565 if not opts['daemon']:
565 if not opts['daemon']:
566 writepid(os.getpid())
566 writepid(os.getpid())
567
567
568 if opts['daemon_pipefds']:
568 if opts['daemon_pipefds']:
569 lockpath = opts['daemon_pipefds']
569 lockpath = opts['daemon_pipefds']
570 try:
570 try:
571 os.setsid()
571 os.setsid()
572 except AttributeError:
572 except AttributeError:
573 pass
573 pass
574 os.unlink(lockpath)
574 os.unlink(lockpath)
575 util.hidewindow()
575 util.hidewindow()
576 sys.stdout.flush()
576 sys.stdout.flush()
577 sys.stderr.flush()
577 sys.stderr.flush()
578
578
579 nullfd = os.open(os.devnull, os.O_RDWR)
579 nullfd = os.open(os.devnull, os.O_RDWR)
580 logfilefd = nullfd
580 logfilefd = nullfd
581 if logfile:
581 if logfile:
582 logfilefd = os.open(logfile, os.O_RDWR | os.O_CREAT | os.O_APPEND)
582 logfilefd = os.open(logfile, os.O_RDWR | os.O_CREAT | os.O_APPEND)
583 os.dup2(nullfd, 0)
583 os.dup2(nullfd, 0)
584 os.dup2(logfilefd, 1)
584 os.dup2(logfilefd, 1)
585 os.dup2(logfilefd, 2)
585 os.dup2(logfilefd, 2)
586 if nullfd not in (0, 1, 2):
586 if nullfd not in (0, 1, 2):
587 os.close(nullfd)
587 os.close(nullfd)
588 if logfile and logfilefd not in (0, 1, 2):
588 if logfile and logfilefd not in (0, 1, 2):
589 os.close(logfilefd)
589 os.close(logfilefd)
590
590
591 if runfn:
591 if runfn:
592 return runfn()
592 return runfn()
593
593
594 def tryimportone(ui, repo, hunk, parents, opts, msgs, updatefunc):
594 def tryimportone(ui, repo, hunk, parents, opts, msgs, updatefunc):
595 """Utility function used by commands.import to import a single patch
595 """Utility function used by commands.import to import a single patch
596
596
597 This function is explicitly defined here to help the evolve extension to
597 This function is explicitly defined here to help the evolve extension to
598 wrap this part of the import logic.
598 wrap this part of the import logic.
599
599
600 The API is currently a bit ugly because it a simple code translation from
600 The API is currently a bit ugly because it a simple code translation from
601 the import command. Feel free to make it better.
601 the import command. Feel free to make it better.
602
602
603 :hunk: a patch (as a binary string)
603 :hunk: a patch (as a binary string)
604 :parents: nodes that will be parent of the created commit
604 :parents: nodes that will be parent of the created commit
605 :opts: the full dict of option passed to the import command
605 :opts: the full dict of option passed to the import command
606 :msgs: list to save commit message to.
606 :msgs: list to save commit message to.
607 (used in case we need to save it when failing)
607 (used in case we need to save it when failing)
608 :updatefunc: a function that update a repo to a given node
608 :updatefunc: a function that update a repo to a given node
609 updatefunc(<repo>, <node>)
609 updatefunc(<repo>, <node>)
610 """
610 """
611 tmpname, message, user, date, branch, nodeid, p1, p2 = \
611 tmpname, message, user, date, branch, nodeid, p1, p2 = \
612 patch.extract(ui, hunk)
612 patch.extract(ui, hunk)
613
613
614 update = not opts.get('bypass')
614 update = not opts.get('bypass')
615 strip = opts["strip"]
615 strip = opts["strip"]
616 sim = float(opts.get('similarity') or 0)
616 sim = float(opts.get('similarity') or 0)
617 if not tmpname:
617 if not tmpname:
618 return (None, None, False)
618 return (None, None, False)
619 msg = _('applied to working directory')
619 msg = _('applied to working directory')
620
620
621 rejects = False
621 rejects = False
622
622
623 try:
623 try:
624 cmdline_message = logmessage(ui, opts)
624 cmdline_message = logmessage(ui, opts)
625 if cmdline_message:
625 if cmdline_message:
626 # pickup the cmdline msg
626 # pickup the cmdline msg
627 message = cmdline_message
627 message = cmdline_message
628 elif message:
628 elif message:
629 # pickup the patch msg
629 # pickup the patch msg
630 message = message.strip()
630 message = message.strip()
631 else:
631 else:
632 # launch the editor
632 # launch the editor
633 message = None
633 message = None
634 ui.debug('message:\n%s\n' % message)
634 ui.debug('message:\n%s\n' % message)
635
635
636 if len(parents) == 1:
636 if len(parents) == 1:
637 parents.append(repo[nullid])
637 parents.append(repo[nullid])
638 if opts.get('exact'):
638 if opts.get('exact'):
639 if not nodeid or not p1:
639 if not nodeid or not p1:
640 raise util.Abort(_('not a Mercurial patch'))
640 raise util.Abort(_('not a Mercurial patch'))
641 p1 = repo[p1]
641 p1 = repo[p1]
642 p2 = repo[p2 or nullid]
642 p2 = repo[p2 or nullid]
643 elif p2:
643 elif p2:
644 try:
644 try:
645 p1 = repo[p1]
645 p1 = repo[p1]
646 p2 = repo[p2]
646 p2 = repo[p2]
647 # Without any options, consider p2 only if the
647 # Without any options, consider p2 only if the
648 # patch is being applied on top of the recorded
648 # patch is being applied on top of the recorded
649 # first parent.
649 # first parent.
650 if p1 != parents[0]:
650 if p1 != parents[0]:
651 p1 = parents[0]
651 p1 = parents[0]
652 p2 = repo[nullid]
652 p2 = repo[nullid]
653 except error.RepoError:
653 except error.RepoError:
654 p1, p2 = parents
654 p1, p2 = parents
655 if p2.node() == nullid:
655 if p2.node() == nullid:
656 ui.warn(_("warning: import the patch as a normal revision\n"
656 ui.warn(_("warning: import the patch as a normal revision\n"
657 "(use --exact to import the patch as a merge)\n"))
657 "(use --exact to import the patch as a merge)\n"))
658 else:
658 else:
659 p1, p2 = parents
659 p1, p2 = parents
660
660
661 n = None
661 n = None
662 if update:
662 if update:
663 repo.dirstate.beginparentchange()
663 repo.dirstate.beginparentchange()
664 if p1 != parents[0]:
664 if p1 != parents[0]:
665 updatefunc(repo, p1.node())
665 updatefunc(repo, p1.node())
666 if p2 != parents[1]:
666 if p2 != parents[1]:
667 repo.setparents(p1.node(), p2.node())
667 repo.setparents(p1.node(), p2.node())
668
668
669 if opts.get('exact') or opts.get('import_branch'):
669 if opts.get('exact') or opts.get('import_branch'):
670 repo.dirstate.setbranch(branch or 'default')
670 repo.dirstate.setbranch(branch or 'default')
671
671
672 partial = opts.get('partial', False)
672 partial = opts.get('partial', False)
673 files = set()
673 files = set()
674 try:
674 try:
675 patch.patch(ui, repo, tmpname, strip=strip, files=files,
675 patch.patch(ui, repo, tmpname, strip=strip, files=files,
676 eolmode=None, similarity=sim / 100.0)
676 eolmode=None, similarity=sim / 100.0)
677 except patch.PatchError, e:
677 except patch.PatchError, e:
678 if not partial:
678 if not partial:
679 raise util.Abort(str(e))
679 raise util.Abort(str(e))
680 if partial:
680 if partial:
681 rejects = True
681 rejects = True
682
682
683 files = list(files)
683 files = list(files)
684 if opts.get('no_commit'):
684 if opts.get('no_commit'):
685 if message:
685 if message:
686 msgs.append(message)
686 msgs.append(message)
687 else:
687 else:
688 if opts.get('exact') or p2:
688 if opts.get('exact') or p2:
689 # If you got here, you either use --force and know what
689 # If you got here, you either use --force and know what
690 # you are doing or used --exact or a merge patch while
690 # you are doing or used --exact or a merge patch while
691 # being updated to its first parent.
691 # being updated to its first parent.
692 m = None
692 m = None
693 else:
693 else:
694 m = scmutil.matchfiles(repo, files or [])
694 m = scmutil.matchfiles(repo, files or [])
695 editform = mergeeditform(repo[None], 'import.normal')
695 editform = mergeeditform(repo[None], 'import.normal')
696 if opts.get('exact'):
696 if opts.get('exact'):
697 editor = None
697 editor = None
698 else:
698 else:
699 editor = getcommiteditor(editform=editform, **opts)
699 editor = getcommiteditor(editform=editform, **opts)
700 n = repo.commit(message, opts.get('user') or user,
700 n = repo.commit(message, opts.get('user') or user,
701 opts.get('date') or date, match=m,
701 opts.get('date') or date, match=m,
702 editor=editor, force=partial)
702 editor=editor, force=partial)
703 repo.dirstate.endparentchange()
703 repo.dirstate.endparentchange()
704 else:
704 else:
705 if opts.get('exact') or opts.get('import_branch'):
705 if opts.get('exact') or opts.get('import_branch'):
706 branch = branch or 'default'
706 branch = branch or 'default'
707 else:
707 else:
708 branch = p1.branch()
708 branch = p1.branch()
709 store = patch.filestore()
709 store = patch.filestore()
710 try:
710 try:
711 files = set()
711 files = set()
712 try:
712 try:
713 patch.patchrepo(ui, repo, p1, store, tmpname, strip,
713 patch.patchrepo(ui, repo, p1, store, tmpname, strip,
714 files, eolmode=None)
714 files, eolmode=None)
715 except patch.PatchError, e:
715 except patch.PatchError, e:
716 raise util.Abort(str(e))
716 raise util.Abort(str(e))
717 if opts.get('exact'):
717 if opts.get('exact'):
718 editor = None
718 editor = None
719 else:
719 else:
720 editor = getcommiteditor(editform='import.bypass')
720 editor = getcommiteditor(editform='import.bypass')
721 memctx = context.makememctx(repo, (p1.node(), p2.node()),
721 memctx = context.makememctx(repo, (p1.node(), p2.node()),
722 message,
722 message,
723 opts.get('user') or user,
723 opts.get('user') or user,
724 opts.get('date') or date,
724 opts.get('date') or date,
725 branch, files, store,
725 branch, files, store,
726 editor=editor)
726 editor=editor)
727 n = memctx.commit()
727 n = memctx.commit()
728 finally:
728 finally:
729 store.close()
729 store.close()
730 if opts.get('exact') and opts.get('no_commit'):
730 if opts.get('exact') and opts.get('no_commit'):
731 # --exact with --no-commit is still useful in that it does merge
731 # --exact with --no-commit is still useful in that it does merge
732 # and branch bits
732 # and branch bits
733 ui.warn(_("warning: can't check exact import with --no-commit\n"))
733 ui.warn(_("warning: can't check exact import with --no-commit\n"))
734 elif opts.get('exact') and hex(n) != nodeid:
734 elif opts.get('exact') and hex(n) != nodeid:
735 raise util.Abort(_('patch is damaged or loses information'))
735 raise util.Abort(_('patch is damaged or loses information'))
736 if n:
736 if n:
737 # i18n: refers to a short changeset id
737 # i18n: refers to a short changeset id
738 msg = _('created %s') % short(n)
738 msg = _('created %s') % short(n)
739 return (msg, n, rejects)
739 return (msg, n, rejects)
740 finally:
740 finally:
741 os.unlink(tmpname)
741 os.unlink(tmpname)
742
742
743 def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False,
743 def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False,
744 opts=None):
744 opts=None):
745 '''export changesets as hg patches.'''
745 '''export changesets as hg patches.'''
746
746
747 total = len(revs)
747 total = len(revs)
748 revwidth = max([len(str(rev)) for rev in revs])
748 revwidth = max([len(str(rev)) for rev in revs])
749 filemode = {}
749 filemode = {}
750
750
751 def single(rev, seqno, fp):
751 def single(rev, seqno, fp):
752 ctx = repo[rev]
752 ctx = repo[rev]
753 node = ctx.node()
753 node = ctx.node()
754 parents = [p.node() for p in ctx.parents() if p]
754 parents = [p.node() for p in ctx.parents() if p]
755 branch = ctx.branch()
755 branch = ctx.branch()
756 if switch_parent:
756 if switch_parent:
757 parents.reverse()
757 parents.reverse()
758 prev = (parents and parents[0]) or nullid
758 prev = (parents and parents[0]) or nullid
759
759
760 shouldclose = False
760 shouldclose = False
761 if not fp and len(template) > 0:
761 if not fp and len(template) > 0:
762 desc_lines = ctx.description().rstrip().split('\n')
762 desc_lines = ctx.description().rstrip().split('\n')
763 desc = desc_lines[0] #Commit always has a first line.
763 desc = desc_lines[0] #Commit always has a first line.
764 fp = makefileobj(repo, template, node, desc=desc, total=total,
764 fp = makefileobj(repo, template, node, desc=desc, total=total,
765 seqno=seqno, revwidth=revwidth, mode='wb',
765 seqno=seqno, revwidth=revwidth, mode='wb',
766 modemap=filemode)
766 modemap=filemode)
767 if fp != template:
767 if fp != template:
768 shouldclose = True
768 shouldclose = True
769 if fp and fp != sys.stdout and util.safehasattr(fp, 'name'):
769 if fp and fp != sys.stdout and util.safehasattr(fp, 'name'):
770 repo.ui.note("%s\n" % fp.name)
770 repo.ui.note("%s\n" % fp.name)
771
771
772 if not fp:
772 if not fp:
773 write = repo.ui.write
773 write = repo.ui.write
774 else:
774 else:
775 def write(s, **kw):
775 def write(s, **kw):
776 fp.write(s)
776 fp.write(s)
777
777
778
778
779 write("# HG changeset patch\n")
779 write("# HG changeset patch\n")
780 write("# User %s\n" % ctx.user())
780 write("# User %s\n" % ctx.user())
781 write("# Date %d %d\n" % ctx.date())
781 write("# Date %d %d\n" % ctx.date())
782 write("# %s\n" % util.datestr(ctx.date()))
782 write("# %s\n" % util.datestr(ctx.date()))
783 if branch and branch != 'default':
783 if branch and branch != 'default':
784 write("# Branch %s\n" % branch)
784 write("# Branch %s\n" % branch)
785 write("# Node ID %s\n" % hex(node))
785 write("# Node ID %s\n" % hex(node))
786 write("# Parent %s\n" % hex(prev))
786 write("# Parent %s\n" % hex(prev))
787 if len(parents) > 1:
787 if len(parents) > 1:
788 write("# Parent %s\n" % hex(parents[1]))
788 write("# Parent %s\n" % hex(parents[1]))
789 write(ctx.description().rstrip())
789 write(ctx.description().rstrip())
790 write("\n\n")
790 write("\n\n")
791
791
792 for chunk, label in patch.diffui(repo, prev, node, opts=opts):
792 for chunk, label in patch.diffui(repo, prev, node, opts=opts):
793 write(chunk, label=label)
793 write(chunk, label=label)
794
794
795 if shouldclose:
795 if shouldclose:
796 fp.close()
796 fp.close()
797
797
798 for seqno, rev in enumerate(revs):
798 for seqno, rev in enumerate(revs):
799 single(rev, seqno + 1, fp)
799 single(rev, seqno + 1, fp)
800
800
801 def diffordiffstat(ui, repo, diffopts, node1, node2, match,
801 def diffordiffstat(ui, repo, diffopts, node1, node2, match,
802 changes=None, stat=False, fp=None, prefix='',
802 changes=None, stat=False, fp=None, prefix='',
803 listsubrepos=False):
803 listsubrepos=False):
804 '''show diff or diffstat.'''
804 '''show diff or diffstat.'''
805 if fp is None:
805 if fp is None:
806 write = ui.write
806 write = ui.write
807 else:
807 else:
808 def write(s, **kw):
808 def write(s, **kw):
809 fp.write(s)
809 fp.write(s)
810
810
811 if stat:
811 if stat:
812 diffopts = diffopts.copy(context=0)
812 diffopts = diffopts.copy(context=0)
813 width = 80
813 width = 80
814 if not ui.plain():
814 if not ui.plain():
815 width = ui.termwidth()
815 width = ui.termwidth()
816 chunks = patch.diff(repo, node1, node2, match, changes, diffopts,
816 chunks = patch.diff(repo, node1, node2, match, changes, diffopts,
817 prefix=prefix)
817 prefix=prefix)
818 for chunk, label in patch.diffstatui(util.iterlines(chunks),
818 for chunk, label in patch.diffstatui(util.iterlines(chunks),
819 width=width,
819 width=width,
820 git=diffopts.git):
820 git=diffopts.git):
821 write(chunk, label=label)
821 write(chunk, label=label)
822 else:
822 else:
823 for chunk, label in patch.diffui(repo, node1, node2, match,
823 for chunk, label in patch.diffui(repo, node1, node2, match,
824 changes, diffopts, prefix=prefix):
824 changes, diffopts, prefix=prefix):
825 write(chunk, label=label)
825 write(chunk, label=label)
826
826
827 if listsubrepos:
827 if listsubrepos:
828 ctx1 = repo[node1]
828 ctx1 = repo[node1]
829 ctx2 = repo[node2]
829 ctx2 = repo[node2]
830 for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
830 for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
831 tempnode2 = node2
831 tempnode2 = node2
832 try:
832 try:
833 if node2 is not None:
833 if node2 is not None:
834 tempnode2 = ctx2.substate[subpath][1]
834 tempnode2 = ctx2.substate[subpath][1]
835 except KeyError:
835 except KeyError:
836 # A subrepo that existed in node1 was deleted between node1 and
836 # A subrepo that existed in node1 was deleted between node1 and
837 # node2 (inclusive). Thus, ctx2's substate won't contain that
837 # node2 (inclusive). Thus, ctx2's substate won't contain that
838 # subpath. The best we can do is to ignore it.
838 # subpath. The best we can do is to ignore it.
839 tempnode2 = None
839 tempnode2 = None
840 submatch = matchmod.narrowmatcher(subpath, match)
840 submatch = matchmod.narrowmatcher(subpath, match)
841 sub.diff(ui, diffopts, tempnode2, submatch, changes=changes,
841 sub.diff(ui, diffopts, tempnode2, submatch, changes=changes,
842 stat=stat, fp=fp, prefix=prefix)
842 stat=stat, fp=fp, prefix=prefix)
843
843
844 class changeset_printer(object):
844 class changeset_printer(object):
845 '''show changeset information when templating not requested.'''
845 '''show changeset information when templating not requested.'''
846
846
847 def __init__(self, ui, repo, matchfn, diffopts, buffered):
847 def __init__(self, ui, repo, matchfn, diffopts, buffered):
848 self.ui = ui
848 self.ui = ui
849 self.repo = repo
849 self.repo = repo
850 self.buffered = buffered
850 self.buffered = buffered
851 self.matchfn = matchfn
851 self.matchfn = matchfn
852 self.diffopts = diffopts
852 self.diffopts = diffopts
853 self.header = {}
853 self.header = {}
854 self.hunk = {}
854 self.hunk = {}
855 self.lastheader = None
855 self.lastheader = None
856 self.footer = None
856 self.footer = None
857
857
858 def flush(self, rev):
858 def flush(self, rev):
859 if rev in self.header:
859 if rev in self.header:
860 h = self.header[rev]
860 h = self.header[rev]
861 if h != self.lastheader:
861 if h != self.lastheader:
862 self.lastheader = h
862 self.lastheader = h
863 self.ui.write(h)
863 self.ui.write(h)
864 del self.header[rev]
864 del self.header[rev]
865 if rev in self.hunk:
865 if rev in self.hunk:
866 self.ui.write(self.hunk[rev])
866 self.ui.write(self.hunk[rev])
867 del self.hunk[rev]
867 del self.hunk[rev]
868 return 1
868 return 1
869 return 0
869 return 0
870
870
871 def close(self):
871 def close(self):
872 if self.footer:
872 if self.footer:
873 self.ui.write(self.footer)
873 self.ui.write(self.footer)
874
874
875 def show(self, ctx, copies=None, matchfn=None, **props):
875 def show(self, ctx, copies=None, matchfn=None, **props):
876 if self.buffered:
876 if self.buffered:
877 self.ui.pushbuffer()
877 self.ui.pushbuffer()
878 self._show(ctx, copies, matchfn, props)
878 self._show(ctx, copies, matchfn, props)
879 self.hunk[ctx.rev()] = self.ui.popbuffer(labeled=True)
879 self.hunk[ctx.rev()] = self.ui.popbuffer(labeled=True)
880 else:
880 else:
881 self._show(ctx, copies, matchfn, props)
881 self._show(ctx, copies, matchfn, props)
882
882
883 def _show(self, ctx, copies, matchfn, props):
883 def _show(self, ctx, copies, matchfn, props):
884 '''show a single changeset or file revision'''
884 '''show a single changeset or file revision'''
885 changenode = ctx.node()
885 changenode = ctx.node()
886 rev = ctx.rev()
886 rev = ctx.rev()
887
887
888 if self.ui.quiet:
888 if self.ui.quiet:
889 self.ui.write("%d:%s\n" % (rev, short(changenode)),
889 self.ui.write("%d:%s\n" % (rev, short(changenode)),
890 label='log.node')
890 label='log.node')
891 return
891 return
892
892
893 log = self.repo.changelog
893 log = self.repo.changelog
894 date = util.datestr(ctx.date())
894 date = util.datestr(ctx.date())
895
895
896 hexfunc = self.ui.debugflag and hex or short
896 hexfunc = self.ui.debugflag and hex or short
897
897
898 parents = [(p, hexfunc(log.node(p)))
898 parents = [(p, hexfunc(log.node(p)))
899 for p in self._meaningful_parentrevs(log, rev)]
899 for p in self._meaningful_parentrevs(log, rev)]
900
900
901 # i18n: column positioning for "hg log"
901 # i18n: column positioning for "hg log"
902 self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)),
902 self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)),
903 label='log.changeset changeset.%s' % ctx.phasestr())
903 label='log.changeset changeset.%s' % ctx.phasestr())
904
904
905 # branches are shown first before any other names due to backwards
905 # branches are shown first before any other names due to backwards
906 # compatibility
906 # compatibility
907 branch = ctx.branch()
907 branch = ctx.branch()
908 # don't show the default branch name
908 # don't show the default branch name
909 if branch != 'default':
909 if branch != 'default':
910 # i18n: column positioning for "hg log"
910 # i18n: column positioning for "hg log"
911 self.ui.write(_("branch: %s\n") % branch,
911 self.ui.write(_("branch: %s\n") % branch,
912 label='log.branch')
912 label='log.branch')
913
913
914 for name, ns in self.repo.names.iteritems():
914 for name, ns in self.repo.names.iteritems():
915 # branches has special logic already handled above, so here we just
915 # branches has special logic already handled above, so here we just
916 # skip it
916 # skip it
917 if name == 'branches':
917 if name == 'branches':
918 continue
918 continue
919 # we will use the templatename as the color name since those two
919 # we will use the templatename as the color name since those two
920 # should be the same
920 # should be the same
921 for name in ns.names(self.repo, changenode):
921 for name in ns.names(self.repo, changenode):
922 # i18n: column positioning for "hg log"
922 # i18n: column positioning for "hg log"
923 tname = _(("%s:" % ns.templatename).ljust(13) + "%s\n") % name
923 name = _(("%s:" % ns.logname).ljust(13) + "%s\n") % name
924 self.ui.write("%s" % tname, label='log.%s' % ns.templatename)
924 self.ui.write("%s" % name, label='log.%s' % ns.colorname)
925 if self.ui.debugflag:
925 if self.ui.debugflag:
926 # i18n: column positioning for "hg log"
926 # i18n: column positioning for "hg log"
927 self.ui.write(_("phase: %s\n") % _(ctx.phasestr()),
927 self.ui.write(_("phase: %s\n") % _(ctx.phasestr()),
928 label='log.phase')
928 label='log.phase')
929 for parent in parents:
929 for parent in parents:
930 label = 'log.parent changeset.%s' % self.repo[parent[0]].phasestr()
930 label = 'log.parent changeset.%s' % self.repo[parent[0]].phasestr()
931 # i18n: column positioning for "hg log"
931 # i18n: column positioning for "hg log"
932 self.ui.write(_("parent: %d:%s\n") % parent,
932 self.ui.write(_("parent: %d:%s\n") % parent,
933 label=label)
933 label=label)
934
934
935 if self.ui.debugflag:
935 if self.ui.debugflag:
936 mnode = ctx.manifestnode()
936 mnode = ctx.manifestnode()
937 # i18n: column positioning for "hg log"
937 # i18n: column positioning for "hg log"
938 self.ui.write(_("manifest: %d:%s\n") %
938 self.ui.write(_("manifest: %d:%s\n") %
939 (self.repo.manifest.rev(mnode), hex(mnode)),
939 (self.repo.manifest.rev(mnode), hex(mnode)),
940 label='ui.debug log.manifest')
940 label='ui.debug log.manifest')
941 # i18n: column positioning for "hg log"
941 # i18n: column positioning for "hg log"
942 self.ui.write(_("user: %s\n") % ctx.user(),
942 self.ui.write(_("user: %s\n") % ctx.user(),
943 label='log.user')
943 label='log.user')
944 # i18n: column positioning for "hg log"
944 # i18n: column positioning for "hg log"
945 self.ui.write(_("date: %s\n") % date,
945 self.ui.write(_("date: %s\n") % date,
946 label='log.date')
946 label='log.date')
947
947
948 if self.ui.debugflag:
948 if self.ui.debugflag:
949 files = self.repo.status(log.parents(changenode)[0], changenode)[:3]
949 files = self.repo.status(log.parents(changenode)[0], changenode)[:3]
950 for key, value in zip([# i18n: column positioning for "hg log"
950 for key, value in zip([# i18n: column positioning for "hg log"
951 _("files:"),
951 _("files:"),
952 # i18n: column positioning for "hg log"
952 # i18n: column positioning for "hg log"
953 _("files+:"),
953 _("files+:"),
954 # i18n: column positioning for "hg log"
954 # i18n: column positioning for "hg log"
955 _("files-:")], files):
955 _("files-:")], files):
956 if value:
956 if value:
957 self.ui.write("%-12s %s\n" % (key, " ".join(value)),
957 self.ui.write("%-12s %s\n" % (key, " ".join(value)),
958 label='ui.debug log.files')
958 label='ui.debug log.files')
959 elif ctx.files() and self.ui.verbose:
959 elif ctx.files() and self.ui.verbose:
960 # i18n: column positioning for "hg log"
960 # i18n: column positioning for "hg log"
961 self.ui.write(_("files: %s\n") % " ".join(ctx.files()),
961 self.ui.write(_("files: %s\n") % " ".join(ctx.files()),
962 label='ui.note log.files')
962 label='ui.note log.files')
963 if copies and self.ui.verbose:
963 if copies and self.ui.verbose:
964 copies = ['%s (%s)' % c for c in copies]
964 copies = ['%s (%s)' % c for c in copies]
965 # i18n: column positioning for "hg log"
965 # i18n: column positioning for "hg log"
966 self.ui.write(_("copies: %s\n") % ' '.join(copies),
966 self.ui.write(_("copies: %s\n") % ' '.join(copies),
967 label='ui.note log.copies')
967 label='ui.note log.copies')
968
968
969 extra = ctx.extra()
969 extra = ctx.extra()
970 if extra and self.ui.debugflag:
970 if extra and self.ui.debugflag:
971 for key, value in sorted(extra.items()):
971 for key, value in sorted(extra.items()):
972 # i18n: column positioning for "hg log"
972 # i18n: column positioning for "hg log"
973 self.ui.write(_("extra: %s=%s\n")
973 self.ui.write(_("extra: %s=%s\n")
974 % (key, value.encode('string_escape')),
974 % (key, value.encode('string_escape')),
975 label='ui.debug log.extra')
975 label='ui.debug log.extra')
976
976
977 description = ctx.description().strip()
977 description = ctx.description().strip()
978 if description:
978 if description:
979 if self.ui.verbose:
979 if self.ui.verbose:
980 self.ui.write(_("description:\n"),
980 self.ui.write(_("description:\n"),
981 label='ui.note log.description')
981 label='ui.note log.description')
982 self.ui.write(description,
982 self.ui.write(description,
983 label='ui.note log.description')
983 label='ui.note log.description')
984 self.ui.write("\n\n")
984 self.ui.write("\n\n")
985 else:
985 else:
986 # i18n: column positioning for "hg log"
986 # i18n: column positioning for "hg log"
987 self.ui.write(_("summary: %s\n") %
987 self.ui.write(_("summary: %s\n") %
988 description.splitlines()[0],
988 description.splitlines()[0],
989 label='log.summary')
989 label='log.summary')
990 self.ui.write("\n")
990 self.ui.write("\n")
991
991
992 self.showpatch(changenode, matchfn)
992 self.showpatch(changenode, matchfn)
993
993
994 def showpatch(self, node, matchfn):
994 def showpatch(self, node, matchfn):
995 if not matchfn:
995 if not matchfn:
996 matchfn = self.matchfn
996 matchfn = self.matchfn
997 if matchfn:
997 if matchfn:
998 stat = self.diffopts.get('stat')
998 stat = self.diffopts.get('stat')
999 diff = self.diffopts.get('patch')
999 diff = self.diffopts.get('patch')
1000 diffopts = patch.diffallopts(self.ui, self.diffopts)
1000 diffopts = patch.diffallopts(self.ui, self.diffopts)
1001 prev = self.repo.changelog.parents(node)[0]
1001 prev = self.repo.changelog.parents(node)[0]
1002 if stat:
1002 if stat:
1003 diffordiffstat(self.ui, self.repo, diffopts, prev, node,
1003 diffordiffstat(self.ui, self.repo, diffopts, prev, node,
1004 match=matchfn, stat=True)
1004 match=matchfn, stat=True)
1005 if diff:
1005 if diff:
1006 if stat:
1006 if stat:
1007 self.ui.write("\n")
1007 self.ui.write("\n")
1008 diffordiffstat(self.ui, self.repo, diffopts, prev, node,
1008 diffordiffstat(self.ui, self.repo, diffopts, prev, node,
1009 match=matchfn, stat=False)
1009 match=matchfn, stat=False)
1010 self.ui.write("\n")
1010 self.ui.write("\n")
1011
1011
1012 def _meaningful_parentrevs(self, log, rev):
1012 def _meaningful_parentrevs(self, log, rev):
1013 """Return list of meaningful (or all if debug) parentrevs for rev.
1013 """Return list of meaningful (or all if debug) parentrevs for rev.
1014
1014
1015 For merges (two non-nullrev revisions) both parents are meaningful.
1015 For merges (two non-nullrev revisions) both parents are meaningful.
1016 Otherwise the first parent revision is considered meaningful if it
1016 Otherwise the first parent revision is considered meaningful if it
1017 is not the preceding revision.
1017 is not the preceding revision.
1018 """
1018 """
1019 parents = log.parentrevs(rev)
1019 parents = log.parentrevs(rev)
1020 if not self.ui.debugflag and parents[1] == nullrev:
1020 if not self.ui.debugflag and parents[1] == nullrev:
1021 if parents[0] >= rev - 1:
1021 if parents[0] >= rev - 1:
1022 parents = []
1022 parents = []
1023 else:
1023 else:
1024 parents = [parents[0]]
1024 parents = [parents[0]]
1025 return parents
1025 return parents
1026
1026
1027 class jsonchangeset(changeset_printer):
1027 class jsonchangeset(changeset_printer):
1028 '''format changeset information.'''
1028 '''format changeset information.'''
1029
1029
1030 def __init__(self, ui, repo, matchfn, diffopts, buffered):
1030 def __init__(self, ui, repo, matchfn, diffopts, buffered):
1031 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
1031 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
1032 self.cache = {}
1032 self.cache = {}
1033 self._first = True
1033 self._first = True
1034
1034
1035 def close(self):
1035 def close(self):
1036 if not self._first:
1036 if not self._first:
1037 self.ui.write("\n]\n")
1037 self.ui.write("\n]\n")
1038 else:
1038 else:
1039 self.ui.write("[]\n")
1039 self.ui.write("[]\n")
1040
1040
1041 def _show(self, ctx, copies, matchfn, props):
1041 def _show(self, ctx, copies, matchfn, props):
1042 '''show a single changeset or file revision'''
1042 '''show a single changeset or file revision'''
1043 hexnode = hex(ctx.node())
1043 hexnode = hex(ctx.node())
1044 rev = ctx.rev()
1044 rev = ctx.rev()
1045 j = encoding.jsonescape
1045 j = encoding.jsonescape
1046
1046
1047 if self._first:
1047 if self._first:
1048 self.ui.write("[\n {")
1048 self.ui.write("[\n {")
1049 self._first = False
1049 self._first = False
1050 else:
1050 else:
1051 self.ui.write(",\n {")
1051 self.ui.write(",\n {")
1052
1052
1053 if self.ui.quiet:
1053 if self.ui.quiet:
1054 self.ui.write('\n "rev": %d' % rev)
1054 self.ui.write('\n "rev": %d' % rev)
1055 self.ui.write(',\n "node": "%s"' % hexnode)
1055 self.ui.write(',\n "node": "%s"' % hexnode)
1056 self.ui.write('\n }')
1056 self.ui.write('\n }')
1057 return
1057 return
1058
1058
1059 self.ui.write('\n "rev": %d' % rev)
1059 self.ui.write('\n "rev": %d' % rev)
1060 self.ui.write(',\n "node": "%s"' % hexnode)
1060 self.ui.write(',\n "node": "%s"' % hexnode)
1061 self.ui.write(',\n "branch": "%s"' % j(ctx.branch()))
1061 self.ui.write(',\n "branch": "%s"' % j(ctx.branch()))
1062 self.ui.write(',\n "phase": "%s"' % ctx.phasestr())
1062 self.ui.write(',\n "phase": "%s"' % ctx.phasestr())
1063 self.ui.write(',\n "user": "%s"' % j(ctx.user()))
1063 self.ui.write(',\n "user": "%s"' % j(ctx.user()))
1064 self.ui.write(',\n "date": [%d, %d]' % ctx.date())
1064 self.ui.write(',\n "date": [%d, %d]' % ctx.date())
1065 self.ui.write(',\n "desc": "%s"' % j(ctx.description()))
1065 self.ui.write(',\n "desc": "%s"' % j(ctx.description()))
1066
1066
1067 self.ui.write(',\n "bookmarks": [%s]' %
1067 self.ui.write(',\n "bookmarks": [%s]' %
1068 ", ".join('"%s"' % j(b) for b in ctx.bookmarks()))
1068 ", ".join('"%s"' % j(b) for b in ctx.bookmarks()))
1069 self.ui.write(',\n "tags": [%s]' %
1069 self.ui.write(',\n "tags": [%s]' %
1070 ", ".join('"%s"' % j(t) for t in ctx.tags()))
1070 ", ".join('"%s"' % j(t) for t in ctx.tags()))
1071 self.ui.write(',\n "parents": [%s]' %
1071 self.ui.write(',\n "parents": [%s]' %
1072 ", ".join('"%s"' % c.hex() for c in ctx.parents()))
1072 ", ".join('"%s"' % c.hex() for c in ctx.parents()))
1073
1073
1074 if self.ui.debugflag:
1074 if self.ui.debugflag:
1075 self.ui.write(',\n "manifest": "%s"' % hex(ctx.manifestnode()))
1075 self.ui.write(',\n "manifest": "%s"' % hex(ctx.manifestnode()))
1076
1076
1077 self.ui.write(',\n "extra": {%s}' %
1077 self.ui.write(',\n "extra": {%s}' %
1078 ", ".join('"%s": "%s"' % (j(k), j(v))
1078 ", ".join('"%s": "%s"' % (j(k), j(v))
1079 for k, v in ctx.extra().items()))
1079 for k, v in ctx.extra().items()))
1080
1080
1081 files = ctx.p1().status(ctx)
1081 files = ctx.p1().status(ctx)
1082 self.ui.write(',\n "modified": [%s]' %
1082 self.ui.write(',\n "modified": [%s]' %
1083 ", ".join('"%s"' % j(f) for f in files[0]))
1083 ", ".join('"%s"' % j(f) for f in files[0]))
1084 self.ui.write(',\n "added": [%s]' %
1084 self.ui.write(',\n "added": [%s]' %
1085 ", ".join('"%s"' % j(f) for f in files[1]))
1085 ", ".join('"%s"' % j(f) for f in files[1]))
1086 self.ui.write(',\n "removed": [%s]' %
1086 self.ui.write(',\n "removed": [%s]' %
1087 ", ".join('"%s"' % j(f) for f in files[2]))
1087 ", ".join('"%s"' % j(f) for f in files[2]))
1088
1088
1089 elif self.ui.verbose:
1089 elif self.ui.verbose:
1090 self.ui.write(',\n "files": [%s]' %
1090 self.ui.write(',\n "files": [%s]' %
1091 ", ".join('"%s"' % j(f) for f in ctx.files()))
1091 ", ".join('"%s"' % j(f) for f in ctx.files()))
1092
1092
1093 if copies:
1093 if copies:
1094 self.ui.write(',\n "copies": {%s}' %
1094 self.ui.write(',\n "copies": {%s}' %
1095 ", ".join('"%s": %s' % (j(k), j(copies[k]))
1095 ", ".join('"%s": %s' % (j(k), j(copies[k]))
1096 for k in copies))
1096 for k in copies))
1097
1097
1098 matchfn = self.matchfn
1098 matchfn = self.matchfn
1099 if matchfn:
1099 if matchfn:
1100 stat = self.diffopts.get('stat')
1100 stat = self.diffopts.get('stat')
1101 diff = self.diffopts.get('patch')
1101 diff = self.diffopts.get('patch')
1102 diffopts = patch.difffeatureopts(self.ui, self.diffopts, git=True)
1102 diffopts = patch.difffeatureopts(self.ui, self.diffopts, git=True)
1103 node, prev = ctx.node(), ctx.p1().node()
1103 node, prev = ctx.node(), ctx.p1().node()
1104 if stat:
1104 if stat:
1105 self.ui.pushbuffer()
1105 self.ui.pushbuffer()
1106 diffordiffstat(self.ui, self.repo, diffopts, prev, node,
1106 diffordiffstat(self.ui, self.repo, diffopts, prev, node,
1107 match=matchfn, stat=True)
1107 match=matchfn, stat=True)
1108 self.ui.write(',\n "diffstat": "%s"' % j(self.ui.popbuffer()))
1108 self.ui.write(',\n "diffstat": "%s"' % j(self.ui.popbuffer()))
1109 if diff:
1109 if diff:
1110 self.ui.pushbuffer()
1110 self.ui.pushbuffer()
1111 diffordiffstat(self.ui, self.repo, diffopts, prev, node,
1111 diffordiffstat(self.ui, self.repo, diffopts, prev, node,
1112 match=matchfn, stat=False)
1112 match=matchfn, stat=False)
1113 self.ui.write(',\n "diff": "%s"' % j(self.ui.popbuffer()))
1113 self.ui.write(',\n "diff": "%s"' % j(self.ui.popbuffer()))
1114
1114
1115 self.ui.write("\n }")
1115 self.ui.write("\n }")
1116
1116
1117 class changeset_templater(changeset_printer):
1117 class changeset_templater(changeset_printer):
1118 '''format changeset information.'''
1118 '''format changeset information.'''
1119
1119
1120 def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered):
1120 def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered):
1121 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
1121 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
1122 formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12])
1122 formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12])
1123 defaulttempl = {
1123 defaulttempl = {
1124 'parent': '{rev}:{node|formatnode} ',
1124 'parent': '{rev}:{node|formatnode} ',
1125 'manifest': '{rev}:{node|formatnode}',
1125 'manifest': '{rev}:{node|formatnode}',
1126 'file_copy': '{name} ({source})',
1126 'file_copy': '{name} ({source})',
1127 'extra': '{key}={value|stringescape}'
1127 'extra': '{key}={value|stringescape}'
1128 }
1128 }
1129 # filecopy is preserved for compatibility reasons
1129 # filecopy is preserved for compatibility reasons
1130 defaulttempl['filecopy'] = defaulttempl['file_copy']
1130 defaulttempl['filecopy'] = defaulttempl['file_copy']
1131 self.t = templater.templater(mapfile, {'formatnode': formatnode},
1131 self.t = templater.templater(mapfile, {'formatnode': formatnode},
1132 cache=defaulttempl)
1132 cache=defaulttempl)
1133 if tmpl:
1133 if tmpl:
1134 self.t.cache['changeset'] = tmpl
1134 self.t.cache['changeset'] = tmpl
1135
1135
1136 self.cache = {}
1136 self.cache = {}
1137
1137
1138 def _meaningful_parentrevs(self, ctx):
1138 def _meaningful_parentrevs(self, ctx):
1139 """Return list of meaningful (or all if debug) parentrevs for rev.
1139 """Return list of meaningful (or all if debug) parentrevs for rev.
1140 """
1140 """
1141 parents = ctx.parents()
1141 parents = ctx.parents()
1142 if len(parents) > 1:
1142 if len(parents) > 1:
1143 return parents
1143 return parents
1144 if self.ui.debugflag:
1144 if self.ui.debugflag:
1145 return [parents[0], self.repo['null']]
1145 return [parents[0], self.repo['null']]
1146 if parents[0].rev() >= ctx.rev() - 1:
1146 if parents[0].rev() >= ctx.rev() - 1:
1147 return []
1147 return []
1148 return parents
1148 return parents
1149
1149
1150 def _show(self, ctx, copies, matchfn, props):
1150 def _show(self, ctx, copies, matchfn, props):
1151 '''show a single changeset or file revision'''
1151 '''show a single changeset or file revision'''
1152
1152
1153 showlist = templatekw.showlist
1153 showlist = templatekw.showlist
1154
1154
1155 # showparents() behaviour depends on ui trace level which
1155 # showparents() behaviour depends on ui trace level which
1156 # causes unexpected behaviours at templating level and makes
1156 # causes unexpected behaviours at templating level and makes
1157 # it harder to extract it in a standalone function. Its
1157 # it harder to extract it in a standalone function. Its
1158 # behaviour cannot be changed so leave it here for now.
1158 # behaviour cannot be changed so leave it here for now.
1159 def showparents(**args):
1159 def showparents(**args):
1160 ctx = args['ctx']
1160 ctx = args['ctx']
1161 parents = [[('rev', p.rev()),
1161 parents = [[('rev', p.rev()),
1162 ('node', p.hex()),
1162 ('node', p.hex()),
1163 ('phase', p.phasestr())]
1163 ('phase', p.phasestr())]
1164 for p in self._meaningful_parentrevs(ctx)]
1164 for p in self._meaningful_parentrevs(ctx)]
1165 return showlist('parent', parents, **args)
1165 return showlist('parent', parents, **args)
1166
1166
1167 props = props.copy()
1167 props = props.copy()
1168 props.update(templatekw.keywords)
1168 props.update(templatekw.keywords)
1169 props['parents'] = showparents
1169 props['parents'] = showparents
1170 props['templ'] = self.t
1170 props['templ'] = self.t
1171 props['ctx'] = ctx
1171 props['ctx'] = ctx
1172 props['repo'] = self.repo
1172 props['repo'] = self.repo
1173 props['revcache'] = {'copies': copies}
1173 props['revcache'] = {'copies': copies}
1174 props['cache'] = self.cache
1174 props['cache'] = self.cache
1175
1175
1176 # find correct templates for current mode
1176 # find correct templates for current mode
1177
1177
1178 tmplmodes = [
1178 tmplmodes = [
1179 (True, None),
1179 (True, None),
1180 (self.ui.verbose, 'verbose'),
1180 (self.ui.verbose, 'verbose'),
1181 (self.ui.quiet, 'quiet'),
1181 (self.ui.quiet, 'quiet'),
1182 (self.ui.debugflag, 'debug'),
1182 (self.ui.debugflag, 'debug'),
1183 ]
1183 ]
1184
1184
1185 types = {'header': '', 'footer':'', 'changeset': 'changeset'}
1185 types = {'header': '', 'footer':'', 'changeset': 'changeset'}
1186 for mode, postfix in tmplmodes:
1186 for mode, postfix in tmplmodes:
1187 for type in types:
1187 for type in types:
1188 cur = postfix and ('%s_%s' % (type, postfix)) or type
1188 cur = postfix and ('%s_%s' % (type, postfix)) or type
1189 if mode and cur in self.t:
1189 if mode and cur in self.t:
1190 types[type] = cur
1190 types[type] = cur
1191
1191
1192 try:
1192 try:
1193
1193
1194 # write header
1194 # write header
1195 if types['header']:
1195 if types['header']:
1196 h = templater.stringify(self.t(types['header'], **props))
1196 h = templater.stringify(self.t(types['header'], **props))
1197 if self.buffered:
1197 if self.buffered:
1198 self.header[ctx.rev()] = h
1198 self.header[ctx.rev()] = h
1199 else:
1199 else:
1200 if self.lastheader != h:
1200 if self.lastheader != h:
1201 self.lastheader = h
1201 self.lastheader = h
1202 self.ui.write(h)
1202 self.ui.write(h)
1203
1203
1204 # write changeset metadata, then patch if requested
1204 # write changeset metadata, then patch if requested
1205 key = types['changeset']
1205 key = types['changeset']
1206 self.ui.write(templater.stringify(self.t(key, **props)))
1206 self.ui.write(templater.stringify(self.t(key, **props)))
1207 self.showpatch(ctx.node(), matchfn)
1207 self.showpatch(ctx.node(), matchfn)
1208
1208
1209 if types['footer']:
1209 if types['footer']:
1210 if not self.footer:
1210 if not self.footer:
1211 self.footer = templater.stringify(self.t(types['footer'],
1211 self.footer = templater.stringify(self.t(types['footer'],
1212 **props))
1212 **props))
1213
1213
1214 except KeyError, inst:
1214 except KeyError, inst:
1215 msg = _("%s: no key named '%s'")
1215 msg = _("%s: no key named '%s'")
1216 raise util.Abort(msg % (self.t.mapfile, inst.args[0]))
1216 raise util.Abort(msg % (self.t.mapfile, inst.args[0]))
1217 except SyntaxError, inst:
1217 except SyntaxError, inst:
1218 raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0]))
1218 raise util.Abort('%s: %s' % (self.t.mapfile, inst.args[0]))
1219
1219
1220 def gettemplate(ui, tmpl, style):
1220 def gettemplate(ui, tmpl, style):
1221 """
1221 """
1222 Find the template matching the given template spec or style.
1222 Find the template matching the given template spec or style.
1223 """
1223 """
1224
1224
1225 # ui settings
1225 # ui settings
1226 if not tmpl and not style: # template are stronger than style
1226 if not tmpl and not style: # template are stronger than style
1227 tmpl = ui.config('ui', 'logtemplate')
1227 tmpl = ui.config('ui', 'logtemplate')
1228 if tmpl:
1228 if tmpl:
1229 try:
1229 try:
1230 tmpl = templater.parsestring(tmpl)
1230 tmpl = templater.parsestring(tmpl)
1231 except SyntaxError:
1231 except SyntaxError:
1232 tmpl = templater.parsestring(tmpl, quoted=False)
1232 tmpl = templater.parsestring(tmpl, quoted=False)
1233 return tmpl, None
1233 return tmpl, None
1234 else:
1234 else:
1235 style = util.expandpath(ui.config('ui', 'style', ''))
1235 style = util.expandpath(ui.config('ui', 'style', ''))
1236
1236
1237 if not tmpl and style:
1237 if not tmpl and style:
1238 mapfile = style
1238 mapfile = style
1239 if not os.path.split(mapfile)[0]:
1239 if not os.path.split(mapfile)[0]:
1240 mapname = (templater.templatepath('map-cmdline.' + mapfile)
1240 mapname = (templater.templatepath('map-cmdline.' + mapfile)
1241 or templater.templatepath(mapfile))
1241 or templater.templatepath(mapfile))
1242 if mapname:
1242 if mapname:
1243 mapfile = mapname
1243 mapfile = mapname
1244 return None, mapfile
1244 return None, mapfile
1245
1245
1246 if not tmpl:
1246 if not tmpl:
1247 return None, None
1247 return None, None
1248
1248
1249 # looks like a literal template?
1249 # looks like a literal template?
1250 if '{' in tmpl:
1250 if '{' in tmpl:
1251 return tmpl, None
1251 return tmpl, None
1252
1252
1253 # perhaps a stock style?
1253 # perhaps a stock style?
1254 if not os.path.split(tmpl)[0]:
1254 if not os.path.split(tmpl)[0]:
1255 mapname = (templater.templatepath('map-cmdline.' + tmpl)
1255 mapname = (templater.templatepath('map-cmdline.' + tmpl)
1256 or templater.templatepath(tmpl))
1256 or templater.templatepath(tmpl))
1257 if mapname and os.path.isfile(mapname):
1257 if mapname and os.path.isfile(mapname):
1258 return None, mapname
1258 return None, mapname
1259
1259
1260 # perhaps it's a reference to [templates]
1260 # perhaps it's a reference to [templates]
1261 t = ui.config('templates', tmpl)
1261 t = ui.config('templates', tmpl)
1262 if t:
1262 if t:
1263 try:
1263 try:
1264 tmpl = templater.parsestring(t)
1264 tmpl = templater.parsestring(t)
1265 except SyntaxError:
1265 except SyntaxError:
1266 tmpl = templater.parsestring(t, quoted=False)
1266 tmpl = templater.parsestring(t, quoted=False)
1267 return tmpl, None
1267 return tmpl, None
1268
1268
1269 if tmpl == 'list':
1269 if tmpl == 'list':
1270 ui.write(_("available styles: %s\n") % templater.stylelist())
1270 ui.write(_("available styles: %s\n") % templater.stylelist())
1271 raise util.Abort(_("specify a template"))
1271 raise util.Abort(_("specify a template"))
1272
1272
1273 # perhaps it's a path to a map or a template
1273 # perhaps it's a path to a map or a template
1274 if ('/' in tmpl or '\\' in tmpl) and os.path.isfile(tmpl):
1274 if ('/' in tmpl or '\\' in tmpl) and os.path.isfile(tmpl):
1275 # is it a mapfile for a style?
1275 # is it a mapfile for a style?
1276 if os.path.basename(tmpl).startswith("map-"):
1276 if os.path.basename(tmpl).startswith("map-"):
1277 return None, os.path.realpath(tmpl)
1277 return None, os.path.realpath(tmpl)
1278 tmpl = open(tmpl).read()
1278 tmpl = open(tmpl).read()
1279 return tmpl, None
1279 return tmpl, None
1280
1280
1281 # constant string?
1281 # constant string?
1282 return tmpl, None
1282 return tmpl, None
1283
1283
1284 def show_changeset(ui, repo, opts, buffered=False):
1284 def show_changeset(ui, repo, opts, buffered=False):
1285 """show one changeset using template or regular display.
1285 """show one changeset using template or regular display.
1286
1286
1287 Display format will be the first non-empty hit of:
1287 Display format will be the first non-empty hit of:
1288 1. option 'template'
1288 1. option 'template'
1289 2. option 'style'
1289 2. option 'style'
1290 3. [ui] setting 'logtemplate'
1290 3. [ui] setting 'logtemplate'
1291 4. [ui] setting 'style'
1291 4. [ui] setting 'style'
1292 If all of these values are either the unset or the empty string,
1292 If all of these values are either the unset or the empty string,
1293 regular display via changeset_printer() is done.
1293 regular display via changeset_printer() is done.
1294 """
1294 """
1295 # options
1295 # options
1296 matchfn = None
1296 matchfn = None
1297 if opts.get('patch') or opts.get('stat'):
1297 if opts.get('patch') or opts.get('stat'):
1298 matchfn = scmutil.matchall(repo)
1298 matchfn = scmutil.matchall(repo)
1299
1299
1300 if opts.get('template') == 'json':
1300 if opts.get('template') == 'json':
1301 return jsonchangeset(ui, repo, matchfn, opts, buffered)
1301 return jsonchangeset(ui, repo, matchfn, opts, buffered)
1302
1302
1303 tmpl, mapfile = gettemplate(ui, opts.get('template'), opts.get('style'))
1303 tmpl, mapfile = gettemplate(ui, opts.get('template'), opts.get('style'))
1304
1304
1305 if not tmpl and not mapfile:
1305 if not tmpl and not mapfile:
1306 return changeset_printer(ui, repo, matchfn, opts, buffered)
1306 return changeset_printer(ui, repo, matchfn, opts, buffered)
1307
1307
1308 try:
1308 try:
1309 t = changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile,
1309 t = changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile,
1310 buffered)
1310 buffered)
1311 except SyntaxError, inst:
1311 except SyntaxError, inst:
1312 raise util.Abort(inst.args[0])
1312 raise util.Abort(inst.args[0])
1313 return t
1313 return t
1314
1314
1315 def showmarker(ui, marker):
1315 def showmarker(ui, marker):
1316 """utility function to display obsolescence marker in a readable way
1316 """utility function to display obsolescence marker in a readable way
1317
1317
1318 To be used by debug function."""
1318 To be used by debug function."""
1319 ui.write(hex(marker.precnode()))
1319 ui.write(hex(marker.precnode()))
1320 for repl in marker.succnodes():
1320 for repl in marker.succnodes():
1321 ui.write(' ')
1321 ui.write(' ')
1322 ui.write(hex(repl))
1322 ui.write(hex(repl))
1323 ui.write(' %X ' % marker.flags())
1323 ui.write(' %X ' % marker.flags())
1324 parents = marker.parentnodes()
1324 parents = marker.parentnodes()
1325 if parents is not None:
1325 if parents is not None:
1326 ui.write('{%s} ' % ', '.join(hex(p) for p in parents))
1326 ui.write('{%s} ' % ', '.join(hex(p) for p in parents))
1327 ui.write('(%s) ' % util.datestr(marker.date()))
1327 ui.write('(%s) ' % util.datestr(marker.date()))
1328 ui.write('{%s}' % (', '.join('%r: %r' % t for t in
1328 ui.write('{%s}' % (', '.join('%r: %r' % t for t in
1329 sorted(marker.metadata().items())
1329 sorted(marker.metadata().items())
1330 if t[0] != 'date')))
1330 if t[0] != 'date')))
1331 ui.write('\n')
1331 ui.write('\n')
1332
1332
1333 def finddate(ui, repo, date):
1333 def finddate(ui, repo, date):
1334 """Find the tipmost changeset that matches the given date spec"""
1334 """Find the tipmost changeset that matches the given date spec"""
1335
1335
1336 df = util.matchdate(date)
1336 df = util.matchdate(date)
1337 m = scmutil.matchall(repo)
1337 m = scmutil.matchall(repo)
1338 results = {}
1338 results = {}
1339
1339
1340 def prep(ctx, fns):
1340 def prep(ctx, fns):
1341 d = ctx.date()
1341 d = ctx.date()
1342 if df(d[0]):
1342 if df(d[0]):
1343 results[ctx.rev()] = d
1343 results[ctx.rev()] = d
1344
1344
1345 for ctx in walkchangerevs(repo, m, {'rev': None}, prep):
1345 for ctx in walkchangerevs(repo, m, {'rev': None}, prep):
1346 rev = ctx.rev()
1346 rev = ctx.rev()
1347 if rev in results:
1347 if rev in results:
1348 ui.status(_("found revision %s from %s\n") %
1348 ui.status(_("found revision %s from %s\n") %
1349 (rev, util.datestr(results[rev])))
1349 (rev, util.datestr(results[rev])))
1350 return str(rev)
1350 return str(rev)
1351
1351
1352 raise util.Abort(_("revision matching date not found"))
1352 raise util.Abort(_("revision matching date not found"))
1353
1353
1354 def increasingwindows(windowsize=8, sizelimit=512):
1354 def increasingwindows(windowsize=8, sizelimit=512):
1355 while True:
1355 while True:
1356 yield windowsize
1356 yield windowsize
1357 if windowsize < sizelimit:
1357 if windowsize < sizelimit:
1358 windowsize *= 2
1358 windowsize *= 2
1359
1359
1360 class FileWalkError(Exception):
1360 class FileWalkError(Exception):
1361 pass
1361 pass
1362
1362
1363 def walkfilerevs(repo, match, follow, revs, fncache):
1363 def walkfilerevs(repo, match, follow, revs, fncache):
1364 '''Walks the file history for the matched files.
1364 '''Walks the file history for the matched files.
1365
1365
1366 Returns the changeset revs that are involved in the file history.
1366 Returns the changeset revs that are involved in the file history.
1367
1367
1368 Throws FileWalkError if the file history can't be walked using
1368 Throws FileWalkError if the file history can't be walked using
1369 filelogs alone.
1369 filelogs alone.
1370 '''
1370 '''
1371 wanted = set()
1371 wanted = set()
1372 copies = []
1372 copies = []
1373 minrev, maxrev = min(revs), max(revs)
1373 minrev, maxrev = min(revs), max(revs)
1374 def filerevgen(filelog, last):
1374 def filerevgen(filelog, last):
1375 """
1375 """
1376 Only files, no patterns. Check the history of each file.
1376 Only files, no patterns. Check the history of each file.
1377
1377
1378 Examines filelog entries within minrev, maxrev linkrev range
1378 Examines filelog entries within minrev, maxrev linkrev range
1379 Returns an iterator yielding (linkrev, parentlinkrevs, copied)
1379 Returns an iterator yielding (linkrev, parentlinkrevs, copied)
1380 tuples in backwards order
1380 tuples in backwards order
1381 """
1381 """
1382 cl_count = len(repo)
1382 cl_count = len(repo)
1383 revs = []
1383 revs = []
1384 for j in xrange(0, last + 1):
1384 for j in xrange(0, last + 1):
1385 linkrev = filelog.linkrev(j)
1385 linkrev = filelog.linkrev(j)
1386 if linkrev < minrev:
1386 if linkrev < minrev:
1387 continue
1387 continue
1388 # only yield rev for which we have the changelog, it can
1388 # only yield rev for which we have the changelog, it can
1389 # happen while doing "hg log" during a pull or commit
1389 # happen while doing "hg log" during a pull or commit
1390 if linkrev >= cl_count:
1390 if linkrev >= cl_count:
1391 break
1391 break
1392
1392
1393 parentlinkrevs = []
1393 parentlinkrevs = []
1394 for p in filelog.parentrevs(j):
1394 for p in filelog.parentrevs(j):
1395 if p != nullrev:
1395 if p != nullrev:
1396 parentlinkrevs.append(filelog.linkrev(p))
1396 parentlinkrevs.append(filelog.linkrev(p))
1397 n = filelog.node(j)
1397 n = filelog.node(j)
1398 revs.append((linkrev, parentlinkrevs,
1398 revs.append((linkrev, parentlinkrevs,
1399 follow and filelog.renamed(n)))
1399 follow and filelog.renamed(n)))
1400
1400
1401 return reversed(revs)
1401 return reversed(revs)
1402 def iterfiles():
1402 def iterfiles():
1403 pctx = repo['.']
1403 pctx = repo['.']
1404 for filename in match.files():
1404 for filename in match.files():
1405 if follow:
1405 if follow:
1406 if filename not in pctx:
1406 if filename not in pctx:
1407 raise util.Abort(_('cannot follow file not in parent '
1407 raise util.Abort(_('cannot follow file not in parent '
1408 'revision: "%s"') % filename)
1408 'revision: "%s"') % filename)
1409 yield filename, pctx[filename].filenode()
1409 yield filename, pctx[filename].filenode()
1410 else:
1410 else:
1411 yield filename, None
1411 yield filename, None
1412 for filename_node in copies:
1412 for filename_node in copies:
1413 yield filename_node
1413 yield filename_node
1414
1414
1415 for file_, node in iterfiles():
1415 for file_, node in iterfiles():
1416 filelog = repo.file(file_)
1416 filelog = repo.file(file_)
1417 if not len(filelog):
1417 if not len(filelog):
1418 if node is None:
1418 if node is None:
1419 # A zero count may be a directory or deleted file, so
1419 # A zero count may be a directory or deleted file, so
1420 # try to find matching entries on the slow path.
1420 # try to find matching entries on the slow path.
1421 if follow:
1421 if follow:
1422 raise util.Abort(
1422 raise util.Abort(
1423 _('cannot follow nonexistent file: "%s"') % file_)
1423 _('cannot follow nonexistent file: "%s"') % file_)
1424 raise FileWalkError("Cannot walk via filelog")
1424 raise FileWalkError("Cannot walk via filelog")
1425 else:
1425 else:
1426 continue
1426 continue
1427
1427
1428 if node is None:
1428 if node is None:
1429 last = len(filelog) - 1
1429 last = len(filelog) - 1
1430 else:
1430 else:
1431 last = filelog.rev(node)
1431 last = filelog.rev(node)
1432
1432
1433
1433
1434 # keep track of all ancestors of the file
1434 # keep track of all ancestors of the file
1435 ancestors = set([filelog.linkrev(last)])
1435 ancestors = set([filelog.linkrev(last)])
1436
1436
1437 # iterate from latest to oldest revision
1437 # iterate from latest to oldest revision
1438 for rev, flparentlinkrevs, copied in filerevgen(filelog, last):
1438 for rev, flparentlinkrevs, copied in filerevgen(filelog, last):
1439 if not follow:
1439 if not follow:
1440 if rev > maxrev:
1440 if rev > maxrev:
1441 continue
1441 continue
1442 else:
1442 else:
1443 # Note that last might not be the first interesting
1443 # Note that last might not be the first interesting
1444 # rev to us:
1444 # rev to us:
1445 # if the file has been changed after maxrev, we'll
1445 # if the file has been changed after maxrev, we'll
1446 # have linkrev(last) > maxrev, and we still need
1446 # have linkrev(last) > maxrev, and we still need
1447 # to explore the file graph
1447 # to explore the file graph
1448 if rev not in ancestors:
1448 if rev not in ancestors:
1449 continue
1449 continue
1450 # XXX insert 1327 fix here
1450 # XXX insert 1327 fix here
1451 if flparentlinkrevs:
1451 if flparentlinkrevs:
1452 ancestors.update(flparentlinkrevs)
1452 ancestors.update(flparentlinkrevs)
1453
1453
1454 fncache.setdefault(rev, []).append(file_)
1454 fncache.setdefault(rev, []).append(file_)
1455 wanted.add(rev)
1455 wanted.add(rev)
1456 if copied:
1456 if copied:
1457 copies.append(copied)
1457 copies.append(copied)
1458
1458
1459 return wanted
1459 return wanted
1460
1460
1461 def walkchangerevs(repo, match, opts, prepare):
1461 def walkchangerevs(repo, match, opts, prepare):
1462 '''Iterate over files and the revs in which they changed.
1462 '''Iterate over files and the revs in which they changed.
1463
1463
1464 Callers most commonly need to iterate backwards over the history
1464 Callers most commonly need to iterate backwards over the history
1465 in which they are interested. Doing so has awful (quadratic-looking)
1465 in which they are interested. Doing so has awful (quadratic-looking)
1466 performance, so we use iterators in a "windowed" way.
1466 performance, so we use iterators in a "windowed" way.
1467
1467
1468 We walk a window of revisions in the desired order. Within the
1468 We walk a window of revisions in the desired order. Within the
1469 window, we first walk forwards to gather data, then in the desired
1469 window, we first walk forwards to gather data, then in the desired
1470 order (usually backwards) to display it.
1470 order (usually backwards) to display it.
1471
1471
1472 This function returns an iterator yielding contexts. Before
1472 This function returns an iterator yielding contexts. Before
1473 yielding each context, the iterator will first call the prepare
1473 yielding each context, the iterator will first call the prepare
1474 function on each context in the window in forward order.'''
1474 function on each context in the window in forward order.'''
1475
1475
1476 follow = opts.get('follow') or opts.get('follow_first')
1476 follow = opts.get('follow') or opts.get('follow_first')
1477
1477
1478 if opts.get('rev'):
1478 if opts.get('rev'):
1479 revs = scmutil.revrange(repo, opts.get('rev'))
1479 revs = scmutil.revrange(repo, opts.get('rev'))
1480 elif follow:
1480 elif follow:
1481 revs = repo.revs('reverse(:.)')
1481 revs = repo.revs('reverse(:.)')
1482 else:
1482 else:
1483 revs = revset.spanset(repo)
1483 revs = revset.spanset(repo)
1484 revs.reverse()
1484 revs.reverse()
1485 if not revs:
1485 if not revs:
1486 return []
1486 return []
1487 wanted = set()
1487 wanted = set()
1488 slowpath = match.anypats() or (match.files() and opts.get('removed'))
1488 slowpath = match.anypats() or (match.files() and opts.get('removed'))
1489 fncache = {}
1489 fncache = {}
1490 change = repo.changectx
1490 change = repo.changectx
1491
1491
1492 # First step is to fill wanted, the set of revisions that we want to yield.
1492 # First step is to fill wanted, the set of revisions that we want to yield.
1493 # When it does not induce extra cost, we also fill fncache for revisions in
1493 # When it does not induce extra cost, we also fill fncache for revisions in
1494 # wanted: a cache of filenames that were changed (ctx.files()) and that
1494 # wanted: a cache of filenames that were changed (ctx.files()) and that
1495 # match the file filtering conditions.
1495 # match the file filtering conditions.
1496
1496
1497 if not slowpath and not match.files():
1497 if not slowpath and not match.files():
1498 # No files, no patterns. Display all revs.
1498 # No files, no patterns. Display all revs.
1499 wanted = revs
1499 wanted = revs
1500
1500
1501 if not slowpath and match.files():
1501 if not slowpath and match.files():
1502 # We only have to read through the filelog to find wanted revisions
1502 # We only have to read through the filelog to find wanted revisions
1503
1503
1504 try:
1504 try:
1505 wanted = walkfilerevs(repo, match, follow, revs, fncache)
1505 wanted = walkfilerevs(repo, match, follow, revs, fncache)
1506 except FileWalkError:
1506 except FileWalkError:
1507 slowpath = True
1507 slowpath = True
1508
1508
1509 # We decided to fall back to the slowpath because at least one
1509 # We decided to fall back to the slowpath because at least one
1510 # of the paths was not a file. Check to see if at least one of them
1510 # of the paths was not a file. Check to see if at least one of them
1511 # existed in history, otherwise simply return
1511 # existed in history, otherwise simply return
1512 for path in match.files():
1512 for path in match.files():
1513 if path == '.' or path in repo.store:
1513 if path == '.' or path in repo.store:
1514 break
1514 break
1515 else:
1515 else:
1516 return []
1516 return []
1517
1517
1518 if slowpath:
1518 if slowpath:
1519 # We have to read the changelog to match filenames against
1519 # We have to read the changelog to match filenames against
1520 # changed files
1520 # changed files
1521
1521
1522 if follow:
1522 if follow:
1523 raise util.Abort(_('can only follow copies/renames for explicit '
1523 raise util.Abort(_('can only follow copies/renames for explicit '
1524 'filenames'))
1524 'filenames'))
1525
1525
1526 # The slow path checks files modified in every changeset.
1526 # The slow path checks files modified in every changeset.
1527 # This is really slow on large repos, so compute the set lazily.
1527 # This is really slow on large repos, so compute the set lazily.
1528 class lazywantedset(object):
1528 class lazywantedset(object):
1529 def __init__(self):
1529 def __init__(self):
1530 self.set = set()
1530 self.set = set()
1531 self.revs = set(revs)
1531 self.revs = set(revs)
1532
1532
1533 # No need to worry about locality here because it will be accessed
1533 # No need to worry about locality here because it will be accessed
1534 # in the same order as the increasing window below.
1534 # in the same order as the increasing window below.
1535 def __contains__(self, value):
1535 def __contains__(self, value):
1536 if value in self.set:
1536 if value in self.set:
1537 return True
1537 return True
1538 elif not value in self.revs:
1538 elif not value in self.revs:
1539 return False
1539 return False
1540 else:
1540 else:
1541 self.revs.discard(value)
1541 self.revs.discard(value)
1542 ctx = change(value)
1542 ctx = change(value)
1543 matches = filter(match, ctx.files())
1543 matches = filter(match, ctx.files())
1544 if matches:
1544 if matches:
1545 fncache[value] = matches
1545 fncache[value] = matches
1546 self.set.add(value)
1546 self.set.add(value)
1547 return True
1547 return True
1548 return False
1548 return False
1549
1549
1550 def discard(self, value):
1550 def discard(self, value):
1551 self.revs.discard(value)
1551 self.revs.discard(value)
1552 self.set.discard(value)
1552 self.set.discard(value)
1553
1553
1554 wanted = lazywantedset()
1554 wanted = lazywantedset()
1555
1555
1556 class followfilter(object):
1556 class followfilter(object):
1557 def __init__(self, onlyfirst=False):
1557 def __init__(self, onlyfirst=False):
1558 self.startrev = nullrev
1558 self.startrev = nullrev
1559 self.roots = set()
1559 self.roots = set()
1560 self.onlyfirst = onlyfirst
1560 self.onlyfirst = onlyfirst
1561
1561
1562 def match(self, rev):
1562 def match(self, rev):
1563 def realparents(rev):
1563 def realparents(rev):
1564 if self.onlyfirst:
1564 if self.onlyfirst:
1565 return repo.changelog.parentrevs(rev)[0:1]
1565 return repo.changelog.parentrevs(rev)[0:1]
1566 else:
1566 else:
1567 return filter(lambda x: x != nullrev,
1567 return filter(lambda x: x != nullrev,
1568 repo.changelog.parentrevs(rev))
1568 repo.changelog.parentrevs(rev))
1569
1569
1570 if self.startrev == nullrev:
1570 if self.startrev == nullrev:
1571 self.startrev = rev
1571 self.startrev = rev
1572 return True
1572 return True
1573
1573
1574 if rev > self.startrev:
1574 if rev > self.startrev:
1575 # forward: all descendants
1575 # forward: all descendants
1576 if not self.roots:
1576 if not self.roots:
1577 self.roots.add(self.startrev)
1577 self.roots.add(self.startrev)
1578 for parent in realparents(rev):
1578 for parent in realparents(rev):
1579 if parent in self.roots:
1579 if parent in self.roots:
1580 self.roots.add(rev)
1580 self.roots.add(rev)
1581 return True
1581 return True
1582 else:
1582 else:
1583 # backwards: all parents
1583 # backwards: all parents
1584 if not self.roots:
1584 if not self.roots:
1585 self.roots.update(realparents(self.startrev))
1585 self.roots.update(realparents(self.startrev))
1586 if rev in self.roots:
1586 if rev in self.roots:
1587 self.roots.remove(rev)
1587 self.roots.remove(rev)
1588 self.roots.update(realparents(rev))
1588 self.roots.update(realparents(rev))
1589 return True
1589 return True
1590
1590
1591 return False
1591 return False
1592
1592
1593 # it might be worthwhile to do this in the iterator if the rev range
1593 # it might be worthwhile to do this in the iterator if the rev range
1594 # is descending and the prune args are all within that range
1594 # is descending and the prune args are all within that range
1595 for rev in opts.get('prune', ()):
1595 for rev in opts.get('prune', ()):
1596 rev = repo[rev].rev()
1596 rev = repo[rev].rev()
1597 ff = followfilter()
1597 ff = followfilter()
1598 stop = min(revs[0], revs[-1])
1598 stop = min(revs[0], revs[-1])
1599 for x in xrange(rev, stop - 1, -1):
1599 for x in xrange(rev, stop - 1, -1):
1600 if ff.match(x):
1600 if ff.match(x):
1601 wanted = wanted - [x]
1601 wanted = wanted - [x]
1602
1602
1603 # Now that wanted is correctly initialized, we can iterate over the
1603 # Now that wanted is correctly initialized, we can iterate over the
1604 # revision range, yielding only revisions in wanted.
1604 # revision range, yielding only revisions in wanted.
1605 def iterate():
1605 def iterate():
1606 if follow and not match.files():
1606 if follow and not match.files():
1607 ff = followfilter(onlyfirst=opts.get('follow_first'))
1607 ff = followfilter(onlyfirst=opts.get('follow_first'))
1608 def want(rev):
1608 def want(rev):
1609 return ff.match(rev) and rev in wanted
1609 return ff.match(rev) and rev in wanted
1610 else:
1610 else:
1611 def want(rev):
1611 def want(rev):
1612 return rev in wanted
1612 return rev in wanted
1613
1613
1614 it = iter(revs)
1614 it = iter(revs)
1615 stopiteration = False
1615 stopiteration = False
1616 for windowsize in increasingwindows():
1616 for windowsize in increasingwindows():
1617 nrevs = []
1617 nrevs = []
1618 for i in xrange(windowsize):
1618 for i in xrange(windowsize):
1619 try:
1619 try:
1620 rev = it.next()
1620 rev = it.next()
1621 if want(rev):
1621 if want(rev):
1622 nrevs.append(rev)
1622 nrevs.append(rev)
1623 except (StopIteration):
1623 except (StopIteration):
1624 stopiteration = True
1624 stopiteration = True
1625 break
1625 break
1626 for rev in sorted(nrevs):
1626 for rev in sorted(nrevs):
1627 fns = fncache.get(rev)
1627 fns = fncache.get(rev)
1628 ctx = change(rev)
1628 ctx = change(rev)
1629 if not fns:
1629 if not fns:
1630 def fns_generator():
1630 def fns_generator():
1631 for f in ctx.files():
1631 for f in ctx.files():
1632 if match(f):
1632 if match(f):
1633 yield f
1633 yield f
1634 fns = fns_generator()
1634 fns = fns_generator()
1635 prepare(ctx, fns)
1635 prepare(ctx, fns)
1636 for rev in nrevs:
1636 for rev in nrevs:
1637 yield change(rev)
1637 yield change(rev)
1638
1638
1639 if stopiteration:
1639 if stopiteration:
1640 break
1640 break
1641
1641
1642 return iterate()
1642 return iterate()
1643
1643
1644 def _makefollowlogfilematcher(repo, files, followfirst):
1644 def _makefollowlogfilematcher(repo, files, followfirst):
1645 # When displaying a revision with --patch --follow FILE, we have
1645 # When displaying a revision with --patch --follow FILE, we have
1646 # to know which file of the revision must be diffed. With
1646 # to know which file of the revision must be diffed. With
1647 # --follow, we want the names of the ancestors of FILE in the
1647 # --follow, we want the names of the ancestors of FILE in the
1648 # revision, stored in "fcache". "fcache" is populated by
1648 # revision, stored in "fcache". "fcache" is populated by
1649 # reproducing the graph traversal already done by --follow revset
1649 # reproducing the graph traversal already done by --follow revset
1650 # and relating linkrevs to file names (which is not "correct" but
1650 # and relating linkrevs to file names (which is not "correct" but
1651 # good enough).
1651 # good enough).
1652 fcache = {}
1652 fcache = {}
1653 fcacheready = [False]
1653 fcacheready = [False]
1654 pctx = repo['.']
1654 pctx = repo['.']
1655
1655
1656 def populate():
1656 def populate():
1657 for fn in files:
1657 for fn in files:
1658 for i in ((pctx[fn],), pctx[fn].ancestors(followfirst=followfirst)):
1658 for i in ((pctx[fn],), pctx[fn].ancestors(followfirst=followfirst)):
1659 for c in i:
1659 for c in i:
1660 fcache.setdefault(c.linkrev(), set()).add(c.path())
1660 fcache.setdefault(c.linkrev(), set()).add(c.path())
1661
1661
1662 def filematcher(rev):
1662 def filematcher(rev):
1663 if not fcacheready[0]:
1663 if not fcacheready[0]:
1664 # Lazy initialization
1664 # Lazy initialization
1665 fcacheready[0] = True
1665 fcacheready[0] = True
1666 populate()
1666 populate()
1667 return scmutil.matchfiles(repo, fcache.get(rev, []))
1667 return scmutil.matchfiles(repo, fcache.get(rev, []))
1668
1668
1669 return filematcher
1669 return filematcher
1670
1670
1671 def _makenofollowlogfilematcher(repo, pats, opts):
1671 def _makenofollowlogfilematcher(repo, pats, opts):
1672 '''hook for extensions to override the filematcher for non-follow cases'''
1672 '''hook for extensions to override the filematcher for non-follow cases'''
1673 return None
1673 return None
1674
1674
1675 def _makelogrevset(repo, pats, opts, revs):
1675 def _makelogrevset(repo, pats, opts, revs):
1676 """Return (expr, filematcher) where expr is a revset string built
1676 """Return (expr, filematcher) where expr is a revset string built
1677 from log options and file patterns or None. If --stat or --patch
1677 from log options and file patterns or None. If --stat or --patch
1678 are not passed filematcher is None. Otherwise it is a callable
1678 are not passed filematcher is None. Otherwise it is a callable
1679 taking a revision number and returning a match objects filtering
1679 taking a revision number and returning a match objects filtering
1680 the files to be detailed when displaying the revision.
1680 the files to be detailed when displaying the revision.
1681 """
1681 """
1682 opt2revset = {
1682 opt2revset = {
1683 'no_merges': ('not merge()', None),
1683 'no_merges': ('not merge()', None),
1684 'only_merges': ('merge()', None),
1684 'only_merges': ('merge()', None),
1685 '_ancestors': ('ancestors(%(val)s)', None),
1685 '_ancestors': ('ancestors(%(val)s)', None),
1686 '_fancestors': ('_firstancestors(%(val)s)', None),
1686 '_fancestors': ('_firstancestors(%(val)s)', None),
1687 '_descendants': ('descendants(%(val)s)', None),
1687 '_descendants': ('descendants(%(val)s)', None),
1688 '_fdescendants': ('_firstdescendants(%(val)s)', None),
1688 '_fdescendants': ('_firstdescendants(%(val)s)', None),
1689 '_matchfiles': ('_matchfiles(%(val)s)', None),
1689 '_matchfiles': ('_matchfiles(%(val)s)', None),
1690 'date': ('date(%(val)r)', None),
1690 'date': ('date(%(val)r)', None),
1691 'branch': ('branch(%(val)r)', ' or '),
1691 'branch': ('branch(%(val)r)', ' or '),
1692 '_patslog': ('filelog(%(val)r)', ' or '),
1692 '_patslog': ('filelog(%(val)r)', ' or '),
1693 '_patsfollow': ('follow(%(val)r)', ' or '),
1693 '_patsfollow': ('follow(%(val)r)', ' or '),
1694 '_patsfollowfirst': ('_followfirst(%(val)r)', ' or '),
1694 '_patsfollowfirst': ('_followfirst(%(val)r)', ' or '),
1695 'keyword': ('keyword(%(val)r)', ' or '),
1695 'keyword': ('keyword(%(val)r)', ' or '),
1696 'prune': ('not (%(val)r or ancestors(%(val)r))', ' and '),
1696 'prune': ('not (%(val)r or ancestors(%(val)r))', ' and '),
1697 'user': ('user(%(val)r)', ' or '),
1697 'user': ('user(%(val)r)', ' or '),
1698 }
1698 }
1699
1699
1700 opts = dict(opts)
1700 opts = dict(opts)
1701 # follow or not follow?
1701 # follow or not follow?
1702 follow = opts.get('follow') or opts.get('follow_first')
1702 follow = opts.get('follow') or opts.get('follow_first')
1703 followfirst = opts.get('follow_first') and 1 or 0
1703 followfirst = opts.get('follow_first') and 1 or 0
1704 # --follow with FILE behaviour depends on revs...
1704 # --follow with FILE behaviour depends on revs...
1705 it = iter(revs)
1705 it = iter(revs)
1706 startrev = it.next()
1706 startrev = it.next()
1707 try:
1707 try:
1708 followdescendants = startrev < it.next()
1708 followdescendants = startrev < it.next()
1709 except (StopIteration):
1709 except (StopIteration):
1710 followdescendants = False
1710 followdescendants = False
1711
1711
1712 # branch and only_branch are really aliases and must be handled at
1712 # branch and only_branch are really aliases and must be handled at
1713 # the same time
1713 # the same time
1714 opts['branch'] = opts.get('branch', []) + opts.get('only_branch', [])
1714 opts['branch'] = opts.get('branch', []) + opts.get('only_branch', [])
1715 opts['branch'] = [repo.lookupbranch(b) for b in opts['branch']]
1715 opts['branch'] = [repo.lookupbranch(b) for b in opts['branch']]
1716 # pats/include/exclude are passed to match.match() directly in
1716 # pats/include/exclude are passed to match.match() directly in
1717 # _matchfiles() revset but walkchangerevs() builds its matcher with
1717 # _matchfiles() revset but walkchangerevs() builds its matcher with
1718 # scmutil.match(). The difference is input pats are globbed on
1718 # scmutil.match(). The difference is input pats are globbed on
1719 # platforms without shell expansion (windows).
1719 # platforms without shell expansion (windows).
1720 pctx = repo[None]
1720 pctx = repo[None]
1721 match, pats = scmutil.matchandpats(pctx, pats, opts)
1721 match, pats = scmutil.matchandpats(pctx, pats, opts)
1722 slowpath = match.anypats() or (match.files() and opts.get('removed'))
1722 slowpath = match.anypats() or (match.files() and opts.get('removed'))
1723 if not slowpath:
1723 if not slowpath:
1724 for f in match.files():
1724 for f in match.files():
1725 if follow and f not in pctx:
1725 if follow and f not in pctx:
1726 # If the file exists, it may be a directory, so let it
1726 # If the file exists, it may be a directory, so let it
1727 # take the slow path.
1727 # take the slow path.
1728 if os.path.exists(repo.wjoin(f)):
1728 if os.path.exists(repo.wjoin(f)):
1729 slowpath = True
1729 slowpath = True
1730 continue
1730 continue
1731 else:
1731 else:
1732 raise util.Abort(_('cannot follow file not in parent '
1732 raise util.Abort(_('cannot follow file not in parent '
1733 'revision: "%s"') % f)
1733 'revision: "%s"') % f)
1734 filelog = repo.file(f)
1734 filelog = repo.file(f)
1735 if not filelog:
1735 if not filelog:
1736 # A zero count may be a directory or deleted file, so
1736 # A zero count may be a directory or deleted file, so
1737 # try to find matching entries on the slow path.
1737 # try to find matching entries on the slow path.
1738 if follow:
1738 if follow:
1739 raise util.Abort(
1739 raise util.Abort(
1740 _('cannot follow nonexistent file: "%s"') % f)
1740 _('cannot follow nonexistent file: "%s"') % f)
1741 slowpath = True
1741 slowpath = True
1742
1742
1743 # We decided to fall back to the slowpath because at least one
1743 # We decided to fall back to the slowpath because at least one
1744 # of the paths was not a file. Check to see if at least one of them
1744 # of the paths was not a file. Check to see if at least one of them
1745 # existed in history - in that case, we'll continue down the
1745 # existed in history - in that case, we'll continue down the
1746 # slowpath; otherwise, we can turn off the slowpath
1746 # slowpath; otherwise, we can turn off the slowpath
1747 if slowpath:
1747 if slowpath:
1748 for path in match.files():
1748 for path in match.files():
1749 if path == '.' or path in repo.store:
1749 if path == '.' or path in repo.store:
1750 break
1750 break
1751 else:
1751 else:
1752 slowpath = False
1752 slowpath = False
1753
1753
1754 fpats = ('_patsfollow', '_patsfollowfirst')
1754 fpats = ('_patsfollow', '_patsfollowfirst')
1755 fnopats = (('_ancestors', '_fancestors'),
1755 fnopats = (('_ancestors', '_fancestors'),
1756 ('_descendants', '_fdescendants'))
1756 ('_descendants', '_fdescendants'))
1757 if slowpath:
1757 if slowpath:
1758 # See walkchangerevs() slow path.
1758 # See walkchangerevs() slow path.
1759 #
1759 #
1760 # pats/include/exclude cannot be represented as separate
1760 # pats/include/exclude cannot be represented as separate
1761 # revset expressions as their filtering logic applies at file
1761 # revset expressions as their filtering logic applies at file
1762 # level. For instance "-I a -X a" matches a revision touching
1762 # level. For instance "-I a -X a" matches a revision touching
1763 # "a" and "b" while "file(a) and not file(b)" does
1763 # "a" and "b" while "file(a) and not file(b)" does
1764 # not. Besides, filesets are evaluated against the working
1764 # not. Besides, filesets are evaluated against the working
1765 # directory.
1765 # directory.
1766 matchargs = ['r:', 'd:relpath']
1766 matchargs = ['r:', 'd:relpath']
1767 for p in pats:
1767 for p in pats:
1768 matchargs.append('p:' + p)
1768 matchargs.append('p:' + p)
1769 for p in opts.get('include', []):
1769 for p in opts.get('include', []):
1770 matchargs.append('i:' + p)
1770 matchargs.append('i:' + p)
1771 for p in opts.get('exclude', []):
1771 for p in opts.get('exclude', []):
1772 matchargs.append('x:' + p)
1772 matchargs.append('x:' + p)
1773 matchargs = ','.join(('%r' % p) for p in matchargs)
1773 matchargs = ','.join(('%r' % p) for p in matchargs)
1774 opts['_matchfiles'] = matchargs
1774 opts['_matchfiles'] = matchargs
1775 if follow:
1775 if follow:
1776 opts[fnopats[0][followfirst]] = '.'
1776 opts[fnopats[0][followfirst]] = '.'
1777 else:
1777 else:
1778 if follow:
1778 if follow:
1779 if pats:
1779 if pats:
1780 # follow() revset interprets its file argument as a
1780 # follow() revset interprets its file argument as a
1781 # manifest entry, so use match.files(), not pats.
1781 # manifest entry, so use match.files(), not pats.
1782 opts[fpats[followfirst]] = list(match.files())
1782 opts[fpats[followfirst]] = list(match.files())
1783 else:
1783 else:
1784 opts[fnopats[followdescendants][followfirst]] = str(startrev)
1784 opts[fnopats[followdescendants][followfirst]] = str(startrev)
1785 else:
1785 else:
1786 opts['_patslog'] = list(pats)
1786 opts['_patslog'] = list(pats)
1787
1787
1788 filematcher = None
1788 filematcher = None
1789 if opts.get('patch') or opts.get('stat'):
1789 if opts.get('patch') or opts.get('stat'):
1790 # When following files, track renames via a special matcher.
1790 # When following files, track renames via a special matcher.
1791 # If we're forced to take the slowpath it means we're following
1791 # If we're forced to take the slowpath it means we're following
1792 # at least one pattern/directory, so don't bother with rename tracking.
1792 # at least one pattern/directory, so don't bother with rename tracking.
1793 if follow and not match.always() and not slowpath:
1793 if follow and not match.always() and not slowpath:
1794 # _makefollowlogfilematcher expects its files argument to be
1794 # _makefollowlogfilematcher expects its files argument to be
1795 # relative to the repo root, so use match.files(), not pats.
1795 # relative to the repo root, so use match.files(), not pats.
1796 filematcher = _makefollowlogfilematcher(repo, match.files(),
1796 filematcher = _makefollowlogfilematcher(repo, match.files(),
1797 followfirst)
1797 followfirst)
1798 else:
1798 else:
1799 filematcher = _makenofollowlogfilematcher(repo, pats, opts)
1799 filematcher = _makenofollowlogfilematcher(repo, pats, opts)
1800 if filematcher is None:
1800 if filematcher is None:
1801 filematcher = lambda rev: match
1801 filematcher = lambda rev: match
1802
1802
1803 expr = []
1803 expr = []
1804 for op, val in sorted(opts.iteritems()):
1804 for op, val in sorted(opts.iteritems()):
1805 if not val:
1805 if not val:
1806 continue
1806 continue
1807 if op not in opt2revset:
1807 if op not in opt2revset:
1808 continue
1808 continue
1809 revop, andor = opt2revset[op]
1809 revop, andor = opt2revset[op]
1810 if '%(val)' not in revop:
1810 if '%(val)' not in revop:
1811 expr.append(revop)
1811 expr.append(revop)
1812 else:
1812 else:
1813 if not isinstance(val, list):
1813 if not isinstance(val, list):
1814 e = revop % {'val': val}
1814 e = revop % {'val': val}
1815 else:
1815 else:
1816 e = '(' + andor.join((revop % {'val': v}) for v in val) + ')'
1816 e = '(' + andor.join((revop % {'val': v}) for v in val) + ')'
1817 expr.append(e)
1817 expr.append(e)
1818
1818
1819 if expr:
1819 if expr:
1820 expr = '(' + ' and '.join(expr) + ')'
1820 expr = '(' + ' and '.join(expr) + ')'
1821 else:
1821 else:
1822 expr = None
1822 expr = None
1823 return expr, filematcher
1823 return expr, filematcher
1824
1824
1825 def getgraphlogrevs(repo, pats, opts):
1825 def getgraphlogrevs(repo, pats, opts):
1826 """Return (revs, expr, filematcher) where revs is an iterable of
1826 """Return (revs, expr, filematcher) where revs is an iterable of
1827 revision numbers, expr is a revset string built from log options
1827 revision numbers, expr is a revset string built from log options
1828 and file patterns or None, and used to filter 'revs'. If --stat or
1828 and file patterns or None, and used to filter 'revs'. If --stat or
1829 --patch are not passed filematcher is None. Otherwise it is a
1829 --patch are not passed filematcher is None. Otherwise it is a
1830 callable taking a revision number and returning a match objects
1830 callable taking a revision number and returning a match objects
1831 filtering the files to be detailed when displaying the revision.
1831 filtering the files to be detailed when displaying the revision.
1832 """
1832 """
1833 if not len(repo):
1833 if not len(repo):
1834 return [], None, None
1834 return [], None, None
1835 limit = loglimit(opts)
1835 limit = loglimit(opts)
1836 # Default --rev value depends on --follow but --follow behaviour
1836 # Default --rev value depends on --follow but --follow behaviour
1837 # depends on revisions resolved from --rev...
1837 # depends on revisions resolved from --rev...
1838 follow = opts.get('follow') or opts.get('follow_first')
1838 follow = opts.get('follow') or opts.get('follow_first')
1839 possiblyunsorted = False # whether revs might need sorting
1839 possiblyunsorted = False # whether revs might need sorting
1840 if opts.get('rev'):
1840 if opts.get('rev'):
1841 revs = scmutil.revrange(repo, opts['rev'])
1841 revs = scmutil.revrange(repo, opts['rev'])
1842 # Don't sort here because _makelogrevset might depend on the
1842 # Don't sort here because _makelogrevset might depend on the
1843 # order of revs
1843 # order of revs
1844 possiblyunsorted = True
1844 possiblyunsorted = True
1845 else:
1845 else:
1846 if follow and len(repo) > 0:
1846 if follow and len(repo) > 0:
1847 revs = repo.revs('reverse(:.)')
1847 revs = repo.revs('reverse(:.)')
1848 else:
1848 else:
1849 revs = revset.spanset(repo)
1849 revs = revset.spanset(repo)
1850 revs.reverse()
1850 revs.reverse()
1851 if not revs:
1851 if not revs:
1852 return revset.baseset(), None, None
1852 return revset.baseset(), None, None
1853 expr, filematcher = _makelogrevset(repo, pats, opts, revs)
1853 expr, filematcher = _makelogrevset(repo, pats, opts, revs)
1854 if possiblyunsorted:
1854 if possiblyunsorted:
1855 revs.sort(reverse=True)
1855 revs.sort(reverse=True)
1856 if expr:
1856 if expr:
1857 # Revset matchers often operate faster on revisions in changelog
1857 # Revset matchers often operate faster on revisions in changelog
1858 # order, because most filters deal with the changelog.
1858 # order, because most filters deal with the changelog.
1859 revs.reverse()
1859 revs.reverse()
1860 matcher = revset.match(repo.ui, expr)
1860 matcher = revset.match(repo.ui, expr)
1861 # Revset matches can reorder revisions. "A or B" typically returns
1861 # Revset matches can reorder revisions. "A or B" typically returns
1862 # returns the revision matching A then the revision matching B. Sort
1862 # returns the revision matching A then the revision matching B. Sort
1863 # again to fix that.
1863 # again to fix that.
1864 revs = matcher(repo, revs)
1864 revs = matcher(repo, revs)
1865 revs.sort(reverse=True)
1865 revs.sort(reverse=True)
1866 if limit is not None:
1866 if limit is not None:
1867 limitedrevs = []
1867 limitedrevs = []
1868 for idx, rev in enumerate(revs):
1868 for idx, rev in enumerate(revs):
1869 if idx >= limit:
1869 if idx >= limit:
1870 break
1870 break
1871 limitedrevs.append(rev)
1871 limitedrevs.append(rev)
1872 revs = revset.baseset(limitedrevs)
1872 revs = revset.baseset(limitedrevs)
1873
1873
1874 return revs, expr, filematcher
1874 return revs, expr, filematcher
1875
1875
1876 def getlogrevs(repo, pats, opts):
1876 def getlogrevs(repo, pats, opts):
1877 """Return (revs, expr, filematcher) where revs is an iterable of
1877 """Return (revs, expr, filematcher) where revs is an iterable of
1878 revision numbers, expr is a revset string built from log options
1878 revision numbers, expr is a revset string built from log options
1879 and file patterns or None, and used to filter 'revs'. If --stat or
1879 and file patterns or None, and used to filter 'revs'. If --stat or
1880 --patch are not passed filematcher is None. Otherwise it is a
1880 --patch are not passed filematcher is None. Otherwise it is a
1881 callable taking a revision number and returning a match objects
1881 callable taking a revision number and returning a match objects
1882 filtering the files to be detailed when displaying the revision.
1882 filtering the files to be detailed when displaying the revision.
1883 """
1883 """
1884 limit = loglimit(opts)
1884 limit = loglimit(opts)
1885 # Default --rev value depends on --follow but --follow behaviour
1885 # Default --rev value depends on --follow but --follow behaviour
1886 # depends on revisions resolved from --rev...
1886 # depends on revisions resolved from --rev...
1887 follow = opts.get('follow') or opts.get('follow_first')
1887 follow = opts.get('follow') or opts.get('follow_first')
1888 if opts.get('rev'):
1888 if opts.get('rev'):
1889 revs = scmutil.revrange(repo, opts['rev'])
1889 revs = scmutil.revrange(repo, opts['rev'])
1890 elif follow:
1890 elif follow:
1891 revs = repo.revs('reverse(:.)')
1891 revs = repo.revs('reverse(:.)')
1892 else:
1892 else:
1893 revs = revset.spanset(repo)
1893 revs = revset.spanset(repo)
1894 revs.reverse()
1894 revs.reverse()
1895 if not revs:
1895 if not revs:
1896 return revset.baseset([]), None, None
1896 return revset.baseset([]), None, None
1897 expr, filematcher = _makelogrevset(repo, pats, opts, revs)
1897 expr, filematcher = _makelogrevset(repo, pats, opts, revs)
1898 if expr:
1898 if expr:
1899 # Revset matchers often operate faster on revisions in changelog
1899 # Revset matchers often operate faster on revisions in changelog
1900 # order, because most filters deal with the changelog.
1900 # order, because most filters deal with the changelog.
1901 if not opts.get('rev'):
1901 if not opts.get('rev'):
1902 revs.reverse()
1902 revs.reverse()
1903 matcher = revset.match(repo.ui, expr)
1903 matcher = revset.match(repo.ui, expr)
1904 # Revset matches can reorder revisions. "A or B" typically returns
1904 # Revset matches can reorder revisions. "A or B" typically returns
1905 # returns the revision matching A then the revision matching B. Sort
1905 # returns the revision matching A then the revision matching B. Sort
1906 # again to fix that.
1906 # again to fix that.
1907 revs = matcher(repo, revs)
1907 revs = matcher(repo, revs)
1908 if not opts.get('rev'):
1908 if not opts.get('rev'):
1909 revs.sort(reverse=True)
1909 revs.sort(reverse=True)
1910 if limit is not None:
1910 if limit is not None:
1911 count = 0
1911 count = 0
1912 limitedrevs = []
1912 limitedrevs = []
1913 it = iter(revs)
1913 it = iter(revs)
1914 while count < limit:
1914 while count < limit:
1915 try:
1915 try:
1916 limitedrevs.append(it.next())
1916 limitedrevs.append(it.next())
1917 except (StopIteration):
1917 except (StopIteration):
1918 break
1918 break
1919 count += 1
1919 count += 1
1920 revs = revset.baseset(limitedrevs)
1920 revs = revset.baseset(limitedrevs)
1921
1921
1922 return revs, expr, filematcher
1922 return revs, expr, filematcher
1923
1923
1924 def displaygraph(ui, dag, displayer, showparents, edgefn, getrenamed=None,
1924 def displaygraph(ui, dag, displayer, showparents, edgefn, getrenamed=None,
1925 filematcher=None):
1925 filematcher=None):
1926 seen, state = [], graphmod.asciistate()
1926 seen, state = [], graphmod.asciistate()
1927 for rev, type, ctx, parents in dag:
1927 for rev, type, ctx, parents in dag:
1928 char = 'o'
1928 char = 'o'
1929 if ctx.node() in showparents:
1929 if ctx.node() in showparents:
1930 char = '@'
1930 char = '@'
1931 elif ctx.obsolete():
1931 elif ctx.obsolete():
1932 char = 'x'
1932 char = 'x'
1933 copies = None
1933 copies = None
1934 if getrenamed and ctx.rev():
1934 if getrenamed and ctx.rev():
1935 copies = []
1935 copies = []
1936 for fn in ctx.files():
1936 for fn in ctx.files():
1937 rename = getrenamed(fn, ctx.rev())
1937 rename = getrenamed(fn, ctx.rev())
1938 if rename:
1938 if rename:
1939 copies.append((fn, rename[0]))
1939 copies.append((fn, rename[0]))
1940 revmatchfn = None
1940 revmatchfn = None
1941 if filematcher is not None:
1941 if filematcher is not None:
1942 revmatchfn = filematcher(ctx.rev())
1942 revmatchfn = filematcher(ctx.rev())
1943 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
1943 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
1944 lines = displayer.hunk.pop(rev).split('\n')
1944 lines = displayer.hunk.pop(rev).split('\n')
1945 if not lines[-1]:
1945 if not lines[-1]:
1946 del lines[-1]
1946 del lines[-1]
1947 displayer.flush(rev)
1947 displayer.flush(rev)
1948 edges = edgefn(type, char, lines, seen, rev, parents)
1948 edges = edgefn(type, char, lines, seen, rev, parents)
1949 for type, char, lines, coldata in edges:
1949 for type, char, lines, coldata in edges:
1950 graphmod.ascii(ui, state, type, char, lines, coldata)
1950 graphmod.ascii(ui, state, type, char, lines, coldata)
1951 displayer.close()
1951 displayer.close()
1952
1952
1953 def graphlog(ui, repo, *pats, **opts):
1953 def graphlog(ui, repo, *pats, **opts):
1954 # Parameters are identical to log command ones
1954 # Parameters are identical to log command ones
1955 revs, expr, filematcher = getgraphlogrevs(repo, pats, opts)
1955 revs, expr, filematcher = getgraphlogrevs(repo, pats, opts)
1956 revdag = graphmod.dagwalker(repo, revs)
1956 revdag = graphmod.dagwalker(repo, revs)
1957
1957
1958 getrenamed = None
1958 getrenamed = None
1959 if opts.get('copies'):
1959 if opts.get('copies'):
1960 endrev = None
1960 endrev = None
1961 if opts.get('rev'):
1961 if opts.get('rev'):
1962 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
1962 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
1963 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
1963 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
1964 displayer = show_changeset(ui, repo, opts, buffered=True)
1964 displayer = show_changeset(ui, repo, opts, buffered=True)
1965 showparents = [ctx.node() for ctx in repo[None].parents()]
1965 showparents = [ctx.node() for ctx in repo[None].parents()]
1966 displaygraph(ui, revdag, displayer, showparents,
1966 displaygraph(ui, revdag, displayer, showparents,
1967 graphmod.asciiedges, getrenamed, filematcher)
1967 graphmod.asciiedges, getrenamed, filematcher)
1968
1968
1969 def checkunsupportedgraphflags(pats, opts):
1969 def checkunsupportedgraphflags(pats, opts):
1970 for op in ["newest_first"]:
1970 for op in ["newest_first"]:
1971 if op in opts and opts[op]:
1971 if op in opts and opts[op]:
1972 raise util.Abort(_("-G/--graph option is incompatible with --%s")
1972 raise util.Abort(_("-G/--graph option is incompatible with --%s")
1973 % op.replace("_", "-"))
1973 % op.replace("_", "-"))
1974
1974
1975 def graphrevs(repo, nodes, opts):
1975 def graphrevs(repo, nodes, opts):
1976 limit = loglimit(opts)
1976 limit = loglimit(opts)
1977 nodes.reverse()
1977 nodes.reverse()
1978 if limit is not None:
1978 if limit is not None:
1979 nodes = nodes[:limit]
1979 nodes = nodes[:limit]
1980 return graphmod.nodes(repo, nodes)
1980 return graphmod.nodes(repo, nodes)
1981
1981
1982 def add(ui, repo, match, dryrun, listsubrepos, prefix, explicitonly):
1982 def add(ui, repo, match, dryrun, listsubrepos, prefix, explicitonly):
1983 join = lambda f: os.path.join(prefix, f)
1983 join = lambda f: os.path.join(prefix, f)
1984 bad = []
1984 bad = []
1985 oldbad = match.bad
1985 oldbad = match.bad
1986 match.bad = lambda x, y: bad.append(x) or oldbad(x, y)
1986 match.bad = lambda x, y: bad.append(x) or oldbad(x, y)
1987 names = []
1987 names = []
1988 wctx = repo[None]
1988 wctx = repo[None]
1989 cca = None
1989 cca = None
1990 abort, warn = scmutil.checkportabilityalert(ui)
1990 abort, warn = scmutil.checkportabilityalert(ui)
1991 if abort or warn:
1991 if abort or warn:
1992 cca = scmutil.casecollisionauditor(ui, abort, repo.dirstate)
1992 cca = scmutil.casecollisionauditor(ui, abort, repo.dirstate)
1993 for f in wctx.walk(match):
1993 for f in wctx.walk(match):
1994 exact = match.exact(f)
1994 exact = match.exact(f)
1995 if exact or not explicitonly and f not in wctx and repo.wvfs.lexists(f):
1995 if exact or not explicitonly and f not in wctx and repo.wvfs.lexists(f):
1996 if cca:
1996 if cca:
1997 cca(f)
1997 cca(f)
1998 names.append(f)
1998 names.append(f)
1999 if ui.verbose or not exact:
1999 if ui.verbose or not exact:
2000 ui.status(_('adding %s\n') % match.rel(f))
2000 ui.status(_('adding %s\n') % match.rel(f))
2001
2001
2002 for subpath in sorted(wctx.substate):
2002 for subpath in sorted(wctx.substate):
2003 sub = wctx.sub(subpath)
2003 sub = wctx.sub(subpath)
2004 try:
2004 try:
2005 submatch = matchmod.narrowmatcher(subpath, match)
2005 submatch = matchmod.narrowmatcher(subpath, match)
2006 if listsubrepos:
2006 if listsubrepos:
2007 bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix,
2007 bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix,
2008 False))
2008 False))
2009 else:
2009 else:
2010 bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix,
2010 bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix,
2011 True))
2011 True))
2012 except error.LookupError:
2012 except error.LookupError:
2013 ui.status(_("skipping missing subrepository: %s\n")
2013 ui.status(_("skipping missing subrepository: %s\n")
2014 % join(subpath))
2014 % join(subpath))
2015
2015
2016 if not dryrun:
2016 if not dryrun:
2017 rejected = wctx.add(names, prefix)
2017 rejected = wctx.add(names, prefix)
2018 bad.extend(f for f in rejected if f in match.files())
2018 bad.extend(f for f in rejected if f in match.files())
2019 return bad
2019 return bad
2020
2020
2021 def forget(ui, repo, match, prefix, explicitonly):
2021 def forget(ui, repo, match, prefix, explicitonly):
2022 join = lambda f: os.path.join(prefix, f)
2022 join = lambda f: os.path.join(prefix, f)
2023 bad = []
2023 bad = []
2024 oldbad = match.bad
2024 oldbad = match.bad
2025 match.bad = lambda x, y: bad.append(x) or oldbad(x, y)
2025 match.bad = lambda x, y: bad.append(x) or oldbad(x, y)
2026 wctx = repo[None]
2026 wctx = repo[None]
2027 forgot = []
2027 forgot = []
2028 s = repo.status(match=match, clean=True)
2028 s = repo.status(match=match, clean=True)
2029 forget = sorted(s[0] + s[1] + s[3] + s[6])
2029 forget = sorted(s[0] + s[1] + s[3] + s[6])
2030 if explicitonly:
2030 if explicitonly:
2031 forget = [f for f in forget if match.exact(f)]
2031 forget = [f for f in forget if match.exact(f)]
2032
2032
2033 for subpath in sorted(wctx.substate):
2033 for subpath in sorted(wctx.substate):
2034 sub = wctx.sub(subpath)
2034 sub = wctx.sub(subpath)
2035 try:
2035 try:
2036 submatch = matchmod.narrowmatcher(subpath, match)
2036 submatch = matchmod.narrowmatcher(subpath, match)
2037 subbad, subforgot = sub.forget(submatch, prefix)
2037 subbad, subforgot = sub.forget(submatch, prefix)
2038 bad.extend([subpath + '/' + f for f in subbad])
2038 bad.extend([subpath + '/' + f for f in subbad])
2039 forgot.extend([subpath + '/' + f for f in subforgot])
2039 forgot.extend([subpath + '/' + f for f in subforgot])
2040 except error.LookupError:
2040 except error.LookupError:
2041 ui.status(_("skipping missing subrepository: %s\n")
2041 ui.status(_("skipping missing subrepository: %s\n")
2042 % join(subpath))
2042 % join(subpath))
2043
2043
2044 if not explicitonly:
2044 if not explicitonly:
2045 for f in match.files():
2045 for f in match.files():
2046 if f not in repo.dirstate and not repo.wvfs.isdir(f):
2046 if f not in repo.dirstate and not repo.wvfs.isdir(f):
2047 if f not in forgot:
2047 if f not in forgot:
2048 if repo.wvfs.exists(f):
2048 if repo.wvfs.exists(f):
2049 ui.warn(_('not removing %s: '
2049 ui.warn(_('not removing %s: '
2050 'file is already untracked\n')
2050 'file is already untracked\n')
2051 % match.rel(f))
2051 % match.rel(f))
2052 bad.append(f)
2052 bad.append(f)
2053
2053
2054 for f in forget:
2054 for f in forget:
2055 if ui.verbose or not match.exact(f):
2055 if ui.verbose or not match.exact(f):
2056 ui.status(_('removing %s\n') % match.rel(f))
2056 ui.status(_('removing %s\n') % match.rel(f))
2057
2057
2058 rejected = wctx.forget(forget, prefix)
2058 rejected = wctx.forget(forget, prefix)
2059 bad.extend(f for f in rejected if f in match.files())
2059 bad.extend(f for f in rejected if f in match.files())
2060 forgot.extend(f for f in forget if f not in rejected)
2060 forgot.extend(f for f in forget if f not in rejected)
2061 return bad, forgot
2061 return bad, forgot
2062
2062
2063 def remove(ui, repo, m, prefix, after, force, subrepos):
2063 def remove(ui, repo, m, prefix, after, force, subrepos):
2064 join = lambda f: os.path.join(prefix, f)
2064 join = lambda f: os.path.join(prefix, f)
2065 ret = 0
2065 ret = 0
2066 s = repo.status(match=m, clean=True)
2066 s = repo.status(match=m, clean=True)
2067 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
2067 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
2068
2068
2069 wctx = repo[None]
2069 wctx = repo[None]
2070
2070
2071 for subpath in sorted(wctx.substate):
2071 for subpath in sorted(wctx.substate):
2072 def matchessubrepo(matcher, subpath):
2072 def matchessubrepo(matcher, subpath):
2073 if matcher.exact(subpath):
2073 if matcher.exact(subpath):
2074 return True
2074 return True
2075 for f in matcher.files():
2075 for f in matcher.files():
2076 if f.startswith(subpath):
2076 if f.startswith(subpath):
2077 return True
2077 return True
2078 return False
2078 return False
2079
2079
2080 if subrepos or matchessubrepo(m, subpath):
2080 if subrepos or matchessubrepo(m, subpath):
2081 sub = wctx.sub(subpath)
2081 sub = wctx.sub(subpath)
2082 try:
2082 try:
2083 submatch = matchmod.narrowmatcher(subpath, m)
2083 submatch = matchmod.narrowmatcher(subpath, m)
2084 if sub.removefiles(submatch, prefix, after, force, subrepos):
2084 if sub.removefiles(submatch, prefix, after, force, subrepos):
2085 ret = 1
2085 ret = 1
2086 except error.LookupError:
2086 except error.LookupError:
2087 ui.status(_("skipping missing subrepository: %s\n")
2087 ui.status(_("skipping missing subrepository: %s\n")
2088 % join(subpath))
2088 % join(subpath))
2089
2089
2090 # warn about failure to delete explicit files/dirs
2090 # warn about failure to delete explicit files/dirs
2091 for f in m.files():
2091 for f in m.files():
2092 def insubrepo():
2092 def insubrepo():
2093 for subpath in wctx.substate:
2093 for subpath in wctx.substate:
2094 if f.startswith(subpath):
2094 if f.startswith(subpath):
2095 return True
2095 return True
2096 return False
2096 return False
2097
2097
2098 if f in repo.dirstate or f in wctx.dirs() or f == '.' or insubrepo():
2098 if f in repo.dirstate or f in wctx.dirs() or f == '.' or insubrepo():
2099 continue
2099 continue
2100
2100
2101 if repo.wvfs.exists(f):
2101 if repo.wvfs.exists(f):
2102 if repo.wvfs.isdir(f):
2102 if repo.wvfs.isdir(f):
2103 ui.warn(_('not removing %s: no tracked files\n')
2103 ui.warn(_('not removing %s: no tracked files\n')
2104 % m.rel(f))
2104 % m.rel(f))
2105 else:
2105 else:
2106 ui.warn(_('not removing %s: file is untracked\n')
2106 ui.warn(_('not removing %s: file is untracked\n')
2107 % m.rel(f))
2107 % m.rel(f))
2108 # missing files will generate a warning elsewhere
2108 # missing files will generate a warning elsewhere
2109 ret = 1
2109 ret = 1
2110
2110
2111 if force:
2111 if force:
2112 list = modified + deleted + clean + added
2112 list = modified + deleted + clean + added
2113 elif after:
2113 elif after:
2114 list = deleted
2114 list = deleted
2115 for f in modified + added + clean:
2115 for f in modified + added + clean:
2116 ui.warn(_('not removing %s: file still exists\n') % m.rel(f))
2116 ui.warn(_('not removing %s: file still exists\n') % m.rel(f))
2117 ret = 1
2117 ret = 1
2118 else:
2118 else:
2119 list = deleted + clean
2119 list = deleted + clean
2120 for f in modified:
2120 for f in modified:
2121 ui.warn(_('not removing %s: file is modified (use -f'
2121 ui.warn(_('not removing %s: file is modified (use -f'
2122 ' to force removal)\n') % m.rel(f))
2122 ' to force removal)\n') % m.rel(f))
2123 ret = 1
2123 ret = 1
2124 for f in added:
2124 for f in added:
2125 ui.warn(_('not removing %s: file has been marked for add'
2125 ui.warn(_('not removing %s: file has been marked for add'
2126 ' (use forget to undo)\n') % m.rel(f))
2126 ' (use forget to undo)\n') % m.rel(f))
2127 ret = 1
2127 ret = 1
2128
2128
2129 for f in sorted(list):
2129 for f in sorted(list):
2130 if ui.verbose or not m.exact(f):
2130 if ui.verbose or not m.exact(f):
2131 ui.status(_('removing %s\n') % m.rel(f))
2131 ui.status(_('removing %s\n') % m.rel(f))
2132
2132
2133 wlock = repo.wlock()
2133 wlock = repo.wlock()
2134 try:
2134 try:
2135 if not after:
2135 if not after:
2136 for f in list:
2136 for f in list:
2137 if f in added:
2137 if f in added:
2138 continue # we never unlink added files on remove
2138 continue # we never unlink added files on remove
2139 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
2139 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
2140 repo[None].forget(list)
2140 repo[None].forget(list)
2141 finally:
2141 finally:
2142 wlock.release()
2142 wlock.release()
2143
2143
2144 return ret
2144 return ret
2145
2145
2146 def cat(ui, repo, ctx, matcher, prefix, **opts):
2146 def cat(ui, repo, ctx, matcher, prefix, **opts):
2147 err = 1
2147 err = 1
2148
2148
2149 def write(path):
2149 def write(path):
2150 fp = makefileobj(repo, opts.get('output'), ctx.node(),
2150 fp = makefileobj(repo, opts.get('output'), ctx.node(),
2151 pathname=os.path.join(prefix, path))
2151 pathname=os.path.join(prefix, path))
2152 data = ctx[path].data()
2152 data = ctx[path].data()
2153 if opts.get('decode'):
2153 if opts.get('decode'):
2154 data = repo.wwritedata(path, data)
2154 data = repo.wwritedata(path, data)
2155 fp.write(data)
2155 fp.write(data)
2156 fp.close()
2156 fp.close()
2157
2157
2158 # Automation often uses hg cat on single files, so special case it
2158 # Automation often uses hg cat on single files, so special case it
2159 # for performance to avoid the cost of parsing the manifest.
2159 # for performance to avoid the cost of parsing the manifest.
2160 if len(matcher.files()) == 1 and not matcher.anypats():
2160 if len(matcher.files()) == 1 and not matcher.anypats():
2161 file = matcher.files()[0]
2161 file = matcher.files()[0]
2162 mf = repo.manifest
2162 mf = repo.manifest
2163 mfnode = ctx._changeset[0]
2163 mfnode = ctx._changeset[0]
2164 if mf.find(mfnode, file)[0]:
2164 if mf.find(mfnode, file)[0]:
2165 write(file)
2165 write(file)
2166 return 0
2166 return 0
2167
2167
2168 # Don't warn about "missing" files that are really in subrepos
2168 # Don't warn about "missing" files that are really in subrepos
2169 bad = matcher.bad
2169 bad = matcher.bad
2170
2170
2171 def badfn(path, msg):
2171 def badfn(path, msg):
2172 for subpath in ctx.substate:
2172 for subpath in ctx.substate:
2173 if path.startswith(subpath):
2173 if path.startswith(subpath):
2174 return
2174 return
2175 bad(path, msg)
2175 bad(path, msg)
2176
2176
2177 matcher.bad = badfn
2177 matcher.bad = badfn
2178
2178
2179 for abs in ctx.walk(matcher):
2179 for abs in ctx.walk(matcher):
2180 write(abs)
2180 write(abs)
2181 err = 0
2181 err = 0
2182
2182
2183 matcher.bad = bad
2183 matcher.bad = bad
2184
2184
2185 for subpath in sorted(ctx.substate):
2185 for subpath in sorted(ctx.substate):
2186 sub = ctx.sub(subpath)
2186 sub = ctx.sub(subpath)
2187 try:
2187 try:
2188 submatch = matchmod.narrowmatcher(subpath, matcher)
2188 submatch = matchmod.narrowmatcher(subpath, matcher)
2189
2189
2190 if not sub.cat(submatch, os.path.join(prefix, sub._path),
2190 if not sub.cat(submatch, os.path.join(prefix, sub._path),
2191 **opts):
2191 **opts):
2192 err = 0
2192 err = 0
2193 except error.RepoLookupError:
2193 except error.RepoLookupError:
2194 ui.status(_("skipping missing subrepository: %s\n")
2194 ui.status(_("skipping missing subrepository: %s\n")
2195 % os.path.join(prefix, subpath))
2195 % os.path.join(prefix, subpath))
2196
2196
2197 return err
2197 return err
2198
2198
2199 def commit(ui, repo, commitfunc, pats, opts):
2199 def commit(ui, repo, commitfunc, pats, opts):
2200 '''commit the specified files or all outstanding changes'''
2200 '''commit the specified files or all outstanding changes'''
2201 date = opts.get('date')
2201 date = opts.get('date')
2202 if date:
2202 if date:
2203 opts['date'] = util.parsedate(date)
2203 opts['date'] = util.parsedate(date)
2204 message = logmessage(ui, opts)
2204 message = logmessage(ui, opts)
2205 matcher = scmutil.match(repo[None], pats, opts)
2205 matcher = scmutil.match(repo[None], pats, opts)
2206
2206
2207 # extract addremove carefully -- this function can be called from a command
2207 # extract addremove carefully -- this function can be called from a command
2208 # that doesn't support addremove
2208 # that doesn't support addremove
2209 if opts.get('addremove'):
2209 if opts.get('addremove'):
2210 if scmutil.addremove(repo, matcher, "", opts) != 0:
2210 if scmutil.addremove(repo, matcher, "", opts) != 0:
2211 raise util.Abort(
2211 raise util.Abort(
2212 _("failed to mark all new/missing files as added/removed"))
2212 _("failed to mark all new/missing files as added/removed"))
2213
2213
2214 return commitfunc(ui, repo, message, matcher, opts)
2214 return commitfunc(ui, repo, message, matcher, opts)
2215
2215
2216 def amend(ui, repo, commitfunc, old, extra, pats, opts):
2216 def amend(ui, repo, commitfunc, old, extra, pats, opts):
2217 # amend will reuse the existing user if not specified, but the obsolete
2217 # amend will reuse the existing user if not specified, but the obsolete
2218 # marker creation requires that the current user's name is specified.
2218 # marker creation requires that the current user's name is specified.
2219 if obsolete._enabled:
2219 if obsolete._enabled:
2220 ui.username() # raise exception if username not set
2220 ui.username() # raise exception if username not set
2221
2221
2222 ui.note(_('amending changeset %s\n') % old)
2222 ui.note(_('amending changeset %s\n') % old)
2223 base = old.p1()
2223 base = old.p1()
2224
2224
2225 wlock = lock = newid = None
2225 wlock = lock = newid = None
2226 try:
2226 try:
2227 wlock = repo.wlock()
2227 wlock = repo.wlock()
2228 lock = repo.lock()
2228 lock = repo.lock()
2229 tr = repo.transaction('amend')
2229 tr = repo.transaction('amend')
2230 try:
2230 try:
2231 # See if we got a message from -m or -l, if not, open the editor
2231 # See if we got a message from -m or -l, if not, open the editor
2232 # with the message of the changeset to amend
2232 # with the message of the changeset to amend
2233 message = logmessage(ui, opts)
2233 message = logmessage(ui, opts)
2234 # ensure logfile does not conflict with later enforcement of the
2234 # ensure logfile does not conflict with later enforcement of the
2235 # message. potential logfile content has been processed by
2235 # message. potential logfile content has been processed by
2236 # `logmessage` anyway.
2236 # `logmessage` anyway.
2237 opts.pop('logfile')
2237 opts.pop('logfile')
2238 # First, do a regular commit to record all changes in the working
2238 # First, do a regular commit to record all changes in the working
2239 # directory (if there are any)
2239 # directory (if there are any)
2240 ui.callhooks = False
2240 ui.callhooks = False
2241 currentbookmark = repo._bookmarkcurrent
2241 currentbookmark = repo._bookmarkcurrent
2242 try:
2242 try:
2243 repo._bookmarkcurrent = None
2243 repo._bookmarkcurrent = None
2244 opts['message'] = 'temporary amend commit for %s' % old
2244 opts['message'] = 'temporary amend commit for %s' % old
2245 node = commit(ui, repo, commitfunc, pats, opts)
2245 node = commit(ui, repo, commitfunc, pats, opts)
2246 finally:
2246 finally:
2247 repo._bookmarkcurrent = currentbookmark
2247 repo._bookmarkcurrent = currentbookmark
2248 ui.callhooks = True
2248 ui.callhooks = True
2249 ctx = repo[node]
2249 ctx = repo[node]
2250
2250
2251 # Participating changesets:
2251 # Participating changesets:
2252 #
2252 #
2253 # node/ctx o - new (intermediate) commit that contains changes
2253 # node/ctx o - new (intermediate) commit that contains changes
2254 # | from working dir to go into amending commit
2254 # | from working dir to go into amending commit
2255 # | (or a workingctx if there were no changes)
2255 # | (or a workingctx if there were no changes)
2256 # |
2256 # |
2257 # old o - changeset to amend
2257 # old o - changeset to amend
2258 # |
2258 # |
2259 # base o - parent of amending changeset
2259 # base o - parent of amending changeset
2260
2260
2261 # Update extra dict from amended commit (e.g. to preserve graft
2261 # Update extra dict from amended commit (e.g. to preserve graft
2262 # source)
2262 # source)
2263 extra.update(old.extra())
2263 extra.update(old.extra())
2264
2264
2265 # Also update it from the intermediate commit or from the wctx
2265 # Also update it from the intermediate commit or from the wctx
2266 extra.update(ctx.extra())
2266 extra.update(ctx.extra())
2267
2267
2268 if len(old.parents()) > 1:
2268 if len(old.parents()) > 1:
2269 # ctx.files() isn't reliable for merges, so fall back to the
2269 # ctx.files() isn't reliable for merges, so fall back to the
2270 # slower repo.status() method
2270 # slower repo.status() method
2271 files = set([fn for st in repo.status(base, old)[:3]
2271 files = set([fn for st in repo.status(base, old)[:3]
2272 for fn in st])
2272 for fn in st])
2273 else:
2273 else:
2274 files = set(old.files())
2274 files = set(old.files())
2275
2275
2276 # Second, we use either the commit we just did, or if there were no
2276 # Second, we use either the commit we just did, or if there were no
2277 # changes the parent of the working directory as the version of the
2277 # changes the parent of the working directory as the version of the
2278 # files in the final amend commit
2278 # files in the final amend commit
2279 if node:
2279 if node:
2280 ui.note(_('copying changeset %s to %s\n') % (ctx, base))
2280 ui.note(_('copying changeset %s to %s\n') % (ctx, base))
2281
2281
2282 user = ctx.user()
2282 user = ctx.user()
2283 date = ctx.date()
2283 date = ctx.date()
2284 # Recompute copies (avoid recording a -> b -> a)
2284 # Recompute copies (avoid recording a -> b -> a)
2285 copied = copies.pathcopies(base, ctx)
2285 copied = copies.pathcopies(base, ctx)
2286
2286
2287 # Prune files which were reverted by the updates: if old
2287 # Prune files which were reverted by the updates: if old
2288 # introduced file X and our intermediate commit, node,
2288 # introduced file X and our intermediate commit, node,
2289 # renamed that file, then those two files are the same and
2289 # renamed that file, then those two files are the same and
2290 # we can discard X from our list of files. Likewise if X
2290 # we can discard X from our list of files. Likewise if X
2291 # was deleted, it's no longer relevant
2291 # was deleted, it's no longer relevant
2292 files.update(ctx.files())
2292 files.update(ctx.files())
2293
2293
2294 def samefile(f):
2294 def samefile(f):
2295 if f in ctx.manifest():
2295 if f in ctx.manifest():
2296 a = ctx.filectx(f)
2296 a = ctx.filectx(f)
2297 if f in base.manifest():
2297 if f in base.manifest():
2298 b = base.filectx(f)
2298 b = base.filectx(f)
2299 return (not a.cmp(b)
2299 return (not a.cmp(b)
2300 and a.flags() == b.flags())
2300 and a.flags() == b.flags())
2301 else:
2301 else:
2302 return False
2302 return False
2303 else:
2303 else:
2304 return f not in base.manifest()
2304 return f not in base.manifest()
2305 files = [f for f in files if not samefile(f)]
2305 files = [f for f in files if not samefile(f)]
2306
2306
2307 def filectxfn(repo, ctx_, path):
2307 def filectxfn(repo, ctx_, path):
2308 try:
2308 try:
2309 fctx = ctx[path]
2309 fctx = ctx[path]
2310 flags = fctx.flags()
2310 flags = fctx.flags()
2311 mctx = context.memfilectx(repo,
2311 mctx = context.memfilectx(repo,
2312 fctx.path(), fctx.data(),
2312 fctx.path(), fctx.data(),
2313 islink='l' in flags,
2313 islink='l' in flags,
2314 isexec='x' in flags,
2314 isexec='x' in flags,
2315 copied=copied.get(path))
2315 copied=copied.get(path))
2316 return mctx
2316 return mctx
2317 except KeyError:
2317 except KeyError:
2318 return None
2318 return None
2319 else:
2319 else:
2320 ui.note(_('copying changeset %s to %s\n') % (old, base))
2320 ui.note(_('copying changeset %s to %s\n') % (old, base))
2321
2321
2322 # Use version of files as in the old cset
2322 # Use version of files as in the old cset
2323 def filectxfn(repo, ctx_, path):
2323 def filectxfn(repo, ctx_, path):
2324 try:
2324 try:
2325 return old.filectx(path)
2325 return old.filectx(path)
2326 except KeyError:
2326 except KeyError:
2327 return None
2327 return None
2328
2328
2329 user = opts.get('user') or old.user()
2329 user = opts.get('user') or old.user()
2330 date = opts.get('date') or old.date()
2330 date = opts.get('date') or old.date()
2331 editform = mergeeditform(old, 'commit.amend')
2331 editform = mergeeditform(old, 'commit.amend')
2332 editor = getcommiteditor(editform=editform, **opts)
2332 editor = getcommiteditor(editform=editform, **opts)
2333 if not message:
2333 if not message:
2334 editor = getcommiteditor(edit=True, editform=editform)
2334 editor = getcommiteditor(edit=True, editform=editform)
2335 message = old.description()
2335 message = old.description()
2336
2336
2337 pureextra = extra.copy()
2337 pureextra = extra.copy()
2338 extra['amend_source'] = old.hex()
2338 extra['amend_source'] = old.hex()
2339
2339
2340 new = context.memctx(repo,
2340 new = context.memctx(repo,
2341 parents=[base.node(), old.p2().node()],
2341 parents=[base.node(), old.p2().node()],
2342 text=message,
2342 text=message,
2343 files=files,
2343 files=files,
2344 filectxfn=filectxfn,
2344 filectxfn=filectxfn,
2345 user=user,
2345 user=user,
2346 date=date,
2346 date=date,
2347 extra=extra,
2347 extra=extra,
2348 editor=editor)
2348 editor=editor)
2349
2349
2350 newdesc = changelog.stripdesc(new.description())
2350 newdesc = changelog.stripdesc(new.description())
2351 if ((not node)
2351 if ((not node)
2352 and newdesc == old.description()
2352 and newdesc == old.description()
2353 and user == old.user()
2353 and user == old.user()
2354 and date == old.date()
2354 and date == old.date()
2355 and pureextra == old.extra()):
2355 and pureextra == old.extra()):
2356 # nothing changed. continuing here would create a new node
2356 # nothing changed. continuing here would create a new node
2357 # anyway because of the amend_source noise.
2357 # anyway because of the amend_source noise.
2358 #
2358 #
2359 # This not what we expect from amend.
2359 # This not what we expect from amend.
2360 return old.node()
2360 return old.node()
2361
2361
2362 ph = repo.ui.config('phases', 'new-commit', phases.draft)
2362 ph = repo.ui.config('phases', 'new-commit', phases.draft)
2363 try:
2363 try:
2364 if opts.get('secret'):
2364 if opts.get('secret'):
2365 commitphase = 'secret'
2365 commitphase = 'secret'
2366 else:
2366 else:
2367 commitphase = old.phase()
2367 commitphase = old.phase()
2368 repo.ui.setconfig('phases', 'new-commit', commitphase, 'amend')
2368 repo.ui.setconfig('phases', 'new-commit', commitphase, 'amend')
2369 newid = repo.commitctx(new)
2369 newid = repo.commitctx(new)
2370 finally:
2370 finally:
2371 repo.ui.setconfig('phases', 'new-commit', ph, 'amend')
2371 repo.ui.setconfig('phases', 'new-commit', ph, 'amend')
2372 if newid != old.node():
2372 if newid != old.node():
2373 # Reroute the working copy parent to the new changeset
2373 # Reroute the working copy parent to the new changeset
2374 repo.setparents(newid, nullid)
2374 repo.setparents(newid, nullid)
2375
2375
2376 # Move bookmarks from old parent to amend commit
2376 # Move bookmarks from old parent to amend commit
2377 bms = repo.nodebookmarks(old.node())
2377 bms = repo.nodebookmarks(old.node())
2378 if bms:
2378 if bms:
2379 marks = repo._bookmarks
2379 marks = repo._bookmarks
2380 for bm in bms:
2380 for bm in bms:
2381 marks[bm] = newid
2381 marks[bm] = newid
2382 marks.write()
2382 marks.write()
2383 #commit the whole amend process
2383 #commit the whole amend process
2384 createmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt)
2384 createmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt)
2385 if createmarkers and newid != old.node():
2385 if createmarkers and newid != old.node():
2386 # mark the new changeset as successor of the rewritten one
2386 # mark the new changeset as successor of the rewritten one
2387 new = repo[newid]
2387 new = repo[newid]
2388 obs = [(old, (new,))]
2388 obs = [(old, (new,))]
2389 if node:
2389 if node:
2390 obs.append((ctx, ()))
2390 obs.append((ctx, ()))
2391
2391
2392 obsolete.createmarkers(repo, obs)
2392 obsolete.createmarkers(repo, obs)
2393 tr.close()
2393 tr.close()
2394 finally:
2394 finally:
2395 tr.release()
2395 tr.release()
2396 if not createmarkers and newid != old.node():
2396 if not createmarkers and newid != old.node():
2397 # Strip the intermediate commit (if there was one) and the amended
2397 # Strip the intermediate commit (if there was one) and the amended
2398 # commit
2398 # commit
2399 if node:
2399 if node:
2400 ui.note(_('stripping intermediate changeset %s\n') % ctx)
2400 ui.note(_('stripping intermediate changeset %s\n') % ctx)
2401 ui.note(_('stripping amended changeset %s\n') % old)
2401 ui.note(_('stripping amended changeset %s\n') % old)
2402 repair.strip(ui, repo, old.node(), topic='amend-backup')
2402 repair.strip(ui, repo, old.node(), topic='amend-backup')
2403 finally:
2403 finally:
2404 if newid is None:
2404 if newid is None:
2405 repo.dirstate.invalidate()
2405 repo.dirstate.invalidate()
2406 lockmod.release(lock, wlock)
2406 lockmod.release(lock, wlock)
2407 return newid
2407 return newid
2408
2408
2409 def commiteditor(repo, ctx, subs, editform=''):
2409 def commiteditor(repo, ctx, subs, editform=''):
2410 if ctx.description():
2410 if ctx.description():
2411 return ctx.description()
2411 return ctx.description()
2412 return commitforceeditor(repo, ctx, subs, editform=editform)
2412 return commitforceeditor(repo, ctx, subs, editform=editform)
2413
2413
2414 def commitforceeditor(repo, ctx, subs, finishdesc=None, extramsg=None,
2414 def commitforceeditor(repo, ctx, subs, finishdesc=None, extramsg=None,
2415 editform=''):
2415 editform=''):
2416 if not extramsg:
2416 if not extramsg:
2417 extramsg = _("Leave message empty to abort commit.")
2417 extramsg = _("Leave message empty to abort commit.")
2418
2418
2419 forms = [e for e in editform.split('.') if e]
2419 forms = [e for e in editform.split('.') if e]
2420 forms.insert(0, 'changeset')
2420 forms.insert(0, 'changeset')
2421 while forms:
2421 while forms:
2422 tmpl = repo.ui.config('committemplate', '.'.join(forms))
2422 tmpl = repo.ui.config('committemplate', '.'.join(forms))
2423 if tmpl:
2423 if tmpl:
2424 committext = buildcommittemplate(repo, ctx, subs, extramsg, tmpl)
2424 committext = buildcommittemplate(repo, ctx, subs, extramsg, tmpl)
2425 break
2425 break
2426 forms.pop()
2426 forms.pop()
2427 else:
2427 else:
2428 committext = buildcommittext(repo, ctx, subs, extramsg)
2428 committext = buildcommittext(repo, ctx, subs, extramsg)
2429
2429
2430 # run editor in the repository root
2430 # run editor in the repository root
2431 olddir = os.getcwd()
2431 olddir = os.getcwd()
2432 os.chdir(repo.root)
2432 os.chdir(repo.root)
2433 text = repo.ui.edit(committext, ctx.user(), ctx.extra(), editform=editform)
2433 text = repo.ui.edit(committext, ctx.user(), ctx.extra(), editform=editform)
2434 text = re.sub("(?m)^HG:.*(\n|$)", "", text)
2434 text = re.sub("(?m)^HG:.*(\n|$)", "", text)
2435 os.chdir(olddir)
2435 os.chdir(olddir)
2436
2436
2437 if finishdesc:
2437 if finishdesc:
2438 text = finishdesc(text)
2438 text = finishdesc(text)
2439 if not text.strip():
2439 if not text.strip():
2440 raise util.Abort(_("empty commit message"))
2440 raise util.Abort(_("empty commit message"))
2441
2441
2442 return text
2442 return text
2443
2443
2444 def buildcommittemplate(repo, ctx, subs, extramsg, tmpl):
2444 def buildcommittemplate(repo, ctx, subs, extramsg, tmpl):
2445 ui = repo.ui
2445 ui = repo.ui
2446 tmpl, mapfile = gettemplate(ui, tmpl, None)
2446 tmpl, mapfile = gettemplate(ui, tmpl, None)
2447
2447
2448 try:
2448 try:
2449 t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False)
2449 t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False)
2450 except SyntaxError, inst:
2450 except SyntaxError, inst:
2451 raise util.Abort(inst.args[0])
2451 raise util.Abort(inst.args[0])
2452
2452
2453 for k, v in repo.ui.configitems('committemplate'):
2453 for k, v in repo.ui.configitems('committemplate'):
2454 if k != 'changeset':
2454 if k != 'changeset':
2455 t.t.cache[k] = v
2455 t.t.cache[k] = v
2456
2456
2457 if not extramsg:
2457 if not extramsg:
2458 extramsg = '' # ensure that extramsg is string
2458 extramsg = '' # ensure that extramsg is string
2459
2459
2460 ui.pushbuffer()
2460 ui.pushbuffer()
2461 t.show(ctx, extramsg=extramsg)
2461 t.show(ctx, extramsg=extramsg)
2462 return ui.popbuffer()
2462 return ui.popbuffer()
2463
2463
2464 def buildcommittext(repo, ctx, subs, extramsg):
2464 def buildcommittext(repo, ctx, subs, extramsg):
2465 edittext = []
2465 edittext = []
2466 modified, added, removed = ctx.modified(), ctx.added(), ctx.removed()
2466 modified, added, removed = ctx.modified(), ctx.added(), ctx.removed()
2467 if ctx.description():
2467 if ctx.description():
2468 edittext.append(ctx.description())
2468 edittext.append(ctx.description())
2469 edittext.append("")
2469 edittext.append("")
2470 edittext.append("") # Empty line between message and comments.
2470 edittext.append("") # Empty line between message and comments.
2471 edittext.append(_("HG: Enter commit message."
2471 edittext.append(_("HG: Enter commit message."
2472 " Lines beginning with 'HG:' are removed."))
2472 " Lines beginning with 'HG:' are removed."))
2473 edittext.append("HG: %s" % extramsg)
2473 edittext.append("HG: %s" % extramsg)
2474 edittext.append("HG: --")
2474 edittext.append("HG: --")
2475 edittext.append(_("HG: user: %s") % ctx.user())
2475 edittext.append(_("HG: user: %s") % ctx.user())
2476 if ctx.p2():
2476 if ctx.p2():
2477 edittext.append(_("HG: branch merge"))
2477 edittext.append(_("HG: branch merge"))
2478 if ctx.branch():
2478 if ctx.branch():
2479 edittext.append(_("HG: branch '%s'") % ctx.branch())
2479 edittext.append(_("HG: branch '%s'") % ctx.branch())
2480 if bookmarks.iscurrent(repo):
2480 if bookmarks.iscurrent(repo):
2481 edittext.append(_("HG: bookmark '%s'") % repo._bookmarkcurrent)
2481 edittext.append(_("HG: bookmark '%s'") % repo._bookmarkcurrent)
2482 edittext.extend([_("HG: subrepo %s") % s for s in subs])
2482 edittext.extend([_("HG: subrepo %s") % s for s in subs])
2483 edittext.extend([_("HG: added %s") % f for f in added])
2483 edittext.extend([_("HG: added %s") % f for f in added])
2484 edittext.extend([_("HG: changed %s") % f for f in modified])
2484 edittext.extend([_("HG: changed %s") % f for f in modified])
2485 edittext.extend([_("HG: removed %s") % f for f in removed])
2485 edittext.extend([_("HG: removed %s") % f for f in removed])
2486 if not added and not modified and not removed:
2486 if not added and not modified and not removed:
2487 edittext.append(_("HG: no files changed"))
2487 edittext.append(_("HG: no files changed"))
2488 edittext.append("")
2488 edittext.append("")
2489
2489
2490 return "\n".join(edittext)
2490 return "\n".join(edittext)
2491
2491
2492 def commitstatus(repo, node, branch, bheads=None, opts={}):
2492 def commitstatus(repo, node, branch, bheads=None, opts={}):
2493 ctx = repo[node]
2493 ctx = repo[node]
2494 parents = ctx.parents()
2494 parents = ctx.parents()
2495
2495
2496 if (not opts.get('amend') and bheads and node not in bheads and not
2496 if (not opts.get('amend') and bheads and node not in bheads and not
2497 [x for x in parents if x.node() in bheads and x.branch() == branch]):
2497 [x for x in parents if x.node() in bheads and x.branch() == branch]):
2498 repo.ui.status(_('created new head\n'))
2498 repo.ui.status(_('created new head\n'))
2499 # The message is not printed for initial roots. For the other
2499 # The message is not printed for initial roots. For the other
2500 # changesets, it is printed in the following situations:
2500 # changesets, it is printed in the following situations:
2501 #
2501 #
2502 # Par column: for the 2 parents with ...
2502 # Par column: for the 2 parents with ...
2503 # N: null or no parent
2503 # N: null or no parent
2504 # B: parent is on another named branch
2504 # B: parent is on another named branch
2505 # C: parent is a regular non head changeset
2505 # C: parent is a regular non head changeset
2506 # H: parent was a branch head of the current branch
2506 # H: parent was a branch head of the current branch
2507 # Msg column: whether we print "created new head" message
2507 # Msg column: whether we print "created new head" message
2508 # In the following, it is assumed that there already exists some
2508 # In the following, it is assumed that there already exists some
2509 # initial branch heads of the current branch, otherwise nothing is
2509 # initial branch heads of the current branch, otherwise nothing is
2510 # printed anyway.
2510 # printed anyway.
2511 #
2511 #
2512 # Par Msg Comment
2512 # Par Msg Comment
2513 # N N y additional topo root
2513 # N N y additional topo root
2514 #
2514 #
2515 # B N y additional branch root
2515 # B N y additional branch root
2516 # C N y additional topo head
2516 # C N y additional topo head
2517 # H N n usual case
2517 # H N n usual case
2518 #
2518 #
2519 # B B y weird additional branch root
2519 # B B y weird additional branch root
2520 # C B y branch merge
2520 # C B y branch merge
2521 # H B n merge with named branch
2521 # H B n merge with named branch
2522 #
2522 #
2523 # C C y additional head from merge
2523 # C C y additional head from merge
2524 # C H n merge with a head
2524 # C H n merge with a head
2525 #
2525 #
2526 # H H n head merge: head count decreases
2526 # H H n head merge: head count decreases
2527
2527
2528 if not opts.get('close_branch'):
2528 if not opts.get('close_branch'):
2529 for r in parents:
2529 for r in parents:
2530 if r.closesbranch() and r.branch() == branch:
2530 if r.closesbranch() and r.branch() == branch:
2531 repo.ui.status(_('reopening closed branch head %d\n') % r)
2531 repo.ui.status(_('reopening closed branch head %d\n') % r)
2532
2532
2533 if repo.ui.debugflag:
2533 if repo.ui.debugflag:
2534 repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex()))
2534 repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex()))
2535 elif repo.ui.verbose:
2535 elif repo.ui.verbose:
2536 repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx))
2536 repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx))
2537
2537
2538 def revert(ui, repo, ctx, parents, *pats, **opts):
2538 def revert(ui, repo, ctx, parents, *pats, **opts):
2539 parent, p2 = parents
2539 parent, p2 = parents
2540 node = ctx.node()
2540 node = ctx.node()
2541
2541
2542 mf = ctx.manifest()
2542 mf = ctx.manifest()
2543 if node == p2:
2543 if node == p2:
2544 parent = p2
2544 parent = p2
2545 if node == parent:
2545 if node == parent:
2546 pmf = mf
2546 pmf = mf
2547 else:
2547 else:
2548 pmf = None
2548 pmf = None
2549
2549
2550 # need all matching names in dirstate and manifest of target rev,
2550 # need all matching names in dirstate and manifest of target rev,
2551 # so have to walk both. do not print errors if files exist in one
2551 # so have to walk both. do not print errors if files exist in one
2552 # but not other.
2552 # but not other.
2553
2553
2554 # `names` is a mapping for all elements in working copy and target revision
2554 # `names` is a mapping for all elements in working copy and target revision
2555 # The mapping is in the form:
2555 # The mapping is in the form:
2556 # <asb path in repo> -> (<path from CWD>, <exactly specified by matcher?>)
2556 # <asb path in repo> -> (<path from CWD>, <exactly specified by matcher?>)
2557 names = {}
2557 names = {}
2558
2558
2559 wlock = repo.wlock()
2559 wlock = repo.wlock()
2560 try:
2560 try:
2561 ## filling of the `names` mapping
2561 ## filling of the `names` mapping
2562 # walk dirstate to fill `names`
2562 # walk dirstate to fill `names`
2563
2563
2564 m = scmutil.match(repo[None], pats, opts)
2564 m = scmutil.match(repo[None], pats, opts)
2565 if not m.always() or node != parent:
2565 if not m.always() or node != parent:
2566 m.bad = lambda x, y: False
2566 m.bad = lambda x, y: False
2567 for abs in repo.walk(m):
2567 for abs in repo.walk(m):
2568 names[abs] = m.rel(abs), m.exact(abs)
2568 names[abs] = m.rel(abs), m.exact(abs)
2569
2569
2570 # walk target manifest to fill `names`
2570 # walk target manifest to fill `names`
2571
2571
2572 def badfn(path, msg):
2572 def badfn(path, msg):
2573 if path in names:
2573 if path in names:
2574 return
2574 return
2575 if path in ctx.substate:
2575 if path in ctx.substate:
2576 return
2576 return
2577 path_ = path + '/'
2577 path_ = path + '/'
2578 for f in names:
2578 for f in names:
2579 if f.startswith(path_):
2579 if f.startswith(path_):
2580 return
2580 return
2581 ui.warn("%s: %s\n" % (m.rel(path), msg))
2581 ui.warn("%s: %s\n" % (m.rel(path), msg))
2582
2582
2583 m = scmutil.match(ctx, pats, opts)
2583 m = scmutil.match(ctx, pats, opts)
2584 m.bad = badfn
2584 m.bad = badfn
2585 for abs in ctx.walk(m):
2585 for abs in ctx.walk(m):
2586 if abs not in names:
2586 if abs not in names:
2587 names[abs] = m.rel(abs), m.exact(abs)
2587 names[abs] = m.rel(abs), m.exact(abs)
2588
2588
2589 # Find status of all file in `names`.
2589 # Find status of all file in `names`.
2590 m = scmutil.matchfiles(repo, names)
2590 m = scmutil.matchfiles(repo, names)
2591
2591
2592 changes = repo.status(node1=node, match=m,
2592 changes = repo.status(node1=node, match=m,
2593 unknown=True, ignored=True, clean=True)
2593 unknown=True, ignored=True, clean=True)
2594 else:
2594 else:
2595 changes = repo.status(match=m)
2595 changes = repo.status(match=m)
2596 for kind in changes:
2596 for kind in changes:
2597 for abs in kind:
2597 for abs in kind:
2598 names[abs] = m.rel(abs), m.exact(abs)
2598 names[abs] = m.rel(abs), m.exact(abs)
2599
2599
2600 m = scmutil.matchfiles(repo, names)
2600 m = scmutil.matchfiles(repo, names)
2601
2601
2602 modified = set(changes.modified)
2602 modified = set(changes.modified)
2603 added = set(changes.added)
2603 added = set(changes.added)
2604 removed = set(changes.removed)
2604 removed = set(changes.removed)
2605 _deleted = set(changes.deleted)
2605 _deleted = set(changes.deleted)
2606 unknown = set(changes.unknown)
2606 unknown = set(changes.unknown)
2607 unknown.update(changes.ignored)
2607 unknown.update(changes.ignored)
2608 clean = set(changes.clean)
2608 clean = set(changes.clean)
2609 modadded = set()
2609 modadded = set()
2610
2610
2611 # split between files known in target manifest and the others
2611 # split between files known in target manifest and the others
2612 smf = set(mf)
2612 smf = set(mf)
2613
2613
2614 # determine the exact nature of the deleted changesets
2614 # determine the exact nature of the deleted changesets
2615 deladded = _deleted - smf
2615 deladded = _deleted - smf
2616 deleted = _deleted - deladded
2616 deleted = _deleted - deladded
2617
2617
2618 # We need to account for the state of file in the dirstate.
2618 # We need to account for the state of file in the dirstate.
2619 #
2619 #
2620 # Even, when we revert against something else than parent. This will
2620 # Even, when we revert against something else than parent. This will
2621 # slightly alter the behavior of revert (doing back up or not, delete
2621 # slightly alter the behavior of revert (doing back up or not, delete
2622 # or just forget etc).
2622 # or just forget etc).
2623 if parent == node:
2623 if parent == node:
2624 dsmodified = modified
2624 dsmodified = modified
2625 dsadded = added
2625 dsadded = added
2626 dsremoved = removed
2626 dsremoved = removed
2627 # store all local modifications, useful later for rename detection
2627 # store all local modifications, useful later for rename detection
2628 localchanges = dsmodified | dsadded
2628 localchanges = dsmodified | dsadded
2629 modified, added, removed = set(), set(), set()
2629 modified, added, removed = set(), set(), set()
2630 else:
2630 else:
2631 changes = repo.status(node1=parent, match=m)
2631 changes = repo.status(node1=parent, match=m)
2632 dsmodified = set(changes.modified)
2632 dsmodified = set(changes.modified)
2633 dsadded = set(changes.added)
2633 dsadded = set(changes.added)
2634 dsremoved = set(changes.removed)
2634 dsremoved = set(changes.removed)
2635 # store all local modifications, useful later for rename detection
2635 # store all local modifications, useful later for rename detection
2636 localchanges = dsmodified | dsadded
2636 localchanges = dsmodified | dsadded
2637
2637
2638 # only take into account for removes between wc and target
2638 # only take into account for removes between wc and target
2639 clean |= dsremoved - removed
2639 clean |= dsremoved - removed
2640 dsremoved &= removed
2640 dsremoved &= removed
2641 # distinct between dirstate remove and other
2641 # distinct between dirstate remove and other
2642 removed -= dsremoved
2642 removed -= dsremoved
2643
2643
2644 modadded = added & dsmodified
2644 modadded = added & dsmodified
2645 added -= modadded
2645 added -= modadded
2646
2646
2647 # tell newly modified apart.
2647 # tell newly modified apart.
2648 dsmodified &= modified
2648 dsmodified &= modified
2649 dsmodified |= modified & dsadded # dirstate added may needs backup
2649 dsmodified |= modified & dsadded # dirstate added may needs backup
2650 modified -= dsmodified
2650 modified -= dsmodified
2651
2651
2652 # We need to wait for some post-processing to update this set
2652 # We need to wait for some post-processing to update this set
2653 # before making the distinction. The dirstate will be used for
2653 # before making the distinction. The dirstate will be used for
2654 # that purpose.
2654 # that purpose.
2655 dsadded = added
2655 dsadded = added
2656
2656
2657 # in case of merge, files that are actually added can be reported as
2657 # in case of merge, files that are actually added can be reported as
2658 # modified, we need to post process the result
2658 # modified, we need to post process the result
2659 if p2 != nullid:
2659 if p2 != nullid:
2660 if pmf is None:
2660 if pmf is None:
2661 # only need parent manifest in the merge case,
2661 # only need parent manifest in the merge case,
2662 # so do not read by default
2662 # so do not read by default
2663 pmf = repo[parent].manifest()
2663 pmf = repo[parent].manifest()
2664 mergeadd = dsmodified - set(pmf)
2664 mergeadd = dsmodified - set(pmf)
2665 dsadded |= mergeadd
2665 dsadded |= mergeadd
2666 dsmodified -= mergeadd
2666 dsmodified -= mergeadd
2667
2667
2668 # if f is a rename, update `names` to also revert the source
2668 # if f is a rename, update `names` to also revert the source
2669 cwd = repo.getcwd()
2669 cwd = repo.getcwd()
2670 for f in localchanges:
2670 for f in localchanges:
2671 src = repo.dirstate.copied(f)
2671 src = repo.dirstate.copied(f)
2672 # XXX should we check for rename down to target node?
2672 # XXX should we check for rename down to target node?
2673 if src and src not in names and repo.dirstate[src] == 'r':
2673 if src and src not in names and repo.dirstate[src] == 'r':
2674 dsremoved.add(src)
2674 dsremoved.add(src)
2675 names[src] = (repo.pathto(src, cwd), True)
2675 names[src] = (repo.pathto(src, cwd), True)
2676
2676
2677 # distinguish between file to forget and the other
2677 # distinguish between file to forget and the other
2678 added = set()
2678 added = set()
2679 for abs in dsadded:
2679 for abs in dsadded:
2680 if repo.dirstate[abs] != 'a':
2680 if repo.dirstate[abs] != 'a':
2681 added.add(abs)
2681 added.add(abs)
2682 dsadded -= added
2682 dsadded -= added
2683
2683
2684 for abs in deladded:
2684 for abs in deladded:
2685 if repo.dirstate[abs] == 'a':
2685 if repo.dirstate[abs] == 'a':
2686 dsadded.add(abs)
2686 dsadded.add(abs)
2687 deladded -= dsadded
2687 deladded -= dsadded
2688
2688
2689 # For files marked as removed, we check if an unknown file is present at
2689 # For files marked as removed, we check if an unknown file is present at
2690 # the same path. If a such file exists it may need to be backed up.
2690 # the same path. If a such file exists it may need to be backed up.
2691 # Making the distinction at this stage helps have simpler backup
2691 # Making the distinction at this stage helps have simpler backup
2692 # logic.
2692 # logic.
2693 removunk = set()
2693 removunk = set()
2694 for abs in removed:
2694 for abs in removed:
2695 target = repo.wjoin(abs)
2695 target = repo.wjoin(abs)
2696 if os.path.lexists(target):
2696 if os.path.lexists(target):
2697 removunk.add(abs)
2697 removunk.add(abs)
2698 removed -= removunk
2698 removed -= removunk
2699
2699
2700 dsremovunk = set()
2700 dsremovunk = set()
2701 for abs in dsremoved:
2701 for abs in dsremoved:
2702 target = repo.wjoin(abs)
2702 target = repo.wjoin(abs)
2703 if os.path.lexists(target):
2703 if os.path.lexists(target):
2704 dsremovunk.add(abs)
2704 dsremovunk.add(abs)
2705 dsremoved -= dsremovunk
2705 dsremoved -= dsremovunk
2706
2706
2707 # action to be actually performed by revert
2707 # action to be actually performed by revert
2708 # (<list of file>, message>) tuple
2708 # (<list of file>, message>) tuple
2709 actions = {'revert': ([], _('reverting %s\n')),
2709 actions = {'revert': ([], _('reverting %s\n')),
2710 'add': ([], _('adding %s\n')),
2710 'add': ([], _('adding %s\n')),
2711 'remove': ([], _('removing %s\n')),
2711 'remove': ([], _('removing %s\n')),
2712 'drop': ([], _('removing %s\n')),
2712 'drop': ([], _('removing %s\n')),
2713 'forget': ([], _('forgetting %s\n')),
2713 'forget': ([], _('forgetting %s\n')),
2714 'undelete': ([], _('undeleting %s\n')),
2714 'undelete': ([], _('undeleting %s\n')),
2715 'noop': (None, _('no changes needed to %s\n')),
2715 'noop': (None, _('no changes needed to %s\n')),
2716 'unknown': (None, _('file not managed: %s\n')),
2716 'unknown': (None, _('file not managed: %s\n')),
2717 }
2717 }
2718
2718
2719 # "constant" that convey the backup strategy.
2719 # "constant" that convey the backup strategy.
2720 # All set to `discard` if `no-backup` is set do avoid checking
2720 # All set to `discard` if `no-backup` is set do avoid checking
2721 # no_backup lower in the code.
2721 # no_backup lower in the code.
2722 # These values are ordered for comparison purposes
2722 # These values are ordered for comparison purposes
2723 backup = 2 # unconditionally do backup
2723 backup = 2 # unconditionally do backup
2724 check = 1 # check if the existing file differs from target
2724 check = 1 # check if the existing file differs from target
2725 discard = 0 # never do backup
2725 discard = 0 # never do backup
2726 if opts.get('no_backup'):
2726 if opts.get('no_backup'):
2727 backup = check = discard
2727 backup = check = discard
2728
2728
2729 backupanddel = actions['remove']
2729 backupanddel = actions['remove']
2730 if not opts.get('no_backup'):
2730 if not opts.get('no_backup'):
2731 backupanddel = actions['drop']
2731 backupanddel = actions['drop']
2732
2732
2733 disptable = (
2733 disptable = (
2734 # dispatch table:
2734 # dispatch table:
2735 # file state
2735 # file state
2736 # action
2736 # action
2737 # make backup
2737 # make backup
2738
2738
2739 ## Sets that results that will change file on disk
2739 ## Sets that results that will change file on disk
2740 # Modified compared to target, no local change
2740 # Modified compared to target, no local change
2741 (modified, actions['revert'], discard),
2741 (modified, actions['revert'], discard),
2742 # Modified compared to target, but local file is deleted
2742 # Modified compared to target, but local file is deleted
2743 (deleted, actions['revert'], discard),
2743 (deleted, actions['revert'], discard),
2744 # Modified compared to target, local change
2744 # Modified compared to target, local change
2745 (dsmodified, actions['revert'], backup),
2745 (dsmodified, actions['revert'], backup),
2746 # Added since target
2746 # Added since target
2747 (added, actions['remove'], discard),
2747 (added, actions['remove'], discard),
2748 # Added in working directory
2748 # Added in working directory
2749 (dsadded, actions['forget'], discard),
2749 (dsadded, actions['forget'], discard),
2750 # Added since target, have local modification
2750 # Added since target, have local modification
2751 (modadded, backupanddel, backup),
2751 (modadded, backupanddel, backup),
2752 # Added since target but file is missing in working directory
2752 # Added since target but file is missing in working directory
2753 (deladded, actions['drop'], discard),
2753 (deladded, actions['drop'], discard),
2754 # Removed since target, before working copy parent
2754 # Removed since target, before working copy parent
2755 (removed, actions['add'], discard),
2755 (removed, actions['add'], discard),
2756 # Same as `removed` but an unknown file exists at the same path
2756 # Same as `removed` but an unknown file exists at the same path
2757 (removunk, actions['add'], check),
2757 (removunk, actions['add'], check),
2758 # Removed since targe, marked as such in working copy parent
2758 # Removed since targe, marked as such in working copy parent
2759 (dsremoved, actions['undelete'], discard),
2759 (dsremoved, actions['undelete'], discard),
2760 # Same as `dsremoved` but an unknown file exists at the same path
2760 # Same as `dsremoved` but an unknown file exists at the same path
2761 (dsremovunk, actions['undelete'], check),
2761 (dsremovunk, actions['undelete'], check),
2762 ## the following sets does not result in any file changes
2762 ## the following sets does not result in any file changes
2763 # File with no modification
2763 # File with no modification
2764 (clean, actions['noop'], discard),
2764 (clean, actions['noop'], discard),
2765 # Existing file, not tracked anywhere
2765 # Existing file, not tracked anywhere
2766 (unknown, actions['unknown'], discard),
2766 (unknown, actions['unknown'], discard),
2767 )
2767 )
2768
2768
2769 needdata = ('revert', 'add', 'undelete')
2769 needdata = ('revert', 'add', 'undelete')
2770 _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata])
2770 _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata])
2771
2771
2772 wctx = repo[None]
2772 wctx = repo[None]
2773 for abs, (rel, exact) in sorted(names.items()):
2773 for abs, (rel, exact) in sorted(names.items()):
2774 # target file to be touch on disk (relative to cwd)
2774 # target file to be touch on disk (relative to cwd)
2775 target = repo.wjoin(abs)
2775 target = repo.wjoin(abs)
2776 # search the entry in the dispatch table.
2776 # search the entry in the dispatch table.
2777 # if the file is in any of these sets, it was touched in the working
2777 # if the file is in any of these sets, it was touched in the working
2778 # directory parent and we are sure it needs to be reverted.
2778 # directory parent and we are sure it needs to be reverted.
2779 for table, (xlist, msg), dobackup in disptable:
2779 for table, (xlist, msg), dobackup in disptable:
2780 if abs not in table:
2780 if abs not in table:
2781 continue
2781 continue
2782 if xlist is not None:
2782 if xlist is not None:
2783 xlist.append(abs)
2783 xlist.append(abs)
2784 if dobackup and (backup <= dobackup
2784 if dobackup and (backup <= dobackup
2785 or wctx[abs].cmp(ctx[abs])):
2785 or wctx[abs].cmp(ctx[abs])):
2786 bakname = "%s.orig" % rel
2786 bakname = "%s.orig" % rel
2787 ui.note(_('saving current version of %s as %s\n') %
2787 ui.note(_('saving current version of %s as %s\n') %
2788 (rel, bakname))
2788 (rel, bakname))
2789 if not opts.get('dry_run'):
2789 if not opts.get('dry_run'):
2790 util.rename(target, bakname)
2790 util.rename(target, bakname)
2791 if ui.verbose or not exact:
2791 if ui.verbose or not exact:
2792 if not isinstance(msg, basestring):
2792 if not isinstance(msg, basestring):
2793 msg = msg(abs)
2793 msg = msg(abs)
2794 ui.status(msg % rel)
2794 ui.status(msg % rel)
2795 elif exact:
2795 elif exact:
2796 ui.warn(msg % rel)
2796 ui.warn(msg % rel)
2797 break
2797 break
2798
2798
2799
2799
2800 if not opts.get('dry_run'):
2800 if not opts.get('dry_run'):
2801 _performrevert(repo, parents, ctx, actions)
2801 _performrevert(repo, parents, ctx, actions)
2802
2802
2803 # get the list of subrepos that must be reverted
2803 # get the list of subrepos that must be reverted
2804 subrepomatch = scmutil.match(ctx, pats, opts)
2804 subrepomatch = scmutil.match(ctx, pats, opts)
2805 targetsubs = sorted(s for s in ctx.substate if subrepomatch(s))
2805 targetsubs = sorted(s for s in ctx.substate if subrepomatch(s))
2806
2806
2807 if targetsubs:
2807 if targetsubs:
2808 # Revert the subrepos on the revert list
2808 # Revert the subrepos on the revert list
2809 for sub in targetsubs:
2809 for sub in targetsubs:
2810 ctx.sub(sub).revert(ctx.substate[sub], *pats, **opts)
2810 ctx.sub(sub).revert(ctx.substate[sub], *pats, **opts)
2811 finally:
2811 finally:
2812 wlock.release()
2812 wlock.release()
2813
2813
2814 def _revertprefetch(repo, ctx, *files):
2814 def _revertprefetch(repo, ctx, *files):
2815 """Let extension changing the storage layer prefetch content"""
2815 """Let extension changing the storage layer prefetch content"""
2816 pass
2816 pass
2817
2817
2818 def _performrevert(repo, parents, ctx, actions):
2818 def _performrevert(repo, parents, ctx, actions):
2819 """function that actually perform all the actions computed for revert
2819 """function that actually perform all the actions computed for revert
2820
2820
2821 This is an independent function to let extension to plug in and react to
2821 This is an independent function to let extension to plug in and react to
2822 the imminent revert.
2822 the imminent revert.
2823
2823
2824 Make sure you have the working directory locked when calling this function.
2824 Make sure you have the working directory locked when calling this function.
2825 """
2825 """
2826 parent, p2 = parents
2826 parent, p2 = parents
2827 node = ctx.node()
2827 node = ctx.node()
2828 def checkout(f):
2828 def checkout(f):
2829 fc = ctx[f]
2829 fc = ctx[f]
2830 repo.wwrite(f, fc.data(), fc.flags())
2830 repo.wwrite(f, fc.data(), fc.flags())
2831
2831
2832 audit_path = pathutil.pathauditor(repo.root)
2832 audit_path = pathutil.pathauditor(repo.root)
2833 for f in actions['forget'][0]:
2833 for f in actions['forget'][0]:
2834 repo.dirstate.drop(f)
2834 repo.dirstate.drop(f)
2835 for f in actions['remove'][0]:
2835 for f in actions['remove'][0]:
2836 audit_path(f)
2836 audit_path(f)
2837 util.unlinkpath(repo.wjoin(f))
2837 util.unlinkpath(repo.wjoin(f))
2838 repo.dirstate.remove(f)
2838 repo.dirstate.remove(f)
2839 for f in actions['drop'][0]:
2839 for f in actions['drop'][0]:
2840 audit_path(f)
2840 audit_path(f)
2841 repo.dirstate.remove(f)
2841 repo.dirstate.remove(f)
2842
2842
2843 normal = None
2843 normal = None
2844 if node == parent:
2844 if node == parent:
2845 # We're reverting to our parent. If possible, we'd like status
2845 # We're reverting to our parent. If possible, we'd like status
2846 # to report the file as clean. We have to use normallookup for
2846 # to report the file as clean. We have to use normallookup for
2847 # merges to avoid losing information about merged/dirty files.
2847 # merges to avoid losing information about merged/dirty files.
2848 if p2 != nullid:
2848 if p2 != nullid:
2849 normal = repo.dirstate.normallookup
2849 normal = repo.dirstate.normallookup
2850 else:
2850 else:
2851 normal = repo.dirstate.normal
2851 normal = repo.dirstate.normal
2852 for f in actions['revert'][0]:
2852 for f in actions['revert'][0]:
2853 checkout(f)
2853 checkout(f)
2854 if normal:
2854 if normal:
2855 normal(f)
2855 normal(f)
2856
2856
2857 for f in actions['add'][0]:
2857 for f in actions['add'][0]:
2858 checkout(f)
2858 checkout(f)
2859 repo.dirstate.add(f)
2859 repo.dirstate.add(f)
2860
2860
2861 normal = repo.dirstate.normallookup
2861 normal = repo.dirstate.normallookup
2862 if node == parent and p2 == nullid:
2862 if node == parent and p2 == nullid:
2863 normal = repo.dirstate.normal
2863 normal = repo.dirstate.normal
2864 for f in actions['undelete'][0]:
2864 for f in actions['undelete'][0]:
2865 checkout(f)
2865 checkout(f)
2866 normal(f)
2866 normal(f)
2867
2867
2868 copied = copies.pathcopies(repo[parent], ctx)
2868 copied = copies.pathcopies(repo[parent], ctx)
2869
2869
2870 for f in actions['add'][0] + actions['undelete'][0] + actions['revert'][0]:
2870 for f in actions['add'][0] + actions['undelete'][0] + actions['revert'][0]:
2871 if f in copied:
2871 if f in copied:
2872 repo.dirstate.copy(copied[f], f)
2872 repo.dirstate.copy(copied[f], f)
2873
2873
2874 def command(table):
2874 def command(table):
2875 """Returns a function object to be used as a decorator for making commands.
2875 """Returns a function object to be used as a decorator for making commands.
2876
2876
2877 This function receives a command table as its argument. The table should
2877 This function receives a command table as its argument. The table should
2878 be a dict.
2878 be a dict.
2879
2879
2880 The returned function can be used as a decorator for adding commands
2880 The returned function can be used as a decorator for adding commands
2881 to that command table. This function accepts multiple arguments to define
2881 to that command table. This function accepts multiple arguments to define
2882 a command.
2882 a command.
2883
2883
2884 The first argument is the command name.
2884 The first argument is the command name.
2885
2885
2886 The options argument is an iterable of tuples defining command arguments.
2886 The options argument is an iterable of tuples defining command arguments.
2887 See ``mercurial.fancyopts.fancyopts()`` for the format of each tuple.
2887 See ``mercurial.fancyopts.fancyopts()`` for the format of each tuple.
2888
2888
2889 The synopsis argument defines a short, one line summary of how to use the
2889 The synopsis argument defines a short, one line summary of how to use the
2890 command. This shows up in the help output.
2890 command. This shows up in the help output.
2891
2891
2892 The norepo argument defines whether the command does not require a
2892 The norepo argument defines whether the command does not require a
2893 local repository. Most commands operate against a repository, thus the
2893 local repository. Most commands operate against a repository, thus the
2894 default is False.
2894 default is False.
2895
2895
2896 The optionalrepo argument defines whether the command optionally requires
2896 The optionalrepo argument defines whether the command optionally requires
2897 a local repository.
2897 a local repository.
2898
2898
2899 The inferrepo argument defines whether to try to find a repository from the
2899 The inferrepo argument defines whether to try to find a repository from the
2900 command line arguments. If True, arguments will be examined for potential
2900 command line arguments. If True, arguments will be examined for potential
2901 repository locations. See ``findrepo()``. If a repository is found, it
2901 repository locations. See ``findrepo()``. If a repository is found, it
2902 will be used.
2902 will be used.
2903 """
2903 """
2904 def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False,
2904 def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False,
2905 inferrepo=False):
2905 inferrepo=False):
2906 def decorator(func):
2906 def decorator(func):
2907 if synopsis:
2907 if synopsis:
2908 table[name] = func, list(options), synopsis
2908 table[name] = func, list(options), synopsis
2909 else:
2909 else:
2910 table[name] = func, list(options)
2910 table[name] = func, list(options)
2911
2911
2912 if norepo:
2912 if norepo:
2913 # Avoid import cycle.
2913 # Avoid import cycle.
2914 import commands
2914 import commands
2915 commands.norepo += ' %s' % ' '.join(parsealiases(name))
2915 commands.norepo += ' %s' % ' '.join(parsealiases(name))
2916
2916
2917 if optionalrepo:
2917 if optionalrepo:
2918 import commands
2918 import commands
2919 commands.optionalrepo += ' %s' % ' '.join(parsealiases(name))
2919 commands.optionalrepo += ' %s' % ' '.join(parsealiases(name))
2920
2920
2921 if inferrepo:
2921 if inferrepo:
2922 import commands
2922 import commands
2923 commands.inferrepo += ' %s' % ' '.join(parsealiases(name))
2923 commands.inferrepo += ' %s' % ' '.join(parsealiases(name))
2924
2924
2925 return func
2925 return func
2926 return decorator
2926 return decorator
2927
2927
2928 return cmd
2928 return cmd
2929
2929
2930 # a list of (ui, repo, otherpeer, opts, missing) functions called by
2930 # a list of (ui, repo, otherpeer, opts, missing) functions called by
2931 # commands.outgoing. "missing" is "missing" of the result of
2931 # commands.outgoing. "missing" is "missing" of the result of
2932 # "findcommonoutgoing()"
2932 # "findcommonoutgoing()"
2933 outgoinghooks = util.hooks()
2933 outgoinghooks = util.hooks()
2934
2934
2935 # a list of (ui, repo) functions called by commands.summary
2935 # a list of (ui, repo) functions called by commands.summary
2936 summaryhooks = util.hooks()
2936 summaryhooks = util.hooks()
2937
2937
2938 # a list of (ui, repo, opts, changes) functions called by commands.summary.
2938 # a list of (ui, repo, opts, changes) functions called by commands.summary.
2939 #
2939 #
2940 # functions should return tuple of booleans below, if 'changes' is None:
2940 # functions should return tuple of booleans below, if 'changes' is None:
2941 # (whether-incomings-are-needed, whether-outgoings-are-needed)
2941 # (whether-incomings-are-needed, whether-outgoings-are-needed)
2942 #
2942 #
2943 # otherwise, 'changes' is a tuple of tuples below:
2943 # otherwise, 'changes' is a tuple of tuples below:
2944 # - (sourceurl, sourcebranch, sourcepeer, incoming)
2944 # - (sourceurl, sourcebranch, sourcepeer, incoming)
2945 # - (desturl, destbranch, destpeer, outgoing)
2945 # - (desturl, destbranch, destpeer, outgoing)
2946 summaryremotehooks = util.hooks()
2946 summaryremotehooks = util.hooks()
2947
2947
2948 # A list of state files kept by multistep operations like graft.
2948 # A list of state files kept by multistep operations like graft.
2949 # Since graft cannot be aborted, it is considered 'clearable' by update.
2949 # Since graft cannot be aborted, it is considered 'clearable' by update.
2950 # note: bisect is intentionally excluded
2950 # note: bisect is intentionally excluded
2951 # (state file, clearable, allowcommit, error, hint)
2951 # (state file, clearable, allowcommit, error, hint)
2952 unfinishedstates = [
2952 unfinishedstates = [
2953 ('graftstate', True, False, _('graft in progress'),
2953 ('graftstate', True, False, _('graft in progress'),
2954 _("use 'hg graft --continue' or 'hg update' to abort")),
2954 _("use 'hg graft --continue' or 'hg update' to abort")),
2955 ('updatestate', True, False, _('last update was interrupted'),
2955 ('updatestate', True, False, _('last update was interrupted'),
2956 _("use 'hg update' to get a consistent checkout"))
2956 _("use 'hg update' to get a consistent checkout"))
2957 ]
2957 ]
2958
2958
2959 def checkunfinished(repo, commit=False):
2959 def checkunfinished(repo, commit=False):
2960 '''Look for an unfinished multistep operation, like graft, and abort
2960 '''Look for an unfinished multistep operation, like graft, and abort
2961 if found. It's probably good to check this right before
2961 if found. It's probably good to check this right before
2962 bailifchanged().
2962 bailifchanged().
2963 '''
2963 '''
2964 for f, clearable, allowcommit, msg, hint in unfinishedstates:
2964 for f, clearable, allowcommit, msg, hint in unfinishedstates:
2965 if commit and allowcommit:
2965 if commit and allowcommit:
2966 continue
2966 continue
2967 if repo.vfs.exists(f):
2967 if repo.vfs.exists(f):
2968 raise util.Abort(msg, hint=hint)
2968 raise util.Abort(msg, hint=hint)
2969
2969
2970 def clearunfinished(repo):
2970 def clearunfinished(repo):
2971 '''Check for unfinished operations (as above), and clear the ones
2971 '''Check for unfinished operations (as above), and clear the ones
2972 that are clearable.
2972 that are clearable.
2973 '''
2973 '''
2974 for f, clearable, allowcommit, msg, hint in unfinishedstates:
2974 for f, clearable, allowcommit, msg, hint in unfinishedstates:
2975 if not clearable and repo.vfs.exists(f):
2975 if not clearable and repo.vfs.exists(f):
2976 raise util.Abort(msg, hint=hint)
2976 raise util.Abort(msg, hint=hint)
2977 for f, clearable, allowcommit, msg, hint in unfinishedstates:
2977 for f, clearable, allowcommit, msg, hint in unfinishedstates:
2978 if clearable and repo.vfs.exists(f):
2978 if clearable and repo.vfs.exists(f):
2979 util.unlink(repo.join(f))
2979 util.unlink(repo.join(f))
@@ -1,1904 +1,1918 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 > names = lambda r: foo.keys()
1570 > names = lambda r: foo.keys()
1571 > namemap = lambda r, name: foo.get(name)
1571 > namemap = lambda r, name: foo.get(name)
1572 > nodemap = lambda r, node: [name for name, n in foo.iteritems()
1572 > nodemap = lambda r, node: [name for name, n in foo.iteritems()
1573 > if n == node]
1573 > if n == node]
1574 > ns = namespace("bars", templatename="bar", listnames=names,
1574 > ns = namespace("bars", templatename="bar", logname="barlog",
1575 > namemap=namemap, nodemap=nodemap)
1575 > colorname="barcolor", listnames=names, namemap=namemap,
1576 > nodemap=nodemap)
1576 >
1577 >
1577 > repo.names.addnamespace(ns)
1578 > repo.names.addnamespace(ns)
1578 > EOF
1579 > EOF
1579
1580
1580 $ hg --config extensions.names=../names.py log -r 0
1581 $ hg --config extensions.names=../names.py log -r 0
1581 changeset: 0:65624cd9070a
1582 changeset: 0:65624cd9070a
1582 tag: tip
1583 tag: tip
1583 bar: foo
1584 barlog: foo
1584 user: test
1585 user: test
1585 date: Thu Jan 01 00:00:00 1970 +0000
1586 date: Thu Jan 01 00:00:00 1970 +0000
1586 summary: a bunch of weird directories
1587 summary: a bunch of weird directories
1587
1588
1589 $ hg --config extensions.names=../names.py \
1590 > --config extensions.color= --config color.log.barcolor=red \
1591 > --color=always log -r 0
1592 \x1b[0;33mchangeset: 0:65624cd9070a\x1b[0m (esc)
1593 tag: tip
1594 \x1b[0;31mbarlog: foo\x1b[0m (esc)
1595 user: test
1596 date: Thu Jan 01 00:00:00 1970 +0000
1597 summary: a bunch of weird directories
1598
1599 $ hg --config extensions.names=../names.py log -r 0 --template '{bars}\n'
1600 foo
1601
1588 $ cd ..
1602 $ cd ..
1589
1603
1590 hg log -f dir across branches
1604 hg log -f dir across branches
1591
1605
1592 $ hg init acrossbranches
1606 $ hg init acrossbranches
1593 $ cd acrossbranches
1607 $ cd acrossbranches
1594 $ mkdir d
1608 $ mkdir d
1595 $ echo a > d/a && hg ci -Aqm a
1609 $ echo a > d/a && hg ci -Aqm a
1596 $ echo b > d/a && hg ci -Aqm b
1610 $ echo b > d/a && hg ci -Aqm b
1597 $ hg up -q 0
1611 $ hg up -q 0
1598 $ echo b > d/a && hg ci -Aqm c
1612 $ echo b > d/a && hg ci -Aqm c
1599 $ hg log -f d -T '{desc}' -G
1613 $ hg log -f d -T '{desc}' -G
1600 @ c
1614 @ c
1601 |
1615 |
1602 o a
1616 o a
1603
1617
1604 $ hg log -f d/a -T '{desc}' -G
1618 $ hg log -f d/a -T '{desc}' -G
1605 @ c
1619 @ c
1606 |
1620 |
1607 o a
1621 o a
1608
1622
1609 $ cd ..
1623 $ cd ..
1610
1624
1611 hg log -f with linkrev pointing to another branch
1625 hg log -f with linkrev pointing to another branch
1612 -------------------------------------------------
1626 -------------------------------------------------
1613
1627
1614 create history with a filerev whose linkrev points to another branch
1628 create history with a filerev whose linkrev points to another branch
1615
1629
1616 $ hg init branchedlinkrev
1630 $ hg init branchedlinkrev
1617 $ cd branchedlinkrev
1631 $ cd branchedlinkrev
1618 $ echo 1 > a
1632 $ echo 1 > a
1619 $ hg commit -Am 'content1'
1633 $ hg commit -Am 'content1'
1620 adding a
1634 adding a
1621 $ echo 2 > a
1635 $ echo 2 > a
1622 $ hg commit -m 'content2'
1636 $ hg commit -m 'content2'
1623 $ hg up --rev 'desc(content1)'
1637 $ hg up --rev 'desc(content1)'
1624 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1638 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1625 $ echo unrelated > unrelated
1639 $ echo unrelated > unrelated
1626 $ hg commit -Am 'unrelated'
1640 $ hg commit -Am 'unrelated'
1627 adding unrelated
1641 adding unrelated
1628 created new head
1642 created new head
1629 $ hg graft -r 'desc(content2)'
1643 $ hg graft -r 'desc(content2)'
1630 grafting 1:2294ae80ad84 "content2"
1644 grafting 1:2294ae80ad84 "content2"
1631 $ echo 3 > a
1645 $ echo 3 > a
1632 $ hg commit -m 'content3'
1646 $ hg commit -m 'content3'
1633 $ hg log -G
1647 $ hg log -G
1634 @ changeset: 4:50b9b36e9c5d
1648 @ changeset: 4:50b9b36e9c5d
1635 | tag: tip
1649 | tag: tip
1636 | user: test
1650 | user: test
1637 | date: Thu Jan 01 00:00:00 1970 +0000
1651 | date: Thu Jan 01 00:00:00 1970 +0000
1638 | summary: content3
1652 | summary: content3
1639 |
1653 |
1640 o changeset: 3:15b2327059e5
1654 o changeset: 3:15b2327059e5
1641 | user: test
1655 | user: test
1642 | date: Thu Jan 01 00:00:00 1970 +0000
1656 | date: Thu Jan 01 00:00:00 1970 +0000
1643 | summary: content2
1657 | summary: content2
1644 |
1658 |
1645 o changeset: 2:2029acd1168c
1659 o changeset: 2:2029acd1168c
1646 | parent: 0:ae0a3c9f9e95
1660 | parent: 0:ae0a3c9f9e95
1647 | user: test
1661 | user: test
1648 | date: Thu Jan 01 00:00:00 1970 +0000
1662 | date: Thu Jan 01 00:00:00 1970 +0000
1649 | summary: unrelated
1663 | summary: unrelated
1650 |
1664 |
1651 | o changeset: 1:2294ae80ad84
1665 | o changeset: 1:2294ae80ad84
1652 |/ user: test
1666 |/ user: test
1653 | date: Thu Jan 01 00:00:00 1970 +0000
1667 | date: Thu Jan 01 00:00:00 1970 +0000
1654 | summary: content2
1668 | summary: content2
1655 |
1669 |
1656 o changeset: 0:ae0a3c9f9e95
1670 o changeset: 0:ae0a3c9f9e95
1657 user: test
1671 user: test
1658 date: Thu Jan 01 00:00:00 1970 +0000
1672 date: Thu Jan 01 00:00:00 1970 +0000
1659 summary: content1
1673 summary: content1
1660
1674
1661
1675
1662 log -f on the file should list the graft result.
1676 log -f on the file should list the graft result.
1663
1677
1664 $ hg log -Gf a
1678 $ hg log -Gf a
1665 @ changeset: 4:50b9b36e9c5d
1679 @ changeset: 4:50b9b36e9c5d
1666 | tag: tip
1680 | tag: tip
1667 | user: test
1681 | user: test
1668 | date: Thu Jan 01 00:00:00 1970 +0000
1682 | date: Thu Jan 01 00:00:00 1970 +0000
1669 | summary: content3
1683 | summary: content3
1670 |
1684 |
1671 o changeset: 3:15b2327059e5
1685 o changeset: 3:15b2327059e5
1672 | user: test
1686 | user: test
1673 | date: Thu Jan 01 00:00:00 1970 +0000
1687 | date: Thu Jan 01 00:00:00 1970 +0000
1674 | summary: content2
1688 | summary: content2
1675 |
1689 |
1676 o changeset: 0:ae0a3c9f9e95
1690 o changeset: 0:ae0a3c9f9e95
1677 user: test
1691 user: test
1678 date: Thu Jan 01 00:00:00 1970 +0000
1692 date: Thu Jan 01 00:00:00 1970 +0000
1679 summary: content1
1693 summary: content1
1680
1694
1681
1695
1682 plain log lists the original version
1696 plain log lists the original version
1683 (XXX we should probably list both)
1697 (XXX we should probably list both)
1684
1698
1685 $ hg log -G a
1699 $ hg log -G a
1686 @ changeset: 4:50b9b36e9c5d
1700 @ changeset: 4:50b9b36e9c5d
1687 | tag: tip
1701 | tag: tip
1688 | user: test
1702 | user: test
1689 | date: Thu Jan 01 00:00:00 1970 +0000
1703 | date: Thu Jan 01 00:00:00 1970 +0000
1690 | summary: content3
1704 | summary: content3
1691 |
1705 |
1692 | o changeset: 1:2294ae80ad84
1706 | o changeset: 1:2294ae80ad84
1693 |/ user: test
1707 |/ user: test
1694 | date: Thu Jan 01 00:00:00 1970 +0000
1708 | date: Thu Jan 01 00:00:00 1970 +0000
1695 | summary: content2
1709 | summary: content2
1696 |
1710 |
1697 o changeset: 0:ae0a3c9f9e95
1711 o changeset: 0:ae0a3c9f9e95
1698 user: test
1712 user: test
1699 date: Thu Jan 01 00:00:00 1970 +0000
1713 date: Thu Jan 01 00:00:00 1970 +0000
1700 summary: content1
1714 summary: content1
1701
1715
1702
1716
1703 hg log -f from the grafted changeset
1717 hg log -f from the grafted changeset
1704 (The bootstrap should properly take the topology in account)
1718 (The bootstrap should properly take the topology in account)
1705
1719
1706 $ hg up 'desc(content3)^'
1720 $ hg up 'desc(content3)^'
1707 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1721 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1708 $ hg log -Gf a
1722 $ hg log -Gf a
1709 @ changeset: 3:15b2327059e5
1723 @ changeset: 3:15b2327059e5
1710 | user: test
1724 | user: test
1711 | date: Thu Jan 01 00:00:00 1970 +0000
1725 | date: Thu Jan 01 00:00:00 1970 +0000
1712 | summary: content2
1726 | summary: content2
1713 |
1727 |
1714 o changeset: 0:ae0a3c9f9e95
1728 o changeset: 0:ae0a3c9f9e95
1715 user: test
1729 user: test
1716 date: Thu Jan 01 00:00:00 1970 +0000
1730 date: Thu Jan 01 00:00:00 1970 +0000
1717 summary: content1
1731 summary: content1
1718
1732
1719
1733
1720 Test that we use the first non-hidden changeset in that case.
1734 Test that we use the first non-hidden changeset in that case.
1721
1735
1722 (hide the changeset)
1736 (hide the changeset)
1723
1737
1724 $ hg log -T '{node}\n' -r 1
1738 $ hg log -T '{node}\n' -r 1
1725 2294ae80ad8447bc78383182eeac50cb049df623
1739 2294ae80ad8447bc78383182eeac50cb049df623
1726 $ hg debugobsolete 2294ae80ad8447bc78383182eeac50cb049df623
1740 $ hg debugobsolete 2294ae80ad8447bc78383182eeac50cb049df623
1727 $ hg log -G
1741 $ hg log -G
1728 o changeset: 4:50b9b36e9c5d
1742 o changeset: 4:50b9b36e9c5d
1729 | tag: tip
1743 | tag: tip
1730 | user: test
1744 | user: test
1731 | date: Thu Jan 01 00:00:00 1970 +0000
1745 | date: Thu Jan 01 00:00:00 1970 +0000
1732 | summary: content3
1746 | summary: content3
1733 |
1747 |
1734 @ changeset: 3:15b2327059e5
1748 @ changeset: 3:15b2327059e5
1735 | user: test
1749 | user: test
1736 | date: Thu Jan 01 00:00:00 1970 +0000
1750 | date: Thu Jan 01 00:00:00 1970 +0000
1737 | summary: content2
1751 | summary: content2
1738 |
1752 |
1739 o changeset: 2:2029acd1168c
1753 o changeset: 2:2029acd1168c
1740 | parent: 0:ae0a3c9f9e95
1754 | parent: 0:ae0a3c9f9e95
1741 | user: test
1755 | user: test
1742 | date: Thu Jan 01 00:00:00 1970 +0000
1756 | date: Thu Jan 01 00:00:00 1970 +0000
1743 | summary: unrelated
1757 | summary: unrelated
1744 |
1758 |
1745 o changeset: 0:ae0a3c9f9e95
1759 o changeset: 0:ae0a3c9f9e95
1746 user: test
1760 user: test
1747 date: Thu Jan 01 00:00:00 1970 +0000
1761 date: Thu Jan 01 00:00:00 1970 +0000
1748 summary: content1
1762 summary: content1
1749
1763
1750
1764
1751 Check that log on the file does not drop the file revision.
1765 Check that log on the file does not drop the file revision.
1752
1766
1753 $ hg log -G a
1767 $ hg log -G a
1754 o changeset: 4:50b9b36e9c5d
1768 o changeset: 4:50b9b36e9c5d
1755 | tag: tip
1769 | tag: tip
1756 | user: test
1770 | user: test
1757 | date: Thu Jan 01 00:00:00 1970 +0000
1771 | date: Thu Jan 01 00:00:00 1970 +0000
1758 | summary: content3
1772 | summary: content3
1759 |
1773 |
1760 @ changeset: 3:15b2327059e5
1774 @ changeset: 3:15b2327059e5
1761 | user: test
1775 | user: test
1762 | date: Thu Jan 01 00:00:00 1970 +0000
1776 | date: Thu Jan 01 00:00:00 1970 +0000
1763 | summary: content2
1777 | summary: content2
1764 |
1778 |
1765 o changeset: 0:ae0a3c9f9e95
1779 o changeset: 0:ae0a3c9f9e95
1766 user: test
1780 user: test
1767 date: Thu Jan 01 00:00:00 1970 +0000
1781 date: Thu Jan 01 00:00:00 1970 +0000
1768 summary: content1
1782 summary: content1
1769
1783
1770
1784
1771 Even when a head revision is linkrev-shadowed.
1785 Even when a head revision is linkrev-shadowed.
1772
1786
1773 $ hg log -T '{node}\n' -r 4
1787 $ hg log -T '{node}\n' -r 4
1774 50b9b36e9c5df2c6fc6dcefa8ad0da929e84aed2
1788 50b9b36e9c5df2c6fc6dcefa8ad0da929e84aed2
1775 $ hg debugobsolete 50b9b36e9c5df2c6fc6dcefa8ad0da929e84aed2
1789 $ hg debugobsolete 50b9b36e9c5df2c6fc6dcefa8ad0da929e84aed2
1776 $ hg log -G a
1790 $ hg log -G a
1777 @ changeset: 3:15b2327059e5
1791 @ changeset: 3:15b2327059e5
1778 | tag: tip
1792 | tag: tip
1779 | user: test
1793 | user: test
1780 | date: Thu Jan 01 00:00:00 1970 +0000
1794 | date: Thu Jan 01 00:00:00 1970 +0000
1781 | summary: content2
1795 | summary: content2
1782 |
1796 |
1783 o changeset: 0:ae0a3c9f9e95
1797 o changeset: 0:ae0a3c9f9e95
1784 user: test
1798 user: test
1785 date: Thu Jan 01 00:00:00 1970 +0000
1799 date: Thu Jan 01 00:00:00 1970 +0000
1786 summary: content1
1800 summary: content1
1787
1801
1788
1802
1789 $ cd ..
1803 $ cd ..
1790
1804
1791 Even when the file revision is missing from some head:
1805 Even when the file revision is missing from some head:
1792
1806
1793 $ hg init issue4490
1807 $ hg init issue4490
1794 $ cd issue4490
1808 $ cd issue4490
1795 $ echo '[experimental]' >> .hg/hgrc
1809 $ echo '[experimental]' >> .hg/hgrc
1796 $ echo 'evolution=createmarkers' >> .hg/hgrc
1810 $ echo 'evolution=createmarkers' >> .hg/hgrc
1797 $ echo a > a
1811 $ echo a > a
1798 $ hg ci -Am0
1812 $ hg ci -Am0
1799 adding a
1813 adding a
1800 $ echo b > b
1814 $ echo b > b
1801 $ hg ci -Am1
1815 $ hg ci -Am1
1802 adding b
1816 adding b
1803 $ echo B > b
1817 $ echo B > b
1804 $ hg ci --amend -m 1
1818 $ hg ci --amend -m 1
1805 $ hg up 0
1819 $ hg up 0
1806 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1820 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1807 $ echo c > c
1821 $ echo c > c
1808 $ hg ci -Am2
1822 $ hg ci -Am2
1809 adding c
1823 adding c
1810 created new head
1824 created new head
1811 $ hg up 'head() and not .'
1825 $ hg up 'head() and not .'
1812 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1826 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1813 $ hg log -G
1827 $ hg log -G
1814 o changeset: 4:db815d6d32e6
1828 o changeset: 4:db815d6d32e6
1815 | tag: tip
1829 | tag: tip
1816 | parent: 0:f7b1eb17ad24
1830 | parent: 0:f7b1eb17ad24
1817 | user: test
1831 | user: test
1818 | date: Thu Jan 01 00:00:00 1970 +0000
1832 | date: Thu Jan 01 00:00:00 1970 +0000
1819 | summary: 2
1833 | summary: 2
1820 |
1834 |
1821 | @ changeset: 3:9bc8ce7f9356
1835 | @ changeset: 3:9bc8ce7f9356
1822 |/ parent: 0:f7b1eb17ad24
1836 |/ parent: 0:f7b1eb17ad24
1823 | user: test
1837 | user: test
1824 | date: Thu Jan 01 00:00:00 1970 +0000
1838 | date: Thu Jan 01 00:00:00 1970 +0000
1825 | summary: 1
1839 | summary: 1
1826 |
1840 |
1827 o changeset: 0:f7b1eb17ad24
1841 o changeset: 0:f7b1eb17ad24
1828 user: test
1842 user: test
1829 date: Thu Jan 01 00:00:00 1970 +0000
1843 date: Thu Jan 01 00:00:00 1970 +0000
1830 summary: 0
1844 summary: 0
1831
1845
1832 $ hg log -f -G b
1846 $ hg log -f -G b
1833 @ changeset: 3:9bc8ce7f9356
1847 @ changeset: 3:9bc8ce7f9356
1834 | parent: 0:f7b1eb17ad24
1848 | parent: 0:f7b1eb17ad24
1835 | user: test
1849 | user: test
1836 | date: Thu Jan 01 00:00:00 1970 +0000
1850 | date: Thu Jan 01 00:00:00 1970 +0000
1837 | summary: 1
1851 | summary: 1
1838 |
1852 |
1839 $ hg log -G b
1853 $ hg log -G b
1840 @ changeset: 3:9bc8ce7f9356
1854 @ changeset: 3:9bc8ce7f9356
1841 | parent: 0:f7b1eb17ad24
1855 | parent: 0:f7b1eb17ad24
1842 | user: test
1856 | user: test
1843 | date: Thu Jan 01 00:00:00 1970 +0000
1857 | date: Thu Jan 01 00:00:00 1970 +0000
1844 | summary: 1
1858 | summary: 1
1845 |
1859 |
1846 $ cd ..
1860 $ cd ..
1847
1861
1848 Check proper report when the manifest changes but not the file issue4499
1862 Check proper report when the manifest changes but not the file issue4499
1849 ------------------------------------------------------------------------
1863 ------------------------------------------------------------------------
1850
1864
1851 $ hg init issue4499
1865 $ hg init issue4499
1852 $ cd issue4499
1866 $ cd issue4499
1853 $ 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
1867 $ 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
1854 > echo 1 > $f;
1868 > echo 1 > $f;
1855 > hg add $f;
1869 > hg add $f;
1856 > done
1870 > done
1857 $ hg commit -m 'A1B1C1'
1871 $ hg commit -m 'A1B1C1'
1858 $ echo 2 > A
1872 $ echo 2 > A
1859 $ echo 2 > B
1873 $ echo 2 > B
1860 $ echo 2 > C
1874 $ echo 2 > C
1861 $ hg commit -m 'A2B2C2'
1875 $ hg commit -m 'A2B2C2'
1862 $ hg up 0
1876 $ hg up 0
1863 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
1877 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
1864 $ echo 3 > A
1878 $ echo 3 > A
1865 $ echo 2 > B
1879 $ echo 2 > B
1866 $ echo 2 > C
1880 $ echo 2 > C
1867 $ hg commit -m 'A3B2C2'
1881 $ hg commit -m 'A3B2C2'
1868 created new head
1882 created new head
1869
1883
1870 $ hg log -G
1884 $ hg log -G
1871 @ changeset: 2:fe5fc3d0eb17
1885 @ changeset: 2:fe5fc3d0eb17
1872 | tag: tip
1886 | tag: tip
1873 | parent: 0:abf4f0e38563
1887 | parent: 0:abf4f0e38563
1874 | user: test
1888 | user: test
1875 | date: Thu Jan 01 00:00:00 1970 +0000
1889 | date: Thu Jan 01 00:00:00 1970 +0000
1876 | summary: A3B2C2
1890 | summary: A3B2C2
1877 |
1891 |
1878 | o changeset: 1:07dcc6b312c0
1892 | o changeset: 1:07dcc6b312c0
1879 |/ user: test
1893 |/ user: test
1880 | date: Thu Jan 01 00:00:00 1970 +0000
1894 | date: Thu Jan 01 00:00:00 1970 +0000
1881 | summary: A2B2C2
1895 | summary: A2B2C2
1882 |
1896 |
1883 o changeset: 0:abf4f0e38563
1897 o changeset: 0:abf4f0e38563
1884 user: test
1898 user: test
1885 date: Thu Jan 01 00:00:00 1970 +0000
1899 date: Thu Jan 01 00:00:00 1970 +0000
1886 summary: A1B1C1
1900 summary: A1B1C1
1887
1901
1888
1902
1889 Log -f on B should reports current changesets
1903 Log -f on B should reports current changesets
1890
1904
1891 $ hg log -fG B
1905 $ hg log -fG B
1892 @ changeset: 2:fe5fc3d0eb17
1906 @ changeset: 2:fe5fc3d0eb17
1893 | tag: tip
1907 | tag: tip
1894 | parent: 0:abf4f0e38563
1908 | parent: 0:abf4f0e38563
1895 | user: test
1909 | user: test
1896 | date: Thu Jan 01 00:00:00 1970 +0000
1910 | date: Thu Jan 01 00:00:00 1970 +0000
1897 | summary: A3B2C2
1911 | summary: A3B2C2
1898 |
1912 |
1899 o changeset: 0:abf4f0e38563
1913 o changeset: 0:abf4f0e38563
1900 user: test
1914 user: test
1901 date: Thu Jan 01 00:00:00 1970 +0000
1915 date: Thu Jan 01 00:00:00 1970 +0000
1902 summary: A1B1C1
1916 summary: A1B1C1
1903
1917
1904 $ cd ..
1918 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now