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