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