Show More
@@ -1,783 +1,786 b'' | |||
|
1 | 1 | # hgweb/webutil.py - utility library for the web interface. |
|
2 | 2 | # |
|
3 | 3 | # Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net> |
|
4 | 4 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
5 | 5 | # |
|
6 | 6 | # This software may be used and distributed according to the terms of the |
|
7 | 7 | # GNU General Public License version 2 or any later version. |
|
8 | 8 | |
|
9 | 9 | from __future__ import absolute_import |
|
10 | 10 | |
|
11 | 11 | import copy |
|
12 | 12 | import difflib |
|
13 | 13 | import os |
|
14 | 14 | import re |
|
15 | 15 | |
|
16 | 16 | from ..i18n import _ |
|
17 | 17 | from ..node import hex, nullid, short |
|
18 | 18 | |
|
19 | 19 | from .common import ( |
|
20 | 20 | ErrorResponse, |
|
21 | 21 | HTTP_BAD_REQUEST, |
|
22 | 22 | HTTP_NOT_FOUND, |
|
23 | 23 | paritygen, |
|
24 | 24 | ) |
|
25 | 25 | |
|
26 | 26 | from .. import ( |
|
27 | 27 | context, |
|
28 | 28 | error, |
|
29 | 29 | match, |
|
30 | 30 | mdiff, |
|
31 | 31 | obsutil, |
|
32 | 32 | patch, |
|
33 | 33 | pathutil, |
|
34 | 34 | pycompat, |
|
35 | 35 | scmutil, |
|
36 | 36 | templatefilters, |
|
37 | 37 | templatekw, |
|
38 | 38 | templateutil, |
|
39 | 39 | ui as uimod, |
|
40 | 40 | util, |
|
41 | 41 | ) |
|
42 | 42 | |
|
43 | 43 | from ..utils import ( |
|
44 | 44 | stringutil, |
|
45 | 45 | ) |
|
46 | 46 | |
|
47 | 47 | archivespecs = util.sortdict(( |
|
48 | 48 | ('zip', ('application/zip', 'zip', '.zip', None)), |
|
49 | 49 | ('gz', ('application/x-gzip', 'tgz', '.tar.gz', None)), |
|
50 | 50 | ('bz2', ('application/x-bzip2', 'tbz2', '.tar.bz2', None)), |
|
51 | 51 | )) |
|
52 | 52 | |
|
53 | 53 | def archivelist(ui, nodeid, url=None): |
|
54 | 54 | allowed = ui.configlist('web', 'allow-archive', untrusted=True) |
|
55 | 55 | archives = [] |
|
56 | 56 | |
|
57 | 57 | for typ, spec in archivespecs.iteritems(): |
|
58 | 58 | if typ in allowed or ui.configbool('web', 'allow' + typ, |
|
59 | 59 | untrusted=True): |
|
60 | 60 | archives.append({ |
|
61 | 61 | 'type': typ, |
|
62 | 62 | 'extension': spec[2], |
|
63 | 63 | 'node': nodeid, |
|
64 | 64 | 'url': url, |
|
65 | 65 | }) |
|
66 | 66 | |
|
67 | 67 | return templateutil.mappinglist(archives) |
|
68 | 68 | |
|
69 | 69 | def up(p): |
|
70 | 70 | if p[0:1] != "/": |
|
71 | 71 | p = "/" + p |
|
72 | 72 | if p[-1:] == "/": |
|
73 | 73 | p = p[:-1] |
|
74 | 74 | up = os.path.dirname(p) |
|
75 | 75 | if up == "/": |
|
76 | 76 | return "/" |
|
77 | 77 | return up + "/" |
|
78 | 78 | |
|
79 | 79 | def _navseq(step, firststep=None): |
|
80 | 80 | if firststep: |
|
81 | 81 | yield firststep |
|
82 | 82 | if firststep >= 20 and firststep <= 40: |
|
83 | 83 | firststep = 50 |
|
84 | 84 | yield firststep |
|
85 | 85 | assert step > 0 |
|
86 | 86 | assert firststep > 0 |
|
87 | 87 | while step <= firststep: |
|
88 | 88 | step *= 10 |
|
89 | 89 | while True: |
|
90 | 90 | yield 1 * step |
|
91 | 91 | yield 3 * step |
|
92 | 92 | step *= 10 |
|
93 | 93 | |
|
94 | 94 | class revnav(object): |
|
95 | 95 | |
|
96 | 96 | def __init__(self, repo): |
|
97 | 97 | """Navigation generation object |
|
98 | 98 | |
|
99 | 99 | :repo: repo object we generate nav for |
|
100 | 100 | """ |
|
101 | 101 | # used for hex generation |
|
102 | 102 | self._revlog = repo.changelog |
|
103 | 103 | |
|
104 | 104 | def __nonzero__(self): |
|
105 | 105 | """return True if any revision to navigate over""" |
|
106 | 106 | return self._first() is not None |
|
107 | 107 | |
|
108 | 108 | __bool__ = __nonzero__ |
|
109 | 109 | |
|
110 | 110 | def _first(self): |
|
111 | 111 | """return the minimum non-filtered changeset or None""" |
|
112 | 112 | try: |
|
113 | 113 | return next(iter(self._revlog)) |
|
114 | 114 | except StopIteration: |
|
115 | 115 | return None |
|
116 | 116 | |
|
117 | 117 | def hex(self, rev): |
|
118 | 118 | return hex(self._revlog.node(rev)) |
|
119 | 119 | |
|
120 | 120 | def gen(self, pos, pagelen, limit): |
|
121 | 121 | """computes label and revision id for navigation link |
|
122 | 122 | |
|
123 | 123 | :pos: is the revision relative to which we generate navigation. |
|
124 | 124 | :pagelen: the size of each navigation page |
|
125 | 125 | :limit: how far shall we link |
|
126 | 126 | |
|
127 | 127 | The return is: |
|
128 | 128 | - a single element mappinglist |
|
129 | 129 | - containing a dictionary with a `before` and `after` key |
|
130 | 130 | - values are dictionaries with `label` and `node` keys |
|
131 | 131 | """ |
|
132 | 132 | if not self: |
|
133 | 133 | # empty repo |
|
134 | 134 | return templateutil.mappinglist([ |
|
135 | 135 | {'before': templateutil.mappinglist([]), |
|
136 | 136 | 'after': templateutil.mappinglist([])}, |
|
137 | 137 | ]) |
|
138 | 138 | |
|
139 | 139 | targets = [] |
|
140 | 140 | for f in _navseq(1, pagelen): |
|
141 | 141 | if f > limit: |
|
142 | 142 | break |
|
143 | 143 | targets.append(pos + f) |
|
144 | 144 | targets.append(pos - f) |
|
145 | 145 | targets.sort() |
|
146 | 146 | |
|
147 | 147 | first = self._first() |
|
148 | 148 | navbefore = [{'label': '(%i)' % first, 'node': self.hex(first)}] |
|
149 | 149 | navafter = [] |
|
150 | 150 | for rev in targets: |
|
151 | 151 | if rev not in self._revlog: |
|
152 | 152 | continue |
|
153 | 153 | if pos < rev < limit: |
|
154 | 154 | navafter.append({'label': '+%d' % abs(rev - pos), |
|
155 | 155 | 'node': self.hex(rev)}) |
|
156 | 156 | if 0 < rev < pos: |
|
157 | 157 | navbefore.append({'label': '-%d' % abs(rev - pos), |
|
158 | 158 | 'node': self.hex(rev)}) |
|
159 | 159 | |
|
160 | 160 | navafter.append({'label': 'tip', 'node': 'tip'}) |
|
161 | 161 | |
|
162 | 162 | # TODO: maybe this can be a scalar object supporting tomap() |
|
163 | 163 | return templateutil.mappinglist([ |
|
164 | 164 | {'before': templateutil.mappinglist(navbefore), |
|
165 | 165 | 'after': templateutil.mappinglist(navafter)}, |
|
166 | 166 | ]) |
|
167 | 167 | |
|
168 | 168 | class filerevnav(revnav): |
|
169 | 169 | |
|
170 | 170 | def __init__(self, repo, path): |
|
171 | 171 | """Navigation generation object |
|
172 | 172 | |
|
173 | 173 | :repo: repo object we generate nav for |
|
174 | 174 | :path: path of the file we generate nav for |
|
175 | 175 | """ |
|
176 | 176 | # used for iteration |
|
177 | 177 | self._changelog = repo.unfiltered().changelog |
|
178 | 178 | # used for hex generation |
|
179 | 179 | self._revlog = repo.file(path) |
|
180 | 180 | |
|
181 | 181 | def hex(self, rev): |
|
182 | 182 | return hex(self._changelog.node(self._revlog.linkrev(rev))) |
|
183 | 183 | |
|
184 | 184 | # TODO: maybe this can be a wrapper class for changectx/filectx list, which |
|
185 | 185 | # yields {'ctx': ctx} |
|
186 | 186 | def _ctxsgen(context, ctxs): |
|
187 | 187 | for s in ctxs: |
|
188 | 188 | d = { |
|
189 | 189 | 'node': s.hex(), |
|
190 | 190 | 'rev': s.rev(), |
|
191 | 191 | 'user': s.user(), |
|
192 | 192 | 'date': s.date(), |
|
193 | 193 | 'description': s.description(), |
|
194 | 194 | 'branch': s.branch(), |
|
195 | 195 | } |
|
196 | 196 | if util.safehasattr(s, 'path'): |
|
197 | 197 | d['file'] = s.path() |
|
198 | 198 | yield d |
|
199 | 199 | |
|
200 | 200 | def _siblings(siblings=None, hiderev=None): |
|
201 | 201 | if siblings is None: |
|
202 | 202 | siblings = [] |
|
203 | 203 | siblings = [s for s in siblings if s.node() != nullid] |
|
204 | 204 | if len(siblings) == 1 and siblings[0].rev() == hiderev: |
|
205 | 205 | siblings = [] |
|
206 | 206 | return templateutil.mappinggenerator(_ctxsgen, args=(siblings,)) |
|
207 | 207 | |
|
208 | 208 | def difffeatureopts(req, ui, section): |
|
209 | 209 | diffopts = patch.difffeatureopts(ui, untrusted=True, |
|
210 | 210 | section=section, whitespace=True) |
|
211 | 211 | |
|
212 | 212 | for k in ('ignorews', 'ignorewsamount', 'ignorewseol', 'ignoreblanklines'): |
|
213 | 213 | v = req.qsparams.get(k) |
|
214 | 214 | if v is not None: |
|
215 | 215 | v = stringutil.parsebool(v) |
|
216 | 216 | setattr(diffopts, k, v if v is not None else True) |
|
217 | 217 | |
|
218 | 218 | return diffopts |
|
219 | 219 | |
|
220 | 220 | def annotate(req, fctx, ui): |
|
221 | 221 | diffopts = difffeatureopts(req, ui, 'annotate') |
|
222 | 222 | return fctx.annotate(follow=True, diffopts=diffopts) |
|
223 | 223 | |
|
224 | 224 | def parents(ctx, hide=None): |
|
225 | 225 | if isinstance(ctx, context.basefilectx): |
|
226 | 226 | introrev = ctx.introrev() |
|
227 | 227 | if ctx.changectx().rev() != introrev: |
|
228 | 228 | return _siblings([ctx.repo()[introrev]], hide) |
|
229 | 229 | return _siblings(ctx.parents(), hide) |
|
230 | 230 | |
|
231 | 231 | def children(ctx, hide=None): |
|
232 | 232 | return _siblings(ctx.children(), hide) |
|
233 | 233 | |
|
234 | 234 | def renamelink(fctx): |
|
235 | 235 | r = fctx.renamed() |
|
236 | 236 | if r: |
|
237 | 237 | return templateutil.mappinglist([{'file': r[0], 'node': hex(r[1])}]) |
|
238 | 238 | return templateutil.mappinglist([]) |
|
239 | 239 | |
|
240 | 240 | def nodetagsdict(repo, node): |
|
241 | 241 | return templateutil.hybridlist(repo.nodetags(node), name='name') |
|
242 | 242 | |
|
243 | 243 | def nodebookmarksdict(repo, node): |
|
244 | 244 | return templateutil.hybridlist(repo.nodebookmarks(node), name='name') |
|
245 | 245 | |
|
246 | 246 | def nodebranchdict(repo, ctx): |
|
247 | 247 | branches = [] |
|
248 | 248 | branch = ctx.branch() |
|
249 | 249 | # If this is an empty repo, ctx.node() == nullid, |
|
250 | 250 | # ctx.branch() == 'default'. |
|
251 | 251 | try: |
|
252 | 252 | branchnode = repo.branchtip(branch) |
|
253 | 253 | except error.RepoLookupError: |
|
254 | 254 | branchnode = None |
|
255 | 255 | if branchnode == ctx.node(): |
|
256 | 256 | branches.append(branch) |
|
257 | 257 | return templateutil.hybridlist(branches, name='name') |
|
258 | 258 | |
|
259 | 259 | def nodeinbranch(repo, ctx): |
|
260 | 260 | branches = [] |
|
261 | 261 | branch = ctx.branch() |
|
262 | 262 | try: |
|
263 | 263 | branchnode = repo.branchtip(branch) |
|
264 | 264 | except error.RepoLookupError: |
|
265 | 265 | branchnode = None |
|
266 | 266 | if branch != 'default' and branchnode != ctx.node(): |
|
267 | 267 | branches.append(branch) |
|
268 | 268 | return templateutil.hybridlist(branches, name='name') |
|
269 | 269 | |
|
270 | 270 | def nodebranchnodefault(ctx): |
|
271 | 271 | branches = [] |
|
272 | 272 | branch = ctx.branch() |
|
273 | 273 | if branch != 'default': |
|
274 | 274 | branches.append(branch) |
|
275 | 275 | return templateutil.hybridlist(branches, name='name') |
|
276 | 276 | |
|
277 | 277 | def _nodenamesgen(context, f, node, name): |
|
278 | 278 | for t in f(node): |
|
279 | 279 | yield {name: t} |
|
280 | 280 | |
|
281 | 281 | def showtag(repo, t1, node=nullid): |
|
282 | 282 | args = (repo.nodetags, node, 'tag') |
|
283 | 283 | return templateutil.mappinggenerator(_nodenamesgen, args=args, name=t1) |
|
284 | 284 | |
|
285 | 285 | def showbookmark(repo, t1, node=nullid): |
|
286 | 286 | args = (repo.nodebookmarks, node, 'bookmark') |
|
287 | 287 | return templateutil.mappinggenerator(_nodenamesgen, args=args, name=t1) |
|
288 | 288 | |
|
289 | 289 | def branchentries(repo, stripecount, limit=0): |
|
290 | 290 | tips = [] |
|
291 | 291 | heads = repo.heads() |
|
292 | 292 | parity = paritygen(stripecount) |
|
293 | 293 | sortkey = lambda item: (not item[1], item[0].rev()) |
|
294 | 294 | |
|
295 | 295 | def entries(context): |
|
296 | 296 | count = 0 |
|
297 | 297 | if not tips: |
|
298 | 298 | for tag, hs, tip, closed in repo.branchmap().iterbranches(): |
|
299 | 299 | tips.append((repo[tip], closed)) |
|
300 | 300 | for ctx, closed in sorted(tips, key=sortkey, reverse=True): |
|
301 | 301 | if limit > 0 and count >= limit: |
|
302 | 302 | return |
|
303 | 303 | count += 1 |
|
304 | 304 | if closed: |
|
305 | 305 | status = 'closed' |
|
306 | 306 | elif ctx.node() not in heads: |
|
307 | 307 | status = 'inactive' |
|
308 | 308 | else: |
|
309 | 309 | status = 'open' |
|
310 | 310 | yield { |
|
311 | 311 | 'parity': next(parity), |
|
312 | 312 | 'branch': ctx.branch(), |
|
313 | 313 | 'status': status, |
|
314 | 314 | 'node': ctx.hex(), |
|
315 | 315 | 'date': ctx.date() |
|
316 | 316 | } |
|
317 | 317 | |
|
318 | 318 | return templateutil.mappinggenerator(entries) |
|
319 | 319 | |
|
320 | 320 | def cleanpath(repo, path): |
|
321 | 321 | path = path.lstrip('/') |
|
322 | 322 | return pathutil.canonpath(repo.root, '', path) |
|
323 | 323 | |
|
324 | 324 | def changectx(repo, req): |
|
325 | 325 | changeid = "tip" |
|
326 | 326 | if 'node' in req.qsparams: |
|
327 | 327 | changeid = req.qsparams['node'] |
|
328 | 328 | ipos = changeid.find(':') |
|
329 | 329 | if ipos != -1: |
|
330 | 330 | changeid = changeid[(ipos + 1):] |
|
331 | 331 | |
|
332 | 332 | return scmutil.revsymbol(repo, changeid) |
|
333 | 333 | |
|
334 | 334 | def basechangectx(repo, req): |
|
335 | 335 | if 'node' in req.qsparams: |
|
336 | 336 | changeid = req.qsparams['node'] |
|
337 | 337 | ipos = changeid.find(':') |
|
338 | 338 | if ipos != -1: |
|
339 | 339 | changeid = changeid[:ipos] |
|
340 | 340 | return scmutil.revsymbol(repo, changeid) |
|
341 | 341 | |
|
342 | 342 | return None |
|
343 | 343 | |
|
344 | 344 | def filectx(repo, req): |
|
345 | 345 | if 'file' not in req.qsparams: |
|
346 | 346 | raise ErrorResponse(HTTP_NOT_FOUND, 'file not given') |
|
347 | 347 | path = cleanpath(repo, req.qsparams['file']) |
|
348 | 348 | if 'node' in req.qsparams: |
|
349 | 349 | changeid = req.qsparams['node'] |
|
350 | 350 | elif 'filenode' in req.qsparams: |
|
351 | 351 | changeid = req.qsparams['filenode'] |
|
352 | 352 | else: |
|
353 | 353 | raise ErrorResponse(HTTP_NOT_FOUND, 'node or filenode not given') |
|
354 | 354 | try: |
|
355 | 355 | fctx = scmutil.revsymbol(repo, changeid)[path] |
|
356 | 356 | except error.RepoError: |
|
357 | 357 | fctx = repo.filectx(path, fileid=changeid) |
|
358 | 358 | |
|
359 | 359 | return fctx |
|
360 | 360 | |
|
361 | 361 | def linerange(req): |
|
362 | 362 | linerange = req.qsparams.getall('linerange') |
|
363 | 363 | if not linerange: |
|
364 | 364 | return None |
|
365 | 365 | if len(linerange) > 1: |
|
366 | 366 | raise ErrorResponse(HTTP_BAD_REQUEST, |
|
367 | 367 | 'redundant linerange parameter') |
|
368 | 368 | try: |
|
369 | 369 | fromline, toline = map(int, linerange[0].split(':', 1)) |
|
370 | 370 | except ValueError: |
|
371 | 371 | raise ErrorResponse(HTTP_BAD_REQUEST, |
|
372 | 372 | 'invalid linerange parameter') |
|
373 | 373 | try: |
|
374 | 374 | return util.processlinerange(fromline, toline) |
|
375 | 375 | except error.ParseError as exc: |
|
376 | 376 | raise ErrorResponse(HTTP_BAD_REQUEST, pycompat.bytestr(exc)) |
|
377 | 377 | |
|
378 | 378 | def formatlinerange(fromline, toline): |
|
379 | 379 | return '%d:%d' % (fromline + 1, toline) |
|
380 | 380 | |
|
381 | 381 | def _succsandmarkersgen(context, mapping): |
|
382 | 382 | repo = context.resource(mapping, 'repo') |
|
383 | 383 | itemmappings = templatekw.showsuccsandmarkers(context, mapping) |
|
384 | 384 | for item in itemmappings.tovalue(context, mapping): |
|
385 | 385 | item['successors'] = _siblings(repo[successor] |
|
386 | 386 | for successor in item['successors']) |
|
387 | 387 | yield item |
|
388 | 388 | |
|
389 | 389 | def succsandmarkers(context, mapping): |
|
390 | 390 | return templateutil.mappinggenerator(_succsandmarkersgen, args=(mapping,)) |
|
391 | 391 | |
|
392 | 392 | # teach templater succsandmarkers is switched to (context, mapping) API |
|
393 | 393 | succsandmarkers._requires = {'repo', 'ctx'} |
|
394 | 394 | |
|
395 | 395 | def _whyunstablegen(context, mapping): |
|
396 | 396 | repo = context.resource(mapping, 'repo') |
|
397 | 397 | ctx = context.resource(mapping, 'ctx') |
|
398 | 398 | |
|
399 | 399 | entries = obsutil.whyunstable(repo, ctx) |
|
400 | 400 | for entry in entries: |
|
401 | 401 | if entry.get('divergentnodes'): |
|
402 | 402 | entry['divergentnodes'] = _siblings(entry['divergentnodes']) |
|
403 | 403 | yield entry |
|
404 | 404 | |
|
405 | 405 | def whyunstable(context, mapping): |
|
406 | 406 | return templateutil.mappinggenerator(_whyunstablegen, args=(mapping,)) |
|
407 | 407 | |
|
408 | 408 | whyunstable._requires = {'repo', 'ctx'} |
|
409 | 409 | |
|
410 | 410 | def commonentry(repo, ctx): |
|
411 | 411 | node = ctx.node() |
|
412 | 412 | return { |
|
413 | 413 | # TODO: perhaps ctx.changectx() should be assigned if ctx is a |
|
414 | 414 | # filectx, but I'm not pretty sure if that would always work because |
|
415 | 415 | # fctx.parents() != fctx.changectx.parents() for example. |
|
416 | 416 | 'ctx': ctx, |
|
417 | 417 | 'rev': ctx.rev(), |
|
418 | 418 | 'node': hex(node), |
|
419 | 419 | 'author': ctx.user(), |
|
420 | 420 | 'desc': ctx.description(), |
|
421 | 421 | 'date': ctx.date(), |
|
422 | 422 | 'extra': ctx.extra(), |
|
423 | 423 | 'phase': ctx.phasestr(), |
|
424 | 424 | 'obsolete': ctx.obsolete(), |
|
425 | 425 | 'succsandmarkers': succsandmarkers, |
|
426 | 426 | 'instabilities': templateutil.hybridlist(ctx.instabilities(), |
|
427 | 427 | name='instability'), |
|
428 | 428 | 'whyunstable': whyunstable, |
|
429 | 429 | 'branch': nodebranchnodefault(ctx), |
|
430 | 430 | 'inbranch': nodeinbranch(repo, ctx), |
|
431 | 431 | 'branches': nodebranchdict(repo, ctx), |
|
432 | 432 | 'tags': nodetagsdict(repo, node), |
|
433 | 433 | 'bookmarks': nodebookmarksdict(repo, node), |
|
434 | 434 | 'parent': lambda **x: parents(ctx), |
|
435 | 435 | 'child': lambda **x: children(ctx), |
|
436 | 436 | } |
|
437 | 437 | |
|
438 | 438 | def changelistentry(web, ctx): |
|
439 | 439 | '''Obtain a dictionary to be used for entries in a changelist. |
|
440 | 440 | |
|
441 | 441 | This function is called when producing items for the "entries" list passed |
|
442 | 442 | to the "shortlog" and "changelog" templates. |
|
443 | 443 | ''' |
|
444 | 444 | repo = web.repo |
|
445 | 445 | rev = ctx.rev() |
|
446 | 446 | n = ctx.node() |
|
447 | 447 | showtags = showtag(repo, 'changelogtag', n) |
|
448 | 448 | files = listfilediffs(ctx.files(), n, web.maxfiles) |
|
449 | 449 | |
|
450 | 450 | entry = commonentry(repo, ctx) |
|
451 | 451 | entry.update( |
|
452 | 452 | allparents=lambda **x: parents(ctx), |
|
453 | 453 | parent=lambda **x: parents(ctx, rev - 1), |
|
454 | 454 | child=lambda **x: children(ctx, rev + 1), |
|
455 | 455 | changelogtag=showtags, |
|
456 | 456 | files=files, |
|
457 | 457 | ) |
|
458 | 458 | return entry |
|
459 | 459 | |
|
460 | 460 | def changelistentries(web, revs, maxcount, parityfn): |
|
461 | 461 | """Emit up to N records for an iterable of revisions.""" |
|
462 | 462 | repo = web.repo |
|
463 | 463 | |
|
464 | 464 | count = 0 |
|
465 | 465 | for rev in revs: |
|
466 | 466 | if count >= maxcount: |
|
467 | 467 | break |
|
468 | 468 | |
|
469 | 469 | count += 1 |
|
470 | 470 | |
|
471 | 471 | entry = changelistentry(web, repo[rev]) |
|
472 | 472 | entry['parity'] = next(parityfn) |
|
473 | 473 | |
|
474 | 474 | yield entry |
|
475 | 475 | |
|
476 | 476 | def symrevorshortnode(req, ctx): |
|
477 | 477 | if 'node' in req.qsparams: |
|
478 | 478 | return templatefilters.revescape(req.qsparams['node']) |
|
479 | 479 | else: |
|
480 | 480 | return short(ctx.node()) |
|
481 | 481 | |
|
482 | 482 | def _listfilesgen(context, ctx, stripecount): |
|
483 | 483 | parity = paritygen(stripecount) |
|
484 | 484 | for blockno, f in enumerate(ctx.files()): |
|
485 | 485 | template = 'filenodelink' if f in ctx else 'filenolink' |
|
486 | 486 | yield context.process(template, { |
|
487 | 487 | 'node': ctx.hex(), |
|
488 | 488 | 'file': f, |
|
489 | 489 | 'blockno': blockno + 1, |
|
490 | 490 | 'parity': next(parity), |
|
491 | 491 | }) |
|
492 | 492 | |
|
493 | 493 | def changesetentry(web, ctx): |
|
494 | 494 | '''Obtain a dictionary to be used to render the "changeset" template.''' |
|
495 | 495 | |
|
496 | 496 | showtags = showtag(web.repo, 'changesettag', ctx.node()) |
|
497 | 497 | showbookmarks = showbookmark(web.repo, 'changesetbookmark', ctx.node()) |
|
498 | 498 | showbranch = nodebranchnodefault(ctx) |
|
499 | 499 | |
|
500 | 500 | basectx = basechangectx(web.repo, web.req) |
|
501 | 501 | if basectx is None: |
|
502 | 502 | basectx = ctx.p1() |
|
503 | 503 | |
|
504 | 504 | style = web.config('web', 'style') |
|
505 | 505 | if 'style' in web.req.qsparams: |
|
506 | 506 | style = web.req.qsparams['style'] |
|
507 | 507 | |
|
508 | 508 | diff = diffs(web, ctx, basectx, None, style) |
|
509 | 509 | |
|
510 | 510 | parity = paritygen(web.stripecount) |
|
511 | 511 | diffstatsgen = diffstatgen(ctx, basectx) |
|
512 | 512 | diffstats = diffstat(ctx, diffstatsgen, parity) |
|
513 | 513 | |
|
514 | 514 | return dict( |
|
515 | 515 | diff=diff, |
|
516 | 516 | symrev=symrevorshortnode(web.req, ctx), |
|
517 | 517 | basenode=basectx.hex(), |
|
518 | 518 | changesettag=showtags, |
|
519 | 519 | changesetbookmark=showbookmarks, |
|
520 | 520 | changesetbranch=showbranch, |
|
521 | 521 | files=templateutil.mappedgenerator(_listfilesgen, |
|
522 | 522 | args=(ctx, web.stripecount)), |
|
523 | 523 | diffsummary=lambda **x: diffsummary(diffstatsgen), |
|
524 | 524 | diffstat=diffstats, |
|
525 | 525 | archives=web.archivelist(ctx.hex()), |
|
526 | 526 | **pycompat.strkwargs(commonentry(web.repo, ctx))) |
|
527 | 527 | |
|
528 | 528 | def _listfilediffsgen(context, files, node, max): |
|
529 | 529 | for f in files[:max]: |
|
530 | 530 | yield context.process('filedifflink', {'node': hex(node), 'file': f}) |
|
531 | 531 | if len(files) > max: |
|
532 | 532 | yield context.process('fileellipses', {}) |
|
533 | 533 | |
|
534 | 534 | def listfilediffs(files, node, max): |
|
535 | 535 | return templateutil.mappedgenerator(_listfilediffsgen, |
|
536 | 536 | args=(files, node, max)) |
|
537 | 537 | |
|
538 | 538 | def _prettyprintdifflines(context, lines, blockno, lineidprefix): |
|
539 | 539 | for lineno, l in enumerate(lines, 1): |
|
540 | 540 | difflineno = "%d.%d" % (blockno, lineno) |
|
541 | 541 | if l.startswith('+'): |
|
542 | 542 | ltype = "difflineplus" |
|
543 | 543 | elif l.startswith('-'): |
|
544 | 544 | ltype = "difflineminus" |
|
545 | 545 | elif l.startswith('@'): |
|
546 | 546 | ltype = "difflineat" |
|
547 | 547 | else: |
|
548 | 548 | ltype = "diffline" |
|
549 | 549 | yield context.process(ltype, { |
|
550 | 550 | 'line': l, |
|
551 | 551 | 'lineno': lineno, |
|
552 | 552 | 'lineid': lineidprefix + "l%s" % difflineno, |
|
553 | 553 | 'linenumber': "% 8s" % difflineno, |
|
554 | 554 | }) |
|
555 | 555 | |
|
556 | 556 | def _diffsgen(context, repo, ctx, basectx, files, style, stripecount, |
|
557 | 557 | linerange, lineidprefix): |
|
558 | 558 | if files: |
|
559 | 559 | m = match.exact(repo.root, repo.getcwd(), files) |
|
560 | 560 | else: |
|
561 | 561 | m = match.always(repo.root, repo.getcwd()) |
|
562 | 562 | |
|
563 | 563 | diffopts = patch.diffopts(repo.ui, untrusted=True) |
|
564 | 564 | node1 = basectx.node() |
|
565 | 565 | node2 = ctx.node() |
|
566 | 566 | parity = paritygen(stripecount) |
|
567 | 567 | |
|
568 | 568 | diffhunks = patch.diffhunks(repo, node1, node2, m, opts=diffopts) |
|
569 | 569 | for blockno, (fctx1, fctx2, header, hunks) in enumerate(diffhunks, 1): |
|
570 | 570 | if style != 'raw': |
|
571 | 571 | header = header[1:] |
|
572 | 572 | lines = [h + '\n' for h in header] |
|
573 | 573 | for hunkrange, hunklines in hunks: |
|
574 | 574 | if linerange is not None and hunkrange is not None: |
|
575 | 575 | s1, l1, s2, l2 = hunkrange |
|
576 | 576 | if not mdiff.hunkinrange((s2, l2), linerange): |
|
577 | 577 | continue |
|
578 | 578 | lines.extend(hunklines) |
|
579 | 579 | if lines: |
|
580 | 580 | l = templateutil.mappedgenerator(_prettyprintdifflines, |
|
581 | 581 | args=(lines, blockno, |
|
582 | 582 | lineidprefix)) |
|
583 | 583 | yield { |
|
584 | 584 | 'parity': next(parity), |
|
585 | 585 | 'blockno': blockno, |
|
586 | 586 | 'lines': l, |
|
587 | 587 | } |
|
588 | 588 | |
|
589 | 589 | def diffs(web, ctx, basectx, files, style, linerange=None, lineidprefix=''): |
|
590 | 590 | args = (web.repo, ctx, basectx, files, style, web.stripecount, |
|
591 | 591 | linerange, lineidprefix) |
|
592 | 592 | return templateutil.mappinggenerator(_diffsgen, args=args, name='diffblock') |
|
593 | 593 | |
|
594 | 594 | def _compline(type, leftlineno, leftline, rightlineno, rightline): |
|
595 | 595 | lineid = leftlineno and ("l%d" % leftlineno) or '' |
|
596 | 596 | lineid += rightlineno and ("r%d" % rightlineno) or '' |
|
597 | 597 | llno = '%d' % leftlineno if leftlineno else '' |
|
598 | 598 | rlno = '%d' % rightlineno if rightlineno else '' |
|
599 | 599 | return { |
|
600 | 600 | 'type': type, |
|
601 | 601 | 'lineid': lineid, |
|
602 | 602 | 'leftlineno': leftlineno, |
|
603 | 603 | 'leftlinenumber': "% 6s" % llno, |
|
604 | 604 | 'leftline': leftline or '', |
|
605 | 605 | 'rightlineno': rightlineno, |
|
606 | 606 | 'rightlinenumber': "% 6s" % rlno, |
|
607 | 607 | 'rightline': rightline or '', |
|
608 | 608 | } |
|
609 | 609 | |
|
610 | 610 | def _getcompblockgen(context, leftlines, rightlines, opcodes): |
|
611 | 611 | for type, llo, lhi, rlo, rhi in opcodes: |
|
612 | 612 | len1 = lhi - llo |
|
613 | 613 | len2 = rhi - rlo |
|
614 | 614 | count = min(len1, len2) |
|
615 | 615 | for i in xrange(count): |
|
616 | 616 | yield _compline(type=type, |
|
617 | 617 | leftlineno=llo + i + 1, |
|
618 | 618 | leftline=leftlines[llo + i], |
|
619 | 619 | rightlineno=rlo + i + 1, |
|
620 | 620 | rightline=rightlines[rlo + i]) |
|
621 | 621 | if len1 > len2: |
|
622 | 622 | for i in xrange(llo + count, lhi): |
|
623 | 623 | yield _compline(type=type, |
|
624 | 624 | leftlineno=i + 1, |
|
625 | 625 | leftline=leftlines[i], |
|
626 | 626 | rightlineno=None, |
|
627 | 627 | rightline=None) |
|
628 | 628 | elif len2 > len1: |
|
629 | 629 | for i in xrange(rlo + count, rhi): |
|
630 | 630 | yield _compline(type=type, |
|
631 | 631 | leftlineno=None, |
|
632 | 632 | leftline=None, |
|
633 | 633 | rightlineno=i + 1, |
|
634 | 634 | rightline=rightlines[i]) |
|
635 | 635 | |
|
636 | 636 | def _getcompblock(leftlines, rightlines, opcodes): |
|
637 | 637 | args = (leftlines, rightlines, opcodes) |
|
638 | 638 | return templateutil.mappinggenerator(_getcompblockgen, args=args, |
|
639 | 639 | name='comparisonline') |
|
640 | 640 | |
|
641 | 641 | def _comparegen(context, contextnum, leftlines, rightlines): |
|
642 | 642 | '''Generator function that provides side-by-side comparison data.''' |
|
643 | 643 | s = difflib.SequenceMatcher(None, leftlines, rightlines) |
|
644 | 644 | if contextnum < 0: |
|
645 | 645 | l = _getcompblock(leftlines, rightlines, s.get_opcodes()) |
|
646 | 646 | yield {'lines': l} |
|
647 | 647 | else: |
|
648 | 648 | for oc in s.get_grouped_opcodes(n=contextnum): |
|
649 | 649 | l = _getcompblock(leftlines, rightlines, oc) |
|
650 | 650 | yield {'lines': l} |
|
651 | 651 | |
|
652 | 652 | def compare(contextnum, leftlines, rightlines): |
|
653 | 653 | args = (contextnum, leftlines, rightlines) |
|
654 | 654 | return templateutil.mappinggenerator(_comparegen, args=args, |
|
655 | 655 | name='comparisonblock') |
|
656 | 656 | |
|
657 | 657 | def diffstatgen(ctx, basectx): |
|
658 | 658 | '''Generator function that provides the diffstat data.''' |
|
659 | 659 | |
|
660 | 660 | stats = patch.diffstatdata( |
|
661 | 661 | util.iterlines(ctx.diff(basectx, noprefix=False))) |
|
662 | 662 | maxname, maxtotal, addtotal, removetotal, binary = patch.diffstatsum(stats) |
|
663 | 663 | while True: |
|
664 | 664 | yield stats, maxname, maxtotal, addtotal, removetotal, binary |
|
665 | 665 | |
|
666 | 666 | def diffsummary(statgen): |
|
667 | 667 | '''Return a short summary of the diff.''' |
|
668 | 668 | |
|
669 | 669 | stats, maxname, maxtotal, addtotal, removetotal, binary = next(statgen) |
|
670 | 670 | return _(' %d files changed, %d insertions(+), %d deletions(-)\n') % ( |
|
671 | 671 | len(stats), addtotal, removetotal) |
|
672 | 672 | |
|
673 | 673 | def _diffstattmplgen(context, ctx, statgen, parity): |
|
674 | 674 | stats, maxname, maxtotal, addtotal, removetotal, binary = next(statgen) |
|
675 | 675 | files = ctx.files() |
|
676 | 676 | |
|
677 | 677 | def pct(i): |
|
678 | 678 | if maxtotal == 0: |
|
679 | 679 | return 0 |
|
680 | 680 | return (float(i) / maxtotal) * 100 |
|
681 | 681 | |
|
682 | 682 | fileno = 0 |
|
683 | 683 | for filename, adds, removes, isbinary in stats: |
|
684 | 684 | template = 'diffstatlink' if filename in files else 'diffstatnolink' |
|
685 | 685 | total = adds + removes |
|
686 | 686 | fileno += 1 |
|
687 | 687 | yield context.process(template, { |
|
688 | 688 | 'node': ctx.hex(), |
|
689 | 689 | 'file': filename, |
|
690 | 690 | 'fileno': fileno, |
|
691 | 691 | 'total': total, |
|
692 | 692 | 'addpct': pct(adds), |
|
693 | 693 | 'removepct': pct(removes), |
|
694 | 694 | 'parity': next(parity), |
|
695 | 695 | }) |
|
696 | 696 | |
|
697 | 697 | def diffstat(ctx, statgen, parity): |
|
698 | 698 | '''Return a diffstat template for each file in the diff.''' |
|
699 | 699 | args = (ctx, statgen, parity) |
|
700 | 700 | return templateutil.mappedgenerator(_diffstattmplgen, args=args) |
|
701 | 701 | |
|
702 | 702 | class sessionvars(templateutil.wrapped): |
|
703 | 703 | def __init__(self, vars, start='?'): |
|
704 | 704 | self._start = start |
|
705 | 705 | self._vars = vars |
|
706 | 706 | |
|
707 | 707 | def __getitem__(self, key): |
|
708 | 708 | return self._vars[key] |
|
709 | 709 | |
|
710 | 710 | def __setitem__(self, key, value): |
|
711 | 711 | self._vars[key] = value |
|
712 | 712 | |
|
713 | 713 | def __copy__(self): |
|
714 | 714 | return sessionvars(copy.copy(self._vars), self._start) |
|
715 | 715 | |
|
716 | def getmember(self, context, mapping, key): | |
|
717 | return self._vars.get(key) | |
|
718 | ||
|
716 | 719 | def itermaps(self, context): |
|
717 | 720 | separator = self._start |
|
718 | 721 | for key, value in sorted(self._vars.iteritems()): |
|
719 | 722 | yield {'name': key, |
|
720 | 723 | 'value': pycompat.bytestr(value), |
|
721 | 724 | 'separator': separator, |
|
722 | 725 | } |
|
723 | 726 | separator = '&' |
|
724 | 727 | |
|
725 | 728 | def join(self, context, mapping, sep): |
|
726 | 729 | # could be '{separator}{name}={value|urlescape}' |
|
727 | 730 | raise error.ParseError(_('not displayable without template')) |
|
728 | 731 | |
|
729 | 732 | def show(self, context, mapping): |
|
730 | 733 | return self.join(context, '') |
|
731 | 734 | |
|
732 | 735 | def tovalue(self, context, mapping): |
|
733 | 736 | return self._vars |
|
734 | 737 | |
|
735 | 738 | class wsgiui(uimod.ui): |
|
736 | 739 | # default termwidth breaks under mod_wsgi |
|
737 | 740 | def termwidth(self): |
|
738 | 741 | return 80 |
|
739 | 742 | |
|
740 | 743 | def getwebsubs(repo): |
|
741 | 744 | websubtable = [] |
|
742 | 745 | websubdefs = repo.ui.configitems('websub') |
|
743 | 746 | # we must maintain interhg backwards compatibility |
|
744 | 747 | websubdefs += repo.ui.configitems('interhg') |
|
745 | 748 | for key, pattern in websubdefs: |
|
746 | 749 | # grab the delimiter from the character after the "s" |
|
747 | 750 | unesc = pattern[1:2] |
|
748 | 751 | delim = re.escape(unesc) |
|
749 | 752 | |
|
750 | 753 | # identify portions of the pattern, taking care to avoid escaped |
|
751 | 754 | # delimiters. the replace format and flags are optional, but |
|
752 | 755 | # delimiters are required. |
|
753 | 756 | match = re.match( |
|
754 | 757 | br'^s%s(.+)(?:(?<=\\\\)|(?<!\\))%s(.*)%s([ilmsux])*$' |
|
755 | 758 | % (delim, delim, delim), pattern) |
|
756 | 759 | if not match: |
|
757 | 760 | repo.ui.warn(_("websub: invalid pattern for %s: %s\n") |
|
758 | 761 | % (key, pattern)) |
|
759 | 762 | continue |
|
760 | 763 | |
|
761 | 764 | # we need to unescape the delimiter for regexp and format |
|
762 | 765 | delim_re = re.compile(br'(?<!\\)\\%s' % delim) |
|
763 | 766 | regexp = delim_re.sub(unesc, match.group(1)) |
|
764 | 767 | format = delim_re.sub(unesc, match.group(2)) |
|
765 | 768 | |
|
766 | 769 | # the pattern allows for 6 regexp flags, so set them if necessary |
|
767 | 770 | flagin = match.group(3) |
|
768 | 771 | flags = 0 |
|
769 | 772 | if flagin: |
|
770 | 773 | for flag in flagin.upper(): |
|
771 | 774 | flags |= re.__dict__[flag] |
|
772 | 775 | |
|
773 | 776 | try: |
|
774 | 777 | regexp = re.compile(regexp, flags) |
|
775 | 778 | websubtable.append((regexp, format)) |
|
776 | 779 | except re.error: |
|
777 | 780 | repo.ui.warn(_("websub: invalid regexp for %s: %s\n") |
|
778 | 781 | % (key, regexp)) |
|
779 | 782 | return websubtable |
|
780 | 783 | |
|
781 | 784 | def getgraphnode(repo, ctx): |
|
782 | 785 | return (templatekw.getgraphnodecurrent(repo, ctx) + |
|
783 | 786 | templatekw.getgraphnodesymbol(ctx)) |
@@ -1,701 +1,702 b'' | |||
|
1 | 1 | # templatefuncs.py - common template functions |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import re |
|
11 | 11 | |
|
12 | 12 | from .i18n import _ |
|
13 | 13 | from .node import ( |
|
14 | 14 | bin, |
|
15 | 15 | wdirid, |
|
16 | 16 | ) |
|
17 | 17 | from . import ( |
|
18 | 18 | color, |
|
19 | 19 | encoding, |
|
20 | 20 | error, |
|
21 | 21 | minirst, |
|
22 | 22 | obsutil, |
|
23 | 23 | pycompat, |
|
24 | 24 | registrar, |
|
25 | 25 | revset as revsetmod, |
|
26 | 26 | revsetlang, |
|
27 | 27 | scmutil, |
|
28 | 28 | templatefilters, |
|
29 | 29 | templatekw, |
|
30 | 30 | templateutil, |
|
31 | 31 | util, |
|
32 | 32 | ) |
|
33 | 33 | from .utils import ( |
|
34 | 34 | dateutil, |
|
35 | 35 | stringutil, |
|
36 | 36 | ) |
|
37 | 37 | |
|
38 | 38 | evalrawexp = templateutil.evalrawexp |
|
39 | 39 | evalwrapped = templateutil.evalwrapped |
|
40 | 40 | evalfuncarg = templateutil.evalfuncarg |
|
41 | 41 | evalboolean = templateutil.evalboolean |
|
42 | 42 | evaldate = templateutil.evaldate |
|
43 | 43 | evalinteger = templateutil.evalinteger |
|
44 | 44 | evalstring = templateutil.evalstring |
|
45 | 45 | evalstringliteral = templateutil.evalstringliteral |
|
46 | 46 | |
|
47 | 47 | # dict of template built-in functions |
|
48 | 48 | funcs = {} |
|
49 | 49 | templatefunc = registrar.templatefunc(funcs) |
|
50 | 50 | |
|
51 | 51 | @templatefunc('date(date[, fmt])') |
|
52 | 52 | def date(context, mapping, args): |
|
53 | 53 | """Format a date. See :hg:`help dates` for formatting |
|
54 | 54 | strings. The default is a Unix date format, including the timezone: |
|
55 | 55 | "Mon Sep 04 15:13:13 2006 0700".""" |
|
56 | 56 | if not (1 <= len(args) <= 2): |
|
57 | 57 | # i18n: "date" is a keyword |
|
58 | 58 | raise error.ParseError(_("date expects one or two arguments")) |
|
59 | 59 | |
|
60 | 60 | date = evaldate(context, mapping, args[0], |
|
61 | 61 | # i18n: "date" is a keyword |
|
62 | 62 | _("date expects a date information")) |
|
63 | 63 | fmt = None |
|
64 | 64 | if len(args) == 2: |
|
65 | 65 | fmt = evalstring(context, mapping, args[1]) |
|
66 | 66 | if fmt is None: |
|
67 | 67 | return dateutil.datestr(date) |
|
68 | 68 | else: |
|
69 | 69 | return dateutil.datestr(date, fmt) |
|
70 | 70 | |
|
71 | 71 | @templatefunc('dict([[key=]value...])', argspec='*args **kwargs') |
|
72 | 72 | def dict_(context, mapping, args): |
|
73 | 73 | """Construct a dict from key-value pairs. A key may be omitted if |
|
74 | 74 | a value expression can provide an unambiguous name.""" |
|
75 | 75 | data = util.sortdict() |
|
76 | 76 | |
|
77 | 77 | for v in args['args']: |
|
78 | 78 | k = templateutil.findsymbolicname(v) |
|
79 | 79 | if not k: |
|
80 | 80 | raise error.ParseError(_('dict key cannot be inferred')) |
|
81 | 81 | if k in data or k in args['kwargs']: |
|
82 | 82 | raise error.ParseError(_("duplicated dict key '%s' inferred") % k) |
|
83 | 83 | data[k] = evalfuncarg(context, mapping, v) |
|
84 | 84 | |
|
85 | 85 | data.update((k, evalfuncarg(context, mapping, v)) |
|
86 | 86 | for k, v in args['kwargs'].iteritems()) |
|
87 | 87 | return templateutil.hybriddict(data) |
|
88 | 88 | |
|
89 | 89 | @templatefunc('diff([includepattern [, excludepattern]])') |
|
90 | 90 | def diff(context, mapping, args): |
|
91 | 91 | """Show a diff, optionally |
|
92 | 92 | specifying files to include or exclude.""" |
|
93 | 93 | if len(args) > 2: |
|
94 | 94 | # i18n: "diff" is a keyword |
|
95 | 95 | raise error.ParseError(_("diff expects zero, one, or two arguments")) |
|
96 | 96 | |
|
97 | 97 | def getpatterns(i): |
|
98 | 98 | if i < len(args): |
|
99 | 99 | s = evalstring(context, mapping, args[i]).strip() |
|
100 | 100 | if s: |
|
101 | 101 | return [s] |
|
102 | 102 | return [] |
|
103 | 103 | |
|
104 | 104 | ctx = context.resource(mapping, 'ctx') |
|
105 | 105 | chunks = ctx.diff(match=ctx.match([], getpatterns(0), getpatterns(1))) |
|
106 | 106 | |
|
107 | 107 | return ''.join(chunks) |
|
108 | 108 | |
|
109 | 109 | @templatefunc('extdata(source)', argspec='source') |
|
110 | 110 | def extdata(context, mapping, args): |
|
111 | 111 | """Show a text read from the specified extdata source. (EXPERIMENTAL)""" |
|
112 | 112 | if 'source' not in args: |
|
113 | 113 | # i18n: "extdata" is a keyword |
|
114 | 114 | raise error.ParseError(_('extdata expects one argument')) |
|
115 | 115 | |
|
116 | 116 | source = evalstring(context, mapping, args['source']) |
|
117 | 117 | if not source: |
|
118 | 118 | sym = templateutil.findsymbolicname(args['source']) |
|
119 | 119 | if sym: |
|
120 | 120 | raise error.ParseError(_('empty data source specified'), |
|
121 | 121 | hint=_("did you mean extdata('%s')?") % sym) |
|
122 | 122 | else: |
|
123 | 123 | raise error.ParseError(_('empty data source specified')) |
|
124 | 124 | cache = context.resource(mapping, 'cache').setdefault('extdata', {}) |
|
125 | 125 | ctx = context.resource(mapping, 'ctx') |
|
126 | 126 | if source in cache: |
|
127 | 127 | data = cache[source] |
|
128 | 128 | else: |
|
129 | 129 | data = cache[source] = scmutil.extdatasource(ctx.repo(), source) |
|
130 | 130 | return data.get(ctx.rev(), '') |
|
131 | 131 | |
|
132 | 132 | @templatefunc('files(pattern)') |
|
133 | 133 | def files(context, mapping, args): |
|
134 | 134 | """All files of the current changeset matching the pattern. See |
|
135 | 135 | :hg:`help patterns`.""" |
|
136 | 136 | if not len(args) == 1: |
|
137 | 137 | # i18n: "files" is a keyword |
|
138 | 138 | raise error.ParseError(_("files expects one argument")) |
|
139 | 139 | |
|
140 | 140 | raw = evalstring(context, mapping, args[0]) |
|
141 | 141 | ctx = context.resource(mapping, 'ctx') |
|
142 | 142 | m = ctx.match([raw]) |
|
143 | 143 | files = list(ctx.matches(m)) |
|
144 | 144 | return templateutil.compatlist(context, mapping, "file", files) |
|
145 | 145 | |
|
146 | 146 | @templatefunc('fill(text[, width[, initialident[, hangindent]]])') |
|
147 | 147 | def fill(context, mapping, args): |
|
148 | 148 | """Fill many |
|
149 | 149 | paragraphs with optional indentation. See the "fill" filter.""" |
|
150 | 150 | if not (1 <= len(args) <= 4): |
|
151 | 151 | # i18n: "fill" is a keyword |
|
152 | 152 | raise error.ParseError(_("fill expects one to four arguments")) |
|
153 | 153 | |
|
154 | 154 | text = evalstring(context, mapping, args[0]) |
|
155 | 155 | width = 76 |
|
156 | 156 | initindent = '' |
|
157 | 157 | hangindent = '' |
|
158 | 158 | if 2 <= len(args) <= 4: |
|
159 | 159 | width = evalinteger(context, mapping, args[1], |
|
160 | 160 | # i18n: "fill" is a keyword |
|
161 | 161 | _("fill expects an integer width")) |
|
162 | 162 | try: |
|
163 | 163 | initindent = evalstring(context, mapping, args[2]) |
|
164 | 164 | hangindent = evalstring(context, mapping, args[3]) |
|
165 | 165 | except IndexError: |
|
166 | 166 | pass |
|
167 | 167 | |
|
168 | 168 | return templatefilters.fill(text, width, initindent, hangindent) |
|
169 | 169 | |
|
170 | 170 | @templatefunc('formatnode(node)') |
|
171 | 171 | def formatnode(context, mapping, args): |
|
172 | 172 | """Obtain the preferred form of a changeset hash. (DEPRECATED)""" |
|
173 | 173 | if len(args) != 1: |
|
174 | 174 | # i18n: "formatnode" is a keyword |
|
175 | 175 | raise error.ParseError(_("formatnode expects one argument")) |
|
176 | 176 | |
|
177 | 177 | ui = context.resource(mapping, 'ui') |
|
178 | 178 | node = evalstring(context, mapping, args[0]) |
|
179 | 179 | if ui.debugflag: |
|
180 | 180 | return node |
|
181 | 181 | return templatefilters.short(node) |
|
182 | 182 | |
|
183 | 183 | @templatefunc('mailmap(author)') |
|
184 | 184 | def mailmap(context, mapping, args): |
|
185 | 185 | """Return the author, updated according to the value |
|
186 | 186 | set in the .mailmap file""" |
|
187 | 187 | if len(args) != 1: |
|
188 | 188 | raise error.ParseError(_("mailmap expects one argument")) |
|
189 | 189 | |
|
190 | 190 | author = evalstring(context, mapping, args[0]) |
|
191 | 191 | |
|
192 | 192 | cache = context.resource(mapping, 'cache') |
|
193 | 193 | repo = context.resource(mapping, 'repo') |
|
194 | 194 | |
|
195 | 195 | if 'mailmap' not in cache: |
|
196 | 196 | data = repo.wvfs.tryread('.mailmap') |
|
197 | 197 | cache['mailmap'] = stringutil.parsemailmap(data) |
|
198 | 198 | |
|
199 | 199 | return stringutil.mapname(cache['mailmap'], author) |
|
200 | 200 | |
|
201 | 201 | @templatefunc('pad(text, width[, fillchar=\' \'[, left=False]])', |
|
202 | 202 | argspec='text width fillchar left') |
|
203 | 203 | def pad(context, mapping, args): |
|
204 | 204 | """Pad text with a |
|
205 | 205 | fill character.""" |
|
206 | 206 | if 'text' not in args or 'width' not in args: |
|
207 | 207 | # i18n: "pad" is a keyword |
|
208 | 208 | raise error.ParseError(_("pad() expects two to four arguments")) |
|
209 | 209 | |
|
210 | 210 | width = evalinteger(context, mapping, args['width'], |
|
211 | 211 | # i18n: "pad" is a keyword |
|
212 | 212 | _("pad() expects an integer width")) |
|
213 | 213 | |
|
214 | 214 | text = evalstring(context, mapping, args['text']) |
|
215 | 215 | |
|
216 | 216 | left = False |
|
217 | 217 | fillchar = ' ' |
|
218 | 218 | if 'fillchar' in args: |
|
219 | 219 | fillchar = evalstring(context, mapping, args['fillchar']) |
|
220 | 220 | if len(color.stripeffects(fillchar)) != 1: |
|
221 | 221 | # i18n: "pad" is a keyword |
|
222 | 222 | raise error.ParseError(_("pad() expects a single fill character")) |
|
223 | 223 | if 'left' in args: |
|
224 | 224 | left = evalboolean(context, mapping, args['left']) |
|
225 | 225 | |
|
226 | 226 | fillwidth = width - encoding.colwidth(color.stripeffects(text)) |
|
227 | 227 | if fillwidth <= 0: |
|
228 | 228 | return text |
|
229 | 229 | if left: |
|
230 | 230 | return fillchar * fillwidth + text |
|
231 | 231 | else: |
|
232 | 232 | return text + fillchar * fillwidth |
|
233 | 233 | |
|
234 | 234 | @templatefunc('indent(text, indentchars[, firstline])') |
|
235 | 235 | def indent(context, mapping, args): |
|
236 | 236 | """Indents all non-empty lines |
|
237 | 237 | with the characters given in the indentchars string. An optional |
|
238 | 238 | third parameter will override the indent for the first line only |
|
239 | 239 | if present.""" |
|
240 | 240 | if not (2 <= len(args) <= 3): |
|
241 | 241 | # i18n: "indent" is a keyword |
|
242 | 242 | raise error.ParseError(_("indent() expects two or three arguments")) |
|
243 | 243 | |
|
244 | 244 | text = evalstring(context, mapping, args[0]) |
|
245 | 245 | indent = evalstring(context, mapping, args[1]) |
|
246 | 246 | |
|
247 | 247 | if len(args) == 3: |
|
248 | 248 | firstline = evalstring(context, mapping, args[2]) |
|
249 | 249 | else: |
|
250 | 250 | firstline = indent |
|
251 | 251 | |
|
252 | 252 | # the indent function doesn't indent the first line, so we do it here |
|
253 | 253 | return templatefilters.indent(firstline + text, indent) |
|
254 | 254 | |
|
255 | 255 | @templatefunc('get(dict, key)') |
|
256 | 256 | def get(context, mapping, args): |
|
257 | 257 | """Get an attribute/key from an object. Some keywords |
|
258 | 258 | are complex types. This function allows you to obtain the value of an |
|
259 | 259 | attribute on these types.""" |
|
260 | 260 | if len(args) != 2: |
|
261 | 261 | # i18n: "get" is a keyword |
|
262 | 262 | raise error.ParseError(_("get() expects two arguments")) |
|
263 | 263 | |
|
264 | 264 | dictarg = evalwrapped(context, mapping, args[0]) |
|
265 | if not util.safehasattr(dictarg, 'getmember'): | |
|
265 | key = evalfuncarg(context, mapping, args[1]) | |
|
266 | try: | |
|
267 | return dictarg.getmember(context, mapping, key) | |
|
268 | except error.ParseError as err: | |
|
266 | 269 | # i18n: "get" is a keyword |
|
267 |
|
|
|
268 | ||
|
269 | key = evalfuncarg(context, mapping, args[1]) | |
|
270 | return dictarg.getmember(context, mapping, key) | |
|
270 | hint = _("get() expects a dict as first argument") | |
|
271 | raise error.ParseError(bytes(err), hint=hint) | |
|
271 | 272 | |
|
272 | 273 | @templatefunc('if(expr, then[, else])') |
|
273 | 274 | def if_(context, mapping, args): |
|
274 | 275 | """Conditionally execute based on the result of |
|
275 | 276 | an expression.""" |
|
276 | 277 | if not (2 <= len(args) <= 3): |
|
277 | 278 | # i18n: "if" is a keyword |
|
278 | 279 | raise error.ParseError(_("if expects two or three arguments")) |
|
279 | 280 | |
|
280 | 281 | test = evalboolean(context, mapping, args[0]) |
|
281 | 282 | if test: |
|
282 | 283 | return evalrawexp(context, mapping, args[1]) |
|
283 | 284 | elif len(args) == 3: |
|
284 | 285 | return evalrawexp(context, mapping, args[2]) |
|
285 | 286 | |
|
286 | 287 | @templatefunc('ifcontains(needle, haystack, then[, else])') |
|
287 | 288 | def ifcontains(context, mapping, args): |
|
288 | 289 | """Conditionally execute based |
|
289 | 290 | on whether the item "needle" is in "haystack".""" |
|
290 | 291 | if not (3 <= len(args) <= 4): |
|
291 | 292 | # i18n: "ifcontains" is a keyword |
|
292 | 293 | raise error.ParseError(_("ifcontains expects three or four arguments")) |
|
293 | 294 | |
|
294 | 295 | haystack = evalfuncarg(context, mapping, args[1]) |
|
295 | 296 | keytype = getattr(haystack, 'keytype', None) |
|
296 | 297 | try: |
|
297 | 298 | needle = evalrawexp(context, mapping, args[0]) |
|
298 | 299 | needle = templateutil.unwrapastype(context, mapping, needle, |
|
299 | 300 | keytype or bytes) |
|
300 | 301 | found = (needle in haystack) |
|
301 | 302 | except error.ParseError: |
|
302 | 303 | found = False |
|
303 | 304 | |
|
304 | 305 | if found: |
|
305 | 306 | return evalrawexp(context, mapping, args[2]) |
|
306 | 307 | elif len(args) == 4: |
|
307 | 308 | return evalrawexp(context, mapping, args[3]) |
|
308 | 309 | |
|
309 | 310 | @templatefunc('ifeq(expr1, expr2, then[, else])') |
|
310 | 311 | def ifeq(context, mapping, args): |
|
311 | 312 | """Conditionally execute based on |
|
312 | 313 | whether 2 items are equivalent.""" |
|
313 | 314 | if not (3 <= len(args) <= 4): |
|
314 | 315 | # i18n: "ifeq" is a keyword |
|
315 | 316 | raise error.ParseError(_("ifeq expects three or four arguments")) |
|
316 | 317 | |
|
317 | 318 | test = evalstring(context, mapping, args[0]) |
|
318 | 319 | match = evalstring(context, mapping, args[1]) |
|
319 | 320 | if test == match: |
|
320 | 321 | return evalrawexp(context, mapping, args[2]) |
|
321 | 322 | elif len(args) == 4: |
|
322 | 323 | return evalrawexp(context, mapping, args[3]) |
|
323 | 324 | |
|
324 | 325 | @templatefunc('join(list, sep)') |
|
325 | 326 | def join(context, mapping, args): |
|
326 | 327 | """Join items in a list with a delimiter.""" |
|
327 | 328 | if not (1 <= len(args) <= 2): |
|
328 | 329 | # i18n: "join" is a keyword |
|
329 | 330 | raise error.ParseError(_("join expects one or two arguments")) |
|
330 | 331 | |
|
331 | 332 | joinset = evalwrapped(context, mapping, args[0]) |
|
332 | 333 | joiner = " " |
|
333 | 334 | if len(args) > 1: |
|
334 | 335 | joiner = evalstring(context, mapping, args[1]) |
|
335 | 336 | return joinset.join(context, mapping, joiner) |
|
336 | 337 | |
|
337 | 338 | @templatefunc('label(label, expr)') |
|
338 | 339 | def label(context, mapping, args): |
|
339 | 340 | """Apply a label to generated content. Content with |
|
340 | 341 | a label applied can result in additional post-processing, such as |
|
341 | 342 | automatic colorization.""" |
|
342 | 343 | if len(args) != 2: |
|
343 | 344 | # i18n: "label" is a keyword |
|
344 | 345 | raise error.ParseError(_("label expects two arguments")) |
|
345 | 346 | |
|
346 | 347 | ui = context.resource(mapping, 'ui') |
|
347 | 348 | thing = evalstring(context, mapping, args[1]) |
|
348 | 349 | # preserve unknown symbol as literal so effects like 'red', 'bold', |
|
349 | 350 | # etc. don't need to be quoted |
|
350 | 351 | label = evalstringliteral(context, mapping, args[0]) |
|
351 | 352 | |
|
352 | 353 | return ui.label(thing, label) |
|
353 | 354 | |
|
354 | 355 | @templatefunc('latesttag([pattern])') |
|
355 | 356 | def latesttag(context, mapping, args): |
|
356 | 357 | """The global tags matching the given pattern on the |
|
357 | 358 | most recent globally tagged ancestor of this changeset. |
|
358 | 359 | If no such tags exist, the "{tag}" template resolves to |
|
359 | 360 | the string "null". See :hg:`help revisions.patterns` for the pattern |
|
360 | 361 | syntax. |
|
361 | 362 | """ |
|
362 | 363 | if len(args) > 1: |
|
363 | 364 | # i18n: "latesttag" is a keyword |
|
364 | 365 | raise error.ParseError(_("latesttag expects at most one argument")) |
|
365 | 366 | |
|
366 | 367 | pattern = None |
|
367 | 368 | if len(args) == 1: |
|
368 | 369 | pattern = evalstring(context, mapping, args[0]) |
|
369 | 370 | return templatekw.showlatesttags(context, mapping, pattern) |
|
370 | 371 | |
|
371 | 372 | @templatefunc('localdate(date[, tz])') |
|
372 | 373 | def localdate(context, mapping, args): |
|
373 | 374 | """Converts a date to the specified timezone. |
|
374 | 375 | The default is local date.""" |
|
375 | 376 | if not (1 <= len(args) <= 2): |
|
376 | 377 | # i18n: "localdate" is a keyword |
|
377 | 378 | raise error.ParseError(_("localdate expects one or two arguments")) |
|
378 | 379 | |
|
379 | 380 | date = evaldate(context, mapping, args[0], |
|
380 | 381 | # i18n: "localdate" is a keyword |
|
381 | 382 | _("localdate expects a date information")) |
|
382 | 383 | if len(args) >= 2: |
|
383 | 384 | tzoffset = None |
|
384 | 385 | tz = evalfuncarg(context, mapping, args[1]) |
|
385 | 386 | if isinstance(tz, bytes): |
|
386 | 387 | tzoffset, remainder = dateutil.parsetimezone(tz) |
|
387 | 388 | if remainder: |
|
388 | 389 | tzoffset = None |
|
389 | 390 | if tzoffset is None: |
|
390 | 391 | try: |
|
391 | 392 | tzoffset = int(tz) |
|
392 | 393 | except (TypeError, ValueError): |
|
393 | 394 | # i18n: "localdate" is a keyword |
|
394 | 395 | raise error.ParseError(_("localdate expects a timezone")) |
|
395 | 396 | else: |
|
396 | 397 | tzoffset = dateutil.makedate()[1] |
|
397 | 398 | return (date[0], tzoffset) |
|
398 | 399 | |
|
399 | 400 | @templatefunc('max(iterable)') |
|
400 | 401 | def max_(context, mapping, args, **kwargs): |
|
401 | 402 | """Return the max of an iterable""" |
|
402 | 403 | if len(args) != 1: |
|
403 | 404 | # i18n: "max" is a keyword |
|
404 | 405 | raise error.ParseError(_("max expects one argument")) |
|
405 | 406 | |
|
406 | 407 | iterable = evalfuncarg(context, mapping, args[0]) |
|
407 | 408 | try: |
|
408 | 409 | x = max(pycompat.maybebytestr(iterable)) |
|
409 | 410 | except (TypeError, ValueError): |
|
410 | 411 | # i18n: "max" is a keyword |
|
411 | 412 | raise error.ParseError(_("max first argument should be an iterable")) |
|
412 | 413 | return templateutil.wraphybridvalue(iterable, x, x) |
|
413 | 414 | |
|
414 | 415 | @templatefunc('min(iterable)') |
|
415 | 416 | def min_(context, mapping, args, **kwargs): |
|
416 | 417 | """Return the min of an iterable""" |
|
417 | 418 | if len(args) != 1: |
|
418 | 419 | # i18n: "min" is a keyword |
|
419 | 420 | raise error.ParseError(_("min expects one argument")) |
|
420 | 421 | |
|
421 | 422 | iterable = evalfuncarg(context, mapping, args[0]) |
|
422 | 423 | try: |
|
423 | 424 | x = min(pycompat.maybebytestr(iterable)) |
|
424 | 425 | except (TypeError, ValueError): |
|
425 | 426 | # i18n: "min" is a keyword |
|
426 | 427 | raise error.ParseError(_("min first argument should be an iterable")) |
|
427 | 428 | return templateutil.wraphybridvalue(iterable, x, x) |
|
428 | 429 | |
|
429 | 430 | @templatefunc('mod(a, b)') |
|
430 | 431 | def mod(context, mapping, args): |
|
431 | 432 | """Calculate a mod b such that a / b + a mod b == a""" |
|
432 | 433 | if not len(args) == 2: |
|
433 | 434 | # i18n: "mod" is a keyword |
|
434 | 435 | raise error.ParseError(_("mod expects two arguments")) |
|
435 | 436 | |
|
436 | 437 | func = lambda a, b: a % b |
|
437 | 438 | return templateutil.runarithmetic(context, mapping, |
|
438 | 439 | (func, args[0], args[1])) |
|
439 | 440 | |
|
440 | 441 | @templatefunc('obsfateoperations(markers)') |
|
441 | 442 | def obsfateoperations(context, mapping, args): |
|
442 | 443 | """Compute obsfate related information based on markers (EXPERIMENTAL)""" |
|
443 | 444 | if len(args) != 1: |
|
444 | 445 | # i18n: "obsfateoperations" is a keyword |
|
445 | 446 | raise error.ParseError(_("obsfateoperations expects one argument")) |
|
446 | 447 | |
|
447 | 448 | markers = evalfuncarg(context, mapping, args[0]) |
|
448 | 449 | |
|
449 | 450 | try: |
|
450 | 451 | data = obsutil.markersoperations(markers) |
|
451 | 452 | return templateutil.hybridlist(data, name='operation') |
|
452 | 453 | except (TypeError, KeyError): |
|
453 | 454 | # i18n: "obsfateoperations" is a keyword |
|
454 | 455 | errmsg = _("obsfateoperations first argument should be an iterable") |
|
455 | 456 | raise error.ParseError(errmsg) |
|
456 | 457 | |
|
457 | 458 | @templatefunc('obsfatedate(markers)') |
|
458 | 459 | def obsfatedate(context, mapping, args): |
|
459 | 460 | """Compute obsfate related information based on markers (EXPERIMENTAL)""" |
|
460 | 461 | if len(args) != 1: |
|
461 | 462 | # i18n: "obsfatedate" is a keyword |
|
462 | 463 | raise error.ParseError(_("obsfatedate expects one argument")) |
|
463 | 464 | |
|
464 | 465 | markers = evalfuncarg(context, mapping, args[0]) |
|
465 | 466 | |
|
466 | 467 | try: |
|
467 | 468 | data = obsutil.markersdates(markers) |
|
468 | 469 | return templateutil.hybridlist(data, name='date', fmt='%d %d') |
|
469 | 470 | except (TypeError, KeyError): |
|
470 | 471 | # i18n: "obsfatedate" is a keyword |
|
471 | 472 | errmsg = _("obsfatedate first argument should be an iterable") |
|
472 | 473 | raise error.ParseError(errmsg) |
|
473 | 474 | |
|
474 | 475 | @templatefunc('obsfateusers(markers)') |
|
475 | 476 | def obsfateusers(context, mapping, args): |
|
476 | 477 | """Compute obsfate related information based on markers (EXPERIMENTAL)""" |
|
477 | 478 | if len(args) != 1: |
|
478 | 479 | # i18n: "obsfateusers" is a keyword |
|
479 | 480 | raise error.ParseError(_("obsfateusers expects one argument")) |
|
480 | 481 | |
|
481 | 482 | markers = evalfuncarg(context, mapping, args[0]) |
|
482 | 483 | |
|
483 | 484 | try: |
|
484 | 485 | data = obsutil.markersusers(markers) |
|
485 | 486 | return templateutil.hybridlist(data, name='user') |
|
486 | 487 | except (TypeError, KeyError, ValueError): |
|
487 | 488 | # i18n: "obsfateusers" is a keyword |
|
488 | 489 | msg = _("obsfateusers first argument should be an iterable of " |
|
489 | 490 | "obsmakers") |
|
490 | 491 | raise error.ParseError(msg) |
|
491 | 492 | |
|
492 | 493 | @templatefunc('obsfateverb(successors, markers)') |
|
493 | 494 | def obsfateverb(context, mapping, args): |
|
494 | 495 | """Compute obsfate related information based on successors (EXPERIMENTAL)""" |
|
495 | 496 | if len(args) != 2: |
|
496 | 497 | # i18n: "obsfateverb" is a keyword |
|
497 | 498 | raise error.ParseError(_("obsfateverb expects two arguments")) |
|
498 | 499 | |
|
499 | 500 | successors = evalfuncarg(context, mapping, args[0]) |
|
500 | 501 | markers = evalfuncarg(context, mapping, args[1]) |
|
501 | 502 | |
|
502 | 503 | try: |
|
503 | 504 | return obsutil.obsfateverb(successors, markers) |
|
504 | 505 | except TypeError: |
|
505 | 506 | # i18n: "obsfateverb" is a keyword |
|
506 | 507 | errmsg = _("obsfateverb first argument should be countable") |
|
507 | 508 | raise error.ParseError(errmsg) |
|
508 | 509 | |
|
509 | 510 | @templatefunc('relpath(path)') |
|
510 | 511 | def relpath(context, mapping, args): |
|
511 | 512 | """Convert a repository-absolute path into a filesystem path relative to |
|
512 | 513 | the current working directory.""" |
|
513 | 514 | if len(args) != 1: |
|
514 | 515 | # i18n: "relpath" is a keyword |
|
515 | 516 | raise error.ParseError(_("relpath expects one argument")) |
|
516 | 517 | |
|
517 | 518 | repo = context.resource(mapping, 'ctx').repo() |
|
518 | 519 | path = evalstring(context, mapping, args[0]) |
|
519 | 520 | return repo.pathto(path) |
|
520 | 521 | |
|
521 | 522 | @templatefunc('revset(query[, formatargs...])') |
|
522 | 523 | def revset(context, mapping, args): |
|
523 | 524 | """Execute a revision set query. See |
|
524 | 525 | :hg:`help revset`.""" |
|
525 | 526 | if not len(args) > 0: |
|
526 | 527 | # i18n: "revset" is a keyword |
|
527 | 528 | raise error.ParseError(_("revset expects one or more arguments")) |
|
528 | 529 | |
|
529 | 530 | raw = evalstring(context, mapping, args[0]) |
|
530 | 531 | ctx = context.resource(mapping, 'ctx') |
|
531 | 532 | repo = ctx.repo() |
|
532 | 533 | |
|
533 | 534 | def query(expr): |
|
534 | 535 | m = revsetmod.match(repo.ui, expr, lookup=revsetmod.lookupfn(repo)) |
|
535 | 536 | return m(repo) |
|
536 | 537 | |
|
537 | 538 | if len(args) > 1: |
|
538 | 539 | formatargs = [evalfuncarg(context, mapping, a) for a in args[1:]] |
|
539 | 540 | revs = query(revsetlang.formatspec(raw, *formatargs)) |
|
540 | 541 | revs = list(revs) |
|
541 | 542 | else: |
|
542 | 543 | cache = context.resource(mapping, 'cache') |
|
543 | 544 | revsetcache = cache.setdefault("revsetcache", {}) |
|
544 | 545 | if raw in revsetcache: |
|
545 | 546 | revs = revsetcache[raw] |
|
546 | 547 | else: |
|
547 | 548 | revs = query(raw) |
|
548 | 549 | revs = list(revs) |
|
549 | 550 | revsetcache[raw] = revs |
|
550 | 551 | return templatekw.showrevslist(context, mapping, "revision", revs) |
|
551 | 552 | |
|
552 | 553 | @templatefunc('rstdoc(text, style)') |
|
553 | 554 | def rstdoc(context, mapping, args): |
|
554 | 555 | """Format reStructuredText.""" |
|
555 | 556 | if len(args) != 2: |
|
556 | 557 | # i18n: "rstdoc" is a keyword |
|
557 | 558 | raise error.ParseError(_("rstdoc expects two arguments")) |
|
558 | 559 | |
|
559 | 560 | text = evalstring(context, mapping, args[0]) |
|
560 | 561 | style = evalstring(context, mapping, args[1]) |
|
561 | 562 | |
|
562 | 563 | return minirst.format(text, style=style, keep=['verbose'])[0] |
|
563 | 564 | |
|
564 | 565 | @templatefunc('separate(sep, args...)', argspec='sep *args') |
|
565 | 566 | def separate(context, mapping, args): |
|
566 | 567 | """Add a separator between non-empty arguments.""" |
|
567 | 568 | if 'sep' not in args: |
|
568 | 569 | # i18n: "separate" is a keyword |
|
569 | 570 | raise error.ParseError(_("separate expects at least one argument")) |
|
570 | 571 | |
|
571 | 572 | sep = evalstring(context, mapping, args['sep']) |
|
572 | 573 | first = True |
|
573 | 574 | for arg in args['args']: |
|
574 | 575 | argstr = evalstring(context, mapping, arg) |
|
575 | 576 | if not argstr: |
|
576 | 577 | continue |
|
577 | 578 | if first: |
|
578 | 579 | first = False |
|
579 | 580 | else: |
|
580 | 581 | yield sep |
|
581 | 582 | yield argstr |
|
582 | 583 | |
|
583 | 584 | @templatefunc('shortest(node, minlength=4)') |
|
584 | 585 | def shortest(context, mapping, args): |
|
585 | 586 | """Obtain the shortest representation of |
|
586 | 587 | a node.""" |
|
587 | 588 | if not (1 <= len(args) <= 2): |
|
588 | 589 | # i18n: "shortest" is a keyword |
|
589 | 590 | raise error.ParseError(_("shortest() expects one or two arguments")) |
|
590 | 591 | |
|
591 | 592 | hexnode = evalstring(context, mapping, args[0]) |
|
592 | 593 | |
|
593 | 594 | minlength = 4 |
|
594 | 595 | if len(args) > 1: |
|
595 | 596 | minlength = evalinteger(context, mapping, args[1], |
|
596 | 597 | # i18n: "shortest" is a keyword |
|
597 | 598 | _("shortest() expects an integer minlength")) |
|
598 | 599 | |
|
599 | 600 | repo = context.resource(mapping, 'ctx')._repo |
|
600 | 601 | if len(hexnode) > 40: |
|
601 | 602 | return hexnode |
|
602 | 603 | elif len(hexnode) == 40: |
|
603 | 604 | try: |
|
604 | 605 | node = bin(hexnode) |
|
605 | 606 | except TypeError: |
|
606 | 607 | return hexnode |
|
607 | 608 | else: |
|
608 | 609 | try: |
|
609 | 610 | node = scmutil.resolvehexnodeidprefix(repo, hexnode) |
|
610 | 611 | except error.WdirUnsupported: |
|
611 | 612 | node = wdirid |
|
612 | 613 | except error.LookupError: |
|
613 | 614 | return hexnode |
|
614 | 615 | if not node: |
|
615 | 616 | return hexnode |
|
616 | 617 | try: |
|
617 | 618 | return scmutil.shortesthexnodeidprefix(repo, node, minlength) |
|
618 | 619 | except error.RepoLookupError: |
|
619 | 620 | return hexnode |
|
620 | 621 | |
|
621 | 622 | @templatefunc('strip(text[, chars])') |
|
622 | 623 | def strip(context, mapping, args): |
|
623 | 624 | """Strip characters from a string. By default, |
|
624 | 625 | strips all leading and trailing whitespace.""" |
|
625 | 626 | if not (1 <= len(args) <= 2): |
|
626 | 627 | # i18n: "strip" is a keyword |
|
627 | 628 | raise error.ParseError(_("strip expects one or two arguments")) |
|
628 | 629 | |
|
629 | 630 | text = evalstring(context, mapping, args[0]) |
|
630 | 631 | if len(args) == 2: |
|
631 | 632 | chars = evalstring(context, mapping, args[1]) |
|
632 | 633 | return text.strip(chars) |
|
633 | 634 | return text.strip() |
|
634 | 635 | |
|
635 | 636 | @templatefunc('sub(pattern, replacement, expression)') |
|
636 | 637 | def sub(context, mapping, args): |
|
637 | 638 | """Perform text substitution |
|
638 | 639 | using regular expressions.""" |
|
639 | 640 | if len(args) != 3: |
|
640 | 641 | # i18n: "sub" is a keyword |
|
641 | 642 | raise error.ParseError(_("sub expects three arguments")) |
|
642 | 643 | |
|
643 | 644 | pat = evalstring(context, mapping, args[0]) |
|
644 | 645 | rpl = evalstring(context, mapping, args[1]) |
|
645 | 646 | src = evalstring(context, mapping, args[2]) |
|
646 | 647 | try: |
|
647 | 648 | patre = re.compile(pat) |
|
648 | 649 | except re.error: |
|
649 | 650 | # i18n: "sub" is a keyword |
|
650 | 651 | raise error.ParseError(_("sub got an invalid pattern: %s") % pat) |
|
651 | 652 | try: |
|
652 | 653 | yield patre.sub(rpl, src) |
|
653 | 654 | except re.error: |
|
654 | 655 | # i18n: "sub" is a keyword |
|
655 | 656 | raise error.ParseError(_("sub got an invalid replacement: %s") % rpl) |
|
656 | 657 | |
|
657 | 658 | @templatefunc('startswith(pattern, text)') |
|
658 | 659 | def startswith(context, mapping, args): |
|
659 | 660 | """Returns the value from the "text" argument |
|
660 | 661 | if it begins with the content from the "pattern" argument.""" |
|
661 | 662 | if len(args) != 2: |
|
662 | 663 | # i18n: "startswith" is a keyword |
|
663 | 664 | raise error.ParseError(_("startswith expects two arguments")) |
|
664 | 665 | |
|
665 | 666 | patn = evalstring(context, mapping, args[0]) |
|
666 | 667 | text = evalstring(context, mapping, args[1]) |
|
667 | 668 | if text.startswith(patn): |
|
668 | 669 | return text |
|
669 | 670 | return '' |
|
670 | 671 | |
|
671 | 672 | @templatefunc('word(number, text[, separator])') |
|
672 | 673 | def word(context, mapping, args): |
|
673 | 674 | """Return the nth word from a string.""" |
|
674 | 675 | if not (2 <= len(args) <= 3): |
|
675 | 676 | # i18n: "word" is a keyword |
|
676 | 677 | raise error.ParseError(_("word expects two or three arguments, got %d") |
|
677 | 678 | % len(args)) |
|
678 | 679 | |
|
679 | 680 | num = evalinteger(context, mapping, args[0], |
|
680 | 681 | # i18n: "word" is a keyword |
|
681 | 682 | _("word expects an integer index")) |
|
682 | 683 | text = evalstring(context, mapping, args[1]) |
|
683 | 684 | if len(args) == 3: |
|
684 | 685 | splitter = evalstring(context, mapping, args[2]) |
|
685 | 686 | else: |
|
686 | 687 | splitter = None |
|
687 | 688 | |
|
688 | 689 | tokens = text.split(splitter) |
|
689 | 690 | if num >= len(tokens) or num < -len(tokens): |
|
690 | 691 | return '' |
|
691 | 692 | else: |
|
692 | 693 | return tokens[num] |
|
693 | 694 | |
|
694 | 695 | def loadfunction(ui, extname, registrarobj): |
|
695 | 696 | """Load template function from specified registrarobj |
|
696 | 697 | """ |
|
697 | 698 | for name, func in registrarobj._table.iteritems(): |
|
698 | 699 | funcs[name] = func |
|
699 | 700 | |
|
700 | 701 | # tell hggettext to extract docstrings from these functions: |
|
701 | 702 | i18nfunctions = funcs.values() |
@@ -1,715 +1,738 b'' | |||
|
1 | 1 | # templateutil.py - utility for template evaluation |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import abc |
|
11 | 11 | import types |
|
12 | 12 | |
|
13 | 13 | from .i18n import _ |
|
14 | 14 | from . import ( |
|
15 | 15 | error, |
|
16 | 16 | pycompat, |
|
17 | 17 | util, |
|
18 | 18 | ) |
|
19 | 19 | from .utils import ( |
|
20 | 20 | dateutil, |
|
21 | 21 | stringutil, |
|
22 | 22 | ) |
|
23 | 23 | |
|
24 | 24 | class ResourceUnavailable(error.Abort): |
|
25 | 25 | pass |
|
26 | 26 | |
|
27 | 27 | class TemplateNotFound(error.Abort): |
|
28 | 28 | pass |
|
29 | 29 | |
|
30 | 30 | class wrapped(object): |
|
31 | 31 | """Object requiring extra conversion prior to displaying or processing |
|
32 | 32 | as value |
|
33 | 33 | |
|
34 | 34 | Use unwrapvalue(), unwrapastype(), or unwraphybrid() to obtain the inner |
|
35 | 35 | object. |
|
36 | 36 | """ |
|
37 | 37 | |
|
38 | 38 | __metaclass__ = abc.ABCMeta |
|
39 | 39 | |
|
40 | 40 | @abc.abstractmethod |
|
41 | def getmember(self, context, mapping, key): | |
|
42 | """Return a member item for the specified key | |
|
43 | ||
|
44 | A returned object may be either a wrapped object or a pure value | |
|
45 | depending on the self type. | |
|
46 | """ | |
|
47 | ||
|
48 | @abc.abstractmethod | |
|
41 | 49 | def itermaps(self, context): |
|
42 | 50 | """Yield each template mapping""" |
|
43 | 51 | |
|
44 | 52 | @abc.abstractmethod |
|
45 | 53 | def join(self, context, mapping, sep): |
|
46 | 54 | """Join items with the separator; Returns a bytes or (possibly nested) |
|
47 | 55 | generator of bytes |
|
48 | 56 | |
|
49 | 57 | A pre-configured template may be rendered per item if this container |
|
50 | 58 | holds unprintable items. |
|
51 | 59 | """ |
|
52 | 60 | |
|
53 | 61 | @abc.abstractmethod |
|
54 | 62 | def show(self, context, mapping): |
|
55 | 63 | """Return a bytes or (possibly nested) generator of bytes representing |
|
56 | 64 | the underlying object |
|
57 | 65 | |
|
58 | 66 | A pre-configured template may be rendered if the underlying object is |
|
59 | 67 | not printable. |
|
60 | 68 | """ |
|
61 | 69 | |
|
62 | 70 | @abc.abstractmethod |
|
63 | 71 | def tovalue(self, context, mapping): |
|
64 | 72 | """Move the inner value object out or create a value representation |
|
65 | 73 | |
|
66 | 74 | A returned value must be serializable by templaterfilters.json(). |
|
67 | 75 | """ |
|
68 | 76 | |
|
69 | 77 | class wrappedbytes(wrapped): |
|
70 | 78 | """Wrapper for byte string""" |
|
71 | 79 | |
|
72 | 80 | def __init__(self, value): |
|
73 | 81 | self._value = value |
|
74 | 82 | |
|
83 | def getmember(self, context, mapping, key): | |
|
84 | raise error.ParseError(_('%r is not a dictionary') | |
|
85 | % pycompat.bytestr(self._value)) | |
|
86 | ||
|
75 | 87 | def itermaps(self, context): |
|
76 | 88 | raise error.ParseError(_('%r is not iterable of mappings') |
|
77 | 89 | % pycompat.bytestr(self._value)) |
|
78 | 90 | |
|
79 | 91 | def join(self, context, mapping, sep): |
|
80 | 92 | return joinitems(pycompat.iterbytestr(self._value), sep) |
|
81 | 93 | |
|
82 | 94 | def show(self, context, mapping): |
|
83 | 95 | return self._value |
|
84 | 96 | |
|
85 | 97 | def tovalue(self, context, mapping): |
|
86 | 98 | return self._value |
|
87 | 99 | |
|
88 | 100 | class wrappedvalue(wrapped): |
|
89 | 101 | """Generic wrapper for pure non-list/dict/bytes value""" |
|
90 | 102 | |
|
91 | 103 | def __init__(self, value): |
|
92 | 104 | self._value = value |
|
93 | 105 | |
|
106 | def getmember(self, context, mapping, key): | |
|
107 | raise error.ParseError(_('%r is not a dictionary') % self._value) | |
|
108 | ||
|
94 | 109 | def itermaps(self, context): |
|
95 | 110 | raise error.ParseError(_('%r is not iterable of mappings') |
|
96 | 111 | % self._value) |
|
97 | 112 | |
|
98 | 113 | def join(self, context, mapping, sep): |
|
99 | 114 | raise error.ParseError(_('%r is not iterable') % self._value) |
|
100 | 115 | |
|
101 | 116 | def show(self, context, mapping): |
|
102 | 117 | return pycompat.bytestr(self._value) |
|
103 | 118 | |
|
104 | 119 | def tovalue(self, context, mapping): |
|
105 | 120 | return self._value |
|
106 | 121 | |
|
107 | 122 | # stub for representing a date type; may be a real date type that can |
|
108 | 123 | # provide a readable string value |
|
109 | 124 | class date(object): |
|
110 | 125 | pass |
|
111 | 126 | |
|
112 | 127 | class hybrid(wrapped): |
|
113 | 128 | """Wrapper for list or dict to support legacy template |
|
114 | 129 | |
|
115 | 130 | This class allows us to handle both: |
|
116 | 131 | - "{files}" (legacy command-line-specific list hack) and |
|
117 | 132 | - "{files % '{file}\n'}" (hgweb-style with inlining and function support) |
|
118 | 133 | and to access raw values: |
|
119 | 134 | - "{ifcontains(file, files, ...)}", "{ifcontains(key, extras, ...)}" |
|
120 | 135 | - "{get(extras, key)}" |
|
121 | 136 | - "{files|json}" |
|
122 | 137 | """ |
|
123 | 138 | |
|
124 | 139 | def __init__(self, gen, values, makemap, joinfmt, keytype=None): |
|
125 | 140 | self._gen = gen # generator or function returning generator |
|
126 | 141 | self._values = values |
|
127 | 142 | self._makemap = makemap |
|
128 | 143 | self._joinfmt = joinfmt |
|
129 | 144 | self.keytype = keytype # hint for 'x in y' where type(x) is unresolved |
|
130 | 145 | |
|
131 | 146 | def getmember(self, context, mapping, key): |
|
132 | 147 | # TODO: maybe split hybrid list/dict types? |
|
133 | 148 | if not util.safehasattr(self._values, 'get'): |
|
134 | 149 | raise error.ParseError(_('not a dictionary')) |
|
135 | 150 | return self._wrapvalue(key, self._values.get(key)) |
|
136 | 151 | |
|
137 | 152 | def _wrapvalue(self, key, val): |
|
138 | 153 | if val is None: |
|
139 | 154 | return |
|
140 | 155 | return wraphybridvalue(self, key, val) |
|
141 | 156 | |
|
142 | 157 | def itermaps(self, context): |
|
143 | 158 | makemap = self._makemap |
|
144 | 159 | for x in self._values: |
|
145 | 160 | yield makemap(x) |
|
146 | 161 | |
|
147 | 162 | def join(self, context, mapping, sep): |
|
148 | 163 | # TODO: switch gen to (context, mapping) API? |
|
149 | 164 | return joinitems((self._joinfmt(x) for x in self._values), sep) |
|
150 | 165 | |
|
151 | 166 | def show(self, context, mapping): |
|
152 | 167 | # TODO: switch gen to (context, mapping) API? |
|
153 | 168 | gen = self._gen |
|
154 | 169 | if gen is None: |
|
155 | 170 | return self.join(context, mapping, ' ') |
|
156 | 171 | if callable(gen): |
|
157 | 172 | return gen() |
|
158 | 173 | return gen |
|
159 | 174 | |
|
160 | 175 | def tovalue(self, context, mapping): |
|
161 | 176 | # TODO: return self._values and get rid of proxy methods |
|
162 | 177 | return self |
|
163 | 178 | |
|
164 | 179 | def __contains__(self, x): |
|
165 | 180 | return x in self._values |
|
166 | 181 | def __getitem__(self, key): |
|
167 | 182 | return self._values[key] |
|
168 | 183 | def __len__(self): |
|
169 | 184 | return len(self._values) |
|
170 | 185 | def __iter__(self): |
|
171 | 186 | return iter(self._values) |
|
172 | 187 | def __getattr__(self, name): |
|
173 | 188 | if name not in (r'get', r'items', r'iteritems', r'iterkeys', |
|
174 | 189 | r'itervalues', r'keys', r'values'): |
|
175 | 190 | raise AttributeError(name) |
|
176 | 191 | return getattr(self._values, name) |
|
177 | 192 | |
|
178 | 193 | class mappable(wrapped): |
|
179 | 194 | """Wrapper for non-list/dict object to support map operation |
|
180 | 195 | |
|
181 | 196 | This class allows us to handle both: |
|
182 | 197 | - "{manifest}" |
|
183 | 198 | - "{manifest % '{rev}:{node}'}" |
|
184 | 199 | - "{manifest.rev}" |
|
185 | 200 | |
|
186 | 201 | Unlike a hybrid, this does not simulate the behavior of the underling |
|
187 | 202 | value. |
|
188 | 203 | """ |
|
189 | 204 | |
|
190 | 205 | def __init__(self, gen, key, value, makemap): |
|
191 | 206 | self._gen = gen # generator or function returning generator |
|
192 | 207 | self._key = key |
|
193 | 208 | self._value = value # may be generator of strings |
|
194 | 209 | self._makemap = makemap |
|
195 | 210 | |
|
196 | 211 | def tomap(self): |
|
197 | 212 | return self._makemap(self._key) |
|
198 | 213 | |
|
214 | def getmember(self, context, mapping, key): | |
|
215 | w = makewrapped(context, mapping, self._value) | |
|
216 | return w.getmember(context, mapping, key) | |
|
217 | ||
|
199 | 218 | def itermaps(self, context): |
|
200 | 219 | yield self.tomap() |
|
201 | 220 | |
|
202 | 221 | def join(self, context, mapping, sep): |
|
203 | 222 | w = makewrapped(context, mapping, self._value) |
|
204 | 223 | return w.join(context, mapping, sep) |
|
205 | 224 | |
|
206 | 225 | def show(self, context, mapping): |
|
207 | 226 | # TODO: switch gen to (context, mapping) API? |
|
208 | 227 | gen = self._gen |
|
209 | 228 | if gen is None: |
|
210 | 229 | return pycompat.bytestr(self._value) |
|
211 | 230 | if callable(gen): |
|
212 | 231 | return gen() |
|
213 | 232 | return gen |
|
214 | 233 | |
|
215 | 234 | def tovalue(self, context, mapping): |
|
216 | 235 | return _unthunk(context, mapping, self._value) |
|
217 | 236 | |
|
218 | 237 | class _mappingsequence(wrapped): |
|
219 | 238 | """Wrapper for sequence of template mappings |
|
220 | 239 | |
|
221 | 240 | This represents an inner template structure (i.e. a list of dicts), |
|
222 | 241 | which can also be rendered by the specified named/literal template. |
|
223 | 242 | |
|
224 | 243 | Template mappings may be nested. |
|
225 | 244 | """ |
|
226 | 245 | |
|
227 | 246 | def __init__(self, name=None, tmpl=None, sep=''): |
|
228 | 247 | if name is not None and tmpl is not None: |
|
229 | 248 | raise error.ProgrammingError('name and tmpl are mutually exclusive') |
|
230 | 249 | self._name = name |
|
231 | 250 | self._tmpl = tmpl |
|
232 | 251 | self._defaultsep = sep |
|
233 | 252 | |
|
253 | def getmember(self, context, mapping, key): | |
|
254 | raise error.ParseError(_('not a dictionary')) | |
|
255 | ||
|
234 | 256 | def join(self, context, mapping, sep): |
|
235 | 257 | mapsiter = _iteroverlaymaps(context, mapping, self.itermaps(context)) |
|
236 | 258 | if self._name: |
|
237 | 259 | itemiter = (context.process(self._name, m) for m in mapsiter) |
|
238 | 260 | elif self._tmpl: |
|
239 | 261 | itemiter = (context.expand(self._tmpl, m) for m in mapsiter) |
|
240 | 262 | else: |
|
241 | 263 | raise error.ParseError(_('not displayable without template')) |
|
242 | 264 | return joinitems(itemiter, sep) |
|
243 | 265 | |
|
244 | 266 | def show(self, context, mapping): |
|
245 | 267 | return self.join(context, mapping, self._defaultsep) |
|
246 | 268 | |
|
247 | 269 | def tovalue(self, context, mapping): |
|
248 | 270 | knownres = context.knownresourcekeys() |
|
249 | 271 | items = [] |
|
250 | 272 | for nm in self.itermaps(context): |
|
251 | 273 | # drop internal resources (recursively) which shouldn't be displayed |
|
252 | 274 | lm = context.overlaymap(mapping, nm) |
|
253 | 275 | items.append({k: unwrapvalue(context, lm, v) |
|
254 | 276 | for k, v in nm.iteritems() if k not in knownres}) |
|
255 | 277 | return items |
|
256 | 278 | |
|
257 | 279 | class mappinggenerator(_mappingsequence): |
|
258 | 280 | """Wrapper for generator of template mappings |
|
259 | 281 | |
|
260 | 282 | The function ``make(context, *args)`` should return a generator of |
|
261 | 283 | mapping dicts. |
|
262 | 284 | """ |
|
263 | 285 | |
|
264 | 286 | def __init__(self, make, args=(), name=None, tmpl=None, sep=''): |
|
265 | 287 | super(mappinggenerator, self).__init__(name, tmpl, sep) |
|
266 | 288 | self._make = make |
|
267 | 289 | self._args = args |
|
268 | 290 | |
|
269 | 291 | def itermaps(self, context): |
|
270 | 292 | return self._make(context, *self._args) |
|
271 | 293 | |
|
272 | 294 | class mappinglist(_mappingsequence): |
|
273 | 295 | """Wrapper for list of template mappings""" |
|
274 | 296 | |
|
275 | 297 | def __init__(self, mappings, name=None, tmpl=None, sep=''): |
|
276 | 298 | super(mappinglist, self).__init__(name, tmpl, sep) |
|
277 | 299 | self._mappings = mappings |
|
278 | 300 | |
|
279 | 301 | def itermaps(self, context): |
|
280 | 302 | return iter(self._mappings) |
|
281 | 303 | |
|
282 | 304 | class mappedgenerator(wrapped): |
|
283 | 305 | """Wrapper for generator of strings which acts as a list |
|
284 | 306 | |
|
285 | 307 | The function ``make(context, *args)`` should return a generator of |
|
286 | 308 | byte strings, or a generator of (possibly nested) generators of byte |
|
287 | 309 | strings (i.e. a generator for a list of byte strings.) |
|
288 | 310 | """ |
|
289 | 311 | |
|
290 | 312 | def __init__(self, make, args=()): |
|
291 | 313 | self._make = make |
|
292 | 314 | self._args = args |
|
293 | 315 | |
|
294 | 316 | def _gen(self, context): |
|
295 | 317 | return self._make(context, *self._args) |
|
296 | 318 | |
|
319 | def getmember(self, context, mapping, key): | |
|
320 | raise error.ParseError(_('not a dictionary')) | |
|
321 | ||
|
297 | 322 | def itermaps(self, context): |
|
298 | 323 | raise error.ParseError(_('list of strings is not mappable')) |
|
299 | 324 | |
|
300 | 325 | def join(self, context, mapping, sep): |
|
301 | 326 | return joinitems(self._gen(context), sep) |
|
302 | 327 | |
|
303 | 328 | def show(self, context, mapping): |
|
304 | 329 | return self.join(context, mapping, '') |
|
305 | 330 | |
|
306 | 331 | def tovalue(self, context, mapping): |
|
307 | 332 | return [stringify(context, mapping, x) for x in self._gen(context)] |
|
308 | 333 | |
|
309 | 334 | def hybriddict(data, key='key', value='value', fmt=None, gen=None): |
|
310 | 335 | """Wrap data to support both dict-like and string-like operations""" |
|
311 | 336 | prefmt = pycompat.identity |
|
312 | 337 | if fmt is None: |
|
313 | 338 | fmt = '%s=%s' |
|
314 | 339 | prefmt = pycompat.bytestr |
|
315 | 340 | return hybrid(gen, data, lambda k: {key: k, value: data[k]}, |
|
316 | 341 | lambda k: fmt % (prefmt(k), prefmt(data[k]))) |
|
317 | 342 | |
|
318 | 343 | def hybridlist(data, name, fmt=None, gen=None): |
|
319 | 344 | """Wrap data to support both list-like and string-like operations""" |
|
320 | 345 | prefmt = pycompat.identity |
|
321 | 346 | if fmt is None: |
|
322 | 347 | fmt = '%s' |
|
323 | 348 | prefmt = pycompat.bytestr |
|
324 | 349 | return hybrid(gen, data, lambda x: {name: x}, lambda x: fmt % prefmt(x)) |
|
325 | 350 | |
|
326 | 351 | def unwraphybrid(context, mapping, thing): |
|
327 | 352 | """Return an object which can be stringified possibly by using a legacy |
|
328 | 353 | template""" |
|
329 | 354 | if not isinstance(thing, wrapped): |
|
330 | 355 | return thing |
|
331 | 356 | return thing.show(context, mapping) |
|
332 | 357 | |
|
333 | 358 | def wraphybridvalue(container, key, value): |
|
334 | 359 | """Wrap an element of hybrid container to be mappable |
|
335 | 360 | |
|
336 | 361 | The key is passed to the makemap function of the given container, which |
|
337 | 362 | should be an item generated by iter(container). |
|
338 | 363 | """ |
|
339 | 364 | makemap = getattr(container, '_makemap', None) |
|
340 | 365 | if makemap is None: |
|
341 | 366 | return value |
|
342 | 367 | if util.safehasattr(value, '_makemap'): |
|
343 | 368 | # a nested hybrid list/dict, which has its own way of map operation |
|
344 | 369 | return value |
|
345 | 370 | return mappable(None, key, value, makemap) |
|
346 | 371 | |
|
347 | 372 | def compatdict(context, mapping, name, data, key='key', value='value', |
|
348 | 373 | fmt=None, plural=None, separator=' '): |
|
349 | 374 | """Wrap data like hybriddict(), but also supports old-style list template |
|
350 | 375 | |
|
351 | 376 | This exists for backward compatibility with the old-style template. Use |
|
352 | 377 | hybriddict() for new template keywords. |
|
353 | 378 | """ |
|
354 | 379 | c = [{key: k, value: v} for k, v in data.iteritems()] |
|
355 | 380 | f = _showcompatlist(context, mapping, name, c, plural, separator) |
|
356 | 381 | return hybriddict(data, key=key, value=value, fmt=fmt, gen=f) |
|
357 | 382 | |
|
358 | 383 | def compatlist(context, mapping, name, data, element=None, fmt=None, |
|
359 | 384 | plural=None, separator=' '): |
|
360 | 385 | """Wrap data like hybridlist(), but also supports old-style list template |
|
361 | 386 | |
|
362 | 387 | This exists for backward compatibility with the old-style template. Use |
|
363 | 388 | hybridlist() for new template keywords. |
|
364 | 389 | """ |
|
365 | 390 | f = _showcompatlist(context, mapping, name, data, plural, separator) |
|
366 | 391 | return hybridlist(data, name=element or name, fmt=fmt, gen=f) |
|
367 | 392 | |
|
368 | 393 | def _showcompatlist(context, mapping, name, values, plural=None, separator=' '): |
|
369 | 394 | """Return a generator that renders old-style list template |
|
370 | 395 | |
|
371 | 396 | name is name of key in template map. |
|
372 | 397 | values is list of strings or dicts. |
|
373 | 398 | plural is plural of name, if not simply name + 's'. |
|
374 | 399 | separator is used to join values as a string |
|
375 | 400 | |
|
376 | 401 | expansion works like this, given name 'foo'. |
|
377 | 402 | |
|
378 | 403 | if values is empty, expand 'no_foos'. |
|
379 | 404 | |
|
380 | 405 | if 'foo' not in template map, return values as a string, |
|
381 | 406 | joined by 'separator'. |
|
382 | 407 | |
|
383 | 408 | expand 'start_foos'. |
|
384 | 409 | |
|
385 | 410 | for each value, expand 'foo'. if 'last_foo' in template |
|
386 | 411 | map, expand it instead of 'foo' for last key. |
|
387 | 412 | |
|
388 | 413 | expand 'end_foos'. |
|
389 | 414 | """ |
|
390 | 415 | if not plural: |
|
391 | 416 | plural = name + 's' |
|
392 | 417 | if not values: |
|
393 | 418 | noname = 'no_' + plural |
|
394 | 419 | if context.preload(noname): |
|
395 | 420 | yield context.process(noname, mapping) |
|
396 | 421 | return |
|
397 | 422 | if not context.preload(name): |
|
398 | 423 | if isinstance(values[0], bytes): |
|
399 | 424 | yield separator.join(values) |
|
400 | 425 | else: |
|
401 | 426 | for v in values: |
|
402 | 427 | r = dict(v) |
|
403 | 428 | r.update(mapping) |
|
404 | 429 | yield r |
|
405 | 430 | return |
|
406 | 431 | startname = 'start_' + plural |
|
407 | 432 | if context.preload(startname): |
|
408 | 433 | yield context.process(startname, mapping) |
|
409 | 434 | def one(v, tag=name): |
|
410 | 435 | vmapping = {} |
|
411 | 436 | try: |
|
412 | 437 | vmapping.update(v) |
|
413 | 438 | # Python 2 raises ValueError if the type of v is wrong. Python |
|
414 | 439 | # 3 raises TypeError. |
|
415 | 440 | except (AttributeError, TypeError, ValueError): |
|
416 | 441 | try: |
|
417 | 442 | # Python 2 raises ValueError trying to destructure an e.g. |
|
418 | 443 | # bytes. Python 3 raises TypeError. |
|
419 | 444 | for a, b in v: |
|
420 | 445 | vmapping[a] = b |
|
421 | 446 | except (TypeError, ValueError): |
|
422 | 447 | vmapping[name] = v |
|
423 | 448 | vmapping = context.overlaymap(mapping, vmapping) |
|
424 | 449 | return context.process(tag, vmapping) |
|
425 | 450 | lastname = 'last_' + name |
|
426 | 451 | if context.preload(lastname): |
|
427 | 452 | last = values.pop() |
|
428 | 453 | else: |
|
429 | 454 | last = None |
|
430 | 455 | for v in values: |
|
431 | 456 | yield one(v) |
|
432 | 457 | if last is not None: |
|
433 | 458 | yield one(last, tag=lastname) |
|
434 | 459 | endname = 'end_' + plural |
|
435 | 460 | if context.preload(endname): |
|
436 | 461 | yield context.process(endname, mapping) |
|
437 | 462 | |
|
438 | 463 | def flatten(context, mapping, thing): |
|
439 | 464 | """Yield a single stream from a possibly nested set of iterators""" |
|
440 | 465 | thing = unwraphybrid(context, mapping, thing) |
|
441 | 466 | if isinstance(thing, bytes): |
|
442 | 467 | yield thing |
|
443 | 468 | elif isinstance(thing, str): |
|
444 | 469 | # We can only hit this on Python 3, and it's here to guard |
|
445 | 470 | # against infinite recursion. |
|
446 | 471 | raise error.ProgrammingError('Mercurial IO including templates is done' |
|
447 | 472 | ' with bytes, not strings, got %r' % thing) |
|
448 | 473 | elif thing is None: |
|
449 | 474 | pass |
|
450 | 475 | elif not util.safehasattr(thing, '__iter__'): |
|
451 | 476 | yield pycompat.bytestr(thing) |
|
452 | 477 | else: |
|
453 | 478 | for i in thing: |
|
454 | 479 | i = unwraphybrid(context, mapping, i) |
|
455 | 480 | if isinstance(i, bytes): |
|
456 | 481 | yield i |
|
457 | 482 | elif i is None: |
|
458 | 483 | pass |
|
459 | 484 | elif not util.safehasattr(i, '__iter__'): |
|
460 | 485 | yield pycompat.bytestr(i) |
|
461 | 486 | else: |
|
462 | 487 | for j in flatten(context, mapping, i): |
|
463 | 488 | yield j |
|
464 | 489 | |
|
465 | 490 | def stringify(context, mapping, thing): |
|
466 | 491 | """Turn values into bytes by converting into text and concatenating them""" |
|
467 | 492 | if isinstance(thing, bytes): |
|
468 | 493 | return thing # retain localstr to be round-tripped |
|
469 | 494 | return b''.join(flatten(context, mapping, thing)) |
|
470 | 495 | |
|
471 | 496 | def findsymbolicname(arg): |
|
472 | 497 | """Find symbolic name for the given compiled expression; returns None |
|
473 | 498 | if nothing found reliably""" |
|
474 | 499 | while True: |
|
475 | 500 | func, data = arg |
|
476 | 501 | if func is runsymbol: |
|
477 | 502 | return data |
|
478 | 503 | elif func is runfilter: |
|
479 | 504 | arg = data[0] |
|
480 | 505 | else: |
|
481 | 506 | return None |
|
482 | 507 | |
|
483 | 508 | def _unthunk(context, mapping, thing): |
|
484 | 509 | """Evaluate a lazy byte string into value""" |
|
485 | 510 | if not isinstance(thing, types.GeneratorType): |
|
486 | 511 | return thing |
|
487 | 512 | return stringify(context, mapping, thing) |
|
488 | 513 | |
|
489 | 514 | def evalrawexp(context, mapping, arg): |
|
490 | 515 | """Evaluate given argument as a bare template object which may require |
|
491 | 516 | further processing (such as folding generator of strings)""" |
|
492 | 517 | func, data = arg |
|
493 | 518 | return func(context, mapping, data) |
|
494 | 519 | |
|
495 | 520 | def evalwrapped(context, mapping, arg): |
|
496 | 521 | """Evaluate given argument to wrapped object""" |
|
497 | 522 | thing = evalrawexp(context, mapping, arg) |
|
498 | 523 | return makewrapped(context, mapping, thing) |
|
499 | 524 | |
|
500 | 525 | def makewrapped(context, mapping, thing): |
|
501 | 526 | """Lift object to a wrapped type""" |
|
502 | 527 | if isinstance(thing, wrapped): |
|
503 | 528 | return thing |
|
504 | 529 | thing = _unthunk(context, mapping, thing) |
|
505 | 530 | if isinstance(thing, bytes): |
|
506 | 531 | return wrappedbytes(thing) |
|
507 | 532 | return wrappedvalue(thing) |
|
508 | 533 | |
|
509 | 534 | def evalfuncarg(context, mapping, arg): |
|
510 | 535 | """Evaluate given argument as value type""" |
|
511 | 536 | return unwrapvalue(context, mapping, evalrawexp(context, mapping, arg)) |
|
512 | 537 | |
|
513 | 538 | def unwrapvalue(context, mapping, thing): |
|
514 | 539 | """Move the inner value object out of the wrapper""" |
|
515 | 540 | if isinstance(thing, wrapped): |
|
516 | 541 | return thing.tovalue(context, mapping) |
|
517 | 542 | # evalrawexp() may return string, generator of strings or arbitrary object |
|
518 | 543 | # such as date tuple, but filter does not want generator. |
|
519 | 544 | return _unthunk(context, mapping, thing) |
|
520 | 545 | |
|
521 | 546 | def evalboolean(context, mapping, arg): |
|
522 | 547 | """Evaluate given argument as boolean, but also takes boolean literals""" |
|
523 | 548 | func, data = arg |
|
524 | 549 | if func is runsymbol: |
|
525 | 550 | thing = func(context, mapping, data, default=None) |
|
526 | 551 | if thing is None: |
|
527 | 552 | # not a template keyword, takes as a boolean literal |
|
528 | 553 | thing = stringutil.parsebool(data) |
|
529 | 554 | else: |
|
530 | 555 | thing = func(context, mapping, data) |
|
531 | 556 | if isinstance(thing, wrapped): |
|
532 | 557 | thing = thing.tovalue(context, mapping) |
|
533 | 558 | if isinstance(thing, bool): |
|
534 | 559 | return thing |
|
535 | 560 | # other objects are evaluated as strings, which means 0 is True, but |
|
536 | 561 | # empty dict/list should be False as they are expected to be '' |
|
537 | 562 | return bool(stringify(context, mapping, thing)) |
|
538 | 563 | |
|
539 | 564 | def evaldate(context, mapping, arg, err=None): |
|
540 | 565 | """Evaluate given argument as a date tuple or a date string; returns |
|
541 | 566 | a (unixtime, offset) tuple""" |
|
542 | 567 | thing = evalrawexp(context, mapping, arg) |
|
543 | 568 | return unwrapdate(context, mapping, thing, err) |
|
544 | 569 | |
|
545 | 570 | def unwrapdate(context, mapping, thing, err=None): |
|
546 | 571 | thing = unwrapvalue(context, mapping, thing) |
|
547 | 572 | try: |
|
548 | 573 | return dateutil.parsedate(thing) |
|
549 | 574 | except AttributeError: |
|
550 | 575 | raise error.ParseError(err or _('not a date tuple nor a string')) |
|
551 | 576 | except error.ParseError: |
|
552 | 577 | if not err: |
|
553 | 578 | raise |
|
554 | 579 | raise error.ParseError(err) |
|
555 | 580 | |
|
556 | 581 | def evalinteger(context, mapping, arg, err=None): |
|
557 | 582 | thing = evalrawexp(context, mapping, arg) |
|
558 | 583 | return unwrapinteger(context, mapping, thing, err) |
|
559 | 584 | |
|
560 | 585 | def unwrapinteger(context, mapping, thing, err=None): |
|
561 | 586 | thing = unwrapvalue(context, mapping, thing) |
|
562 | 587 | try: |
|
563 | 588 | return int(thing) |
|
564 | 589 | except (TypeError, ValueError): |
|
565 | 590 | raise error.ParseError(err or _('not an integer')) |
|
566 | 591 | |
|
567 | 592 | def evalstring(context, mapping, arg): |
|
568 | 593 | return stringify(context, mapping, evalrawexp(context, mapping, arg)) |
|
569 | 594 | |
|
570 | 595 | def evalstringliteral(context, mapping, arg): |
|
571 | 596 | """Evaluate given argument as string template, but returns symbol name |
|
572 | 597 | if it is unknown""" |
|
573 | 598 | func, data = arg |
|
574 | 599 | if func is runsymbol: |
|
575 | 600 | thing = func(context, mapping, data, default=data) |
|
576 | 601 | else: |
|
577 | 602 | thing = func(context, mapping, data) |
|
578 | 603 | return stringify(context, mapping, thing) |
|
579 | 604 | |
|
580 | 605 | _unwrapfuncbytype = { |
|
581 | 606 | None: unwrapvalue, |
|
582 | 607 | bytes: stringify, |
|
583 | 608 | date: unwrapdate, |
|
584 | 609 | int: unwrapinteger, |
|
585 | 610 | } |
|
586 | 611 | |
|
587 | 612 | def unwrapastype(context, mapping, thing, typ): |
|
588 | 613 | """Move the inner value object out of the wrapper and coerce its type""" |
|
589 | 614 | try: |
|
590 | 615 | f = _unwrapfuncbytype[typ] |
|
591 | 616 | except KeyError: |
|
592 | 617 | raise error.ProgrammingError('invalid type specified: %r' % typ) |
|
593 | 618 | return f(context, mapping, thing) |
|
594 | 619 | |
|
595 | 620 | def runinteger(context, mapping, data): |
|
596 | 621 | return int(data) |
|
597 | 622 | |
|
598 | 623 | def runstring(context, mapping, data): |
|
599 | 624 | return data |
|
600 | 625 | |
|
601 | 626 | def _recursivesymbolblocker(key): |
|
602 | 627 | def showrecursion(**args): |
|
603 | 628 | raise error.Abort(_("recursive reference '%s' in template") % key) |
|
604 | 629 | return showrecursion |
|
605 | 630 | |
|
606 | 631 | def runsymbol(context, mapping, key, default=''): |
|
607 | 632 | v = context.symbol(mapping, key) |
|
608 | 633 | if v is None: |
|
609 | 634 | # put poison to cut recursion. we can't move this to parsing phase |
|
610 | 635 | # because "x = {x}" is allowed if "x" is a keyword. (issue4758) |
|
611 | 636 | safemapping = mapping.copy() |
|
612 | 637 | safemapping[key] = _recursivesymbolblocker(key) |
|
613 | 638 | try: |
|
614 | 639 | v = context.process(key, safemapping) |
|
615 | 640 | except TemplateNotFound: |
|
616 | 641 | v = default |
|
617 | 642 | if callable(v) and getattr(v, '_requires', None) is None: |
|
618 | 643 | # old templatekw: expand all keywords and resources |
|
619 | 644 | # (TODO: deprecate this after porting web template keywords to new API) |
|
620 | 645 | props = {k: context._resources.lookup(context, mapping, k) |
|
621 | 646 | for k in context._resources.knownkeys()} |
|
622 | 647 | # pass context to _showcompatlist() through templatekw._showlist() |
|
623 | 648 | props['templ'] = context |
|
624 | 649 | props.update(mapping) |
|
625 | 650 | return v(**pycompat.strkwargs(props)) |
|
626 | 651 | if callable(v): |
|
627 | 652 | # new templatekw |
|
628 | 653 | try: |
|
629 | 654 | return v(context, mapping) |
|
630 | 655 | except ResourceUnavailable: |
|
631 | 656 | # unsupported keyword is mapped to empty just like unknown keyword |
|
632 | 657 | return None |
|
633 | 658 | return v |
|
634 | 659 | |
|
635 | 660 | def runtemplate(context, mapping, template): |
|
636 | 661 | for arg in template: |
|
637 | 662 | yield evalrawexp(context, mapping, arg) |
|
638 | 663 | |
|
639 | 664 | def runfilter(context, mapping, data): |
|
640 | 665 | arg, filt = data |
|
641 | 666 | thing = evalrawexp(context, mapping, arg) |
|
642 | 667 | intype = getattr(filt, '_intype', None) |
|
643 | 668 | try: |
|
644 | 669 | thing = unwrapastype(context, mapping, thing, intype) |
|
645 | 670 | return filt(thing) |
|
646 | 671 | except error.ParseError as e: |
|
647 | 672 | raise error.ParseError(bytes(e), hint=_formatfiltererror(arg, filt)) |
|
648 | 673 | |
|
649 | 674 | def _formatfiltererror(arg, filt): |
|
650 | 675 | fn = pycompat.sysbytes(filt.__name__) |
|
651 | 676 | sym = findsymbolicname(arg) |
|
652 | 677 | if not sym: |
|
653 | 678 | return _("incompatible use of template filter '%s'") % fn |
|
654 | 679 | return (_("template filter '%s' is not compatible with keyword '%s'") |
|
655 | 680 | % (fn, sym)) |
|
656 | 681 | |
|
657 | 682 | def _iteroverlaymaps(context, origmapping, newmappings): |
|
658 | 683 | """Generate combined mappings from the original mapping and an iterable |
|
659 | 684 | of partial mappings to override the original""" |
|
660 | 685 | for i, nm in enumerate(newmappings): |
|
661 | 686 | lm = context.overlaymap(origmapping, nm) |
|
662 | 687 | lm['index'] = i |
|
663 | 688 | yield lm |
|
664 | 689 | |
|
665 | 690 | def _applymap(context, mapping, d, targ): |
|
666 | 691 | for lm in _iteroverlaymaps(context, mapping, d.itermaps(context)): |
|
667 | 692 | yield evalrawexp(context, lm, targ) |
|
668 | 693 | |
|
669 | 694 | def runmap(context, mapping, data): |
|
670 | 695 | darg, targ = data |
|
671 | 696 | d = evalwrapped(context, mapping, darg) |
|
672 | 697 | return mappedgenerator(_applymap, args=(mapping, d, targ)) |
|
673 | 698 | |
|
674 | 699 | def runmember(context, mapping, data): |
|
675 | 700 | darg, memb = data |
|
676 | 701 | d = evalwrapped(context, mapping, darg) |
|
677 | 702 | if util.safehasattr(d, 'tomap'): |
|
678 | 703 | lm = context.overlaymap(mapping, d.tomap()) |
|
679 | 704 | return runsymbol(context, lm, memb) |
|
680 | 705 | try: |
|
681 | if util.safehasattr(d, 'getmember'): | |
|
682 | 706 |
|
|
683 |
|
|
|
684 | except error.ParseError: | |
|
707 | except error.ParseError as err: | |
|
685 | 708 | sym = findsymbolicname(darg) |
|
686 | if sym: | |
|
687 | raise error.ParseError(_("keyword '%s' has no member") % sym) | |
|
688 | else: | |
|
689 | raise error.ParseError(_("%r has no member") % pycompat.bytestr(d)) | |
|
709 | if not sym: | |
|
710 | raise | |
|
711 | hint = _("keyword '%s' does not support member operation") % sym | |
|
712 | raise error.ParseError(bytes(err), hint=hint) | |
|
690 | 713 | |
|
691 | 714 | def runnegate(context, mapping, data): |
|
692 | 715 | data = evalinteger(context, mapping, data, |
|
693 | 716 | _('negation needs an integer argument')) |
|
694 | 717 | return -data |
|
695 | 718 | |
|
696 | 719 | def runarithmetic(context, mapping, data): |
|
697 | 720 | func, left, right = data |
|
698 | 721 | left = evalinteger(context, mapping, left, |
|
699 | 722 | _('arithmetic only defined on integers')) |
|
700 | 723 | right = evalinteger(context, mapping, right, |
|
701 | 724 | _('arithmetic only defined on integers')) |
|
702 | 725 | try: |
|
703 | 726 | return func(left, right) |
|
704 | 727 | except ZeroDivisionError: |
|
705 | 728 | raise error.Abort(_('division by zero is not defined')) |
|
706 | 729 | |
|
707 | 730 | def joinitems(itemiter, sep): |
|
708 | 731 | """Join items with the separator; Returns generator of bytes""" |
|
709 | 732 | first = True |
|
710 | 733 | for x in itemiter: |
|
711 | 734 | if first: |
|
712 | 735 | first = False |
|
713 | 736 | elif sep: |
|
714 | 737 | yield sep |
|
715 | 738 | yield x |
@@ -1,4911 +1,4913 b'' | |||
|
1 | 1 | $ hg init a |
|
2 | 2 | $ cd a |
|
3 | 3 | $ echo a > a |
|
4 | 4 | $ hg add a |
|
5 | 5 | $ echo line 1 > b |
|
6 | 6 | $ echo line 2 >> b |
|
7 | 7 | $ hg commit -l b -d '1000000 0' -u 'User Name <user@hostname>' |
|
8 | 8 | |
|
9 | 9 | $ hg add b |
|
10 | 10 | $ echo other 1 > c |
|
11 | 11 | $ echo other 2 >> c |
|
12 | 12 | $ echo >> c |
|
13 | 13 | $ echo other 3 >> c |
|
14 | 14 | $ hg commit -l c -d '1100000 0' -u 'A. N. Other <other@place>' |
|
15 | 15 | |
|
16 | 16 | $ hg add c |
|
17 | 17 | $ hg commit -m 'no person' -d '1200000 0' -u 'other@place' |
|
18 | 18 | $ echo c >> c |
|
19 | 19 | $ hg commit -m 'no user, no domain' -d '1300000 0' -u 'person' |
|
20 | 20 | |
|
21 | 21 | $ echo foo > .hg/branch |
|
22 | 22 | $ hg commit -m 'new branch' -d '1400000 0' -u 'person' |
|
23 | 23 | |
|
24 | 24 | $ hg co -q 3 |
|
25 | 25 | $ echo other 4 >> d |
|
26 | 26 | $ hg add d |
|
27 | 27 | $ hg commit -m 'new head' -d '1500000 0' -u 'person' |
|
28 | 28 | |
|
29 | 29 | $ hg merge -q foo |
|
30 | 30 | $ hg commit -m 'merge' -d '1500001 0' -u 'person' |
|
31 | 31 | |
|
32 | 32 | Test arithmetic operators have the right precedence: |
|
33 | 33 | |
|
34 | 34 | $ hg log -l 1 -T '{date(date, "%Y") + 5 * 10} {date(date, "%Y") - 2 * 3}\n' |
|
35 | 35 | 2020 1964 |
|
36 | 36 | $ hg log -l 1 -T '{date(date, "%Y") * 5 + 10} {date(date, "%Y") * 3 - 2}\n' |
|
37 | 37 | 9860 5908 |
|
38 | 38 | |
|
39 | 39 | Test division: |
|
40 | 40 | |
|
41 | 41 | $ hg debugtemplate -r0 -v '{5 / 2} {mod(5, 2)}\n' |
|
42 | 42 | (template |
|
43 | 43 | (/ |
|
44 | 44 | (integer '5') |
|
45 | 45 | (integer '2')) |
|
46 | 46 | (string ' ') |
|
47 | 47 | (func |
|
48 | 48 | (symbol 'mod') |
|
49 | 49 | (list |
|
50 | 50 | (integer '5') |
|
51 | 51 | (integer '2'))) |
|
52 | 52 | (string '\n')) |
|
53 | 53 | 2 1 |
|
54 | 54 | $ hg debugtemplate -r0 -v '{5 / -2} {mod(5, -2)}\n' |
|
55 | 55 | (template |
|
56 | 56 | (/ |
|
57 | 57 | (integer '5') |
|
58 | 58 | (negate |
|
59 | 59 | (integer '2'))) |
|
60 | 60 | (string ' ') |
|
61 | 61 | (func |
|
62 | 62 | (symbol 'mod') |
|
63 | 63 | (list |
|
64 | 64 | (integer '5') |
|
65 | 65 | (negate |
|
66 | 66 | (integer '2')))) |
|
67 | 67 | (string '\n')) |
|
68 | 68 | -3 -1 |
|
69 | 69 | $ hg debugtemplate -r0 -v '{-5 / 2} {mod(-5, 2)}\n' |
|
70 | 70 | (template |
|
71 | 71 | (/ |
|
72 | 72 | (negate |
|
73 | 73 | (integer '5')) |
|
74 | 74 | (integer '2')) |
|
75 | 75 | (string ' ') |
|
76 | 76 | (func |
|
77 | 77 | (symbol 'mod') |
|
78 | 78 | (list |
|
79 | 79 | (negate |
|
80 | 80 | (integer '5')) |
|
81 | 81 | (integer '2'))) |
|
82 | 82 | (string '\n')) |
|
83 | 83 | -3 1 |
|
84 | 84 | $ hg debugtemplate -r0 -v '{-5 / -2} {mod(-5, -2)}\n' |
|
85 | 85 | (template |
|
86 | 86 | (/ |
|
87 | 87 | (negate |
|
88 | 88 | (integer '5')) |
|
89 | 89 | (negate |
|
90 | 90 | (integer '2'))) |
|
91 | 91 | (string ' ') |
|
92 | 92 | (func |
|
93 | 93 | (symbol 'mod') |
|
94 | 94 | (list |
|
95 | 95 | (negate |
|
96 | 96 | (integer '5')) |
|
97 | 97 | (negate |
|
98 | 98 | (integer '2')))) |
|
99 | 99 | (string '\n')) |
|
100 | 100 | 2 -1 |
|
101 | 101 | |
|
102 | 102 | Filters bind closer than arithmetic: |
|
103 | 103 | |
|
104 | 104 | $ hg debugtemplate -r0 -v '{revset(".")|count - 1}\n' |
|
105 | 105 | (template |
|
106 | 106 | (- |
|
107 | 107 | (| |
|
108 | 108 | (func |
|
109 | 109 | (symbol 'revset') |
|
110 | 110 | (string '.')) |
|
111 | 111 | (symbol 'count')) |
|
112 | 112 | (integer '1')) |
|
113 | 113 | (string '\n')) |
|
114 | 114 | 0 |
|
115 | 115 | |
|
116 | 116 | But negate binds closer still: |
|
117 | 117 | |
|
118 | 118 | $ hg debugtemplate -r0 -v '{1-3|stringify}\n' |
|
119 | 119 | (template |
|
120 | 120 | (- |
|
121 | 121 | (integer '1') |
|
122 | 122 | (| |
|
123 | 123 | (integer '3') |
|
124 | 124 | (symbol 'stringify'))) |
|
125 | 125 | (string '\n')) |
|
126 | 126 | hg: parse error: arithmetic only defined on integers |
|
127 | 127 | [255] |
|
128 | 128 | $ hg debugtemplate -r0 -v '{-3|stringify}\n' |
|
129 | 129 | (template |
|
130 | 130 | (| |
|
131 | 131 | (negate |
|
132 | 132 | (integer '3')) |
|
133 | 133 | (symbol 'stringify')) |
|
134 | 134 | (string '\n')) |
|
135 | 135 | -3 |
|
136 | 136 | |
|
137 | 137 | Filters bind as close as map operator: |
|
138 | 138 | |
|
139 | 139 | $ hg debugtemplate -r0 -v '{desc|splitlines % "{line}\n"}' |
|
140 | 140 | (template |
|
141 | 141 | (% |
|
142 | 142 | (| |
|
143 | 143 | (symbol 'desc') |
|
144 | 144 | (symbol 'splitlines')) |
|
145 | 145 | (template |
|
146 | 146 | (symbol 'line') |
|
147 | 147 | (string '\n')))) |
|
148 | 148 | line 1 |
|
149 | 149 | line 2 |
|
150 | 150 | |
|
151 | 151 | Keyword arguments: |
|
152 | 152 | |
|
153 | 153 | $ hg debugtemplate -r0 -v '{foo=bar|baz}' |
|
154 | 154 | (template |
|
155 | 155 | (keyvalue |
|
156 | 156 | (symbol 'foo') |
|
157 | 157 | (| |
|
158 | 158 | (symbol 'bar') |
|
159 | 159 | (symbol 'baz')))) |
|
160 | 160 | hg: parse error: can't use a key-value pair in this context |
|
161 | 161 | [255] |
|
162 | 162 | |
|
163 | 163 | $ hg debugtemplate '{pad("foo", width=10, left=true)}\n' |
|
164 | 164 | foo |
|
165 | 165 | |
|
166 | 166 | Call function which takes named arguments by filter syntax: |
|
167 | 167 | |
|
168 | 168 | $ hg debugtemplate '{" "|separate}' |
|
169 | 169 | $ hg debugtemplate '{("not", "an", "argument", "list")|separate}' |
|
170 | 170 | hg: parse error: unknown method 'list' |
|
171 | 171 | [255] |
|
172 | 172 | |
|
173 | 173 | Second branch starting at nullrev: |
|
174 | 174 | |
|
175 | 175 | $ hg update null |
|
176 | 176 | 0 files updated, 0 files merged, 4 files removed, 0 files unresolved |
|
177 | 177 | $ echo second > second |
|
178 | 178 | $ hg add second |
|
179 | 179 | $ hg commit -m second -d '1000000 0' -u 'User Name <user@hostname>' |
|
180 | 180 | created new head |
|
181 | 181 | |
|
182 | 182 | $ echo third > third |
|
183 | 183 | $ hg add third |
|
184 | 184 | $ hg mv second fourth |
|
185 | 185 | $ hg commit -m third -d "2020-01-01 10:01" |
|
186 | 186 | |
|
187 | 187 | $ hg log --template '{join(file_copies, ",\n")}\n' -r . |
|
188 | 188 | fourth (second) |
|
189 | 189 | $ hg log -T '{file_copies % "{source} -> {name}\n"}' -r . |
|
190 | 190 | second -> fourth |
|
191 | 191 | $ hg log -T '{rev} {ifcontains("fourth", file_copies, "t", "f")}\n' -r .:7 |
|
192 | 192 | 8 t |
|
193 | 193 | 7 f |
|
194 | 194 | |
|
195 | 195 | Working-directory revision has special identifiers, though they are still |
|
196 | 196 | experimental: |
|
197 | 197 | |
|
198 | 198 | $ hg log -r 'wdir()' -T '{rev}:{node}\n' |
|
199 | 199 | 2147483647:ffffffffffffffffffffffffffffffffffffffff |
|
200 | 200 | |
|
201 | 201 | Some keywords are invalid for working-directory revision, but they should |
|
202 | 202 | never cause crash: |
|
203 | 203 | |
|
204 | 204 | $ hg log -r 'wdir()' -T '{manifest}\n' |
|
205 | 205 | |
|
206 | 206 | |
|
207 | 207 | Internal resources shouldn't be exposed (issue5699): |
|
208 | 208 | |
|
209 | 209 | $ hg log -r. -T '{cache}{ctx}{repo}{revcache}{templ}{ui}' |
|
210 | 210 | |
|
211 | 211 | Never crash on internal resource not available: |
|
212 | 212 | |
|
213 | 213 | $ hg --cwd .. debugtemplate '{"c0bebeef"|shortest}\n' |
|
214 | 214 | abort: template resource not available: ctx |
|
215 | 215 | [255] |
|
216 | 216 | |
|
217 | 217 | $ hg config -T '{author}' |
|
218 | 218 | |
|
219 | 219 | Quoting for ui.logtemplate |
|
220 | 220 | |
|
221 | 221 | $ hg tip --config "ui.logtemplate={rev}\n" |
|
222 | 222 | 8 |
|
223 | 223 | $ hg tip --config "ui.logtemplate='{rev}\n'" |
|
224 | 224 | 8 |
|
225 | 225 | $ hg tip --config 'ui.logtemplate="{rev}\n"' |
|
226 | 226 | 8 |
|
227 | 227 | $ hg tip --config 'ui.logtemplate=n{rev}\n' |
|
228 | 228 | n8 |
|
229 | 229 | |
|
230 | 230 | Make sure user/global hgrc does not affect tests |
|
231 | 231 | |
|
232 | 232 | $ echo '[ui]' > .hg/hgrc |
|
233 | 233 | $ echo 'logtemplate =' >> .hg/hgrc |
|
234 | 234 | $ echo 'style =' >> .hg/hgrc |
|
235 | 235 | |
|
236 | 236 | Add some simple styles to settings |
|
237 | 237 | |
|
238 | 238 | $ cat <<'EOF' >> .hg/hgrc |
|
239 | 239 | > [templates] |
|
240 | 240 | > simple = "{rev}\n" |
|
241 | 241 | > simple2 = {rev}\n |
|
242 | 242 | > rev = "should not precede {rev} keyword\n" |
|
243 | 243 | > EOF |
|
244 | 244 | |
|
245 | 245 | $ hg log -l1 -Tsimple |
|
246 | 246 | 8 |
|
247 | 247 | $ hg log -l1 -Tsimple2 |
|
248 | 248 | 8 |
|
249 | 249 | $ hg log -l1 -Trev |
|
250 | 250 | should not precede 8 keyword |
|
251 | 251 | $ hg log -l1 -T '{simple}' |
|
252 | 252 | 8 |
|
253 | 253 | |
|
254 | 254 | Map file shouldn't see user templates: |
|
255 | 255 | |
|
256 | 256 | $ cat <<EOF > tmpl |
|
257 | 257 | > changeset = 'nothing expanded:{simple}\n' |
|
258 | 258 | > EOF |
|
259 | 259 | $ hg log -l1 --style ./tmpl |
|
260 | 260 | nothing expanded: |
|
261 | 261 | |
|
262 | 262 | Test templates and style maps in files: |
|
263 | 263 | |
|
264 | 264 | $ echo "{rev}" > tmpl |
|
265 | 265 | $ hg log -l1 -T./tmpl |
|
266 | 266 | 8 |
|
267 | 267 | $ hg log -l1 -Tblah/blah |
|
268 | 268 | blah/blah (no-eol) |
|
269 | 269 | |
|
270 | 270 | $ printf 'changeset = "{rev}\\n"\n' > map-simple |
|
271 | 271 | $ hg log -l1 -T./map-simple |
|
272 | 272 | 8 |
|
273 | 273 | |
|
274 | 274 | a map file may have [templates] and [templatealias] sections: |
|
275 | 275 | |
|
276 | 276 | $ cat <<'EOF' > map-simple |
|
277 | 277 | > [templates] |
|
278 | 278 | > changeset = "{a}\n" |
|
279 | 279 | > [templatealias] |
|
280 | 280 | > a = rev |
|
281 | 281 | > EOF |
|
282 | 282 | $ hg log -l1 -T./map-simple |
|
283 | 283 | 8 |
|
284 | 284 | |
|
285 | 285 | so it can be included in hgrc |
|
286 | 286 | |
|
287 | 287 | $ cat <<EOF > myhgrc |
|
288 | 288 | > %include $HGRCPATH |
|
289 | 289 | > %include map-simple |
|
290 | 290 | > [templates] |
|
291 | 291 | > foo = "{changeset}" |
|
292 | 292 | > EOF |
|
293 | 293 | $ HGRCPATH=./myhgrc hg log -l1 -Tfoo |
|
294 | 294 | 8 |
|
295 | 295 | $ HGRCPATH=./myhgrc hg log -l1 -T'{a}\n' |
|
296 | 296 | 8 |
|
297 | 297 | |
|
298 | 298 | Test template map inheritance |
|
299 | 299 | |
|
300 | 300 | $ echo "__base__ = map-cmdline.default" > map-simple |
|
301 | 301 | $ printf 'cset = "changeset: ***{rev}***\\n"\n' >> map-simple |
|
302 | 302 | $ hg log -l1 -T./map-simple |
|
303 | 303 | changeset: ***8*** |
|
304 | 304 | tag: tip |
|
305 | 305 | user: test |
|
306 | 306 | date: Wed Jan 01 10:01:00 2020 +0000 |
|
307 | 307 | summary: third |
|
308 | 308 | |
|
309 | 309 | |
|
310 | 310 | Test docheader, docfooter and separator in template map |
|
311 | 311 | |
|
312 | 312 | $ cat <<'EOF' > map-myjson |
|
313 | 313 | > docheader = '\{\n' |
|
314 | 314 | > docfooter = '\n}\n' |
|
315 | 315 | > separator = ',\n' |
|
316 | 316 | > changeset = ' {dict(rev, node|short)|json}' |
|
317 | 317 | > EOF |
|
318 | 318 | $ hg log -l2 -T./map-myjson |
|
319 | 319 | { |
|
320 | 320 | {"node": "95c24699272e", "rev": 8}, |
|
321 | 321 | {"node": "29114dbae42b", "rev": 7} |
|
322 | 322 | } |
|
323 | 323 | |
|
324 | 324 | Test docheader, docfooter and separator in [templates] section |
|
325 | 325 | |
|
326 | 326 | $ cat <<'EOF' >> .hg/hgrc |
|
327 | 327 | > [templates] |
|
328 | 328 | > myjson = ' {dict(rev, node|short)|json}' |
|
329 | 329 | > myjson:docheader = '\{\n' |
|
330 | 330 | > myjson:docfooter = '\n}\n' |
|
331 | 331 | > myjson:separator = ',\n' |
|
332 | 332 | > :docheader = 'should not be selected as a docheader for literal templates\n' |
|
333 | 333 | > EOF |
|
334 | 334 | $ hg log -l2 -Tmyjson |
|
335 | 335 | { |
|
336 | 336 | {"node": "95c24699272e", "rev": 8}, |
|
337 | 337 | {"node": "29114dbae42b", "rev": 7} |
|
338 | 338 | } |
|
339 | 339 | $ hg log -l1 -T'{rev}\n' |
|
340 | 340 | 8 |
|
341 | 341 | |
|
342 | 342 | Template should precede style option |
|
343 | 343 | |
|
344 | 344 | $ hg log -l1 --style default -T '{rev}\n' |
|
345 | 345 | 8 |
|
346 | 346 | |
|
347 | 347 | Add a commit with empty description, to ensure that the templates |
|
348 | 348 | below will omit the description line. |
|
349 | 349 | |
|
350 | 350 | $ echo c >> c |
|
351 | 351 | $ hg add c |
|
352 | 352 | $ hg commit -qm ' ' |
|
353 | 353 | |
|
354 | 354 | Default style is like normal output. Phases style should be the same |
|
355 | 355 | as default style, except for extra phase lines. |
|
356 | 356 | |
|
357 | 357 | $ hg log > log.out |
|
358 | 358 | $ hg log --style default > style.out |
|
359 | 359 | $ cmp log.out style.out || diff -u log.out style.out |
|
360 | 360 | $ hg log -T phases > phases.out |
|
361 | 361 | $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@' |
|
362 | 362 | +phase: draft |
|
363 | 363 | +phase: draft |
|
364 | 364 | +phase: draft |
|
365 | 365 | +phase: draft |
|
366 | 366 | +phase: draft |
|
367 | 367 | +phase: draft |
|
368 | 368 | +phase: draft |
|
369 | 369 | +phase: draft |
|
370 | 370 | +phase: draft |
|
371 | 371 | +phase: draft |
|
372 | 372 | |
|
373 | 373 | $ hg log -v > log.out |
|
374 | 374 | $ hg log -v --style default > style.out |
|
375 | 375 | $ cmp log.out style.out || diff -u log.out style.out |
|
376 | 376 | $ hg log -v -T phases > phases.out |
|
377 | 377 | $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@' |
|
378 | 378 | +phase: draft |
|
379 | 379 | +phase: draft |
|
380 | 380 | +phase: draft |
|
381 | 381 | +phase: draft |
|
382 | 382 | +phase: draft |
|
383 | 383 | +phase: draft |
|
384 | 384 | +phase: draft |
|
385 | 385 | +phase: draft |
|
386 | 386 | +phase: draft |
|
387 | 387 | +phase: draft |
|
388 | 388 | |
|
389 | 389 | $ hg log -q > log.out |
|
390 | 390 | $ hg log -q --style default > style.out |
|
391 | 391 | $ cmp log.out style.out || diff -u log.out style.out |
|
392 | 392 | $ hg log -q -T phases > phases.out |
|
393 | 393 | $ cmp log.out phases.out || diff -u log.out phases.out |
|
394 | 394 | |
|
395 | 395 | $ hg log --debug > log.out |
|
396 | 396 | $ hg log --debug --style default > style.out |
|
397 | 397 | $ cmp log.out style.out || diff -u log.out style.out |
|
398 | 398 | $ hg log --debug -T phases > phases.out |
|
399 | 399 | $ cmp log.out phases.out || diff -u log.out phases.out |
|
400 | 400 | |
|
401 | 401 | Default style of working-directory revision should also be the same (but |
|
402 | 402 | date may change while running tests): |
|
403 | 403 | |
|
404 | 404 | $ hg log -r 'wdir()' | sed 's|^date:.*|date:|' > log.out |
|
405 | 405 | $ hg log -r 'wdir()' --style default | sed 's|^date:.*|date:|' > style.out |
|
406 | 406 | $ cmp log.out style.out || diff -u log.out style.out |
|
407 | 407 | |
|
408 | 408 | $ hg log -r 'wdir()' -v | sed 's|^date:.*|date:|' > log.out |
|
409 | 409 | $ hg log -r 'wdir()' -v --style default | sed 's|^date:.*|date:|' > style.out |
|
410 | 410 | $ cmp log.out style.out || diff -u log.out style.out |
|
411 | 411 | |
|
412 | 412 | $ hg log -r 'wdir()' -q > log.out |
|
413 | 413 | $ hg log -r 'wdir()' -q --style default > style.out |
|
414 | 414 | $ cmp log.out style.out || diff -u log.out style.out |
|
415 | 415 | |
|
416 | 416 | $ hg log -r 'wdir()' --debug | sed 's|^date:.*|date:|' > log.out |
|
417 | 417 | $ hg log -r 'wdir()' --debug --style default \ |
|
418 | 418 | > | sed 's|^date:.*|date:|' > style.out |
|
419 | 419 | $ cmp log.out style.out || diff -u log.out style.out |
|
420 | 420 | |
|
421 | 421 | Default style should also preserve color information (issue2866): |
|
422 | 422 | |
|
423 | 423 | $ cp $HGRCPATH $HGRCPATH-bak |
|
424 | 424 | $ cat <<EOF >> $HGRCPATH |
|
425 | 425 | > [extensions] |
|
426 | 426 | > color= |
|
427 | 427 | > EOF |
|
428 | 428 | |
|
429 | 429 | $ hg --color=debug log > log.out |
|
430 | 430 | $ hg --color=debug log --style default > style.out |
|
431 | 431 | $ cmp log.out style.out || diff -u log.out style.out |
|
432 | 432 | $ hg --color=debug log -T phases > phases.out |
|
433 | 433 | $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@' |
|
434 | 434 | +[log.phase|phase: draft] |
|
435 | 435 | +[log.phase|phase: draft] |
|
436 | 436 | +[log.phase|phase: draft] |
|
437 | 437 | +[log.phase|phase: draft] |
|
438 | 438 | +[log.phase|phase: draft] |
|
439 | 439 | +[log.phase|phase: draft] |
|
440 | 440 | +[log.phase|phase: draft] |
|
441 | 441 | +[log.phase|phase: draft] |
|
442 | 442 | +[log.phase|phase: draft] |
|
443 | 443 | +[log.phase|phase: draft] |
|
444 | 444 | |
|
445 | 445 | $ hg --color=debug -v log > log.out |
|
446 | 446 | $ hg --color=debug -v log --style default > style.out |
|
447 | 447 | $ cmp log.out style.out || diff -u log.out style.out |
|
448 | 448 | $ hg --color=debug -v log -T phases > phases.out |
|
449 | 449 | $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@' |
|
450 | 450 | +[log.phase|phase: draft] |
|
451 | 451 | +[log.phase|phase: draft] |
|
452 | 452 | +[log.phase|phase: draft] |
|
453 | 453 | +[log.phase|phase: draft] |
|
454 | 454 | +[log.phase|phase: draft] |
|
455 | 455 | +[log.phase|phase: draft] |
|
456 | 456 | +[log.phase|phase: draft] |
|
457 | 457 | +[log.phase|phase: draft] |
|
458 | 458 | +[log.phase|phase: draft] |
|
459 | 459 | +[log.phase|phase: draft] |
|
460 | 460 | |
|
461 | 461 | $ hg --color=debug -q log > log.out |
|
462 | 462 | $ hg --color=debug -q log --style default > style.out |
|
463 | 463 | $ cmp log.out style.out || diff -u log.out style.out |
|
464 | 464 | $ hg --color=debug -q log -T phases > phases.out |
|
465 | 465 | $ cmp log.out phases.out || diff -u log.out phases.out |
|
466 | 466 | |
|
467 | 467 | $ hg --color=debug --debug log > log.out |
|
468 | 468 | $ hg --color=debug --debug log --style default > style.out |
|
469 | 469 | $ cmp log.out style.out || diff -u log.out style.out |
|
470 | 470 | $ hg --color=debug --debug log -T phases > phases.out |
|
471 | 471 | $ cmp log.out phases.out || diff -u log.out phases.out |
|
472 | 472 | |
|
473 | 473 | $ mv $HGRCPATH-bak $HGRCPATH |
|
474 | 474 | |
|
475 | 475 | Remove commit with empty commit message, so as to not pollute further |
|
476 | 476 | tests. |
|
477 | 477 | |
|
478 | 478 | $ hg --config extensions.strip= strip -q . |
|
479 | 479 | |
|
480 | 480 | Revision with no copies (used to print a traceback): |
|
481 | 481 | |
|
482 | 482 | $ hg tip -v --template '\n' |
|
483 | 483 | |
|
484 | 484 | |
|
485 | 485 | Compact style works: |
|
486 | 486 | |
|
487 | 487 | $ hg log -Tcompact |
|
488 | 488 | 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test |
|
489 | 489 | third |
|
490 | 490 | |
|
491 | 491 | 7:-1 29114dbae42b 1970-01-12 13:46 +0000 user |
|
492 | 492 | second |
|
493 | 493 | |
|
494 | 494 | 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person |
|
495 | 495 | merge |
|
496 | 496 | |
|
497 | 497 | 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person |
|
498 | 498 | new head |
|
499 | 499 | |
|
500 | 500 | 4 bbe44766e73d 1970-01-17 04:53 +0000 person |
|
501 | 501 | new branch |
|
502 | 502 | |
|
503 | 503 | 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person |
|
504 | 504 | no user, no domain |
|
505 | 505 | |
|
506 | 506 | 2 97054abb4ab8 1970-01-14 21:20 +0000 other |
|
507 | 507 | no person |
|
508 | 508 | |
|
509 | 509 | 1 b608e9d1a3f0 1970-01-13 17:33 +0000 other |
|
510 | 510 | other 1 |
|
511 | 511 | |
|
512 | 512 | 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 user |
|
513 | 513 | line 1 |
|
514 | 514 | |
|
515 | 515 | |
|
516 | 516 | $ hg log -v --style compact |
|
517 | 517 | 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test |
|
518 | 518 | third |
|
519 | 519 | |
|
520 | 520 | 7:-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname> |
|
521 | 521 | second |
|
522 | 522 | |
|
523 | 523 | 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person |
|
524 | 524 | merge |
|
525 | 525 | |
|
526 | 526 | 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person |
|
527 | 527 | new head |
|
528 | 528 | |
|
529 | 529 | 4 bbe44766e73d 1970-01-17 04:53 +0000 person |
|
530 | 530 | new branch |
|
531 | 531 | |
|
532 | 532 | 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person |
|
533 | 533 | no user, no domain |
|
534 | 534 | |
|
535 | 535 | 2 97054abb4ab8 1970-01-14 21:20 +0000 other@place |
|
536 | 536 | no person |
|
537 | 537 | |
|
538 | 538 | 1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place> |
|
539 | 539 | other 1 |
|
540 | 540 | other 2 |
|
541 | 541 | |
|
542 | 542 | other 3 |
|
543 | 543 | |
|
544 | 544 | 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname> |
|
545 | 545 | line 1 |
|
546 | 546 | line 2 |
|
547 | 547 | |
|
548 | 548 | |
|
549 | 549 | $ hg log --debug --style compact |
|
550 | 550 | 8[tip]:7,-1 95c24699272e 2020-01-01 10:01 +0000 test |
|
551 | 551 | third |
|
552 | 552 | |
|
553 | 553 | 7:-1,-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname> |
|
554 | 554 | second |
|
555 | 555 | |
|
556 | 556 | 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person |
|
557 | 557 | merge |
|
558 | 558 | |
|
559 | 559 | 5:3,-1 13207e5a10d9 1970-01-18 08:40 +0000 person |
|
560 | 560 | new head |
|
561 | 561 | |
|
562 | 562 | 4:3,-1 bbe44766e73d 1970-01-17 04:53 +0000 person |
|
563 | 563 | new branch |
|
564 | 564 | |
|
565 | 565 | 3:2,-1 10e46f2dcbf4 1970-01-16 01:06 +0000 person |
|
566 | 566 | no user, no domain |
|
567 | 567 | |
|
568 | 568 | 2:1,-1 97054abb4ab8 1970-01-14 21:20 +0000 other@place |
|
569 | 569 | no person |
|
570 | 570 | |
|
571 | 571 | 1:0,-1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place> |
|
572 | 572 | other 1 |
|
573 | 573 | other 2 |
|
574 | 574 | |
|
575 | 575 | other 3 |
|
576 | 576 | |
|
577 | 577 | 0:-1,-1 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname> |
|
578 | 578 | line 1 |
|
579 | 579 | line 2 |
|
580 | 580 | |
|
581 | 581 | |
|
582 | 582 | Test xml styles: |
|
583 | 583 | |
|
584 | 584 | $ hg log --style xml -r 'not all()' |
|
585 | 585 | <?xml version="1.0"?> |
|
586 | 586 | <log> |
|
587 | 587 | </log> |
|
588 | 588 | |
|
589 | 589 | $ hg log --style xml |
|
590 | 590 | <?xml version="1.0"?> |
|
591 | 591 | <log> |
|
592 | 592 | <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a"> |
|
593 | 593 | <tag>tip</tag> |
|
594 | 594 | <author email="test">test</author> |
|
595 | 595 | <date>2020-01-01T10:01:00+00:00</date> |
|
596 | 596 | <msg xml:space="preserve">third</msg> |
|
597 | 597 | </logentry> |
|
598 | 598 | <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453"> |
|
599 | 599 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
600 | 600 | <author email="user@hostname">User Name</author> |
|
601 | 601 | <date>1970-01-12T13:46:40+00:00</date> |
|
602 | 602 | <msg xml:space="preserve">second</msg> |
|
603 | 603 | </logentry> |
|
604 | 604 | <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b"> |
|
605 | 605 | <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" /> |
|
606 | 606 | <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" /> |
|
607 | 607 | <author email="person">person</author> |
|
608 | 608 | <date>1970-01-18T08:40:01+00:00</date> |
|
609 | 609 | <msg xml:space="preserve">merge</msg> |
|
610 | 610 | </logentry> |
|
611 | 611 | <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f"> |
|
612 | 612 | <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" /> |
|
613 | 613 | <author email="person">person</author> |
|
614 | 614 | <date>1970-01-18T08:40:00+00:00</date> |
|
615 | 615 | <msg xml:space="preserve">new head</msg> |
|
616 | 616 | </logentry> |
|
617 | 617 | <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74"> |
|
618 | 618 | <branch>foo</branch> |
|
619 | 619 | <author email="person">person</author> |
|
620 | 620 | <date>1970-01-17T04:53:20+00:00</date> |
|
621 | 621 | <msg xml:space="preserve">new branch</msg> |
|
622 | 622 | </logentry> |
|
623 | 623 | <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47"> |
|
624 | 624 | <author email="person">person</author> |
|
625 | 625 | <date>1970-01-16T01:06:40+00:00</date> |
|
626 | 626 | <msg xml:space="preserve">no user, no domain</msg> |
|
627 | 627 | </logentry> |
|
628 | 628 | <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465"> |
|
629 | 629 | <author email="other@place">other</author> |
|
630 | 630 | <date>1970-01-14T21:20:00+00:00</date> |
|
631 | 631 | <msg xml:space="preserve">no person</msg> |
|
632 | 632 | </logentry> |
|
633 | 633 | <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965"> |
|
634 | 634 | <author email="other@place">A. N. Other</author> |
|
635 | 635 | <date>1970-01-13T17:33:20+00:00</date> |
|
636 | 636 | <msg xml:space="preserve">other 1 |
|
637 | 637 | other 2 |
|
638 | 638 | |
|
639 | 639 | other 3</msg> |
|
640 | 640 | </logentry> |
|
641 | 641 | <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f"> |
|
642 | 642 | <author email="user@hostname">User Name</author> |
|
643 | 643 | <date>1970-01-12T13:46:40+00:00</date> |
|
644 | 644 | <msg xml:space="preserve">line 1 |
|
645 | 645 | line 2</msg> |
|
646 | 646 | </logentry> |
|
647 | 647 | </log> |
|
648 | 648 | |
|
649 | 649 | $ hg log -v --style xml |
|
650 | 650 | <?xml version="1.0"?> |
|
651 | 651 | <log> |
|
652 | 652 | <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a"> |
|
653 | 653 | <tag>tip</tag> |
|
654 | 654 | <author email="test">test</author> |
|
655 | 655 | <date>2020-01-01T10:01:00+00:00</date> |
|
656 | 656 | <msg xml:space="preserve">third</msg> |
|
657 | 657 | <paths> |
|
658 | 658 | <path action="A">fourth</path> |
|
659 | 659 | <path action="A">third</path> |
|
660 | 660 | <path action="R">second</path> |
|
661 | 661 | </paths> |
|
662 | 662 | <copies> |
|
663 | 663 | <copy source="second">fourth</copy> |
|
664 | 664 | </copies> |
|
665 | 665 | </logentry> |
|
666 | 666 | <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453"> |
|
667 | 667 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
668 | 668 | <author email="user@hostname">User Name</author> |
|
669 | 669 | <date>1970-01-12T13:46:40+00:00</date> |
|
670 | 670 | <msg xml:space="preserve">second</msg> |
|
671 | 671 | <paths> |
|
672 | 672 | <path action="A">second</path> |
|
673 | 673 | </paths> |
|
674 | 674 | </logentry> |
|
675 | 675 | <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b"> |
|
676 | 676 | <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" /> |
|
677 | 677 | <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" /> |
|
678 | 678 | <author email="person">person</author> |
|
679 | 679 | <date>1970-01-18T08:40:01+00:00</date> |
|
680 | 680 | <msg xml:space="preserve">merge</msg> |
|
681 | 681 | <paths> |
|
682 | 682 | </paths> |
|
683 | 683 | </logentry> |
|
684 | 684 | <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f"> |
|
685 | 685 | <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" /> |
|
686 | 686 | <author email="person">person</author> |
|
687 | 687 | <date>1970-01-18T08:40:00+00:00</date> |
|
688 | 688 | <msg xml:space="preserve">new head</msg> |
|
689 | 689 | <paths> |
|
690 | 690 | <path action="A">d</path> |
|
691 | 691 | </paths> |
|
692 | 692 | </logentry> |
|
693 | 693 | <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74"> |
|
694 | 694 | <branch>foo</branch> |
|
695 | 695 | <author email="person">person</author> |
|
696 | 696 | <date>1970-01-17T04:53:20+00:00</date> |
|
697 | 697 | <msg xml:space="preserve">new branch</msg> |
|
698 | 698 | <paths> |
|
699 | 699 | </paths> |
|
700 | 700 | </logentry> |
|
701 | 701 | <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47"> |
|
702 | 702 | <author email="person">person</author> |
|
703 | 703 | <date>1970-01-16T01:06:40+00:00</date> |
|
704 | 704 | <msg xml:space="preserve">no user, no domain</msg> |
|
705 | 705 | <paths> |
|
706 | 706 | <path action="M">c</path> |
|
707 | 707 | </paths> |
|
708 | 708 | </logentry> |
|
709 | 709 | <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465"> |
|
710 | 710 | <author email="other@place">other</author> |
|
711 | 711 | <date>1970-01-14T21:20:00+00:00</date> |
|
712 | 712 | <msg xml:space="preserve">no person</msg> |
|
713 | 713 | <paths> |
|
714 | 714 | <path action="A">c</path> |
|
715 | 715 | </paths> |
|
716 | 716 | </logentry> |
|
717 | 717 | <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965"> |
|
718 | 718 | <author email="other@place">A. N. Other</author> |
|
719 | 719 | <date>1970-01-13T17:33:20+00:00</date> |
|
720 | 720 | <msg xml:space="preserve">other 1 |
|
721 | 721 | other 2 |
|
722 | 722 | |
|
723 | 723 | other 3</msg> |
|
724 | 724 | <paths> |
|
725 | 725 | <path action="A">b</path> |
|
726 | 726 | </paths> |
|
727 | 727 | </logentry> |
|
728 | 728 | <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f"> |
|
729 | 729 | <author email="user@hostname">User Name</author> |
|
730 | 730 | <date>1970-01-12T13:46:40+00:00</date> |
|
731 | 731 | <msg xml:space="preserve">line 1 |
|
732 | 732 | line 2</msg> |
|
733 | 733 | <paths> |
|
734 | 734 | <path action="A">a</path> |
|
735 | 735 | </paths> |
|
736 | 736 | </logentry> |
|
737 | 737 | </log> |
|
738 | 738 | |
|
739 | 739 | $ hg log --debug --style xml |
|
740 | 740 | <?xml version="1.0"?> |
|
741 | 741 | <log> |
|
742 | 742 | <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a"> |
|
743 | 743 | <tag>tip</tag> |
|
744 | 744 | <parent revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453" /> |
|
745 | 745 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
746 | 746 | <author email="test">test</author> |
|
747 | 747 | <date>2020-01-01T10:01:00+00:00</date> |
|
748 | 748 | <msg xml:space="preserve">third</msg> |
|
749 | 749 | <paths> |
|
750 | 750 | <path action="A">fourth</path> |
|
751 | 751 | <path action="A">third</path> |
|
752 | 752 | <path action="R">second</path> |
|
753 | 753 | </paths> |
|
754 | 754 | <copies> |
|
755 | 755 | <copy source="second">fourth</copy> |
|
756 | 756 | </copies> |
|
757 | 757 | <extra key="branch">default</extra> |
|
758 | 758 | </logentry> |
|
759 | 759 | <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453"> |
|
760 | 760 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
761 | 761 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
762 | 762 | <author email="user@hostname">User Name</author> |
|
763 | 763 | <date>1970-01-12T13:46:40+00:00</date> |
|
764 | 764 | <msg xml:space="preserve">second</msg> |
|
765 | 765 | <paths> |
|
766 | 766 | <path action="A">second</path> |
|
767 | 767 | </paths> |
|
768 | 768 | <extra key="branch">default</extra> |
|
769 | 769 | </logentry> |
|
770 | 770 | <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b"> |
|
771 | 771 | <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" /> |
|
772 | 772 | <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" /> |
|
773 | 773 | <author email="person">person</author> |
|
774 | 774 | <date>1970-01-18T08:40:01+00:00</date> |
|
775 | 775 | <msg xml:space="preserve">merge</msg> |
|
776 | 776 | <paths> |
|
777 | 777 | </paths> |
|
778 | 778 | <extra key="branch">default</extra> |
|
779 | 779 | </logentry> |
|
780 | 780 | <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f"> |
|
781 | 781 | <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" /> |
|
782 | 782 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
783 | 783 | <author email="person">person</author> |
|
784 | 784 | <date>1970-01-18T08:40:00+00:00</date> |
|
785 | 785 | <msg xml:space="preserve">new head</msg> |
|
786 | 786 | <paths> |
|
787 | 787 | <path action="A">d</path> |
|
788 | 788 | </paths> |
|
789 | 789 | <extra key="branch">default</extra> |
|
790 | 790 | </logentry> |
|
791 | 791 | <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74"> |
|
792 | 792 | <branch>foo</branch> |
|
793 | 793 | <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" /> |
|
794 | 794 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
795 | 795 | <author email="person">person</author> |
|
796 | 796 | <date>1970-01-17T04:53:20+00:00</date> |
|
797 | 797 | <msg xml:space="preserve">new branch</msg> |
|
798 | 798 | <paths> |
|
799 | 799 | </paths> |
|
800 | 800 | <extra key="branch">foo</extra> |
|
801 | 801 | </logentry> |
|
802 | 802 | <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47"> |
|
803 | 803 | <parent revision="2" node="97054abb4ab824450e9164180baf491ae0078465" /> |
|
804 | 804 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
805 | 805 | <author email="person">person</author> |
|
806 | 806 | <date>1970-01-16T01:06:40+00:00</date> |
|
807 | 807 | <msg xml:space="preserve">no user, no domain</msg> |
|
808 | 808 | <paths> |
|
809 | 809 | <path action="M">c</path> |
|
810 | 810 | </paths> |
|
811 | 811 | <extra key="branch">default</extra> |
|
812 | 812 | </logentry> |
|
813 | 813 | <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465"> |
|
814 | 814 | <parent revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965" /> |
|
815 | 815 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
816 | 816 | <author email="other@place">other</author> |
|
817 | 817 | <date>1970-01-14T21:20:00+00:00</date> |
|
818 | 818 | <msg xml:space="preserve">no person</msg> |
|
819 | 819 | <paths> |
|
820 | 820 | <path action="A">c</path> |
|
821 | 821 | </paths> |
|
822 | 822 | <extra key="branch">default</extra> |
|
823 | 823 | </logentry> |
|
824 | 824 | <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965"> |
|
825 | 825 | <parent revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f" /> |
|
826 | 826 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
827 | 827 | <author email="other@place">A. N. Other</author> |
|
828 | 828 | <date>1970-01-13T17:33:20+00:00</date> |
|
829 | 829 | <msg xml:space="preserve">other 1 |
|
830 | 830 | other 2 |
|
831 | 831 | |
|
832 | 832 | other 3</msg> |
|
833 | 833 | <paths> |
|
834 | 834 | <path action="A">b</path> |
|
835 | 835 | </paths> |
|
836 | 836 | <extra key="branch">default</extra> |
|
837 | 837 | </logentry> |
|
838 | 838 | <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f"> |
|
839 | 839 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
840 | 840 | <parent revision="-1" node="0000000000000000000000000000000000000000" /> |
|
841 | 841 | <author email="user@hostname">User Name</author> |
|
842 | 842 | <date>1970-01-12T13:46:40+00:00</date> |
|
843 | 843 | <msg xml:space="preserve">line 1 |
|
844 | 844 | line 2</msg> |
|
845 | 845 | <paths> |
|
846 | 846 | <path action="A">a</path> |
|
847 | 847 | </paths> |
|
848 | 848 | <extra key="branch">default</extra> |
|
849 | 849 | </logentry> |
|
850 | 850 | </log> |
|
851 | 851 | |
|
852 | 852 | |
|
853 | 853 | Test JSON style: |
|
854 | 854 | |
|
855 | 855 | $ hg log -k nosuch -Tjson |
|
856 | 856 | [ |
|
857 | 857 | ] |
|
858 | 858 | |
|
859 | 859 | $ hg log -qr . -Tjson |
|
860 | 860 | [ |
|
861 | 861 | { |
|
862 | 862 | "node": "95c24699272ef57d062b8bccc32c878bf841784a", |
|
863 | 863 | "rev": 8 |
|
864 | 864 | } |
|
865 | 865 | ] |
|
866 | 866 | |
|
867 | 867 | $ hg log -vpr . -Tjson --stat |
|
868 | 868 | [ |
|
869 | 869 | { |
|
870 | 870 | "bookmarks": [], |
|
871 | 871 | "branch": "default", |
|
872 | 872 | "date": [1577872860, 0], |
|
873 | 873 | "desc": "third", |
|
874 | 874 | "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", |
|
875 | 875 | "diffstat": " fourth | 1 +\n second | 1 -\n third | 1 +\n 3 files changed, 2 insertions(+), 1 deletions(-)\n", |
|
876 | 876 | "files": ["fourth", "second", "third"], |
|
877 | 877 | "node": "95c24699272ef57d062b8bccc32c878bf841784a", |
|
878 | 878 | "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"], |
|
879 | 879 | "phase": "draft", |
|
880 | 880 | "rev": 8, |
|
881 | 881 | "tags": ["tip"], |
|
882 | 882 | "user": "test" |
|
883 | 883 | } |
|
884 | 884 | ] |
|
885 | 885 | |
|
886 | 886 | honor --git but not format-breaking diffopts |
|
887 | 887 | $ hg --config diff.noprefix=True log --git -vpr . -Tjson |
|
888 | 888 | [ |
|
889 | 889 | { |
|
890 | 890 | "bookmarks": [], |
|
891 | 891 | "branch": "default", |
|
892 | 892 | "date": [1577872860, 0], |
|
893 | 893 | "desc": "third", |
|
894 | 894 | "diff": "diff --git a/second b/fourth\nrename from second\nrename to fourth\ndiff --git a/third b/third\nnew file mode 100644\n--- /dev/null\n+++ b/third\n@@ -0,0 +1,1 @@\n+third\n", |
|
895 | 895 | "files": ["fourth", "second", "third"], |
|
896 | 896 | "node": "95c24699272ef57d062b8bccc32c878bf841784a", |
|
897 | 897 | "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"], |
|
898 | 898 | "phase": "draft", |
|
899 | 899 | "rev": 8, |
|
900 | 900 | "tags": ["tip"], |
|
901 | 901 | "user": "test" |
|
902 | 902 | } |
|
903 | 903 | ] |
|
904 | 904 | |
|
905 | 905 | $ hg log -T json |
|
906 | 906 | [ |
|
907 | 907 | { |
|
908 | 908 | "bookmarks": [], |
|
909 | 909 | "branch": "default", |
|
910 | 910 | "date": [1577872860, 0], |
|
911 | 911 | "desc": "third", |
|
912 | 912 | "node": "95c24699272ef57d062b8bccc32c878bf841784a", |
|
913 | 913 | "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"], |
|
914 | 914 | "phase": "draft", |
|
915 | 915 | "rev": 8, |
|
916 | 916 | "tags": ["tip"], |
|
917 | 917 | "user": "test" |
|
918 | 918 | }, |
|
919 | 919 | { |
|
920 | 920 | "bookmarks": [], |
|
921 | 921 | "branch": "default", |
|
922 | 922 | "date": [1000000, 0], |
|
923 | 923 | "desc": "second", |
|
924 | 924 | "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453", |
|
925 | 925 | "parents": ["0000000000000000000000000000000000000000"], |
|
926 | 926 | "phase": "draft", |
|
927 | 927 | "rev": 7, |
|
928 | 928 | "tags": [], |
|
929 | 929 | "user": "User Name <user@hostname>" |
|
930 | 930 | }, |
|
931 | 931 | { |
|
932 | 932 | "bookmarks": [], |
|
933 | 933 | "branch": "default", |
|
934 | 934 | "date": [1500001, 0], |
|
935 | 935 | "desc": "merge", |
|
936 | 936 | "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b", |
|
937 | 937 | "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"], |
|
938 | 938 | "phase": "draft", |
|
939 | 939 | "rev": 6, |
|
940 | 940 | "tags": [], |
|
941 | 941 | "user": "person" |
|
942 | 942 | }, |
|
943 | 943 | { |
|
944 | 944 | "bookmarks": [], |
|
945 | 945 | "branch": "default", |
|
946 | 946 | "date": [1500000, 0], |
|
947 | 947 | "desc": "new head", |
|
948 | 948 | "node": "13207e5a10d9fd28ec424934298e176197f2c67f", |
|
949 | 949 | "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"], |
|
950 | 950 | "phase": "draft", |
|
951 | 951 | "rev": 5, |
|
952 | 952 | "tags": [], |
|
953 | 953 | "user": "person" |
|
954 | 954 | }, |
|
955 | 955 | { |
|
956 | 956 | "bookmarks": [], |
|
957 | 957 | "branch": "foo", |
|
958 | 958 | "date": [1400000, 0], |
|
959 | 959 | "desc": "new branch", |
|
960 | 960 | "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74", |
|
961 | 961 | "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"], |
|
962 | 962 | "phase": "draft", |
|
963 | 963 | "rev": 4, |
|
964 | 964 | "tags": [], |
|
965 | 965 | "user": "person" |
|
966 | 966 | }, |
|
967 | 967 | { |
|
968 | 968 | "bookmarks": [], |
|
969 | 969 | "branch": "default", |
|
970 | 970 | "date": [1300000, 0], |
|
971 | 971 | "desc": "no user, no domain", |
|
972 | 972 | "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47", |
|
973 | 973 | "parents": ["97054abb4ab824450e9164180baf491ae0078465"], |
|
974 | 974 | "phase": "draft", |
|
975 | 975 | "rev": 3, |
|
976 | 976 | "tags": [], |
|
977 | 977 | "user": "person" |
|
978 | 978 | }, |
|
979 | 979 | { |
|
980 | 980 | "bookmarks": [], |
|
981 | 981 | "branch": "default", |
|
982 | 982 | "date": [1200000, 0], |
|
983 | 983 | "desc": "no person", |
|
984 | 984 | "node": "97054abb4ab824450e9164180baf491ae0078465", |
|
985 | 985 | "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"], |
|
986 | 986 | "phase": "draft", |
|
987 | 987 | "rev": 2, |
|
988 | 988 | "tags": [], |
|
989 | 989 | "user": "other@place" |
|
990 | 990 | }, |
|
991 | 991 | { |
|
992 | 992 | "bookmarks": [], |
|
993 | 993 | "branch": "default", |
|
994 | 994 | "date": [1100000, 0], |
|
995 | 995 | "desc": "other 1\nother 2\n\nother 3", |
|
996 | 996 | "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965", |
|
997 | 997 | "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"], |
|
998 | 998 | "phase": "draft", |
|
999 | 999 | "rev": 1, |
|
1000 | 1000 | "tags": [], |
|
1001 | 1001 | "user": "A. N. Other <other@place>" |
|
1002 | 1002 | }, |
|
1003 | 1003 | { |
|
1004 | 1004 | "bookmarks": [], |
|
1005 | 1005 | "branch": "default", |
|
1006 | 1006 | "date": [1000000, 0], |
|
1007 | 1007 | "desc": "line 1\nline 2", |
|
1008 | 1008 | "node": "1e4e1b8f71e05681d422154f5421e385fec3454f", |
|
1009 | 1009 | "parents": ["0000000000000000000000000000000000000000"], |
|
1010 | 1010 | "phase": "draft", |
|
1011 | 1011 | "rev": 0, |
|
1012 | 1012 | "tags": [], |
|
1013 | 1013 | "user": "User Name <user@hostname>" |
|
1014 | 1014 | } |
|
1015 | 1015 | ] |
|
1016 | 1016 | |
|
1017 | 1017 | $ hg heads -v -Tjson |
|
1018 | 1018 | [ |
|
1019 | 1019 | { |
|
1020 | 1020 | "bookmarks": [], |
|
1021 | 1021 | "branch": "default", |
|
1022 | 1022 | "date": [1577872860, 0], |
|
1023 | 1023 | "desc": "third", |
|
1024 | 1024 | "files": ["fourth", "second", "third"], |
|
1025 | 1025 | "node": "95c24699272ef57d062b8bccc32c878bf841784a", |
|
1026 | 1026 | "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"], |
|
1027 | 1027 | "phase": "draft", |
|
1028 | 1028 | "rev": 8, |
|
1029 | 1029 | "tags": ["tip"], |
|
1030 | 1030 | "user": "test" |
|
1031 | 1031 | }, |
|
1032 | 1032 | { |
|
1033 | 1033 | "bookmarks": [], |
|
1034 | 1034 | "branch": "default", |
|
1035 | 1035 | "date": [1500001, 0], |
|
1036 | 1036 | "desc": "merge", |
|
1037 | 1037 | "files": [], |
|
1038 | 1038 | "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b", |
|
1039 | 1039 | "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"], |
|
1040 | 1040 | "phase": "draft", |
|
1041 | 1041 | "rev": 6, |
|
1042 | 1042 | "tags": [], |
|
1043 | 1043 | "user": "person" |
|
1044 | 1044 | }, |
|
1045 | 1045 | { |
|
1046 | 1046 | "bookmarks": [], |
|
1047 | 1047 | "branch": "foo", |
|
1048 | 1048 | "date": [1400000, 0], |
|
1049 | 1049 | "desc": "new branch", |
|
1050 | 1050 | "files": [], |
|
1051 | 1051 | "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74", |
|
1052 | 1052 | "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"], |
|
1053 | 1053 | "phase": "draft", |
|
1054 | 1054 | "rev": 4, |
|
1055 | 1055 | "tags": [], |
|
1056 | 1056 | "user": "person" |
|
1057 | 1057 | } |
|
1058 | 1058 | ] |
|
1059 | 1059 | |
|
1060 | 1060 | $ hg log --debug -Tjson |
|
1061 | 1061 | [ |
|
1062 | 1062 | { |
|
1063 | 1063 | "added": ["fourth", "third"], |
|
1064 | 1064 | "bookmarks": [], |
|
1065 | 1065 | "branch": "default", |
|
1066 | 1066 | "date": [1577872860, 0], |
|
1067 | 1067 | "desc": "third", |
|
1068 | 1068 | "extra": {"branch": "default"}, |
|
1069 | 1069 | "manifest": "94961b75a2da554b4df6fb599e5bfc7d48de0c64", |
|
1070 | 1070 | "modified": [], |
|
1071 | 1071 | "node": "95c24699272ef57d062b8bccc32c878bf841784a", |
|
1072 | 1072 | "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"], |
|
1073 | 1073 | "phase": "draft", |
|
1074 | 1074 | "removed": ["second"], |
|
1075 | 1075 | "rev": 8, |
|
1076 | 1076 | "tags": ["tip"], |
|
1077 | 1077 | "user": "test" |
|
1078 | 1078 | }, |
|
1079 | 1079 | { |
|
1080 | 1080 | "added": ["second"], |
|
1081 | 1081 | "bookmarks": [], |
|
1082 | 1082 | "branch": "default", |
|
1083 | 1083 | "date": [1000000, 0], |
|
1084 | 1084 | "desc": "second", |
|
1085 | 1085 | "extra": {"branch": "default"}, |
|
1086 | 1086 | "manifest": "f2dbc354b94e5ec0b4f10680ee0cee816101d0bf", |
|
1087 | 1087 | "modified": [], |
|
1088 | 1088 | "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453", |
|
1089 | 1089 | "parents": ["0000000000000000000000000000000000000000"], |
|
1090 | 1090 | "phase": "draft", |
|
1091 | 1091 | "removed": [], |
|
1092 | 1092 | "rev": 7, |
|
1093 | 1093 | "tags": [], |
|
1094 | 1094 | "user": "User Name <user@hostname>" |
|
1095 | 1095 | }, |
|
1096 | 1096 | { |
|
1097 | 1097 | "added": [], |
|
1098 | 1098 | "bookmarks": [], |
|
1099 | 1099 | "branch": "default", |
|
1100 | 1100 | "date": [1500001, 0], |
|
1101 | 1101 | "desc": "merge", |
|
1102 | 1102 | "extra": {"branch": "default"}, |
|
1103 | 1103 | "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216", |
|
1104 | 1104 | "modified": [], |
|
1105 | 1105 | "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b", |
|
1106 | 1106 | "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"], |
|
1107 | 1107 | "phase": "draft", |
|
1108 | 1108 | "removed": [], |
|
1109 | 1109 | "rev": 6, |
|
1110 | 1110 | "tags": [], |
|
1111 | 1111 | "user": "person" |
|
1112 | 1112 | }, |
|
1113 | 1113 | { |
|
1114 | 1114 | "added": ["d"], |
|
1115 | 1115 | "bookmarks": [], |
|
1116 | 1116 | "branch": "default", |
|
1117 | 1117 | "date": [1500000, 0], |
|
1118 | 1118 | "desc": "new head", |
|
1119 | 1119 | "extra": {"branch": "default"}, |
|
1120 | 1120 | "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216", |
|
1121 | 1121 | "modified": [], |
|
1122 | 1122 | "node": "13207e5a10d9fd28ec424934298e176197f2c67f", |
|
1123 | 1123 | "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"], |
|
1124 | 1124 | "phase": "draft", |
|
1125 | 1125 | "removed": [], |
|
1126 | 1126 | "rev": 5, |
|
1127 | 1127 | "tags": [], |
|
1128 | 1128 | "user": "person" |
|
1129 | 1129 | }, |
|
1130 | 1130 | { |
|
1131 | 1131 | "added": [], |
|
1132 | 1132 | "bookmarks": [], |
|
1133 | 1133 | "branch": "foo", |
|
1134 | 1134 | "date": [1400000, 0], |
|
1135 | 1135 | "desc": "new branch", |
|
1136 | 1136 | "extra": {"branch": "foo"}, |
|
1137 | 1137 | "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc", |
|
1138 | 1138 | "modified": [], |
|
1139 | 1139 | "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74", |
|
1140 | 1140 | "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"], |
|
1141 | 1141 | "phase": "draft", |
|
1142 | 1142 | "removed": [], |
|
1143 | 1143 | "rev": 4, |
|
1144 | 1144 | "tags": [], |
|
1145 | 1145 | "user": "person" |
|
1146 | 1146 | }, |
|
1147 | 1147 | { |
|
1148 | 1148 | "added": [], |
|
1149 | 1149 | "bookmarks": [], |
|
1150 | 1150 | "branch": "default", |
|
1151 | 1151 | "date": [1300000, 0], |
|
1152 | 1152 | "desc": "no user, no domain", |
|
1153 | 1153 | "extra": {"branch": "default"}, |
|
1154 | 1154 | "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc", |
|
1155 | 1155 | "modified": ["c"], |
|
1156 | 1156 | "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47", |
|
1157 | 1157 | "parents": ["97054abb4ab824450e9164180baf491ae0078465"], |
|
1158 | 1158 | "phase": "draft", |
|
1159 | 1159 | "removed": [], |
|
1160 | 1160 | "rev": 3, |
|
1161 | 1161 | "tags": [], |
|
1162 | 1162 | "user": "person" |
|
1163 | 1163 | }, |
|
1164 | 1164 | { |
|
1165 | 1165 | "added": ["c"], |
|
1166 | 1166 | "bookmarks": [], |
|
1167 | 1167 | "branch": "default", |
|
1168 | 1168 | "date": [1200000, 0], |
|
1169 | 1169 | "desc": "no person", |
|
1170 | 1170 | "extra": {"branch": "default"}, |
|
1171 | 1171 | "manifest": "6e0e82995c35d0d57a52aca8da4e56139e06b4b1", |
|
1172 | 1172 | "modified": [], |
|
1173 | 1173 | "node": "97054abb4ab824450e9164180baf491ae0078465", |
|
1174 | 1174 | "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"], |
|
1175 | 1175 | "phase": "draft", |
|
1176 | 1176 | "removed": [], |
|
1177 | 1177 | "rev": 2, |
|
1178 | 1178 | "tags": [], |
|
1179 | 1179 | "user": "other@place" |
|
1180 | 1180 | }, |
|
1181 | 1181 | { |
|
1182 | 1182 | "added": ["b"], |
|
1183 | 1183 | "bookmarks": [], |
|
1184 | 1184 | "branch": "default", |
|
1185 | 1185 | "date": [1100000, 0], |
|
1186 | 1186 | "desc": "other 1\nother 2\n\nother 3", |
|
1187 | 1187 | "extra": {"branch": "default"}, |
|
1188 | 1188 | "manifest": "4e8d705b1e53e3f9375e0e60dc7b525d8211fe55", |
|
1189 | 1189 | "modified": [], |
|
1190 | 1190 | "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965", |
|
1191 | 1191 | "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"], |
|
1192 | 1192 | "phase": "draft", |
|
1193 | 1193 | "removed": [], |
|
1194 | 1194 | "rev": 1, |
|
1195 | 1195 | "tags": [], |
|
1196 | 1196 | "user": "A. N. Other <other@place>" |
|
1197 | 1197 | }, |
|
1198 | 1198 | { |
|
1199 | 1199 | "added": ["a"], |
|
1200 | 1200 | "bookmarks": [], |
|
1201 | 1201 | "branch": "default", |
|
1202 | 1202 | "date": [1000000, 0], |
|
1203 | 1203 | "desc": "line 1\nline 2", |
|
1204 | 1204 | "extra": {"branch": "default"}, |
|
1205 | 1205 | "manifest": "a0c8bcbbb45c63b90b70ad007bf38961f64f2af0", |
|
1206 | 1206 | "modified": [], |
|
1207 | 1207 | "node": "1e4e1b8f71e05681d422154f5421e385fec3454f", |
|
1208 | 1208 | "parents": ["0000000000000000000000000000000000000000"], |
|
1209 | 1209 | "phase": "draft", |
|
1210 | 1210 | "removed": [], |
|
1211 | 1211 | "rev": 0, |
|
1212 | 1212 | "tags": [], |
|
1213 | 1213 | "user": "User Name <user@hostname>" |
|
1214 | 1214 | } |
|
1215 | 1215 | ] |
|
1216 | 1216 | |
|
1217 | 1217 | Error if style not readable: |
|
1218 | 1218 | |
|
1219 | 1219 | #if unix-permissions no-root |
|
1220 | 1220 | $ touch q |
|
1221 | 1221 | $ chmod 0 q |
|
1222 | 1222 | $ hg log --style ./q |
|
1223 | 1223 | abort: Permission denied: ./q |
|
1224 | 1224 | [255] |
|
1225 | 1225 | #endif |
|
1226 | 1226 | |
|
1227 | 1227 | Error if no style: |
|
1228 | 1228 | |
|
1229 | 1229 | $ hg log --style notexist |
|
1230 | 1230 | abort: style 'notexist' not found |
|
1231 | 1231 | (available styles: bisect, changelog, compact, default, phases, show, status, xml) |
|
1232 | 1232 | [255] |
|
1233 | 1233 | |
|
1234 | 1234 | $ hg log -T list |
|
1235 | 1235 | available styles: bisect, changelog, compact, default, phases, show, status, xml |
|
1236 | 1236 | abort: specify a template |
|
1237 | 1237 | [255] |
|
1238 | 1238 | |
|
1239 | 1239 | Error if style missing key: |
|
1240 | 1240 | |
|
1241 | 1241 | $ echo 'q = q' > t |
|
1242 | 1242 | $ hg log --style ./t |
|
1243 | 1243 | abort: "changeset" not in template map |
|
1244 | 1244 | [255] |
|
1245 | 1245 | |
|
1246 | 1246 | Error if style missing value: |
|
1247 | 1247 | |
|
1248 | 1248 | $ echo 'changeset =' > t |
|
1249 | 1249 | $ hg log --style t |
|
1250 | 1250 | hg: parse error at t:1: missing value |
|
1251 | 1251 | [255] |
|
1252 | 1252 | |
|
1253 | 1253 | Error if include fails: |
|
1254 | 1254 | |
|
1255 | 1255 | $ echo 'changeset = q' >> t |
|
1256 | 1256 | #if unix-permissions no-root |
|
1257 | 1257 | $ hg log --style ./t |
|
1258 | 1258 | abort: template file ./q: Permission denied |
|
1259 | 1259 | [255] |
|
1260 | 1260 | $ rm -f q |
|
1261 | 1261 | #endif |
|
1262 | 1262 | |
|
1263 | 1263 | Include works: |
|
1264 | 1264 | |
|
1265 | 1265 | $ echo '{rev}' > q |
|
1266 | 1266 | $ hg log --style ./t |
|
1267 | 1267 | 8 |
|
1268 | 1268 | 7 |
|
1269 | 1269 | 6 |
|
1270 | 1270 | 5 |
|
1271 | 1271 | 4 |
|
1272 | 1272 | 3 |
|
1273 | 1273 | 2 |
|
1274 | 1274 | 1 |
|
1275 | 1275 | 0 |
|
1276 | 1276 | |
|
1277 | 1277 | Check that recursive reference does not fall into RuntimeError (issue4758): |
|
1278 | 1278 | |
|
1279 | 1279 | common mistake: |
|
1280 | 1280 | |
|
1281 | 1281 | $ cat << EOF > issue4758 |
|
1282 | 1282 | > changeset = '{changeset}\n' |
|
1283 | 1283 | > EOF |
|
1284 | 1284 | $ hg log --style ./issue4758 |
|
1285 | 1285 | abort: recursive reference 'changeset' in template |
|
1286 | 1286 | [255] |
|
1287 | 1287 | |
|
1288 | 1288 | circular reference: |
|
1289 | 1289 | |
|
1290 | 1290 | $ cat << EOF > issue4758 |
|
1291 | 1291 | > changeset = '{foo}' |
|
1292 | 1292 | > foo = '{changeset}' |
|
1293 | 1293 | > EOF |
|
1294 | 1294 | $ hg log --style ./issue4758 |
|
1295 | 1295 | abort: recursive reference 'foo' in template |
|
1296 | 1296 | [255] |
|
1297 | 1297 | |
|
1298 | 1298 | buildmap() -> gettemplate(), where no thunk was made: |
|
1299 | 1299 | |
|
1300 | 1300 | $ cat << EOF > issue4758 |
|
1301 | 1301 | > changeset = '{files % changeset}\n' |
|
1302 | 1302 | > EOF |
|
1303 | 1303 | $ hg log --style ./issue4758 |
|
1304 | 1304 | abort: recursive reference 'changeset' in template |
|
1305 | 1305 | [255] |
|
1306 | 1306 | |
|
1307 | 1307 | not a recursion if a keyword of the same name exists: |
|
1308 | 1308 | |
|
1309 | 1309 | $ cat << EOF > issue4758 |
|
1310 | 1310 | > changeset = '{tags % rev}' |
|
1311 | 1311 | > rev = '{rev} {tag}\n' |
|
1312 | 1312 | > EOF |
|
1313 | 1313 | $ hg log --style ./issue4758 -r tip |
|
1314 | 1314 | 8 tip |
|
1315 | 1315 | |
|
1316 | 1316 | Check that {phase} works correctly on parents: |
|
1317 | 1317 | |
|
1318 | 1318 | $ cat << EOF > parentphase |
|
1319 | 1319 | > changeset_debug = '{rev} ({phase}):{parents}\n' |
|
1320 | 1320 | > parent = ' {rev} ({phase})' |
|
1321 | 1321 | > EOF |
|
1322 | 1322 | $ hg phase -r 5 --public |
|
1323 | 1323 | $ hg phase -r 7 --secret --force |
|
1324 | 1324 | $ hg log --debug -G --style ./parentphase |
|
1325 | 1325 | @ 8 (secret): 7 (secret) -1 (public) |
|
1326 | 1326 | | |
|
1327 | 1327 | o 7 (secret): -1 (public) -1 (public) |
|
1328 | 1328 | |
|
1329 | 1329 | o 6 (draft): 5 (public) 4 (draft) |
|
1330 | 1330 | |\ |
|
1331 | 1331 | | o 5 (public): 3 (public) -1 (public) |
|
1332 | 1332 | | | |
|
1333 | 1333 | o | 4 (draft): 3 (public) -1 (public) |
|
1334 | 1334 | |/ |
|
1335 | 1335 | o 3 (public): 2 (public) -1 (public) |
|
1336 | 1336 | | |
|
1337 | 1337 | o 2 (public): 1 (public) -1 (public) |
|
1338 | 1338 | | |
|
1339 | 1339 | o 1 (public): 0 (public) -1 (public) |
|
1340 | 1340 | | |
|
1341 | 1341 | o 0 (public): -1 (public) -1 (public) |
|
1342 | 1342 | |
|
1343 | 1343 | |
|
1344 | 1344 | Missing non-standard names give no error (backward compatibility): |
|
1345 | 1345 | |
|
1346 | 1346 | $ echo "changeset = '{c}'" > t |
|
1347 | 1347 | $ hg log --style ./t |
|
1348 | 1348 | |
|
1349 | 1349 | Defining non-standard name works: |
|
1350 | 1350 | |
|
1351 | 1351 | $ cat <<EOF > t |
|
1352 | 1352 | > changeset = '{c}' |
|
1353 | 1353 | > c = q |
|
1354 | 1354 | > EOF |
|
1355 | 1355 | $ hg log --style ./t |
|
1356 | 1356 | 8 |
|
1357 | 1357 | 7 |
|
1358 | 1358 | 6 |
|
1359 | 1359 | 5 |
|
1360 | 1360 | 4 |
|
1361 | 1361 | 3 |
|
1362 | 1362 | 2 |
|
1363 | 1363 | 1 |
|
1364 | 1364 | 0 |
|
1365 | 1365 | |
|
1366 | 1366 | ui.style works: |
|
1367 | 1367 | |
|
1368 | 1368 | $ echo '[ui]' > .hg/hgrc |
|
1369 | 1369 | $ echo 'style = t' >> .hg/hgrc |
|
1370 | 1370 | $ hg log |
|
1371 | 1371 | 8 |
|
1372 | 1372 | 7 |
|
1373 | 1373 | 6 |
|
1374 | 1374 | 5 |
|
1375 | 1375 | 4 |
|
1376 | 1376 | 3 |
|
1377 | 1377 | 2 |
|
1378 | 1378 | 1 |
|
1379 | 1379 | 0 |
|
1380 | 1380 | |
|
1381 | 1381 | |
|
1382 | 1382 | Issue338: |
|
1383 | 1383 | |
|
1384 | 1384 | $ hg log --style=changelog > changelog |
|
1385 | 1385 | |
|
1386 | 1386 | $ cat changelog |
|
1387 | 1387 | 2020-01-01 test <test> |
|
1388 | 1388 | |
|
1389 | 1389 | * fourth, second, third: |
|
1390 | 1390 | third |
|
1391 | 1391 | [95c24699272e] [tip] |
|
1392 | 1392 | |
|
1393 | 1393 | 1970-01-12 User Name <user@hostname> |
|
1394 | 1394 | |
|
1395 | 1395 | * second: |
|
1396 | 1396 | second |
|
1397 | 1397 | [29114dbae42b] |
|
1398 | 1398 | |
|
1399 | 1399 | 1970-01-18 person <person> |
|
1400 | 1400 | |
|
1401 | 1401 | * merge |
|
1402 | 1402 | [d41e714fe50d] |
|
1403 | 1403 | |
|
1404 | 1404 | * d: |
|
1405 | 1405 | new head |
|
1406 | 1406 | [13207e5a10d9] |
|
1407 | 1407 | |
|
1408 | 1408 | 1970-01-17 person <person> |
|
1409 | 1409 | |
|
1410 | 1410 | * new branch |
|
1411 | 1411 | [bbe44766e73d] <foo> |
|
1412 | 1412 | |
|
1413 | 1413 | 1970-01-16 person <person> |
|
1414 | 1414 | |
|
1415 | 1415 | * c: |
|
1416 | 1416 | no user, no domain |
|
1417 | 1417 | [10e46f2dcbf4] |
|
1418 | 1418 | |
|
1419 | 1419 | 1970-01-14 other <other@place> |
|
1420 | 1420 | |
|
1421 | 1421 | * c: |
|
1422 | 1422 | no person |
|
1423 | 1423 | [97054abb4ab8] |
|
1424 | 1424 | |
|
1425 | 1425 | 1970-01-13 A. N. Other <other@place> |
|
1426 | 1426 | |
|
1427 | 1427 | * b: |
|
1428 | 1428 | other 1 other 2 |
|
1429 | 1429 | |
|
1430 | 1430 | other 3 |
|
1431 | 1431 | [b608e9d1a3f0] |
|
1432 | 1432 | |
|
1433 | 1433 | 1970-01-12 User Name <user@hostname> |
|
1434 | 1434 | |
|
1435 | 1435 | * a: |
|
1436 | 1436 | line 1 line 2 |
|
1437 | 1437 | [1e4e1b8f71e0] |
|
1438 | 1438 | |
|
1439 | 1439 | |
|
1440 | 1440 | Issue2130: xml output for 'hg heads' is malformed |
|
1441 | 1441 | |
|
1442 | 1442 | $ hg heads --style changelog |
|
1443 | 1443 | 2020-01-01 test <test> |
|
1444 | 1444 | |
|
1445 | 1445 | * fourth, second, third: |
|
1446 | 1446 | third |
|
1447 | 1447 | [95c24699272e] [tip] |
|
1448 | 1448 | |
|
1449 | 1449 | 1970-01-18 person <person> |
|
1450 | 1450 | |
|
1451 | 1451 | * merge |
|
1452 | 1452 | [d41e714fe50d] |
|
1453 | 1453 | |
|
1454 | 1454 | 1970-01-17 person <person> |
|
1455 | 1455 | |
|
1456 | 1456 | * new branch |
|
1457 | 1457 | [bbe44766e73d] <foo> |
|
1458 | 1458 | |
|
1459 | 1459 | |
|
1460 | 1460 | Keys work: |
|
1461 | 1461 | |
|
1462 | 1462 | $ for key in author branch branches date desc file_adds file_dels file_mods \ |
|
1463 | 1463 | > file_copies file_copies_switch files \ |
|
1464 | 1464 | > manifest node parents rev tags diffstat extras \ |
|
1465 | 1465 | > p1rev p2rev p1node p2node; do |
|
1466 | 1466 | > for mode in '' --verbose --debug; do |
|
1467 | 1467 | > hg log $mode --template "$key$mode: {$key}\n" |
|
1468 | 1468 | > done |
|
1469 | 1469 | > done |
|
1470 | 1470 | author: test |
|
1471 | 1471 | author: User Name <user@hostname> |
|
1472 | 1472 | author: person |
|
1473 | 1473 | author: person |
|
1474 | 1474 | author: person |
|
1475 | 1475 | author: person |
|
1476 | 1476 | author: other@place |
|
1477 | 1477 | author: A. N. Other <other@place> |
|
1478 | 1478 | author: User Name <user@hostname> |
|
1479 | 1479 | author--verbose: test |
|
1480 | 1480 | author--verbose: User Name <user@hostname> |
|
1481 | 1481 | author--verbose: person |
|
1482 | 1482 | author--verbose: person |
|
1483 | 1483 | author--verbose: person |
|
1484 | 1484 | author--verbose: person |
|
1485 | 1485 | author--verbose: other@place |
|
1486 | 1486 | author--verbose: A. N. Other <other@place> |
|
1487 | 1487 | author--verbose: User Name <user@hostname> |
|
1488 | 1488 | author--debug: test |
|
1489 | 1489 | author--debug: User Name <user@hostname> |
|
1490 | 1490 | author--debug: person |
|
1491 | 1491 | author--debug: person |
|
1492 | 1492 | author--debug: person |
|
1493 | 1493 | author--debug: person |
|
1494 | 1494 | author--debug: other@place |
|
1495 | 1495 | author--debug: A. N. Other <other@place> |
|
1496 | 1496 | author--debug: User Name <user@hostname> |
|
1497 | 1497 | branch: default |
|
1498 | 1498 | branch: default |
|
1499 | 1499 | branch: default |
|
1500 | 1500 | branch: default |
|
1501 | 1501 | branch: foo |
|
1502 | 1502 | branch: default |
|
1503 | 1503 | branch: default |
|
1504 | 1504 | branch: default |
|
1505 | 1505 | branch: default |
|
1506 | 1506 | branch--verbose: default |
|
1507 | 1507 | branch--verbose: default |
|
1508 | 1508 | branch--verbose: default |
|
1509 | 1509 | branch--verbose: default |
|
1510 | 1510 | branch--verbose: foo |
|
1511 | 1511 | branch--verbose: default |
|
1512 | 1512 | branch--verbose: default |
|
1513 | 1513 | branch--verbose: default |
|
1514 | 1514 | branch--verbose: default |
|
1515 | 1515 | branch--debug: default |
|
1516 | 1516 | branch--debug: default |
|
1517 | 1517 | branch--debug: default |
|
1518 | 1518 | branch--debug: default |
|
1519 | 1519 | branch--debug: foo |
|
1520 | 1520 | branch--debug: default |
|
1521 | 1521 | branch--debug: default |
|
1522 | 1522 | branch--debug: default |
|
1523 | 1523 | branch--debug: default |
|
1524 | 1524 | branches: |
|
1525 | 1525 | branches: |
|
1526 | 1526 | branches: |
|
1527 | 1527 | branches: |
|
1528 | 1528 | branches: foo |
|
1529 | 1529 | branches: |
|
1530 | 1530 | branches: |
|
1531 | 1531 | branches: |
|
1532 | 1532 | branches: |
|
1533 | 1533 | branches--verbose: |
|
1534 | 1534 | branches--verbose: |
|
1535 | 1535 | branches--verbose: |
|
1536 | 1536 | branches--verbose: |
|
1537 | 1537 | branches--verbose: foo |
|
1538 | 1538 | branches--verbose: |
|
1539 | 1539 | branches--verbose: |
|
1540 | 1540 | branches--verbose: |
|
1541 | 1541 | branches--verbose: |
|
1542 | 1542 | branches--debug: |
|
1543 | 1543 | branches--debug: |
|
1544 | 1544 | branches--debug: |
|
1545 | 1545 | branches--debug: |
|
1546 | 1546 | branches--debug: foo |
|
1547 | 1547 | branches--debug: |
|
1548 | 1548 | branches--debug: |
|
1549 | 1549 | branches--debug: |
|
1550 | 1550 | branches--debug: |
|
1551 | 1551 | date: 1577872860.00 |
|
1552 | 1552 | date: 1000000.00 |
|
1553 | 1553 | date: 1500001.00 |
|
1554 | 1554 | date: 1500000.00 |
|
1555 | 1555 | date: 1400000.00 |
|
1556 | 1556 | date: 1300000.00 |
|
1557 | 1557 | date: 1200000.00 |
|
1558 | 1558 | date: 1100000.00 |
|
1559 | 1559 | date: 1000000.00 |
|
1560 | 1560 | date--verbose: 1577872860.00 |
|
1561 | 1561 | date--verbose: 1000000.00 |
|
1562 | 1562 | date--verbose: 1500001.00 |
|
1563 | 1563 | date--verbose: 1500000.00 |
|
1564 | 1564 | date--verbose: 1400000.00 |
|
1565 | 1565 | date--verbose: 1300000.00 |
|
1566 | 1566 | date--verbose: 1200000.00 |
|
1567 | 1567 | date--verbose: 1100000.00 |
|
1568 | 1568 | date--verbose: 1000000.00 |
|
1569 | 1569 | date--debug: 1577872860.00 |
|
1570 | 1570 | date--debug: 1000000.00 |
|
1571 | 1571 | date--debug: 1500001.00 |
|
1572 | 1572 | date--debug: 1500000.00 |
|
1573 | 1573 | date--debug: 1400000.00 |
|
1574 | 1574 | date--debug: 1300000.00 |
|
1575 | 1575 | date--debug: 1200000.00 |
|
1576 | 1576 | date--debug: 1100000.00 |
|
1577 | 1577 | date--debug: 1000000.00 |
|
1578 | 1578 | desc: third |
|
1579 | 1579 | desc: second |
|
1580 | 1580 | desc: merge |
|
1581 | 1581 | desc: new head |
|
1582 | 1582 | desc: new branch |
|
1583 | 1583 | desc: no user, no domain |
|
1584 | 1584 | desc: no person |
|
1585 | 1585 | desc: other 1 |
|
1586 | 1586 | other 2 |
|
1587 | 1587 | |
|
1588 | 1588 | other 3 |
|
1589 | 1589 | desc: line 1 |
|
1590 | 1590 | line 2 |
|
1591 | 1591 | desc--verbose: third |
|
1592 | 1592 | desc--verbose: second |
|
1593 | 1593 | desc--verbose: merge |
|
1594 | 1594 | desc--verbose: new head |
|
1595 | 1595 | desc--verbose: new branch |
|
1596 | 1596 | desc--verbose: no user, no domain |
|
1597 | 1597 | desc--verbose: no person |
|
1598 | 1598 | desc--verbose: other 1 |
|
1599 | 1599 | other 2 |
|
1600 | 1600 | |
|
1601 | 1601 | other 3 |
|
1602 | 1602 | desc--verbose: line 1 |
|
1603 | 1603 | line 2 |
|
1604 | 1604 | desc--debug: third |
|
1605 | 1605 | desc--debug: second |
|
1606 | 1606 | desc--debug: merge |
|
1607 | 1607 | desc--debug: new head |
|
1608 | 1608 | desc--debug: new branch |
|
1609 | 1609 | desc--debug: no user, no domain |
|
1610 | 1610 | desc--debug: no person |
|
1611 | 1611 | desc--debug: other 1 |
|
1612 | 1612 | other 2 |
|
1613 | 1613 | |
|
1614 | 1614 | other 3 |
|
1615 | 1615 | desc--debug: line 1 |
|
1616 | 1616 | line 2 |
|
1617 | 1617 | file_adds: fourth third |
|
1618 | 1618 | file_adds: second |
|
1619 | 1619 | file_adds: |
|
1620 | 1620 | file_adds: d |
|
1621 | 1621 | file_adds: |
|
1622 | 1622 | file_adds: |
|
1623 | 1623 | file_adds: c |
|
1624 | 1624 | file_adds: b |
|
1625 | 1625 | file_adds: a |
|
1626 | 1626 | file_adds--verbose: fourth third |
|
1627 | 1627 | file_adds--verbose: second |
|
1628 | 1628 | file_adds--verbose: |
|
1629 | 1629 | file_adds--verbose: d |
|
1630 | 1630 | file_adds--verbose: |
|
1631 | 1631 | file_adds--verbose: |
|
1632 | 1632 | file_adds--verbose: c |
|
1633 | 1633 | file_adds--verbose: b |
|
1634 | 1634 | file_adds--verbose: a |
|
1635 | 1635 | file_adds--debug: fourth third |
|
1636 | 1636 | file_adds--debug: second |
|
1637 | 1637 | file_adds--debug: |
|
1638 | 1638 | file_adds--debug: d |
|
1639 | 1639 | file_adds--debug: |
|
1640 | 1640 | file_adds--debug: |
|
1641 | 1641 | file_adds--debug: c |
|
1642 | 1642 | file_adds--debug: b |
|
1643 | 1643 | file_adds--debug: a |
|
1644 | 1644 | file_dels: second |
|
1645 | 1645 | file_dels: |
|
1646 | 1646 | file_dels: |
|
1647 | 1647 | file_dels: |
|
1648 | 1648 | file_dels: |
|
1649 | 1649 | file_dels: |
|
1650 | 1650 | file_dels: |
|
1651 | 1651 | file_dels: |
|
1652 | 1652 | file_dels: |
|
1653 | 1653 | file_dels--verbose: second |
|
1654 | 1654 | file_dels--verbose: |
|
1655 | 1655 | file_dels--verbose: |
|
1656 | 1656 | file_dels--verbose: |
|
1657 | 1657 | file_dels--verbose: |
|
1658 | 1658 | file_dels--verbose: |
|
1659 | 1659 | file_dels--verbose: |
|
1660 | 1660 | file_dels--verbose: |
|
1661 | 1661 | file_dels--verbose: |
|
1662 | 1662 | file_dels--debug: second |
|
1663 | 1663 | file_dels--debug: |
|
1664 | 1664 | file_dels--debug: |
|
1665 | 1665 | file_dels--debug: |
|
1666 | 1666 | file_dels--debug: |
|
1667 | 1667 | file_dels--debug: |
|
1668 | 1668 | file_dels--debug: |
|
1669 | 1669 | file_dels--debug: |
|
1670 | 1670 | file_dels--debug: |
|
1671 | 1671 | file_mods: |
|
1672 | 1672 | file_mods: |
|
1673 | 1673 | file_mods: |
|
1674 | 1674 | file_mods: |
|
1675 | 1675 | file_mods: |
|
1676 | 1676 | file_mods: c |
|
1677 | 1677 | file_mods: |
|
1678 | 1678 | file_mods: |
|
1679 | 1679 | file_mods: |
|
1680 | 1680 | file_mods--verbose: |
|
1681 | 1681 | file_mods--verbose: |
|
1682 | 1682 | file_mods--verbose: |
|
1683 | 1683 | file_mods--verbose: |
|
1684 | 1684 | file_mods--verbose: |
|
1685 | 1685 | file_mods--verbose: c |
|
1686 | 1686 | file_mods--verbose: |
|
1687 | 1687 | file_mods--verbose: |
|
1688 | 1688 | file_mods--verbose: |
|
1689 | 1689 | file_mods--debug: |
|
1690 | 1690 | file_mods--debug: |
|
1691 | 1691 | file_mods--debug: |
|
1692 | 1692 | file_mods--debug: |
|
1693 | 1693 | file_mods--debug: |
|
1694 | 1694 | file_mods--debug: c |
|
1695 | 1695 | file_mods--debug: |
|
1696 | 1696 | file_mods--debug: |
|
1697 | 1697 | file_mods--debug: |
|
1698 | 1698 | file_copies: fourth (second) |
|
1699 | 1699 | file_copies: |
|
1700 | 1700 | file_copies: |
|
1701 | 1701 | file_copies: |
|
1702 | 1702 | file_copies: |
|
1703 | 1703 | file_copies: |
|
1704 | 1704 | file_copies: |
|
1705 | 1705 | file_copies: |
|
1706 | 1706 | file_copies: |
|
1707 | 1707 | file_copies--verbose: fourth (second) |
|
1708 | 1708 | file_copies--verbose: |
|
1709 | 1709 | file_copies--verbose: |
|
1710 | 1710 | file_copies--verbose: |
|
1711 | 1711 | file_copies--verbose: |
|
1712 | 1712 | file_copies--verbose: |
|
1713 | 1713 | file_copies--verbose: |
|
1714 | 1714 | file_copies--verbose: |
|
1715 | 1715 | file_copies--verbose: |
|
1716 | 1716 | file_copies--debug: fourth (second) |
|
1717 | 1717 | file_copies--debug: |
|
1718 | 1718 | file_copies--debug: |
|
1719 | 1719 | file_copies--debug: |
|
1720 | 1720 | file_copies--debug: |
|
1721 | 1721 | file_copies--debug: |
|
1722 | 1722 | file_copies--debug: |
|
1723 | 1723 | file_copies--debug: |
|
1724 | 1724 | file_copies--debug: |
|
1725 | 1725 | file_copies_switch: |
|
1726 | 1726 | file_copies_switch: |
|
1727 | 1727 | file_copies_switch: |
|
1728 | 1728 | file_copies_switch: |
|
1729 | 1729 | file_copies_switch: |
|
1730 | 1730 | file_copies_switch: |
|
1731 | 1731 | file_copies_switch: |
|
1732 | 1732 | file_copies_switch: |
|
1733 | 1733 | file_copies_switch: |
|
1734 | 1734 | file_copies_switch--verbose: |
|
1735 | 1735 | file_copies_switch--verbose: |
|
1736 | 1736 | file_copies_switch--verbose: |
|
1737 | 1737 | file_copies_switch--verbose: |
|
1738 | 1738 | file_copies_switch--verbose: |
|
1739 | 1739 | file_copies_switch--verbose: |
|
1740 | 1740 | file_copies_switch--verbose: |
|
1741 | 1741 | file_copies_switch--verbose: |
|
1742 | 1742 | file_copies_switch--verbose: |
|
1743 | 1743 | file_copies_switch--debug: |
|
1744 | 1744 | file_copies_switch--debug: |
|
1745 | 1745 | file_copies_switch--debug: |
|
1746 | 1746 | file_copies_switch--debug: |
|
1747 | 1747 | file_copies_switch--debug: |
|
1748 | 1748 | file_copies_switch--debug: |
|
1749 | 1749 | file_copies_switch--debug: |
|
1750 | 1750 | file_copies_switch--debug: |
|
1751 | 1751 | file_copies_switch--debug: |
|
1752 | 1752 | files: fourth second third |
|
1753 | 1753 | files: second |
|
1754 | 1754 | files: |
|
1755 | 1755 | files: d |
|
1756 | 1756 | files: |
|
1757 | 1757 | files: c |
|
1758 | 1758 | files: c |
|
1759 | 1759 | files: b |
|
1760 | 1760 | files: a |
|
1761 | 1761 | files--verbose: fourth second third |
|
1762 | 1762 | files--verbose: second |
|
1763 | 1763 | files--verbose: |
|
1764 | 1764 | files--verbose: d |
|
1765 | 1765 | files--verbose: |
|
1766 | 1766 | files--verbose: c |
|
1767 | 1767 | files--verbose: c |
|
1768 | 1768 | files--verbose: b |
|
1769 | 1769 | files--verbose: a |
|
1770 | 1770 | files--debug: fourth second third |
|
1771 | 1771 | files--debug: second |
|
1772 | 1772 | files--debug: |
|
1773 | 1773 | files--debug: d |
|
1774 | 1774 | files--debug: |
|
1775 | 1775 | files--debug: c |
|
1776 | 1776 | files--debug: c |
|
1777 | 1777 | files--debug: b |
|
1778 | 1778 | files--debug: a |
|
1779 | 1779 | manifest: 6:94961b75a2da |
|
1780 | 1780 | manifest: 5:f2dbc354b94e |
|
1781 | 1781 | manifest: 4:4dc3def4f9b4 |
|
1782 | 1782 | manifest: 4:4dc3def4f9b4 |
|
1783 | 1783 | manifest: 3:cb5a1327723b |
|
1784 | 1784 | manifest: 3:cb5a1327723b |
|
1785 | 1785 | manifest: 2:6e0e82995c35 |
|
1786 | 1786 | manifest: 1:4e8d705b1e53 |
|
1787 | 1787 | manifest: 0:a0c8bcbbb45c |
|
1788 | 1788 | manifest--verbose: 6:94961b75a2da |
|
1789 | 1789 | manifest--verbose: 5:f2dbc354b94e |
|
1790 | 1790 | manifest--verbose: 4:4dc3def4f9b4 |
|
1791 | 1791 | manifest--verbose: 4:4dc3def4f9b4 |
|
1792 | 1792 | manifest--verbose: 3:cb5a1327723b |
|
1793 | 1793 | manifest--verbose: 3:cb5a1327723b |
|
1794 | 1794 | manifest--verbose: 2:6e0e82995c35 |
|
1795 | 1795 | manifest--verbose: 1:4e8d705b1e53 |
|
1796 | 1796 | manifest--verbose: 0:a0c8bcbbb45c |
|
1797 | 1797 | manifest--debug: 6:94961b75a2da554b4df6fb599e5bfc7d48de0c64 |
|
1798 | 1798 | manifest--debug: 5:f2dbc354b94e5ec0b4f10680ee0cee816101d0bf |
|
1799 | 1799 | manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216 |
|
1800 | 1800 | manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216 |
|
1801 | 1801 | manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc |
|
1802 | 1802 | manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc |
|
1803 | 1803 | manifest--debug: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1 |
|
1804 | 1804 | manifest--debug: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55 |
|
1805 | 1805 | manifest--debug: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 |
|
1806 | 1806 | node: 95c24699272ef57d062b8bccc32c878bf841784a |
|
1807 | 1807 | node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
1808 | 1808 | node: d41e714fe50d9e4a5f11b4d595d543481b5f980b |
|
1809 | 1809 | node: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
1810 | 1810 | node: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
1811 | 1811 | node: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
1812 | 1812 | node: 97054abb4ab824450e9164180baf491ae0078465 |
|
1813 | 1813 | node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
1814 | 1814 | node: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
1815 | 1815 | node--verbose: 95c24699272ef57d062b8bccc32c878bf841784a |
|
1816 | 1816 | node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
1817 | 1817 | node--verbose: d41e714fe50d9e4a5f11b4d595d543481b5f980b |
|
1818 | 1818 | node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
1819 | 1819 | node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
1820 | 1820 | node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
1821 | 1821 | node--verbose: 97054abb4ab824450e9164180baf491ae0078465 |
|
1822 | 1822 | node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
1823 | 1823 | node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
1824 | 1824 | node--debug: 95c24699272ef57d062b8bccc32c878bf841784a |
|
1825 | 1825 | node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
1826 | 1826 | node--debug: d41e714fe50d9e4a5f11b4d595d543481b5f980b |
|
1827 | 1827 | node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
1828 | 1828 | node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
1829 | 1829 | node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
1830 | 1830 | node--debug: 97054abb4ab824450e9164180baf491ae0078465 |
|
1831 | 1831 | node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
1832 | 1832 | node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
1833 | 1833 | parents: |
|
1834 | 1834 | parents: -1:000000000000 |
|
1835 | 1835 | parents: 5:13207e5a10d9 4:bbe44766e73d |
|
1836 | 1836 | parents: 3:10e46f2dcbf4 |
|
1837 | 1837 | parents: |
|
1838 | 1838 | parents: |
|
1839 | 1839 | parents: |
|
1840 | 1840 | parents: |
|
1841 | 1841 | parents: |
|
1842 | 1842 | parents--verbose: |
|
1843 | 1843 | parents--verbose: -1:000000000000 |
|
1844 | 1844 | parents--verbose: 5:13207e5a10d9 4:bbe44766e73d |
|
1845 | 1845 | parents--verbose: 3:10e46f2dcbf4 |
|
1846 | 1846 | parents--verbose: |
|
1847 | 1847 | parents--verbose: |
|
1848 | 1848 | parents--verbose: |
|
1849 | 1849 | parents--verbose: |
|
1850 | 1850 | parents--verbose: |
|
1851 | 1851 | parents--debug: 7:29114dbae42b9f078cf2714dbe3a86bba8ec7453 -1:0000000000000000000000000000000000000000 |
|
1852 | 1852 | parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000 |
|
1853 | 1853 | parents--debug: 5:13207e5a10d9fd28ec424934298e176197f2c67f 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
1854 | 1854 | parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000 |
|
1855 | 1855 | parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000 |
|
1856 | 1856 | parents--debug: 2:97054abb4ab824450e9164180baf491ae0078465 -1:0000000000000000000000000000000000000000 |
|
1857 | 1857 | parents--debug: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965 -1:0000000000000000000000000000000000000000 |
|
1858 | 1858 | parents--debug: 0:1e4e1b8f71e05681d422154f5421e385fec3454f -1:0000000000000000000000000000000000000000 |
|
1859 | 1859 | parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000 |
|
1860 | 1860 | rev: 8 |
|
1861 | 1861 | rev: 7 |
|
1862 | 1862 | rev: 6 |
|
1863 | 1863 | rev: 5 |
|
1864 | 1864 | rev: 4 |
|
1865 | 1865 | rev: 3 |
|
1866 | 1866 | rev: 2 |
|
1867 | 1867 | rev: 1 |
|
1868 | 1868 | rev: 0 |
|
1869 | 1869 | rev--verbose: 8 |
|
1870 | 1870 | rev--verbose: 7 |
|
1871 | 1871 | rev--verbose: 6 |
|
1872 | 1872 | rev--verbose: 5 |
|
1873 | 1873 | rev--verbose: 4 |
|
1874 | 1874 | rev--verbose: 3 |
|
1875 | 1875 | rev--verbose: 2 |
|
1876 | 1876 | rev--verbose: 1 |
|
1877 | 1877 | rev--verbose: 0 |
|
1878 | 1878 | rev--debug: 8 |
|
1879 | 1879 | rev--debug: 7 |
|
1880 | 1880 | rev--debug: 6 |
|
1881 | 1881 | rev--debug: 5 |
|
1882 | 1882 | rev--debug: 4 |
|
1883 | 1883 | rev--debug: 3 |
|
1884 | 1884 | rev--debug: 2 |
|
1885 | 1885 | rev--debug: 1 |
|
1886 | 1886 | rev--debug: 0 |
|
1887 | 1887 | tags: tip |
|
1888 | 1888 | tags: |
|
1889 | 1889 | tags: |
|
1890 | 1890 | tags: |
|
1891 | 1891 | tags: |
|
1892 | 1892 | tags: |
|
1893 | 1893 | tags: |
|
1894 | 1894 | tags: |
|
1895 | 1895 | tags: |
|
1896 | 1896 | tags--verbose: tip |
|
1897 | 1897 | tags--verbose: |
|
1898 | 1898 | tags--verbose: |
|
1899 | 1899 | tags--verbose: |
|
1900 | 1900 | tags--verbose: |
|
1901 | 1901 | tags--verbose: |
|
1902 | 1902 | tags--verbose: |
|
1903 | 1903 | tags--verbose: |
|
1904 | 1904 | tags--verbose: |
|
1905 | 1905 | tags--debug: tip |
|
1906 | 1906 | tags--debug: |
|
1907 | 1907 | tags--debug: |
|
1908 | 1908 | tags--debug: |
|
1909 | 1909 | tags--debug: |
|
1910 | 1910 | tags--debug: |
|
1911 | 1911 | tags--debug: |
|
1912 | 1912 | tags--debug: |
|
1913 | 1913 | tags--debug: |
|
1914 | 1914 | diffstat: 3: +2/-1 |
|
1915 | 1915 | diffstat: 1: +1/-0 |
|
1916 | 1916 | diffstat: 0: +0/-0 |
|
1917 | 1917 | diffstat: 1: +1/-0 |
|
1918 | 1918 | diffstat: 0: +0/-0 |
|
1919 | 1919 | diffstat: 1: +1/-0 |
|
1920 | 1920 | diffstat: 1: +4/-0 |
|
1921 | 1921 | diffstat: 1: +2/-0 |
|
1922 | 1922 | diffstat: 1: +1/-0 |
|
1923 | 1923 | diffstat--verbose: 3: +2/-1 |
|
1924 | 1924 | diffstat--verbose: 1: +1/-0 |
|
1925 | 1925 | diffstat--verbose: 0: +0/-0 |
|
1926 | 1926 | diffstat--verbose: 1: +1/-0 |
|
1927 | 1927 | diffstat--verbose: 0: +0/-0 |
|
1928 | 1928 | diffstat--verbose: 1: +1/-0 |
|
1929 | 1929 | diffstat--verbose: 1: +4/-0 |
|
1930 | 1930 | diffstat--verbose: 1: +2/-0 |
|
1931 | 1931 | diffstat--verbose: 1: +1/-0 |
|
1932 | 1932 | diffstat--debug: 3: +2/-1 |
|
1933 | 1933 | diffstat--debug: 1: +1/-0 |
|
1934 | 1934 | diffstat--debug: 0: +0/-0 |
|
1935 | 1935 | diffstat--debug: 1: +1/-0 |
|
1936 | 1936 | diffstat--debug: 0: +0/-0 |
|
1937 | 1937 | diffstat--debug: 1: +1/-0 |
|
1938 | 1938 | diffstat--debug: 1: +4/-0 |
|
1939 | 1939 | diffstat--debug: 1: +2/-0 |
|
1940 | 1940 | diffstat--debug: 1: +1/-0 |
|
1941 | 1941 | extras: branch=default |
|
1942 | 1942 | extras: branch=default |
|
1943 | 1943 | extras: branch=default |
|
1944 | 1944 | extras: branch=default |
|
1945 | 1945 | extras: branch=foo |
|
1946 | 1946 | extras: branch=default |
|
1947 | 1947 | extras: branch=default |
|
1948 | 1948 | extras: branch=default |
|
1949 | 1949 | extras: branch=default |
|
1950 | 1950 | extras--verbose: branch=default |
|
1951 | 1951 | extras--verbose: branch=default |
|
1952 | 1952 | extras--verbose: branch=default |
|
1953 | 1953 | extras--verbose: branch=default |
|
1954 | 1954 | extras--verbose: branch=foo |
|
1955 | 1955 | extras--verbose: branch=default |
|
1956 | 1956 | extras--verbose: branch=default |
|
1957 | 1957 | extras--verbose: branch=default |
|
1958 | 1958 | extras--verbose: branch=default |
|
1959 | 1959 | extras--debug: branch=default |
|
1960 | 1960 | extras--debug: branch=default |
|
1961 | 1961 | extras--debug: branch=default |
|
1962 | 1962 | extras--debug: branch=default |
|
1963 | 1963 | extras--debug: branch=foo |
|
1964 | 1964 | extras--debug: branch=default |
|
1965 | 1965 | extras--debug: branch=default |
|
1966 | 1966 | extras--debug: branch=default |
|
1967 | 1967 | extras--debug: branch=default |
|
1968 | 1968 | p1rev: 7 |
|
1969 | 1969 | p1rev: -1 |
|
1970 | 1970 | p1rev: 5 |
|
1971 | 1971 | p1rev: 3 |
|
1972 | 1972 | p1rev: 3 |
|
1973 | 1973 | p1rev: 2 |
|
1974 | 1974 | p1rev: 1 |
|
1975 | 1975 | p1rev: 0 |
|
1976 | 1976 | p1rev: -1 |
|
1977 | 1977 | p1rev--verbose: 7 |
|
1978 | 1978 | p1rev--verbose: -1 |
|
1979 | 1979 | p1rev--verbose: 5 |
|
1980 | 1980 | p1rev--verbose: 3 |
|
1981 | 1981 | p1rev--verbose: 3 |
|
1982 | 1982 | p1rev--verbose: 2 |
|
1983 | 1983 | p1rev--verbose: 1 |
|
1984 | 1984 | p1rev--verbose: 0 |
|
1985 | 1985 | p1rev--verbose: -1 |
|
1986 | 1986 | p1rev--debug: 7 |
|
1987 | 1987 | p1rev--debug: -1 |
|
1988 | 1988 | p1rev--debug: 5 |
|
1989 | 1989 | p1rev--debug: 3 |
|
1990 | 1990 | p1rev--debug: 3 |
|
1991 | 1991 | p1rev--debug: 2 |
|
1992 | 1992 | p1rev--debug: 1 |
|
1993 | 1993 | p1rev--debug: 0 |
|
1994 | 1994 | p1rev--debug: -1 |
|
1995 | 1995 | p2rev: -1 |
|
1996 | 1996 | p2rev: -1 |
|
1997 | 1997 | p2rev: 4 |
|
1998 | 1998 | p2rev: -1 |
|
1999 | 1999 | p2rev: -1 |
|
2000 | 2000 | p2rev: -1 |
|
2001 | 2001 | p2rev: -1 |
|
2002 | 2002 | p2rev: -1 |
|
2003 | 2003 | p2rev: -1 |
|
2004 | 2004 | p2rev--verbose: -1 |
|
2005 | 2005 | p2rev--verbose: -1 |
|
2006 | 2006 | p2rev--verbose: 4 |
|
2007 | 2007 | p2rev--verbose: -1 |
|
2008 | 2008 | p2rev--verbose: -1 |
|
2009 | 2009 | p2rev--verbose: -1 |
|
2010 | 2010 | p2rev--verbose: -1 |
|
2011 | 2011 | p2rev--verbose: -1 |
|
2012 | 2012 | p2rev--verbose: -1 |
|
2013 | 2013 | p2rev--debug: -1 |
|
2014 | 2014 | p2rev--debug: -1 |
|
2015 | 2015 | p2rev--debug: 4 |
|
2016 | 2016 | p2rev--debug: -1 |
|
2017 | 2017 | p2rev--debug: -1 |
|
2018 | 2018 | p2rev--debug: -1 |
|
2019 | 2019 | p2rev--debug: -1 |
|
2020 | 2020 | p2rev--debug: -1 |
|
2021 | 2021 | p2rev--debug: -1 |
|
2022 | 2022 | p1node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
2023 | 2023 | p1node: 0000000000000000000000000000000000000000 |
|
2024 | 2024 | p1node: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
2025 | 2025 | p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2026 | 2026 | p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2027 | 2027 | p1node: 97054abb4ab824450e9164180baf491ae0078465 |
|
2028 | 2028 | p1node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
2029 | 2029 | p1node: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
2030 | 2030 | p1node: 0000000000000000000000000000000000000000 |
|
2031 | 2031 | p1node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
2032 | 2032 | p1node--verbose: 0000000000000000000000000000000000000000 |
|
2033 | 2033 | p1node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
2034 | 2034 | p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2035 | 2035 | p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2036 | 2036 | p1node--verbose: 97054abb4ab824450e9164180baf491ae0078465 |
|
2037 | 2037 | p1node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
2038 | 2038 | p1node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
2039 | 2039 | p1node--verbose: 0000000000000000000000000000000000000000 |
|
2040 | 2040 | p1node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453 |
|
2041 | 2041 | p1node--debug: 0000000000000000000000000000000000000000 |
|
2042 | 2042 | p1node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f |
|
2043 | 2043 | p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2044 | 2044 | p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2045 | 2045 | p1node--debug: 97054abb4ab824450e9164180baf491ae0078465 |
|
2046 | 2046 | p1node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
2047 | 2047 | p1node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
2048 | 2048 | p1node--debug: 0000000000000000000000000000000000000000 |
|
2049 | 2049 | p2node: 0000000000000000000000000000000000000000 |
|
2050 | 2050 | p2node: 0000000000000000000000000000000000000000 |
|
2051 | 2051 | p2node: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
2052 | 2052 | p2node: 0000000000000000000000000000000000000000 |
|
2053 | 2053 | p2node: 0000000000000000000000000000000000000000 |
|
2054 | 2054 | p2node: 0000000000000000000000000000000000000000 |
|
2055 | 2055 | p2node: 0000000000000000000000000000000000000000 |
|
2056 | 2056 | p2node: 0000000000000000000000000000000000000000 |
|
2057 | 2057 | p2node: 0000000000000000000000000000000000000000 |
|
2058 | 2058 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2059 | 2059 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2060 | 2060 | p2node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
2061 | 2061 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2062 | 2062 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2063 | 2063 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2064 | 2064 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2065 | 2065 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2066 | 2066 | p2node--verbose: 0000000000000000000000000000000000000000 |
|
2067 | 2067 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2068 | 2068 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2069 | 2069 | p2node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
2070 | 2070 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2071 | 2071 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2072 | 2072 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2073 | 2073 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2074 | 2074 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2075 | 2075 | p2node--debug: 0000000000000000000000000000000000000000 |
|
2076 | 2076 | |
|
2077 | 2077 | Filters work: |
|
2078 | 2078 | |
|
2079 | 2079 | $ hg log --template '{author|domain}\n' |
|
2080 | 2080 | |
|
2081 | 2081 | hostname |
|
2082 | 2082 | |
|
2083 | 2083 | |
|
2084 | 2084 | |
|
2085 | 2085 | |
|
2086 | 2086 | place |
|
2087 | 2087 | place |
|
2088 | 2088 | hostname |
|
2089 | 2089 | |
|
2090 | 2090 | $ hg log --template '{author|person}\n' |
|
2091 | 2091 | test |
|
2092 | 2092 | User Name |
|
2093 | 2093 | person |
|
2094 | 2094 | person |
|
2095 | 2095 | person |
|
2096 | 2096 | person |
|
2097 | 2097 | other |
|
2098 | 2098 | A. N. Other |
|
2099 | 2099 | User Name |
|
2100 | 2100 | |
|
2101 | 2101 | $ hg log --template '{author|user}\n' |
|
2102 | 2102 | test |
|
2103 | 2103 | user |
|
2104 | 2104 | person |
|
2105 | 2105 | person |
|
2106 | 2106 | person |
|
2107 | 2107 | person |
|
2108 | 2108 | other |
|
2109 | 2109 | other |
|
2110 | 2110 | user |
|
2111 | 2111 | |
|
2112 | 2112 | $ hg log --template '{date|date}\n' |
|
2113 | 2113 | Wed Jan 01 10:01:00 2020 +0000 |
|
2114 | 2114 | Mon Jan 12 13:46:40 1970 +0000 |
|
2115 | 2115 | Sun Jan 18 08:40:01 1970 +0000 |
|
2116 | 2116 | Sun Jan 18 08:40:00 1970 +0000 |
|
2117 | 2117 | Sat Jan 17 04:53:20 1970 +0000 |
|
2118 | 2118 | Fri Jan 16 01:06:40 1970 +0000 |
|
2119 | 2119 | Wed Jan 14 21:20:00 1970 +0000 |
|
2120 | 2120 | Tue Jan 13 17:33:20 1970 +0000 |
|
2121 | 2121 | Mon Jan 12 13:46:40 1970 +0000 |
|
2122 | 2122 | |
|
2123 | 2123 | $ hg log --template '{date|isodate}\n' |
|
2124 | 2124 | 2020-01-01 10:01 +0000 |
|
2125 | 2125 | 1970-01-12 13:46 +0000 |
|
2126 | 2126 | 1970-01-18 08:40 +0000 |
|
2127 | 2127 | 1970-01-18 08:40 +0000 |
|
2128 | 2128 | 1970-01-17 04:53 +0000 |
|
2129 | 2129 | 1970-01-16 01:06 +0000 |
|
2130 | 2130 | 1970-01-14 21:20 +0000 |
|
2131 | 2131 | 1970-01-13 17:33 +0000 |
|
2132 | 2132 | 1970-01-12 13:46 +0000 |
|
2133 | 2133 | |
|
2134 | 2134 | $ hg log --template '{date|isodatesec}\n' |
|
2135 | 2135 | 2020-01-01 10:01:00 +0000 |
|
2136 | 2136 | 1970-01-12 13:46:40 +0000 |
|
2137 | 2137 | 1970-01-18 08:40:01 +0000 |
|
2138 | 2138 | 1970-01-18 08:40:00 +0000 |
|
2139 | 2139 | 1970-01-17 04:53:20 +0000 |
|
2140 | 2140 | 1970-01-16 01:06:40 +0000 |
|
2141 | 2141 | 1970-01-14 21:20:00 +0000 |
|
2142 | 2142 | 1970-01-13 17:33:20 +0000 |
|
2143 | 2143 | 1970-01-12 13:46:40 +0000 |
|
2144 | 2144 | |
|
2145 | 2145 | $ hg log --template '{date|rfc822date}\n' |
|
2146 | 2146 | Wed, 01 Jan 2020 10:01:00 +0000 |
|
2147 | 2147 | Mon, 12 Jan 1970 13:46:40 +0000 |
|
2148 | 2148 | Sun, 18 Jan 1970 08:40:01 +0000 |
|
2149 | 2149 | Sun, 18 Jan 1970 08:40:00 +0000 |
|
2150 | 2150 | Sat, 17 Jan 1970 04:53:20 +0000 |
|
2151 | 2151 | Fri, 16 Jan 1970 01:06:40 +0000 |
|
2152 | 2152 | Wed, 14 Jan 1970 21:20:00 +0000 |
|
2153 | 2153 | Tue, 13 Jan 1970 17:33:20 +0000 |
|
2154 | 2154 | Mon, 12 Jan 1970 13:46:40 +0000 |
|
2155 | 2155 | |
|
2156 | 2156 | $ hg log --template '{desc|firstline}\n' |
|
2157 | 2157 | third |
|
2158 | 2158 | second |
|
2159 | 2159 | merge |
|
2160 | 2160 | new head |
|
2161 | 2161 | new branch |
|
2162 | 2162 | no user, no domain |
|
2163 | 2163 | no person |
|
2164 | 2164 | other 1 |
|
2165 | 2165 | line 1 |
|
2166 | 2166 | |
|
2167 | 2167 | $ hg log --template '{node|short}\n' |
|
2168 | 2168 | 95c24699272e |
|
2169 | 2169 | 29114dbae42b |
|
2170 | 2170 | d41e714fe50d |
|
2171 | 2171 | 13207e5a10d9 |
|
2172 | 2172 | bbe44766e73d |
|
2173 | 2173 | 10e46f2dcbf4 |
|
2174 | 2174 | 97054abb4ab8 |
|
2175 | 2175 | b608e9d1a3f0 |
|
2176 | 2176 | 1e4e1b8f71e0 |
|
2177 | 2177 | |
|
2178 | 2178 | $ hg log --template '<changeset author="{author|xmlescape}"/>\n' |
|
2179 | 2179 | <changeset author="test"/> |
|
2180 | 2180 | <changeset author="User Name <user@hostname>"/> |
|
2181 | 2181 | <changeset author="person"/> |
|
2182 | 2182 | <changeset author="person"/> |
|
2183 | 2183 | <changeset author="person"/> |
|
2184 | 2184 | <changeset author="person"/> |
|
2185 | 2185 | <changeset author="other@place"/> |
|
2186 | 2186 | <changeset author="A. N. Other <other@place>"/> |
|
2187 | 2187 | <changeset author="User Name <user@hostname>"/> |
|
2188 | 2188 | |
|
2189 | 2189 | $ hg log --template '{rev}: {children}\n' |
|
2190 | 2190 | 8: |
|
2191 | 2191 | 7: 8:95c24699272e |
|
2192 | 2192 | 6: |
|
2193 | 2193 | 5: 6:d41e714fe50d |
|
2194 | 2194 | 4: 6:d41e714fe50d |
|
2195 | 2195 | 3: 4:bbe44766e73d 5:13207e5a10d9 |
|
2196 | 2196 | 2: 3:10e46f2dcbf4 |
|
2197 | 2197 | 1: 2:97054abb4ab8 |
|
2198 | 2198 | 0: 1:b608e9d1a3f0 |
|
2199 | 2199 | |
|
2200 | 2200 | Formatnode filter works: |
|
2201 | 2201 | |
|
2202 | 2202 | $ hg -q log -r 0 --template '{node|formatnode}\n' |
|
2203 | 2203 | 1e4e1b8f71e0 |
|
2204 | 2204 | |
|
2205 | 2205 | $ hg log -r 0 --template '{node|formatnode}\n' |
|
2206 | 2206 | 1e4e1b8f71e0 |
|
2207 | 2207 | |
|
2208 | 2208 | $ hg -v log -r 0 --template '{node|formatnode}\n' |
|
2209 | 2209 | 1e4e1b8f71e0 |
|
2210 | 2210 | |
|
2211 | 2211 | $ hg --debug log -r 0 --template '{node|formatnode}\n' |
|
2212 | 2212 | 1e4e1b8f71e05681d422154f5421e385fec3454f |
|
2213 | 2213 | |
|
2214 | 2214 | Age filter: |
|
2215 | 2215 | |
|
2216 | 2216 | $ hg init unstable-hash |
|
2217 | 2217 | $ cd unstable-hash |
|
2218 | 2218 | $ hg log --template '{date|age}\n' > /dev/null || exit 1 |
|
2219 | 2219 | |
|
2220 | 2220 | >>> from __future__ import absolute_import |
|
2221 | 2221 | >>> import datetime |
|
2222 | 2222 | >>> fp = open('a', 'wb') |
|
2223 | 2223 | >>> n = datetime.datetime.now() + datetime.timedelta(366 * 7) |
|
2224 | 2224 | >>> fp.write(b'%d-%d-%d 00:00' % (n.year, n.month, n.day)) and None |
|
2225 | 2225 | >>> fp.close() |
|
2226 | 2226 | $ hg add a |
|
2227 | 2227 | $ hg commit -m future -d "`cat a`" |
|
2228 | 2228 | |
|
2229 | 2229 | $ hg log -l1 --template '{date|age}\n' |
|
2230 | 2230 | 7 years from now |
|
2231 | 2231 | |
|
2232 | 2232 | $ cd .. |
|
2233 | 2233 | $ rm -rf unstable-hash |
|
2234 | 2234 | |
|
2235 | 2235 | Filename filters: |
|
2236 | 2236 | |
|
2237 | 2237 | $ hg debugtemplate '{"foo/bar"|basename}|{"foo/"|basename}|{"foo"|basename}|\n' |
|
2238 | 2238 | bar||foo| |
|
2239 | 2239 | $ hg debugtemplate '{"foo/bar"|dirname}|{"foo/"|dirname}|{"foo"|dirname}|\n' |
|
2240 | 2240 | foo|foo|| |
|
2241 | 2241 | $ hg debugtemplate '{"foo/bar"|stripdir}|{"foo/"|stripdir}|{"foo"|stripdir}|\n' |
|
2242 | 2242 | foo|foo|foo| |
|
2243 | 2243 | |
|
2244 | 2244 | Add a dummy commit to make up for the instability of the above: |
|
2245 | 2245 | |
|
2246 | 2246 | $ echo a > a |
|
2247 | 2247 | $ hg add a |
|
2248 | 2248 | $ hg ci -m future |
|
2249 | 2249 | |
|
2250 | 2250 | Count filter: |
|
2251 | 2251 | |
|
2252 | 2252 | $ hg log -l1 --template '{node|count} {node|short|count}\n' |
|
2253 | 2253 | 40 12 |
|
2254 | 2254 | |
|
2255 | 2255 | $ hg log -l1 --template '{revset("null^")|count} {revset(".")|count} {revset("0::3")|count}\n' |
|
2256 | 2256 | 0 1 4 |
|
2257 | 2257 | |
|
2258 | 2258 | $ hg log -G --template '{rev}: children: {children|count}, \ |
|
2259 | 2259 | > tags: {tags|count}, file_adds: {file_adds|count}, \ |
|
2260 | 2260 | > ancestors: {revset("ancestors(%s)", rev)|count}' |
|
2261 | 2261 | @ 9: children: 0, tags: 1, file_adds: 1, ancestors: 3 |
|
2262 | 2262 | | |
|
2263 | 2263 | o 8: children: 1, tags: 0, file_adds: 2, ancestors: 2 |
|
2264 | 2264 | | |
|
2265 | 2265 | o 7: children: 1, tags: 0, file_adds: 1, ancestors: 1 |
|
2266 | 2266 | |
|
2267 | 2267 | o 6: children: 0, tags: 0, file_adds: 0, ancestors: 7 |
|
2268 | 2268 | |\ |
|
2269 | 2269 | | o 5: children: 1, tags: 0, file_adds: 1, ancestors: 5 |
|
2270 | 2270 | | | |
|
2271 | 2271 | o | 4: children: 1, tags: 0, file_adds: 0, ancestors: 5 |
|
2272 | 2272 | |/ |
|
2273 | 2273 | o 3: children: 2, tags: 0, file_adds: 0, ancestors: 4 |
|
2274 | 2274 | | |
|
2275 | 2275 | o 2: children: 1, tags: 0, file_adds: 1, ancestors: 3 |
|
2276 | 2276 | | |
|
2277 | 2277 | o 1: children: 1, tags: 0, file_adds: 1, ancestors: 2 |
|
2278 | 2278 | | |
|
2279 | 2279 | o 0: children: 1, tags: 0, file_adds: 1, ancestors: 1 |
|
2280 | 2280 | |
|
2281 | 2281 | |
|
2282 | 2282 | $ hg log -l1 -T '{termwidth|count}\n' |
|
2283 | 2283 | hg: parse error: not countable |
|
2284 | 2284 | (template filter 'count' is not compatible with keyword 'termwidth') |
|
2285 | 2285 | [255] |
|
2286 | 2286 | |
|
2287 | 2287 | Upper/lower filters: |
|
2288 | 2288 | |
|
2289 | 2289 | $ hg log -r0 --template '{branch|upper}\n' |
|
2290 | 2290 | DEFAULT |
|
2291 | 2291 | $ hg log -r0 --template '{author|lower}\n' |
|
2292 | 2292 | user name <user@hostname> |
|
2293 | 2293 | $ hg log -r0 --template '{date|upper}\n' |
|
2294 | 2294 | 1000000.00 |
|
2295 | 2295 | |
|
2296 | 2296 | Add a commit that does all possible modifications at once |
|
2297 | 2297 | |
|
2298 | 2298 | $ echo modify >> third |
|
2299 | 2299 | $ touch b |
|
2300 | 2300 | $ hg add b |
|
2301 | 2301 | $ hg mv fourth fifth |
|
2302 | 2302 | $ hg rm a |
|
2303 | 2303 | $ hg ci -m "Modify, add, remove, rename" |
|
2304 | 2304 | |
|
2305 | 2305 | Check the status template |
|
2306 | 2306 | |
|
2307 | 2307 | $ cat <<EOF >> $HGRCPATH |
|
2308 | 2308 | > [extensions] |
|
2309 | 2309 | > color= |
|
2310 | 2310 | > EOF |
|
2311 | 2311 | |
|
2312 | 2312 | $ hg log -T status -r 10 |
|
2313 | 2313 | changeset: 10:0f9759ec227a |
|
2314 | 2314 | tag: tip |
|
2315 | 2315 | user: test |
|
2316 | 2316 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
2317 | 2317 | summary: Modify, add, remove, rename |
|
2318 | 2318 | files: |
|
2319 | 2319 | M third |
|
2320 | 2320 | A b |
|
2321 | 2321 | A fifth |
|
2322 | 2322 | R a |
|
2323 | 2323 | R fourth |
|
2324 | 2324 | |
|
2325 | 2325 | $ hg log -T status -C -r 10 |
|
2326 | 2326 | changeset: 10:0f9759ec227a |
|
2327 | 2327 | tag: tip |
|
2328 | 2328 | user: test |
|
2329 | 2329 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
2330 | 2330 | summary: Modify, add, remove, rename |
|
2331 | 2331 | files: |
|
2332 | 2332 | M third |
|
2333 | 2333 | A b |
|
2334 | 2334 | A fifth |
|
2335 | 2335 | fourth |
|
2336 | 2336 | R a |
|
2337 | 2337 | R fourth |
|
2338 | 2338 | |
|
2339 | 2339 | $ hg log -T status -C -r 10 -v |
|
2340 | 2340 | changeset: 10:0f9759ec227a |
|
2341 | 2341 | tag: tip |
|
2342 | 2342 | user: test |
|
2343 | 2343 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
2344 | 2344 | description: |
|
2345 | 2345 | Modify, add, remove, rename |
|
2346 | 2346 | |
|
2347 | 2347 | files: |
|
2348 | 2348 | M third |
|
2349 | 2349 | A b |
|
2350 | 2350 | A fifth |
|
2351 | 2351 | fourth |
|
2352 | 2352 | R a |
|
2353 | 2353 | R fourth |
|
2354 | 2354 | |
|
2355 | 2355 | $ hg log -T status -C -r 10 --debug |
|
2356 | 2356 | changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c |
|
2357 | 2357 | tag: tip |
|
2358 | 2358 | phase: secret |
|
2359 | 2359 | parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066 |
|
2360 | 2360 | parent: -1:0000000000000000000000000000000000000000 |
|
2361 | 2361 | manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567 |
|
2362 | 2362 | user: test |
|
2363 | 2363 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
2364 | 2364 | extra: branch=default |
|
2365 | 2365 | description: |
|
2366 | 2366 | Modify, add, remove, rename |
|
2367 | 2367 | |
|
2368 | 2368 | files: |
|
2369 | 2369 | M third |
|
2370 | 2370 | A b |
|
2371 | 2371 | A fifth |
|
2372 | 2372 | fourth |
|
2373 | 2373 | R a |
|
2374 | 2374 | R fourth |
|
2375 | 2375 | |
|
2376 | 2376 | $ hg log -T status -C -r 10 --quiet |
|
2377 | 2377 | 10:0f9759ec227a |
|
2378 | 2378 | $ hg --color=debug log -T status -r 10 |
|
2379 | 2379 | [log.changeset changeset.secret|changeset: 10:0f9759ec227a] |
|
2380 | 2380 | [log.tag|tag: tip] |
|
2381 | 2381 | [log.user|user: test] |
|
2382 | 2382 | [log.date|date: Thu Jan 01 00:00:00 1970 +0000] |
|
2383 | 2383 | [log.summary|summary: Modify, add, remove, rename] |
|
2384 | 2384 | [ui.note log.files|files:] |
|
2385 | 2385 | [status.modified|M third] |
|
2386 | 2386 | [status.added|A b] |
|
2387 | 2387 | [status.added|A fifth] |
|
2388 | 2388 | [status.removed|R a] |
|
2389 | 2389 | [status.removed|R fourth] |
|
2390 | 2390 | |
|
2391 | 2391 | $ hg --color=debug log -T status -C -r 10 |
|
2392 | 2392 | [log.changeset changeset.secret|changeset: 10:0f9759ec227a] |
|
2393 | 2393 | [log.tag|tag: tip] |
|
2394 | 2394 | [log.user|user: test] |
|
2395 | 2395 | [log.date|date: Thu Jan 01 00:00:00 1970 +0000] |
|
2396 | 2396 | [log.summary|summary: Modify, add, remove, rename] |
|
2397 | 2397 | [ui.note log.files|files:] |
|
2398 | 2398 | [status.modified|M third] |
|
2399 | 2399 | [status.added|A b] |
|
2400 | 2400 | [status.added|A fifth] |
|
2401 | 2401 | [status.copied| fourth] |
|
2402 | 2402 | [status.removed|R a] |
|
2403 | 2403 | [status.removed|R fourth] |
|
2404 | 2404 | |
|
2405 | 2405 | $ hg --color=debug log -T status -C -r 10 -v |
|
2406 | 2406 | [log.changeset changeset.secret|changeset: 10:0f9759ec227a] |
|
2407 | 2407 | [log.tag|tag: tip] |
|
2408 | 2408 | [log.user|user: test] |
|
2409 | 2409 | [log.date|date: Thu Jan 01 00:00:00 1970 +0000] |
|
2410 | 2410 | [ui.note log.description|description:] |
|
2411 | 2411 | [ui.note log.description|Modify, add, remove, rename] |
|
2412 | 2412 | |
|
2413 | 2413 | [ui.note log.files|files:] |
|
2414 | 2414 | [status.modified|M third] |
|
2415 | 2415 | [status.added|A b] |
|
2416 | 2416 | [status.added|A fifth] |
|
2417 | 2417 | [status.copied| fourth] |
|
2418 | 2418 | [status.removed|R a] |
|
2419 | 2419 | [status.removed|R fourth] |
|
2420 | 2420 | |
|
2421 | 2421 | $ hg --color=debug log -T status -C -r 10 --debug |
|
2422 | 2422 | [log.changeset changeset.secret|changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c] |
|
2423 | 2423 | [log.tag|tag: tip] |
|
2424 | 2424 | [log.phase|phase: secret] |
|
2425 | 2425 | [log.parent changeset.secret|parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066] |
|
2426 | 2426 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2427 | 2427 | [ui.debug log.manifest|manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567] |
|
2428 | 2428 | [log.user|user: test] |
|
2429 | 2429 | [log.date|date: Thu Jan 01 00:00:00 1970 +0000] |
|
2430 | 2430 | [ui.debug log.extra|extra: branch=default] |
|
2431 | 2431 | [ui.note log.description|description:] |
|
2432 | 2432 | [ui.note log.description|Modify, add, remove, rename] |
|
2433 | 2433 | |
|
2434 | 2434 | [ui.note log.files|files:] |
|
2435 | 2435 | [status.modified|M third] |
|
2436 | 2436 | [status.added|A b] |
|
2437 | 2437 | [status.added|A fifth] |
|
2438 | 2438 | [status.copied| fourth] |
|
2439 | 2439 | [status.removed|R a] |
|
2440 | 2440 | [status.removed|R fourth] |
|
2441 | 2441 | |
|
2442 | 2442 | $ hg --color=debug log -T status -C -r 10 --quiet |
|
2443 | 2443 | [log.node|10:0f9759ec227a] |
|
2444 | 2444 | |
|
2445 | 2445 | Check the bisect template |
|
2446 | 2446 | |
|
2447 | 2447 | $ hg bisect -g 1 |
|
2448 | 2448 | $ hg bisect -b 3 --noupdate |
|
2449 | 2449 | Testing changeset 2:97054abb4ab8 (2 changesets remaining, ~1 tests) |
|
2450 | 2450 | $ hg log -T bisect -r 0:4 |
|
2451 | 2451 | changeset: 0:1e4e1b8f71e0 |
|
2452 | 2452 | bisect: good (implicit) |
|
2453 | 2453 | user: User Name <user@hostname> |
|
2454 | 2454 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
2455 | 2455 | summary: line 1 |
|
2456 | 2456 | |
|
2457 | 2457 | changeset: 1:b608e9d1a3f0 |
|
2458 | 2458 | bisect: good |
|
2459 | 2459 | user: A. N. Other <other@place> |
|
2460 | 2460 | date: Tue Jan 13 17:33:20 1970 +0000 |
|
2461 | 2461 | summary: other 1 |
|
2462 | 2462 | |
|
2463 | 2463 | changeset: 2:97054abb4ab8 |
|
2464 | 2464 | bisect: untested |
|
2465 | 2465 | user: other@place |
|
2466 | 2466 | date: Wed Jan 14 21:20:00 1970 +0000 |
|
2467 | 2467 | summary: no person |
|
2468 | 2468 | |
|
2469 | 2469 | changeset: 3:10e46f2dcbf4 |
|
2470 | 2470 | bisect: bad |
|
2471 | 2471 | user: person |
|
2472 | 2472 | date: Fri Jan 16 01:06:40 1970 +0000 |
|
2473 | 2473 | summary: no user, no domain |
|
2474 | 2474 | |
|
2475 | 2475 | changeset: 4:bbe44766e73d |
|
2476 | 2476 | bisect: bad (implicit) |
|
2477 | 2477 | branch: foo |
|
2478 | 2478 | user: person |
|
2479 | 2479 | date: Sat Jan 17 04:53:20 1970 +0000 |
|
2480 | 2480 | summary: new branch |
|
2481 | 2481 | |
|
2482 | 2482 | $ hg log --debug -T bisect -r 0:4 |
|
2483 | 2483 | changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f |
|
2484 | 2484 | bisect: good (implicit) |
|
2485 | 2485 | phase: public |
|
2486 | 2486 | parent: -1:0000000000000000000000000000000000000000 |
|
2487 | 2487 | parent: -1:0000000000000000000000000000000000000000 |
|
2488 | 2488 | manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 |
|
2489 | 2489 | user: User Name <user@hostname> |
|
2490 | 2490 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
2491 | 2491 | files+: a |
|
2492 | 2492 | extra: branch=default |
|
2493 | 2493 | description: |
|
2494 | 2494 | line 1 |
|
2495 | 2495 | line 2 |
|
2496 | 2496 | |
|
2497 | 2497 | |
|
2498 | 2498 | changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
2499 | 2499 | bisect: good |
|
2500 | 2500 | phase: public |
|
2501 | 2501 | parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f |
|
2502 | 2502 | parent: -1:0000000000000000000000000000000000000000 |
|
2503 | 2503 | manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55 |
|
2504 | 2504 | user: A. N. Other <other@place> |
|
2505 | 2505 | date: Tue Jan 13 17:33:20 1970 +0000 |
|
2506 | 2506 | files+: b |
|
2507 | 2507 | extra: branch=default |
|
2508 | 2508 | description: |
|
2509 | 2509 | other 1 |
|
2510 | 2510 | other 2 |
|
2511 | 2511 | |
|
2512 | 2512 | other 3 |
|
2513 | 2513 | |
|
2514 | 2514 | |
|
2515 | 2515 | changeset: 2:97054abb4ab824450e9164180baf491ae0078465 |
|
2516 | 2516 | bisect: untested |
|
2517 | 2517 | phase: public |
|
2518 | 2518 | parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965 |
|
2519 | 2519 | parent: -1:0000000000000000000000000000000000000000 |
|
2520 | 2520 | manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1 |
|
2521 | 2521 | user: other@place |
|
2522 | 2522 | date: Wed Jan 14 21:20:00 1970 +0000 |
|
2523 | 2523 | files+: c |
|
2524 | 2524 | extra: branch=default |
|
2525 | 2525 | description: |
|
2526 | 2526 | no person |
|
2527 | 2527 | |
|
2528 | 2528 | |
|
2529 | 2529 | changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2530 | 2530 | bisect: bad |
|
2531 | 2531 | phase: public |
|
2532 | 2532 | parent: 2:97054abb4ab824450e9164180baf491ae0078465 |
|
2533 | 2533 | parent: -1:0000000000000000000000000000000000000000 |
|
2534 | 2534 | manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc |
|
2535 | 2535 | user: person |
|
2536 | 2536 | date: Fri Jan 16 01:06:40 1970 +0000 |
|
2537 | 2537 | files: c |
|
2538 | 2538 | extra: branch=default |
|
2539 | 2539 | description: |
|
2540 | 2540 | no user, no domain |
|
2541 | 2541 | |
|
2542 | 2542 | |
|
2543 | 2543 | changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
2544 | 2544 | bisect: bad (implicit) |
|
2545 | 2545 | branch: foo |
|
2546 | 2546 | phase: draft |
|
2547 | 2547 | parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 |
|
2548 | 2548 | parent: -1:0000000000000000000000000000000000000000 |
|
2549 | 2549 | manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc |
|
2550 | 2550 | user: person |
|
2551 | 2551 | date: Sat Jan 17 04:53:20 1970 +0000 |
|
2552 | 2552 | extra: branch=foo |
|
2553 | 2553 | description: |
|
2554 | 2554 | new branch |
|
2555 | 2555 | |
|
2556 | 2556 | |
|
2557 | 2557 | $ hg log -v -T bisect -r 0:4 |
|
2558 | 2558 | changeset: 0:1e4e1b8f71e0 |
|
2559 | 2559 | bisect: good (implicit) |
|
2560 | 2560 | user: User Name <user@hostname> |
|
2561 | 2561 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
2562 | 2562 | files: a |
|
2563 | 2563 | description: |
|
2564 | 2564 | line 1 |
|
2565 | 2565 | line 2 |
|
2566 | 2566 | |
|
2567 | 2567 | |
|
2568 | 2568 | changeset: 1:b608e9d1a3f0 |
|
2569 | 2569 | bisect: good |
|
2570 | 2570 | user: A. N. Other <other@place> |
|
2571 | 2571 | date: Tue Jan 13 17:33:20 1970 +0000 |
|
2572 | 2572 | files: b |
|
2573 | 2573 | description: |
|
2574 | 2574 | other 1 |
|
2575 | 2575 | other 2 |
|
2576 | 2576 | |
|
2577 | 2577 | other 3 |
|
2578 | 2578 | |
|
2579 | 2579 | |
|
2580 | 2580 | changeset: 2:97054abb4ab8 |
|
2581 | 2581 | bisect: untested |
|
2582 | 2582 | user: other@place |
|
2583 | 2583 | date: Wed Jan 14 21:20:00 1970 +0000 |
|
2584 | 2584 | files: c |
|
2585 | 2585 | description: |
|
2586 | 2586 | no person |
|
2587 | 2587 | |
|
2588 | 2588 | |
|
2589 | 2589 | changeset: 3:10e46f2dcbf4 |
|
2590 | 2590 | bisect: bad |
|
2591 | 2591 | user: person |
|
2592 | 2592 | date: Fri Jan 16 01:06:40 1970 +0000 |
|
2593 | 2593 | files: c |
|
2594 | 2594 | description: |
|
2595 | 2595 | no user, no domain |
|
2596 | 2596 | |
|
2597 | 2597 | |
|
2598 | 2598 | changeset: 4:bbe44766e73d |
|
2599 | 2599 | bisect: bad (implicit) |
|
2600 | 2600 | branch: foo |
|
2601 | 2601 | user: person |
|
2602 | 2602 | date: Sat Jan 17 04:53:20 1970 +0000 |
|
2603 | 2603 | description: |
|
2604 | 2604 | new branch |
|
2605 | 2605 | |
|
2606 | 2606 | |
|
2607 | 2607 | $ hg --color=debug log -T bisect -r 0:4 |
|
2608 | 2608 | [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0] |
|
2609 | 2609 | [log.bisect bisect.good|bisect: good (implicit)] |
|
2610 | 2610 | [log.user|user: User Name <user@hostname>] |
|
2611 | 2611 | [log.date|date: Mon Jan 12 13:46:40 1970 +0000] |
|
2612 | 2612 | [log.summary|summary: line 1] |
|
2613 | 2613 | |
|
2614 | 2614 | [log.changeset changeset.public|changeset: 1:b608e9d1a3f0] |
|
2615 | 2615 | [log.bisect bisect.good|bisect: good] |
|
2616 | 2616 | [log.user|user: A. N. Other <other@place>] |
|
2617 | 2617 | [log.date|date: Tue Jan 13 17:33:20 1970 +0000] |
|
2618 | 2618 | [log.summary|summary: other 1] |
|
2619 | 2619 | |
|
2620 | 2620 | [log.changeset changeset.public|changeset: 2:97054abb4ab8] |
|
2621 | 2621 | [log.bisect bisect.untested|bisect: untested] |
|
2622 | 2622 | [log.user|user: other@place] |
|
2623 | 2623 | [log.date|date: Wed Jan 14 21:20:00 1970 +0000] |
|
2624 | 2624 | [log.summary|summary: no person] |
|
2625 | 2625 | |
|
2626 | 2626 | [log.changeset changeset.public|changeset: 3:10e46f2dcbf4] |
|
2627 | 2627 | [log.bisect bisect.bad|bisect: bad] |
|
2628 | 2628 | [log.user|user: person] |
|
2629 | 2629 | [log.date|date: Fri Jan 16 01:06:40 1970 +0000] |
|
2630 | 2630 | [log.summary|summary: no user, no domain] |
|
2631 | 2631 | |
|
2632 | 2632 | [log.changeset changeset.draft|changeset: 4:bbe44766e73d] |
|
2633 | 2633 | [log.bisect bisect.bad|bisect: bad (implicit)] |
|
2634 | 2634 | [log.branch|branch: foo] |
|
2635 | 2635 | [log.user|user: person] |
|
2636 | 2636 | [log.date|date: Sat Jan 17 04:53:20 1970 +0000] |
|
2637 | 2637 | [log.summary|summary: new branch] |
|
2638 | 2638 | |
|
2639 | 2639 | $ hg --color=debug log --debug -T bisect -r 0:4 |
|
2640 | 2640 | [log.changeset changeset.public|changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f] |
|
2641 | 2641 | [log.bisect bisect.good|bisect: good (implicit)] |
|
2642 | 2642 | [log.phase|phase: public] |
|
2643 | 2643 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2644 | 2644 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2645 | 2645 | [ui.debug log.manifest|manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0] |
|
2646 | 2646 | [log.user|user: User Name <user@hostname>] |
|
2647 | 2647 | [log.date|date: Mon Jan 12 13:46:40 1970 +0000] |
|
2648 | 2648 | [ui.debug log.files|files+: a] |
|
2649 | 2649 | [ui.debug log.extra|extra: branch=default] |
|
2650 | 2650 | [ui.note log.description|description:] |
|
2651 | 2651 | [ui.note log.description|line 1 |
|
2652 | 2652 | line 2] |
|
2653 | 2653 | |
|
2654 | 2654 | |
|
2655 | 2655 | [log.changeset changeset.public|changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965] |
|
2656 | 2656 | [log.bisect bisect.good|bisect: good] |
|
2657 | 2657 | [log.phase|phase: public] |
|
2658 | 2658 | [log.parent changeset.public|parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f] |
|
2659 | 2659 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2660 | 2660 | [ui.debug log.manifest|manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55] |
|
2661 | 2661 | [log.user|user: A. N. Other <other@place>] |
|
2662 | 2662 | [log.date|date: Tue Jan 13 17:33:20 1970 +0000] |
|
2663 | 2663 | [ui.debug log.files|files+: b] |
|
2664 | 2664 | [ui.debug log.extra|extra: branch=default] |
|
2665 | 2665 | [ui.note log.description|description:] |
|
2666 | 2666 | [ui.note log.description|other 1 |
|
2667 | 2667 | other 2 |
|
2668 | 2668 | |
|
2669 | 2669 | other 3] |
|
2670 | 2670 | |
|
2671 | 2671 | |
|
2672 | 2672 | [log.changeset changeset.public|changeset: 2:97054abb4ab824450e9164180baf491ae0078465] |
|
2673 | 2673 | [log.bisect bisect.untested|bisect: untested] |
|
2674 | 2674 | [log.phase|phase: public] |
|
2675 | 2675 | [log.parent changeset.public|parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965] |
|
2676 | 2676 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2677 | 2677 | [ui.debug log.manifest|manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1] |
|
2678 | 2678 | [log.user|user: other@place] |
|
2679 | 2679 | [log.date|date: Wed Jan 14 21:20:00 1970 +0000] |
|
2680 | 2680 | [ui.debug log.files|files+: c] |
|
2681 | 2681 | [ui.debug log.extra|extra: branch=default] |
|
2682 | 2682 | [ui.note log.description|description:] |
|
2683 | 2683 | [ui.note log.description|no person] |
|
2684 | 2684 | |
|
2685 | 2685 | |
|
2686 | 2686 | [log.changeset changeset.public|changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47] |
|
2687 | 2687 | [log.bisect bisect.bad|bisect: bad] |
|
2688 | 2688 | [log.phase|phase: public] |
|
2689 | 2689 | [log.parent changeset.public|parent: 2:97054abb4ab824450e9164180baf491ae0078465] |
|
2690 | 2690 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2691 | 2691 | [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc] |
|
2692 | 2692 | [log.user|user: person] |
|
2693 | 2693 | [log.date|date: Fri Jan 16 01:06:40 1970 +0000] |
|
2694 | 2694 | [ui.debug log.files|files: c] |
|
2695 | 2695 | [ui.debug log.extra|extra: branch=default] |
|
2696 | 2696 | [ui.note log.description|description:] |
|
2697 | 2697 | [ui.note log.description|no user, no domain] |
|
2698 | 2698 | |
|
2699 | 2699 | |
|
2700 | 2700 | [log.changeset changeset.draft|changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74] |
|
2701 | 2701 | [log.bisect bisect.bad|bisect: bad (implicit)] |
|
2702 | 2702 | [log.branch|branch: foo] |
|
2703 | 2703 | [log.phase|phase: draft] |
|
2704 | 2704 | [log.parent changeset.public|parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47] |
|
2705 | 2705 | [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000] |
|
2706 | 2706 | [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc] |
|
2707 | 2707 | [log.user|user: person] |
|
2708 | 2708 | [log.date|date: Sat Jan 17 04:53:20 1970 +0000] |
|
2709 | 2709 | [ui.debug log.extra|extra: branch=foo] |
|
2710 | 2710 | [ui.note log.description|description:] |
|
2711 | 2711 | [ui.note log.description|new branch] |
|
2712 | 2712 | |
|
2713 | 2713 | |
|
2714 | 2714 | $ hg --color=debug log -v -T bisect -r 0:4 |
|
2715 | 2715 | [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0] |
|
2716 | 2716 | [log.bisect bisect.good|bisect: good (implicit)] |
|
2717 | 2717 | [log.user|user: User Name <user@hostname>] |
|
2718 | 2718 | [log.date|date: Mon Jan 12 13:46:40 1970 +0000] |
|
2719 | 2719 | [ui.note log.files|files: a] |
|
2720 | 2720 | [ui.note log.description|description:] |
|
2721 | 2721 | [ui.note log.description|line 1 |
|
2722 | 2722 | line 2] |
|
2723 | 2723 | |
|
2724 | 2724 | |
|
2725 | 2725 | [log.changeset changeset.public|changeset: 1:b608e9d1a3f0] |
|
2726 | 2726 | [log.bisect bisect.good|bisect: good] |
|
2727 | 2727 | [log.user|user: A. N. Other <other@place>] |
|
2728 | 2728 | [log.date|date: Tue Jan 13 17:33:20 1970 +0000] |
|
2729 | 2729 | [ui.note log.files|files: b] |
|
2730 | 2730 | [ui.note log.description|description:] |
|
2731 | 2731 | [ui.note log.description|other 1 |
|
2732 | 2732 | other 2 |
|
2733 | 2733 | |
|
2734 | 2734 | other 3] |
|
2735 | 2735 | |
|
2736 | 2736 | |
|
2737 | 2737 | [log.changeset changeset.public|changeset: 2:97054abb4ab8] |
|
2738 | 2738 | [log.bisect bisect.untested|bisect: untested] |
|
2739 | 2739 | [log.user|user: other@place] |
|
2740 | 2740 | [log.date|date: Wed Jan 14 21:20:00 1970 +0000] |
|
2741 | 2741 | [ui.note log.files|files: c] |
|
2742 | 2742 | [ui.note log.description|description:] |
|
2743 | 2743 | [ui.note log.description|no person] |
|
2744 | 2744 | |
|
2745 | 2745 | |
|
2746 | 2746 | [log.changeset changeset.public|changeset: 3:10e46f2dcbf4] |
|
2747 | 2747 | [log.bisect bisect.bad|bisect: bad] |
|
2748 | 2748 | [log.user|user: person] |
|
2749 | 2749 | [log.date|date: Fri Jan 16 01:06:40 1970 +0000] |
|
2750 | 2750 | [ui.note log.files|files: c] |
|
2751 | 2751 | [ui.note log.description|description:] |
|
2752 | 2752 | [ui.note log.description|no user, no domain] |
|
2753 | 2753 | |
|
2754 | 2754 | |
|
2755 | 2755 | [log.changeset changeset.draft|changeset: 4:bbe44766e73d] |
|
2756 | 2756 | [log.bisect bisect.bad|bisect: bad (implicit)] |
|
2757 | 2757 | [log.branch|branch: foo] |
|
2758 | 2758 | [log.user|user: person] |
|
2759 | 2759 | [log.date|date: Sat Jan 17 04:53:20 1970 +0000] |
|
2760 | 2760 | [ui.note log.description|description:] |
|
2761 | 2761 | [ui.note log.description|new branch] |
|
2762 | 2762 | |
|
2763 | 2763 | |
|
2764 | 2764 | $ hg bisect --reset |
|
2765 | 2765 | |
|
2766 | 2766 | Error on syntax: |
|
2767 | 2767 | |
|
2768 | 2768 | $ echo 'x = "f' >> t |
|
2769 | 2769 | $ hg log |
|
2770 | 2770 | hg: parse error at t:3: unmatched quotes |
|
2771 | 2771 | [255] |
|
2772 | 2772 | |
|
2773 | 2773 | $ hg log -T '{date' |
|
2774 | 2774 | hg: parse error at 1: unterminated template expansion |
|
2775 | 2775 | ({date |
|
2776 | 2776 | ^ here) |
|
2777 | 2777 | [255] |
|
2778 | 2778 | $ hg log -T '{date(}' |
|
2779 | 2779 | hg: parse error at 6: not a prefix: end |
|
2780 | 2780 | ({date(} |
|
2781 | 2781 | ^ here) |
|
2782 | 2782 | [255] |
|
2783 | 2783 | $ hg log -T '{date)}' |
|
2784 | 2784 | hg: parse error at 5: invalid token |
|
2785 | 2785 | ({date)} |
|
2786 | 2786 | ^ here) |
|
2787 | 2787 | [255] |
|
2788 | 2788 | $ hg log -T '{date date}' |
|
2789 | 2789 | hg: parse error at 6: invalid token |
|
2790 | 2790 | ({date date} |
|
2791 | 2791 | ^ here) |
|
2792 | 2792 | [255] |
|
2793 | 2793 | |
|
2794 | 2794 | $ hg log -T '{}' |
|
2795 | 2795 | hg: parse error at 1: not a prefix: end |
|
2796 | 2796 | ({} |
|
2797 | 2797 | ^ here) |
|
2798 | 2798 | [255] |
|
2799 | 2799 | $ hg debugtemplate -v '{()}' |
|
2800 | 2800 | (template |
|
2801 | 2801 | (group |
|
2802 | 2802 | None)) |
|
2803 | 2803 | hg: parse error: missing argument |
|
2804 | 2804 | [255] |
|
2805 | 2805 | |
|
2806 | 2806 | Behind the scenes, this would throw TypeError without intype=bytes |
|
2807 | 2807 | |
|
2808 | 2808 | $ hg log -l 3 --template '{date|obfuscate}\n' |
|
2809 | 2809 | 0.00 |
|
2810 | 2810 | 0.00 |
|
2811 | 2811 | 1577872860.00 |
|
2812 | 2812 | |
|
2813 | 2813 | Behind the scenes, this will throw a ValueError |
|
2814 | 2814 | |
|
2815 | 2815 | $ hg log -l 3 --template 'line: {desc|shortdate}\n' |
|
2816 | 2816 | hg: parse error: invalid date: 'Modify, add, remove, rename' |
|
2817 | 2817 | (template filter 'shortdate' is not compatible with keyword 'desc') |
|
2818 | 2818 | [255] |
|
2819 | 2819 | |
|
2820 | 2820 | Behind the scenes, this would throw AttributeError without intype=bytes |
|
2821 | 2821 | |
|
2822 | 2822 | $ hg log -l 3 --template 'line: {date|escape}\n' |
|
2823 | 2823 | line: 0.00 |
|
2824 | 2824 | line: 0.00 |
|
2825 | 2825 | line: 1577872860.00 |
|
2826 | 2826 | |
|
2827 | 2827 | $ hg log -l 3 --template 'line: {extras|localdate}\n' |
|
2828 | 2828 | hg: parse error: localdate expects a date information |
|
2829 | 2829 | [255] |
|
2830 | 2830 | |
|
2831 | 2831 | Behind the scenes, this will throw ValueError |
|
2832 | 2832 | |
|
2833 | 2833 | $ hg tip --template '{author|email|date}\n' |
|
2834 | 2834 | hg: parse error: date expects a date information |
|
2835 | 2835 | [255] |
|
2836 | 2836 | |
|
2837 | 2837 | $ hg tip -T '{author|email|shortdate}\n' |
|
2838 | 2838 | hg: parse error: invalid date: 'test' |
|
2839 | 2839 | (template filter 'shortdate' is not compatible with keyword 'author') |
|
2840 | 2840 | [255] |
|
2841 | 2841 | |
|
2842 | 2842 | $ hg tip -T '{get(extras, "branch")|shortdate}\n' |
|
2843 | 2843 | hg: parse error: invalid date: 'default' |
|
2844 | 2844 | (incompatible use of template filter 'shortdate') |
|
2845 | 2845 | [255] |
|
2846 | 2846 | |
|
2847 | 2847 | Error in nested template: |
|
2848 | 2848 | |
|
2849 | 2849 | $ hg log -T '{"date' |
|
2850 | 2850 | hg: parse error at 2: unterminated string |
|
2851 | 2851 | ({"date |
|
2852 | 2852 | ^ here) |
|
2853 | 2853 | [255] |
|
2854 | 2854 | |
|
2855 | 2855 | $ hg log -T '{"foo{date|?}"}' |
|
2856 | 2856 | hg: parse error at 11: syntax error |
|
2857 | 2857 | ({"foo{date|?}"} |
|
2858 | 2858 | ^ here) |
|
2859 | 2859 | [255] |
|
2860 | 2860 | |
|
2861 | 2861 | Thrown an error if a template function doesn't exist |
|
2862 | 2862 | |
|
2863 | 2863 | $ hg tip --template '{foo()}\n' |
|
2864 | 2864 | hg: parse error: unknown function 'foo' |
|
2865 | 2865 | [255] |
|
2866 | 2866 | |
|
2867 | 2867 | Pass generator object created by template function to filter |
|
2868 | 2868 | |
|
2869 | 2869 | $ hg log -l 1 --template '{if(author, author)|user}\n' |
|
2870 | 2870 | test |
|
2871 | 2871 | |
|
2872 | 2872 | Test index keyword: |
|
2873 | 2873 | |
|
2874 | 2874 | $ hg log -l 2 -T '{index + 10}{files % " {index}:{file}"}\n' |
|
2875 | 2875 | 10 0:a 1:b 2:fifth 3:fourth 4:third |
|
2876 | 2876 | 11 0:a |
|
2877 | 2877 | |
|
2878 | 2878 | $ hg branches -T '{index} {branch}\n' |
|
2879 | 2879 | 0 default |
|
2880 | 2880 | 1 foo |
|
2881 | 2881 | |
|
2882 | 2882 | Test diff function: |
|
2883 | 2883 | |
|
2884 | 2884 | $ hg diff -c 8 |
|
2885 | 2885 | diff -r 29114dbae42b -r 95c24699272e fourth |
|
2886 | 2886 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2887 | 2887 | +++ b/fourth Wed Jan 01 10:01:00 2020 +0000 |
|
2888 | 2888 | @@ -0,0 +1,1 @@ |
|
2889 | 2889 | +second |
|
2890 | 2890 | diff -r 29114dbae42b -r 95c24699272e second |
|
2891 | 2891 | --- a/second Mon Jan 12 13:46:40 1970 +0000 |
|
2892 | 2892 | +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2893 | 2893 | @@ -1,1 +0,0 @@ |
|
2894 | 2894 | -second |
|
2895 | 2895 | diff -r 29114dbae42b -r 95c24699272e third |
|
2896 | 2896 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2897 | 2897 | +++ b/third Wed Jan 01 10:01:00 2020 +0000 |
|
2898 | 2898 | @@ -0,0 +1,1 @@ |
|
2899 | 2899 | +third |
|
2900 | 2900 | |
|
2901 | 2901 | $ hg log -r 8 -T "{diff()}" |
|
2902 | 2902 | diff -r 29114dbae42b -r 95c24699272e fourth |
|
2903 | 2903 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2904 | 2904 | +++ b/fourth Wed Jan 01 10:01:00 2020 +0000 |
|
2905 | 2905 | @@ -0,0 +1,1 @@ |
|
2906 | 2906 | +second |
|
2907 | 2907 | diff -r 29114dbae42b -r 95c24699272e second |
|
2908 | 2908 | --- a/second Mon Jan 12 13:46:40 1970 +0000 |
|
2909 | 2909 | +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2910 | 2910 | @@ -1,1 +0,0 @@ |
|
2911 | 2911 | -second |
|
2912 | 2912 | diff -r 29114dbae42b -r 95c24699272e third |
|
2913 | 2913 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2914 | 2914 | +++ b/third Wed Jan 01 10:01:00 2020 +0000 |
|
2915 | 2915 | @@ -0,0 +1,1 @@ |
|
2916 | 2916 | +third |
|
2917 | 2917 | |
|
2918 | 2918 | $ hg log -r 8 -T "{diff('glob:f*')}" |
|
2919 | 2919 | diff -r 29114dbae42b -r 95c24699272e fourth |
|
2920 | 2920 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2921 | 2921 | +++ b/fourth Wed Jan 01 10:01:00 2020 +0000 |
|
2922 | 2922 | @@ -0,0 +1,1 @@ |
|
2923 | 2923 | +second |
|
2924 | 2924 | |
|
2925 | 2925 | $ hg log -r 8 -T "{diff('', 'glob:f*')}" |
|
2926 | 2926 | diff -r 29114dbae42b -r 95c24699272e second |
|
2927 | 2927 | --- a/second Mon Jan 12 13:46:40 1970 +0000 |
|
2928 | 2928 | +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2929 | 2929 | @@ -1,1 +0,0 @@ |
|
2930 | 2930 | -second |
|
2931 | 2931 | diff -r 29114dbae42b -r 95c24699272e third |
|
2932 | 2932 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2933 | 2933 | +++ b/third Wed Jan 01 10:01:00 2020 +0000 |
|
2934 | 2934 | @@ -0,0 +1,1 @@ |
|
2935 | 2935 | +third |
|
2936 | 2936 | |
|
2937 | 2937 | $ hg log -r 8 -T "{diff('FOURTH'|lower)}" |
|
2938 | 2938 | diff -r 29114dbae42b -r 95c24699272e fourth |
|
2939 | 2939 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
2940 | 2940 | +++ b/fourth Wed Jan 01 10:01:00 2020 +0000 |
|
2941 | 2941 | @@ -0,0 +1,1 @@ |
|
2942 | 2942 | +second |
|
2943 | 2943 | |
|
2944 | 2944 | ui verbosity: |
|
2945 | 2945 | |
|
2946 | 2946 | $ hg log -l1 -T '{verbosity}\n' |
|
2947 | 2947 | |
|
2948 | 2948 | $ hg log -l1 -T '{verbosity}\n' --debug |
|
2949 | 2949 | debug |
|
2950 | 2950 | $ hg log -l1 -T '{verbosity}\n' --quiet |
|
2951 | 2951 | quiet |
|
2952 | 2952 | $ hg log -l1 -T '{verbosity}\n' --verbose |
|
2953 | 2953 | verbose |
|
2954 | 2954 | |
|
2955 | 2955 | $ cd .. |
|
2956 | 2956 | |
|
2957 | 2957 | |
|
2958 | 2958 | latesttag: |
|
2959 | 2959 | |
|
2960 | 2960 | $ hg init latesttag |
|
2961 | 2961 | $ cd latesttag |
|
2962 | 2962 | |
|
2963 | 2963 | $ echo a > file |
|
2964 | 2964 | $ hg ci -Am a -d '0 0' |
|
2965 | 2965 | adding file |
|
2966 | 2966 | |
|
2967 | 2967 | $ echo b >> file |
|
2968 | 2968 | $ hg ci -m b -d '1 0' |
|
2969 | 2969 | |
|
2970 | 2970 | $ echo c >> head1 |
|
2971 | 2971 | $ hg ci -Am h1c -d '2 0' |
|
2972 | 2972 | adding head1 |
|
2973 | 2973 | |
|
2974 | 2974 | $ hg update -q 1 |
|
2975 | 2975 | $ echo d >> head2 |
|
2976 | 2976 | $ hg ci -Am h2d -d '3 0' |
|
2977 | 2977 | adding head2 |
|
2978 | 2978 | created new head |
|
2979 | 2979 | |
|
2980 | 2980 | $ echo e >> head2 |
|
2981 | 2981 | $ hg ci -m h2e -d '4 0' |
|
2982 | 2982 | |
|
2983 | 2983 | $ hg merge -q |
|
2984 | 2984 | $ hg ci -m merge -d '5 -3600' |
|
2985 | 2985 | |
|
2986 | 2986 | No tag set: |
|
2987 | 2987 | |
|
2988 | 2988 | $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n' |
|
2989 | 2989 | @ 5: null+5 |
|
2990 | 2990 | |\ |
|
2991 | 2991 | | o 4: null+4 |
|
2992 | 2992 | | | |
|
2993 | 2993 | | o 3: null+3 |
|
2994 | 2994 | | | |
|
2995 | 2995 | o | 2: null+3 |
|
2996 | 2996 | |/ |
|
2997 | 2997 | o 1: null+2 |
|
2998 | 2998 | | |
|
2999 | 2999 | o 0: null+1 |
|
3000 | 3000 | |
|
3001 | 3001 | |
|
3002 | 3002 | One common tag: longest path wins for {latesttagdistance}: |
|
3003 | 3003 | |
|
3004 | 3004 | $ hg tag -r 1 -m t1 -d '6 0' t1 |
|
3005 | 3005 | $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n' |
|
3006 | 3006 | @ 6: t1+4 |
|
3007 | 3007 | | |
|
3008 | 3008 | o 5: t1+3 |
|
3009 | 3009 | |\ |
|
3010 | 3010 | | o 4: t1+2 |
|
3011 | 3011 | | | |
|
3012 | 3012 | | o 3: t1+1 |
|
3013 | 3013 | | | |
|
3014 | 3014 | o | 2: t1+1 |
|
3015 | 3015 | |/ |
|
3016 | 3016 | o 1: t1+0 |
|
3017 | 3017 | | |
|
3018 | 3018 | o 0: null+1 |
|
3019 | 3019 | |
|
3020 | 3020 | |
|
3021 | 3021 | One ancestor tag: closest wins: |
|
3022 | 3022 | |
|
3023 | 3023 | $ hg tag -r 2 -m t2 -d '7 0' t2 |
|
3024 | 3024 | $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n' |
|
3025 | 3025 | @ 7: t2+3 |
|
3026 | 3026 | | |
|
3027 | 3027 | o 6: t2+2 |
|
3028 | 3028 | | |
|
3029 | 3029 | o 5: t2+1 |
|
3030 | 3030 | |\ |
|
3031 | 3031 | | o 4: t1+2 |
|
3032 | 3032 | | | |
|
3033 | 3033 | | o 3: t1+1 |
|
3034 | 3034 | | | |
|
3035 | 3035 | o | 2: t2+0 |
|
3036 | 3036 | |/ |
|
3037 | 3037 | o 1: t1+0 |
|
3038 | 3038 | | |
|
3039 | 3039 | o 0: null+1 |
|
3040 | 3040 | |
|
3041 | 3041 | |
|
3042 | 3042 | Two branch tags: more recent wins if same number of changes: |
|
3043 | 3043 | |
|
3044 | 3044 | $ hg tag -r 3 -m t3 -d '8 0' t3 |
|
3045 | 3045 | $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n' |
|
3046 | 3046 | @ 8: t3+5 |
|
3047 | 3047 | | |
|
3048 | 3048 | o 7: t3+4 |
|
3049 | 3049 | | |
|
3050 | 3050 | o 6: t3+3 |
|
3051 | 3051 | | |
|
3052 | 3052 | o 5: t3+2 |
|
3053 | 3053 | |\ |
|
3054 | 3054 | | o 4: t3+1 |
|
3055 | 3055 | | | |
|
3056 | 3056 | | o 3: t3+0 |
|
3057 | 3057 | | | |
|
3058 | 3058 | o | 2: t2+0 |
|
3059 | 3059 | |/ |
|
3060 | 3060 | o 1: t1+0 |
|
3061 | 3061 | | |
|
3062 | 3062 | o 0: null+1 |
|
3063 | 3063 | |
|
3064 | 3064 | |
|
3065 | 3065 | Two branch tags: fewest changes wins: |
|
3066 | 3066 | |
|
3067 | 3067 | $ hg tag -r 4 -m t4 -d '4 0' t4 # older than t2, but should not matter |
|
3068 | 3068 | $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n" |
|
3069 | 3069 | @ 9: t4+5,6 |
|
3070 | 3070 | | |
|
3071 | 3071 | o 8: t4+4,5 |
|
3072 | 3072 | | |
|
3073 | 3073 | o 7: t4+3,4 |
|
3074 | 3074 | | |
|
3075 | 3075 | o 6: t4+2,3 |
|
3076 | 3076 | | |
|
3077 | 3077 | o 5: t4+1,2 |
|
3078 | 3078 | |\ |
|
3079 | 3079 | | o 4: t4+0,0 |
|
3080 | 3080 | | | |
|
3081 | 3081 | | o 3: t3+0,0 |
|
3082 | 3082 | | | |
|
3083 | 3083 | o | 2: t2+0,0 |
|
3084 | 3084 | |/ |
|
3085 | 3085 | o 1: t1+0,0 |
|
3086 | 3086 | | |
|
3087 | 3087 | o 0: null+1,1 |
|
3088 | 3088 | |
|
3089 | 3089 | |
|
3090 | 3090 | Merged tag overrides: |
|
3091 | 3091 | |
|
3092 | 3092 | $ hg tag -r 5 -m t5 -d '9 0' t5 |
|
3093 | 3093 | $ hg tag -r 3 -m at3 -d '10 0' at3 |
|
3094 | 3094 | $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n' |
|
3095 | 3095 | @ 11: t5+6 |
|
3096 | 3096 | | |
|
3097 | 3097 | o 10: t5+5 |
|
3098 | 3098 | | |
|
3099 | 3099 | o 9: t5+4 |
|
3100 | 3100 | | |
|
3101 | 3101 | o 8: t5+3 |
|
3102 | 3102 | | |
|
3103 | 3103 | o 7: t5+2 |
|
3104 | 3104 | | |
|
3105 | 3105 | o 6: t5+1 |
|
3106 | 3106 | | |
|
3107 | 3107 | o 5: t5+0 |
|
3108 | 3108 | |\ |
|
3109 | 3109 | | o 4: t4+0 |
|
3110 | 3110 | | | |
|
3111 | 3111 | | o 3: at3:t3+0 |
|
3112 | 3112 | | | |
|
3113 | 3113 | o | 2: t2+0 |
|
3114 | 3114 | |/ |
|
3115 | 3115 | o 1: t1+0 |
|
3116 | 3116 | | |
|
3117 | 3117 | o 0: null+1 |
|
3118 | 3118 | |
|
3119 | 3119 | |
|
3120 | 3120 | $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n" |
|
3121 | 3121 | @ 11: t5+6,6 |
|
3122 | 3122 | | |
|
3123 | 3123 | o 10: t5+5,5 |
|
3124 | 3124 | | |
|
3125 | 3125 | o 9: t5+4,4 |
|
3126 | 3126 | | |
|
3127 | 3127 | o 8: t5+3,3 |
|
3128 | 3128 | | |
|
3129 | 3129 | o 7: t5+2,2 |
|
3130 | 3130 | | |
|
3131 | 3131 | o 6: t5+1,1 |
|
3132 | 3132 | | |
|
3133 | 3133 | o 5: t5+0,0 |
|
3134 | 3134 | |\ |
|
3135 | 3135 | | o 4: t4+0,0 |
|
3136 | 3136 | | | |
|
3137 | 3137 | | o 3: at3+0,0 t3+0,0 |
|
3138 | 3138 | | | |
|
3139 | 3139 | o | 2: t2+0,0 |
|
3140 | 3140 | |/ |
|
3141 | 3141 | o 1: t1+0,0 |
|
3142 | 3142 | | |
|
3143 | 3143 | o 0: null+1,1 |
|
3144 | 3144 | |
|
3145 | 3145 | |
|
3146 | 3146 | $ hg log -G --template "{rev}: {latesttag('re:^t[13]$') % '{tag}, C: {changes}, D: {distance}'}\n" |
|
3147 | 3147 | @ 11: t3, C: 9, D: 8 |
|
3148 | 3148 | | |
|
3149 | 3149 | o 10: t3, C: 8, D: 7 |
|
3150 | 3150 | | |
|
3151 | 3151 | o 9: t3, C: 7, D: 6 |
|
3152 | 3152 | | |
|
3153 | 3153 | o 8: t3, C: 6, D: 5 |
|
3154 | 3154 | | |
|
3155 | 3155 | o 7: t3, C: 5, D: 4 |
|
3156 | 3156 | | |
|
3157 | 3157 | o 6: t3, C: 4, D: 3 |
|
3158 | 3158 | | |
|
3159 | 3159 | o 5: t3, C: 3, D: 2 |
|
3160 | 3160 | |\ |
|
3161 | 3161 | | o 4: t3, C: 1, D: 1 |
|
3162 | 3162 | | | |
|
3163 | 3163 | | o 3: t3, C: 0, D: 0 |
|
3164 | 3164 | | | |
|
3165 | 3165 | o | 2: t1, C: 1, D: 1 |
|
3166 | 3166 | |/ |
|
3167 | 3167 | o 1: t1, C: 0, D: 0 |
|
3168 | 3168 | | |
|
3169 | 3169 | o 0: null, C: 1, D: 1 |
|
3170 | 3170 | |
|
3171 | 3171 | |
|
3172 | 3172 | $ cd .. |
|
3173 | 3173 | |
|
3174 | 3174 | |
|
3175 | 3175 | Style path expansion: issue1948 - ui.style option doesn't work on OSX |
|
3176 | 3176 | if it is a relative path |
|
3177 | 3177 | |
|
3178 | 3178 | $ mkdir -p home/styles |
|
3179 | 3179 | |
|
3180 | 3180 | $ cat > home/styles/teststyle <<EOF |
|
3181 | 3181 | > changeset = 'test {rev}:{node|short}\n' |
|
3182 | 3182 | > EOF |
|
3183 | 3183 | |
|
3184 | 3184 | $ HOME=`pwd`/home; export HOME |
|
3185 | 3185 | |
|
3186 | 3186 | $ cat > latesttag/.hg/hgrc <<EOF |
|
3187 | 3187 | > [ui] |
|
3188 | 3188 | > style = ~/styles/teststyle |
|
3189 | 3189 | > EOF |
|
3190 | 3190 | |
|
3191 | 3191 | $ hg -R latesttag tip |
|
3192 | 3192 | test 11:97e5943b523a |
|
3193 | 3193 | |
|
3194 | 3194 | Test recursive showlist template (issue1989): |
|
3195 | 3195 | |
|
3196 | 3196 | $ cat > style1989 <<EOF |
|
3197 | 3197 | > changeset = '{file_mods}{manifest}{extras}' |
|
3198 | 3198 | > file_mod = 'M|{author|person}\n' |
|
3199 | 3199 | > manifest = '{rev},{author}\n' |
|
3200 | 3200 | > extra = '{key}: {author}\n' |
|
3201 | 3201 | > EOF |
|
3202 | 3202 | |
|
3203 | 3203 | $ hg -R latesttag log -r tip --style=style1989 |
|
3204 | 3204 | M|test |
|
3205 | 3205 | 11,test |
|
3206 | 3206 | branch: test |
|
3207 | 3207 | |
|
3208 | 3208 | Test new-style inline templating: |
|
3209 | 3209 | |
|
3210 | 3210 | $ hg log -R latesttag -r tip --template 'modified files: {file_mods % " {file}\n"}\n' |
|
3211 | 3211 | modified files: .hgtags |
|
3212 | 3212 | |
|
3213 | 3213 | |
|
3214 | 3214 | $ hg log -R latesttag -r tip -T '{rev % "a"}\n' |
|
3215 | 3215 | hg: parse error: 11 is not iterable of mappings |
|
3216 | 3216 | [255] |
|
3217 | 3217 | $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "a"}\n' |
|
3218 | 3218 | hg: parse error: None is not iterable of mappings |
|
3219 | 3219 | [255] |
|
3220 | 3220 | $ hg log -R latesttag -r tip -T '{extras % "{key}\n" % "{key}\n"}' |
|
3221 | 3221 | hg: parse error: list of strings is not mappable |
|
3222 | 3222 | [255] |
|
3223 | 3223 | |
|
3224 | 3224 | Test new-style inline templating of non-list/dict type: |
|
3225 | 3225 | |
|
3226 | 3226 | $ hg log -R latesttag -r tip -T '{manifest}\n' |
|
3227 | 3227 | 11:2bc6e9006ce2 |
|
3228 | 3228 | $ hg log -R latesttag -r tip -T 'string length: {manifest|count}\n' |
|
3229 | 3229 | string length: 15 |
|
3230 | 3230 | $ hg log -R latesttag -r tip -T '{manifest % "{rev}:{node}"}\n' |
|
3231 | 3231 | 11:2bc6e9006ce29882383a22d39fd1f4e66dd3e2fc |
|
3232 | 3232 | |
|
3233 | 3233 | $ hg log -R latesttag -r tip -T '{get(extras, "branch") % "{key}: {value}\n"}' |
|
3234 | 3234 | branch: default |
|
3235 | 3235 | $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "{key}\n"}' |
|
3236 | 3236 | hg: parse error: None is not iterable of mappings |
|
3237 | 3237 | [255] |
|
3238 | 3238 | $ hg log -R latesttag -r tip -T '{min(extras) % "{key}: {value}\n"}' |
|
3239 | 3239 | branch: default |
|
3240 | 3240 | $ hg log -R latesttag -l1 -T '{min(revset("0:9")) % "{rev}:{node|short}\n"}' |
|
3241 | 3241 | 0:ce3cec86e6c2 |
|
3242 | 3242 | $ hg log -R latesttag -l1 -T '{max(revset("0:9")) % "{rev}:{node|short}\n"}' |
|
3243 | 3243 | 9:fbc7cd862e9c |
|
3244 | 3244 | |
|
3245 | 3245 | Test manifest/get() can be join()-ed as string, though it's silly: |
|
3246 | 3246 | |
|
3247 | 3247 | $ hg log -R latesttag -r tip -T '{join(manifest, ".")}\n' |
|
3248 | 3248 | 1.1.:.2.b.c.6.e.9.0.0.6.c.e.2 |
|
3249 | 3249 | $ hg log -R latesttag -r tip -T '{join(get(extras, "branch"), ".")}\n' |
|
3250 | 3250 | d.e.f.a.u.l.t |
|
3251 | 3251 | |
|
3252 | 3252 | Test join() over string |
|
3253 | 3253 | |
|
3254 | 3254 | $ hg log -R latesttag -r tip -T '{join(rev|stringify, ".")}\n' |
|
3255 | 3255 | 1.1 |
|
3256 | 3256 | |
|
3257 | 3257 | Test join() over uniterable |
|
3258 | 3258 | |
|
3259 | 3259 | $ hg log -R latesttag -r tip -T '{join(rev, "")}\n' |
|
3260 | 3260 | hg: parse error: 11 is not iterable |
|
3261 | 3261 | [255] |
|
3262 | 3262 | |
|
3263 | 3263 | Test min/max of integers |
|
3264 | 3264 | |
|
3265 | 3265 | $ hg log -R latesttag -l1 -T '{min(revset("9:10"))}\n' |
|
3266 | 3266 | 9 |
|
3267 | 3267 | $ hg log -R latesttag -l1 -T '{max(revset("9:10"))}\n' |
|
3268 | 3268 | 10 |
|
3269 | 3269 | |
|
3270 | 3270 | Test min/max over map operation: |
|
3271 | 3271 | |
|
3272 | 3272 | $ hg log -R latesttag -r3 -T '{min(tags % "{tag}")}\n' |
|
3273 | 3273 | at3 |
|
3274 | 3274 | $ hg log -R latesttag -r3 -T '{max(tags % "{tag}")}\n' |
|
3275 | 3275 | t3 |
|
3276 | 3276 | |
|
3277 | 3277 | Test min/max of if() result |
|
3278 | 3278 | |
|
3279 | 3279 | $ cd latesttag |
|
3280 | 3280 | $ hg log -l1 -T '{min(if(true, revset("9:10"), ""))}\n' |
|
3281 | 3281 | 9 |
|
3282 | 3282 | $ hg log -l1 -T '{max(if(false, "", revset("9:10")))}\n' |
|
3283 | 3283 | 10 |
|
3284 | 3284 | $ hg log -l1 -T '{min(ifcontains("a", "aa", revset("9:10"), ""))}\n' |
|
3285 | 3285 | 9 |
|
3286 | 3286 | $ hg log -l1 -T '{max(ifcontains("a", "bb", "", revset("9:10")))}\n' |
|
3287 | 3287 | 10 |
|
3288 | 3288 | $ hg log -l1 -T '{min(ifeq(0, 0, revset("9:10"), ""))}\n' |
|
3289 | 3289 | 9 |
|
3290 | 3290 | $ hg log -l1 -T '{max(ifeq(0, 1, "", revset("9:10")))}\n' |
|
3291 | 3291 | 10 |
|
3292 | 3292 | $ cd .. |
|
3293 | 3293 | |
|
3294 | 3294 | Test laziness of if() then/else clause |
|
3295 | 3295 | |
|
3296 | 3296 | $ hg debugtemplate '{count(0)}' |
|
3297 | 3297 | hg: parse error: not countable |
|
3298 | 3298 | (incompatible use of template filter 'count') |
|
3299 | 3299 | [255] |
|
3300 | 3300 | $ hg debugtemplate '{if(true, "", count(0))}' |
|
3301 | 3301 | $ hg debugtemplate '{if(false, count(0), "")}' |
|
3302 | 3302 | $ hg debugtemplate '{ifcontains("a", "aa", "", count(0))}' |
|
3303 | 3303 | $ hg debugtemplate '{ifcontains("a", "bb", count(0), "")}' |
|
3304 | 3304 | $ hg debugtemplate '{ifeq(0, 0, "", count(0))}' |
|
3305 | 3305 | $ hg debugtemplate '{ifeq(0, 1, count(0), "")}' |
|
3306 | 3306 | |
|
3307 | 3307 | Test dot operator precedence: |
|
3308 | 3308 | |
|
3309 | 3309 | $ hg debugtemplate -R latesttag -r0 -v '{manifest.node|short}\n' |
|
3310 | 3310 | (template |
|
3311 | 3311 | (| |
|
3312 | 3312 | (. |
|
3313 | 3313 | (symbol 'manifest') |
|
3314 | 3314 | (symbol 'node')) |
|
3315 | 3315 | (symbol 'short')) |
|
3316 | 3316 | (string '\n')) |
|
3317 | 3317 | 89f4071fec70 |
|
3318 | 3318 | |
|
3319 | 3319 | (the following examples are invalid, but seem natural in parsing POV) |
|
3320 | 3320 | |
|
3321 | 3321 | $ hg debugtemplate -R latesttag -r0 -v '{foo|bar.baz}\n' 2> /dev/null |
|
3322 | 3322 | (template |
|
3323 | 3323 | (| |
|
3324 | 3324 | (symbol 'foo') |
|
3325 | 3325 | (. |
|
3326 | 3326 | (symbol 'bar') |
|
3327 | 3327 | (symbol 'baz'))) |
|
3328 | 3328 | (string '\n')) |
|
3329 | 3329 | [255] |
|
3330 | 3330 | $ hg debugtemplate -R latesttag -r0 -v '{foo.bar()}\n' 2> /dev/null |
|
3331 | 3331 | (template |
|
3332 | 3332 | (. |
|
3333 | 3333 | (symbol 'foo') |
|
3334 | 3334 | (func |
|
3335 | 3335 | (symbol 'bar') |
|
3336 | 3336 | None)) |
|
3337 | 3337 | (string '\n')) |
|
3338 | 3338 | [255] |
|
3339 | 3339 | |
|
3340 | 3340 | Test evaluation of dot operator: |
|
3341 | 3341 | |
|
3342 | 3342 | $ hg log -R latesttag -l1 -T '{min(revset("0:9")).node}\n' |
|
3343 | 3343 | ce3cec86e6c26bd9bdfc590a6b92abc9680f1796 |
|
3344 | 3344 | $ hg log -R latesttag -r0 -T '{extras.branch}\n' |
|
3345 | 3345 | default |
|
3346 | 3346 | |
|
3347 | 3347 | $ hg log -R latesttag -l1 -T '{author.invalid}\n' |
|
3348 |
hg: parse error: |
|
|
3348 | hg: parse error: 'test' is not a dictionary | |
|
3349 | (keyword 'author' does not support member operation) | |
|
3349 | 3350 | [255] |
|
3350 | 3351 | $ hg log -R latesttag -l1 -T '{min("abc").invalid}\n' |
|
3351 |
hg: parse error: 'a' |
|
|
3352 | hg: parse error: 'a' is not a dictionary | |
|
3352 | 3353 | [255] |
|
3353 | 3354 | |
|
3354 | 3355 | Test the sub function of templating for expansion: |
|
3355 | 3356 | |
|
3356 | 3357 | $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n' |
|
3357 | 3358 | xx |
|
3358 | 3359 | |
|
3359 | 3360 | $ hg log -R latesttag -r 10 -T '{sub("[", "x", rev)}\n' |
|
3360 | 3361 | hg: parse error: sub got an invalid pattern: [ |
|
3361 | 3362 | [255] |
|
3362 | 3363 | $ hg log -R latesttag -r 10 -T '{sub("[0-9]", r"\1", rev)}\n' |
|
3363 | 3364 | hg: parse error: sub got an invalid replacement: \1 |
|
3364 | 3365 | [255] |
|
3365 | 3366 | |
|
3366 | 3367 | Test the strip function with chars specified: |
|
3367 | 3368 | |
|
3368 | 3369 | $ hg log -R latesttag --template '{desc}\n' |
|
3369 | 3370 | at3 |
|
3370 | 3371 | t5 |
|
3371 | 3372 | t4 |
|
3372 | 3373 | t3 |
|
3373 | 3374 | t2 |
|
3374 | 3375 | t1 |
|
3375 | 3376 | merge |
|
3376 | 3377 | h2e |
|
3377 | 3378 | h2d |
|
3378 | 3379 | h1c |
|
3379 | 3380 | b |
|
3380 | 3381 | a |
|
3381 | 3382 | |
|
3382 | 3383 | $ hg log -R latesttag --template '{strip(desc, "te")}\n' |
|
3383 | 3384 | at3 |
|
3384 | 3385 | 5 |
|
3385 | 3386 | 4 |
|
3386 | 3387 | 3 |
|
3387 | 3388 | 2 |
|
3388 | 3389 | 1 |
|
3389 | 3390 | merg |
|
3390 | 3391 | h2 |
|
3391 | 3392 | h2d |
|
3392 | 3393 | h1c |
|
3393 | 3394 | b |
|
3394 | 3395 | a |
|
3395 | 3396 | |
|
3396 | 3397 | Test date format: |
|
3397 | 3398 | |
|
3398 | 3399 | $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n' |
|
3399 | 3400 | date: 70 01 01 10 +0000 |
|
3400 | 3401 | date: 70 01 01 09 +0000 |
|
3401 | 3402 | date: 70 01 01 04 +0000 |
|
3402 | 3403 | date: 70 01 01 08 +0000 |
|
3403 | 3404 | date: 70 01 01 07 +0000 |
|
3404 | 3405 | date: 70 01 01 06 +0000 |
|
3405 | 3406 | date: 70 01 01 05 +0100 |
|
3406 | 3407 | date: 70 01 01 04 +0000 |
|
3407 | 3408 | date: 70 01 01 03 +0000 |
|
3408 | 3409 | date: 70 01 01 02 +0000 |
|
3409 | 3410 | date: 70 01 01 01 +0000 |
|
3410 | 3411 | date: 70 01 01 00 +0000 |
|
3411 | 3412 | |
|
3412 | 3413 | Test invalid date: |
|
3413 | 3414 | |
|
3414 | 3415 | $ hg log -R latesttag -T '{date(rev)}\n' |
|
3415 | 3416 | hg: parse error: date expects a date information |
|
3416 | 3417 | [255] |
|
3417 | 3418 | |
|
3418 | 3419 | Test integer literal: |
|
3419 | 3420 | |
|
3420 | 3421 | $ hg debugtemplate -v '{(0)}\n' |
|
3421 | 3422 | (template |
|
3422 | 3423 | (group |
|
3423 | 3424 | (integer '0')) |
|
3424 | 3425 | (string '\n')) |
|
3425 | 3426 | 0 |
|
3426 | 3427 | $ hg debugtemplate -v '{(123)}\n' |
|
3427 | 3428 | (template |
|
3428 | 3429 | (group |
|
3429 | 3430 | (integer '123')) |
|
3430 | 3431 | (string '\n')) |
|
3431 | 3432 | 123 |
|
3432 | 3433 | $ hg debugtemplate -v '{(-4)}\n' |
|
3433 | 3434 | (template |
|
3434 | 3435 | (group |
|
3435 | 3436 | (negate |
|
3436 | 3437 | (integer '4'))) |
|
3437 | 3438 | (string '\n')) |
|
3438 | 3439 | -4 |
|
3439 | 3440 | $ hg debugtemplate '{(-)}\n' |
|
3440 | 3441 | hg: parse error at 3: not a prefix: ) |
|
3441 | 3442 | ({(-)}\n |
|
3442 | 3443 | ^ here) |
|
3443 | 3444 | [255] |
|
3444 | 3445 | $ hg debugtemplate '{(-a)}\n' |
|
3445 | 3446 | hg: parse error: negation needs an integer argument |
|
3446 | 3447 | [255] |
|
3447 | 3448 | |
|
3448 | 3449 | top-level integer literal is interpreted as symbol (i.e. variable name): |
|
3449 | 3450 | |
|
3450 | 3451 | $ hg debugtemplate -D 1=one -v '{1}\n' |
|
3451 | 3452 | (template |
|
3452 | 3453 | (integer '1') |
|
3453 | 3454 | (string '\n')) |
|
3454 | 3455 | one |
|
3455 | 3456 | $ hg debugtemplate -D 1=one -v '{if("t", "{1}")}\n' |
|
3456 | 3457 | (template |
|
3457 | 3458 | (func |
|
3458 | 3459 | (symbol 'if') |
|
3459 | 3460 | (list |
|
3460 | 3461 | (string 't') |
|
3461 | 3462 | (template |
|
3462 | 3463 | (integer '1')))) |
|
3463 | 3464 | (string '\n')) |
|
3464 | 3465 | one |
|
3465 | 3466 | $ hg debugtemplate -D 1=one -v '{1|stringify}\n' |
|
3466 | 3467 | (template |
|
3467 | 3468 | (| |
|
3468 | 3469 | (integer '1') |
|
3469 | 3470 | (symbol 'stringify')) |
|
3470 | 3471 | (string '\n')) |
|
3471 | 3472 | one |
|
3472 | 3473 | |
|
3473 | 3474 | unless explicit symbol is expected: |
|
3474 | 3475 | |
|
3475 | 3476 | $ hg log -Ra -r0 -T '{desc|1}\n' |
|
3476 | 3477 | hg: parse error: expected a symbol, got 'integer' |
|
3477 | 3478 | [255] |
|
3478 | 3479 | $ hg log -Ra -r0 -T '{1()}\n' |
|
3479 | 3480 | hg: parse error: expected a symbol, got 'integer' |
|
3480 | 3481 | [255] |
|
3481 | 3482 | |
|
3482 | 3483 | Test string literal: |
|
3483 | 3484 | |
|
3484 | 3485 | $ hg debugtemplate -Ra -r0 -v '{"string with no template fragment"}\n' |
|
3485 | 3486 | (template |
|
3486 | 3487 | (string 'string with no template fragment') |
|
3487 | 3488 | (string '\n')) |
|
3488 | 3489 | string with no template fragment |
|
3489 | 3490 | $ hg debugtemplate -Ra -r0 -v '{"template: {rev}"}\n' |
|
3490 | 3491 | (template |
|
3491 | 3492 | (template |
|
3492 | 3493 | (string 'template: ') |
|
3493 | 3494 | (symbol 'rev')) |
|
3494 | 3495 | (string '\n')) |
|
3495 | 3496 | template: 0 |
|
3496 | 3497 | $ hg debugtemplate -Ra -r0 -v '{r"rawstring: {rev}"}\n' |
|
3497 | 3498 | (template |
|
3498 | 3499 | (string 'rawstring: {rev}') |
|
3499 | 3500 | (string '\n')) |
|
3500 | 3501 | rawstring: {rev} |
|
3501 | 3502 | $ hg debugtemplate -Ra -r0 -v '{files % r"rawstring: {file}"}\n' |
|
3502 | 3503 | (template |
|
3503 | 3504 | (% |
|
3504 | 3505 | (symbol 'files') |
|
3505 | 3506 | (string 'rawstring: {file}')) |
|
3506 | 3507 | (string '\n')) |
|
3507 | 3508 | rawstring: {file} |
|
3508 | 3509 | |
|
3509 | 3510 | Test string escaping: |
|
3510 | 3511 | |
|
3511 | 3512 | $ hg log -R latesttag -r 0 --template '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' |
|
3512 | 3513 | > |
|
3513 | 3514 | <>\n<[> |
|
3514 | 3515 | <>\n<]> |
|
3515 | 3516 | <>\n< |
|
3516 | 3517 | |
|
3517 | 3518 | $ hg log -R latesttag -r 0 \ |
|
3518 | 3519 | > --config ui.logtemplate='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' |
|
3519 | 3520 | > |
|
3520 | 3521 | <>\n<[> |
|
3521 | 3522 | <>\n<]> |
|
3522 | 3523 | <>\n< |
|
3523 | 3524 | |
|
3524 | 3525 | $ hg log -R latesttag -r 0 -T esc \ |
|
3525 | 3526 | > --config templates.esc='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' |
|
3526 | 3527 | > |
|
3527 | 3528 | <>\n<[> |
|
3528 | 3529 | <>\n<]> |
|
3529 | 3530 | <>\n< |
|
3530 | 3531 | |
|
3531 | 3532 | $ cat <<'EOF' > esctmpl |
|
3532 | 3533 | > changeset = '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n' |
|
3533 | 3534 | > EOF |
|
3534 | 3535 | $ hg log -R latesttag -r 0 --style ./esctmpl |
|
3535 | 3536 | > |
|
3536 | 3537 | <>\n<[> |
|
3537 | 3538 | <>\n<]> |
|
3538 | 3539 | <>\n< |
|
3539 | 3540 | |
|
3540 | 3541 | Test string escaping of quotes: |
|
3541 | 3542 | |
|
3542 | 3543 | $ hg log -Ra -r0 -T '{"\""}\n' |
|
3543 | 3544 | " |
|
3544 | 3545 | $ hg log -Ra -r0 -T '{"\\\""}\n' |
|
3545 | 3546 | \" |
|
3546 | 3547 | $ hg log -Ra -r0 -T '{r"\""}\n' |
|
3547 | 3548 | \" |
|
3548 | 3549 | $ hg log -Ra -r0 -T '{r"\\\""}\n' |
|
3549 | 3550 | \\\" |
|
3550 | 3551 | |
|
3551 | 3552 | |
|
3552 | 3553 | $ hg log -Ra -r0 -T '{"\""}\n' |
|
3553 | 3554 | " |
|
3554 | 3555 | $ hg log -Ra -r0 -T '{"\\\""}\n' |
|
3555 | 3556 | \" |
|
3556 | 3557 | $ hg log -Ra -r0 -T '{r"\""}\n' |
|
3557 | 3558 | \" |
|
3558 | 3559 | $ hg log -Ra -r0 -T '{r"\\\""}\n' |
|
3559 | 3560 | \\\" |
|
3560 | 3561 | |
|
3561 | 3562 | Test exception in quoted template. single backslash before quotation mark is |
|
3562 | 3563 | stripped before parsing: |
|
3563 | 3564 | |
|
3564 | 3565 | $ cat <<'EOF' > escquotetmpl |
|
3565 | 3566 | > changeset = "\" \\" \\\" \\\\" {files % \"{file}\"}\n" |
|
3566 | 3567 | > EOF |
|
3567 | 3568 | $ cd latesttag |
|
3568 | 3569 | $ hg log -r 2 --style ../escquotetmpl |
|
3569 | 3570 | " \" \" \\" head1 |
|
3570 | 3571 | |
|
3571 | 3572 | $ hg log -r 2 -T esc --config templates.esc='"{\"valid\"}\n"' |
|
3572 | 3573 | valid |
|
3573 | 3574 | $ hg log -r 2 -T esc --config templates.esc="'"'{\'"'"'valid\'"'"'}\n'"'" |
|
3574 | 3575 | valid |
|
3575 | 3576 | |
|
3576 | 3577 | Test compatibility with 2.9.2-3.4 of escaped quoted strings in nested |
|
3577 | 3578 | _evalifliteral() templates (issue4733): |
|
3578 | 3579 | |
|
3579 | 3580 | $ hg log -r 2 -T '{if(rev, "\"{rev}")}\n' |
|
3580 | 3581 | "2 |
|
3581 | 3582 | $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\"{rev}\")}")}\n' |
|
3582 | 3583 | "2 |
|
3583 | 3584 | $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\"{rev}\\\")}\")}")}\n' |
|
3584 | 3585 | "2 |
|
3585 | 3586 | |
|
3586 | 3587 | $ hg log -r 2 -T '{if(rev, "\\\"")}\n' |
|
3587 | 3588 | \" |
|
3588 | 3589 | $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\\\\\"\")}")}\n' |
|
3589 | 3590 | \" |
|
3590 | 3591 | $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n' |
|
3591 | 3592 | \" |
|
3592 | 3593 | |
|
3593 | 3594 | $ hg log -r 2 -T '{if(rev, r"\\\"")}\n' |
|
3594 | 3595 | \\\" |
|
3595 | 3596 | $ hg log -r 2 -T '{if(rev, "{if(rev, r\"\\\\\\\"\")}")}\n' |
|
3596 | 3597 | \\\" |
|
3597 | 3598 | $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, r\\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n' |
|
3598 | 3599 | \\\" |
|
3599 | 3600 | |
|
3600 | 3601 | escaped single quotes and errors: |
|
3601 | 3602 | |
|
3602 | 3603 | $ hg log -r 2 -T "{if(rev, '{if(rev, \'foo\')}')}"'\n' |
|
3603 | 3604 | foo |
|
3604 | 3605 | $ hg log -r 2 -T "{if(rev, '{if(rev, r\'foo\')}')}"'\n' |
|
3605 | 3606 | foo |
|
3606 | 3607 | $ hg log -r 2 -T '{if(rev, "{if(rev, \")}")}\n' |
|
3607 | 3608 | hg: parse error at 21: unterminated string |
|
3608 | 3609 | ({if(rev, "{if(rev, \")}")}\n |
|
3609 | 3610 | ^ here) |
|
3610 | 3611 | [255] |
|
3611 | 3612 | $ hg log -r 2 -T '{if(rev, \"\\"")}\n' |
|
3612 | 3613 | hg: parse error: trailing \ in string |
|
3613 | 3614 | [255] |
|
3614 | 3615 | $ hg log -r 2 -T '{if(rev, r\"\\"")}\n' |
|
3615 | 3616 | hg: parse error: trailing \ in string |
|
3616 | 3617 | [255] |
|
3617 | 3618 | |
|
3618 | 3619 | $ cd .. |
|
3619 | 3620 | |
|
3620 | 3621 | Test leading backslashes: |
|
3621 | 3622 | |
|
3622 | 3623 | $ cd latesttag |
|
3623 | 3624 | $ hg log -r 2 -T '\{rev} {files % "\{file}"}\n' |
|
3624 | 3625 | {rev} {file} |
|
3625 | 3626 | $ hg log -r 2 -T '\\{rev} {files % "\\{file}"}\n' |
|
3626 | 3627 | \2 \head1 |
|
3627 | 3628 | $ hg log -r 2 -T '\\\{rev} {files % "\\\{file}"}\n' |
|
3628 | 3629 | \{rev} \{file} |
|
3629 | 3630 | $ cd .. |
|
3630 | 3631 | |
|
3631 | 3632 | Test leading backslashes in "if" expression (issue4714): |
|
3632 | 3633 | |
|
3633 | 3634 | $ cd latesttag |
|
3634 | 3635 | $ hg log -r 2 -T '{if("1", "\{rev}")} {if("1", r"\{rev}")}\n' |
|
3635 | 3636 | {rev} \{rev} |
|
3636 | 3637 | $ hg log -r 2 -T '{if("1", "\\{rev}")} {if("1", r"\\{rev}")}\n' |
|
3637 | 3638 | \2 \\{rev} |
|
3638 | 3639 | $ hg log -r 2 -T '{if("1", "\\\{rev}")} {if("1", r"\\\{rev}")}\n' |
|
3639 | 3640 | \{rev} \\\{rev} |
|
3640 | 3641 | $ cd .. |
|
3641 | 3642 | |
|
3642 | 3643 | "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice) |
|
3643 | 3644 | |
|
3644 | 3645 | $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n' |
|
3645 | 3646 | \x6e |
|
3646 | 3647 | $ hg log -R a -r 0 --template '{if("1", r"\x5c\x786e", "NG")}\n' |
|
3647 | 3648 | \x5c\x786e |
|
3648 | 3649 | $ hg log -R a -r 0 --template '{if("", "NG", "\x5c\x786e")}\n' |
|
3649 | 3650 | \x6e |
|
3650 | 3651 | $ hg log -R a -r 0 --template '{if("", "NG", r"\x5c\x786e")}\n' |
|
3651 | 3652 | \x5c\x786e |
|
3652 | 3653 | |
|
3653 | 3654 | $ hg log -R a -r 2 --template '{ifeq("no perso\x6e", desc, "\x5c\x786e", "NG")}\n' |
|
3654 | 3655 | \x6e |
|
3655 | 3656 | $ hg log -R a -r 2 --template '{ifeq(r"no perso\x6e", desc, "NG", r"\x5c\x786e")}\n' |
|
3656 | 3657 | \x5c\x786e |
|
3657 | 3658 | $ hg log -R a -r 2 --template '{ifeq(desc, "no perso\x6e", "\x5c\x786e", "NG")}\n' |
|
3658 | 3659 | \x6e |
|
3659 | 3660 | $ hg log -R a -r 2 --template '{ifeq(desc, r"no perso\x6e", "NG", r"\x5c\x786e")}\n' |
|
3660 | 3661 | \x5c\x786e |
|
3661 | 3662 | |
|
3662 | 3663 | $ hg log -R a -r 8 --template '{join(files, "\n")}\n' |
|
3663 | 3664 | fourth |
|
3664 | 3665 | second |
|
3665 | 3666 | third |
|
3666 | 3667 | $ hg log -R a -r 8 --template '{join(files, r"\n")}\n' |
|
3667 | 3668 | fourth\nsecond\nthird |
|
3668 | 3669 | |
|
3669 | 3670 | $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", "htm\x6c")}' |
|
3670 | 3671 | <p> |
|
3671 | 3672 | 1st |
|
3672 | 3673 | </p> |
|
3673 | 3674 | <p> |
|
3674 | 3675 | 2nd |
|
3675 | 3676 | </p> |
|
3676 | 3677 | $ hg log -R a -r 2 --template '{rstdoc(r"1st\n\n2nd", "html")}' |
|
3677 | 3678 | <p> |
|
3678 | 3679 | 1st\n\n2nd |
|
3679 | 3680 | </p> |
|
3680 | 3681 | $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", r"htm\x6c")}' |
|
3681 | 3682 | 1st |
|
3682 | 3683 | |
|
3683 | 3684 | 2nd |
|
3684 | 3685 | |
|
3685 | 3686 | $ hg log -R a -r 2 --template '{strip(desc, "\x6e")}\n' |
|
3686 | 3687 | o perso |
|
3687 | 3688 | $ hg log -R a -r 2 --template '{strip(desc, r"\x6e")}\n' |
|
3688 | 3689 | no person |
|
3689 | 3690 | $ hg log -R a -r 2 --template '{strip("no perso\x6e", "\x6e")}\n' |
|
3690 | 3691 | o perso |
|
3691 | 3692 | $ hg log -R a -r 2 --template '{strip(r"no perso\x6e", r"\x6e")}\n' |
|
3692 | 3693 | no perso |
|
3693 | 3694 | |
|
3694 | 3695 | $ hg log -R a -r 2 --template '{sub("\\x6e", "\x2d", desc)}\n' |
|
3695 | 3696 | -o perso- |
|
3696 | 3697 | $ hg log -R a -r 2 --template '{sub(r"\\x6e", "-", desc)}\n' |
|
3697 | 3698 | no person |
|
3698 | 3699 | $ hg log -R a -r 2 --template '{sub("n", r"\x2d", desc)}\n' |
|
3699 | 3700 | \x2do perso\x2d |
|
3700 | 3701 | $ hg log -R a -r 2 --template '{sub("n", "\x2d", "no perso\x6e")}\n' |
|
3701 | 3702 | -o perso- |
|
3702 | 3703 | $ hg log -R a -r 2 --template '{sub("n", r"\x2d", r"no perso\x6e")}\n' |
|
3703 | 3704 | \x2do perso\x6e |
|
3704 | 3705 | |
|
3705 | 3706 | $ hg log -R a -r 8 --template '{files % "{file}\n"}' |
|
3706 | 3707 | fourth |
|
3707 | 3708 | second |
|
3708 | 3709 | third |
|
3709 | 3710 | |
|
3710 | 3711 | Test string escaping in nested expression: |
|
3711 | 3712 | |
|
3712 | 3713 | $ hg log -R a -r 8 --template '{ifeq(r"\x6e", if("1", "\x5c\x786e"), join(files, "\x5c\x786e"))}\n' |
|
3713 | 3714 | fourth\x6esecond\x6ethird |
|
3714 | 3715 | $ hg log -R a -r 8 --template '{ifeq(if("1", r"\x6e"), "\x5c\x786e", join(files, "\x5c\x786e"))}\n' |
|
3715 | 3716 | fourth\x6esecond\x6ethird |
|
3716 | 3717 | |
|
3717 | 3718 | $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", "\x5c\x786e"))}\n' |
|
3718 | 3719 | fourth\x6esecond\x6ethird |
|
3719 | 3720 | $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", r"\x5c\x786e"))}\n' |
|
3720 | 3721 | fourth\x5c\x786esecond\x5c\x786ethird |
|
3721 | 3722 | |
|
3722 | 3723 | $ hg log -R a -r 3:4 --template '{rev}:{sub(if("1", "\x6e"), ifeq(branch, "foo", r"\x5c\x786e", "\x5c\x786e"), desc)}\n' |
|
3723 | 3724 | 3:\x6eo user, \x6eo domai\x6e |
|
3724 | 3725 | 4:\x5c\x786eew bra\x5c\x786ech |
|
3725 | 3726 | |
|
3726 | 3727 | Test quotes in nested expression are evaluated just like a $(command) |
|
3727 | 3728 | substitution in POSIX shells: |
|
3728 | 3729 | |
|
3729 | 3730 | $ hg log -R a -r 8 -T '{"{"{rev}:{node|short}"}"}\n' |
|
3730 | 3731 | 8:95c24699272e |
|
3731 | 3732 | $ hg log -R a -r 8 -T '{"{"\{{rev}} \"{node|short}\""}"}\n' |
|
3732 | 3733 | {8} "95c24699272e" |
|
3733 | 3734 | |
|
3734 | 3735 | Test recursive evaluation: |
|
3735 | 3736 | |
|
3736 | 3737 | $ hg init r |
|
3737 | 3738 | $ cd r |
|
3738 | 3739 | $ echo a > a |
|
3739 | 3740 | $ hg ci -Am '{rev}' |
|
3740 | 3741 | adding a |
|
3741 | 3742 | $ hg log -r 0 --template '{if(rev, desc)}\n' |
|
3742 | 3743 | {rev} |
|
3743 | 3744 | $ hg log -r 0 --template '{if(rev, "{author} {rev}")}\n' |
|
3744 | 3745 | test 0 |
|
3745 | 3746 | |
|
3746 | 3747 | $ hg branch -q 'text.{rev}' |
|
3747 | 3748 | $ echo aa >> aa |
|
3748 | 3749 | $ hg ci -u '{node|short}' -m 'desc to be wrapped desc to be wrapped' |
|
3749 | 3750 | |
|
3750 | 3751 | $ hg log -l1 --template '{fill(desc, "20", author, branch)}' |
|
3751 | 3752 | {node|short}desc to |
|
3752 | 3753 | text.{rev}be wrapped |
|
3753 | 3754 | text.{rev}desc to be |
|
3754 | 3755 | text.{rev}wrapped (no-eol) |
|
3755 | 3756 | $ hg log -l1 --template '{fill(desc, "20", "{node|short}:", "text.{rev}:")}' |
|
3756 | 3757 | bcc7ff960b8e:desc to |
|
3757 | 3758 | text.1:be wrapped |
|
3758 | 3759 | text.1:desc to be |
|
3759 | 3760 | text.1:wrapped (no-eol) |
|
3760 | 3761 | $ hg log -l1 -T '{fill(desc, date, "", "")}\n' |
|
3761 | 3762 | hg: parse error: fill expects an integer width |
|
3762 | 3763 | [255] |
|
3763 | 3764 | |
|
3764 | 3765 | $ COLUMNS=25 hg log -l1 --template '{fill(desc, termwidth, "{node|short}:", "termwidth.{rev}:")}' |
|
3765 | 3766 | bcc7ff960b8e:desc to be |
|
3766 | 3767 | termwidth.1:wrapped desc |
|
3767 | 3768 | termwidth.1:to be wrapped (no-eol) |
|
3768 | 3769 | |
|
3769 | 3770 | $ hg log -l 1 --template '{sub(r"[0-9]", "-", author)}' |
|
3770 | 3771 | {node|short} (no-eol) |
|
3771 | 3772 | $ hg log -l 1 --template '{sub(r"[0-9]", "-", "{node|short}")}' |
|
3772 | 3773 | bcc-ff---b-e (no-eol) |
|
3773 | 3774 | |
|
3774 | 3775 | $ cat >> .hg/hgrc <<EOF |
|
3775 | 3776 | > [extensions] |
|
3776 | 3777 | > color= |
|
3777 | 3778 | > [color] |
|
3778 | 3779 | > mode=ansi |
|
3779 | 3780 | > text.{rev} = red |
|
3780 | 3781 | > text.1 = green |
|
3781 | 3782 | > EOF |
|
3782 | 3783 | $ hg log --color=always -l 1 --template '{label(branch, "text\n")}' |
|
3783 | 3784 | \x1b[0;31mtext\x1b[0m (esc) |
|
3784 | 3785 | $ hg log --color=always -l 1 --template '{label("text.{rev}", "text\n")}' |
|
3785 | 3786 | \x1b[0;32mtext\x1b[0m (esc) |
|
3786 | 3787 | |
|
3787 | 3788 | color effect can be specified without quoting: |
|
3788 | 3789 | |
|
3789 | 3790 | $ hg log --color=always -l 1 --template '{label(red, "text\n")}' |
|
3790 | 3791 | \x1b[0;31mtext\x1b[0m (esc) |
|
3791 | 3792 | |
|
3792 | 3793 | color effects can be nested (issue5413) |
|
3793 | 3794 | |
|
3794 | 3795 | $ hg debugtemplate --color=always \ |
|
3795 | 3796 | > '{label(red, "red{label(magenta, "ma{label(cyan, "cyan")}{label(yellow, "yellow")}genta")}")}\n' |
|
3796 | 3797 | \x1b[0;31mred\x1b[0;35mma\x1b[0;36mcyan\x1b[0m\x1b[0;31m\x1b[0;35m\x1b[0;33myellow\x1b[0m\x1b[0;31m\x1b[0;35mgenta\x1b[0m (esc) |
|
3797 | 3798 | |
|
3798 | 3799 | pad() should interact well with color codes (issue5416) |
|
3799 | 3800 | |
|
3800 | 3801 | $ hg debugtemplate --color=always \ |
|
3801 | 3802 | > '{pad(label(red, "red"), 5, label(cyan, "-"))}\n' |
|
3802 | 3803 | \x1b[0;31mred\x1b[0m\x1b[0;36m-\x1b[0m\x1b[0;36m-\x1b[0m (esc) |
|
3803 | 3804 | |
|
3804 | 3805 | label should be no-op if color is disabled: |
|
3805 | 3806 | |
|
3806 | 3807 | $ hg log --color=never -l 1 --template '{label(red, "text\n")}' |
|
3807 | 3808 | text |
|
3808 | 3809 | $ hg log --config extensions.color=! -l 1 --template '{label(red, "text\n")}' |
|
3809 | 3810 | text |
|
3810 | 3811 | |
|
3811 | 3812 | Test branches inside if statement: |
|
3812 | 3813 | |
|
3813 | 3814 | $ hg log -r 0 --template '{if(branches, "yes", "no")}\n' |
|
3814 | 3815 | no |
|
3815 | 3816 | |
|
3816 | 3817 | Test dict constructor: |
|
3817 | 3818 | |
|
3818 | 3819 | $ hg log -r 0 -T '{dict(y=node|short, x=rev)}\n' |
|
3819 | 3820 | y=f7769ec2ab97 x=0 |
|
3820 | 3821 | $ hg log -r 0 -T '{dict(x=rev, y=node|short) % "{key}={value}\n"}' |
|
3821 | 3822 | x=0 |
|
3822 | 3823 | y=f7769ec2ab97 |
|
3823 | 3824 | $ hg log -r 0 -T '{dict(x=rev, y=node|short)|json}\n' |
|
3824 | 3825 | {"x": 0, "y": "f7769ec2ab97"} |
|
3825 | 3826 | $ hg log -r 0 -T '{dict()|json}\n' |
|
3826 | 3827 | {} |
|
3827 | 3828 | |
|
3828 | 3829 | $ hg log -r 0 -T '{dict(rev, node=node|short)}\n' |
|
3829 | 3830 | rev=0 node=f7769ec2ab97 |
|
3830 | 3831 | $ hg log -r 0 -T '{dict(rev, node|short)}\n' |
|
3831 | 3832 | rev=0 node=f7769ec2ab97 |
|
3832 | 3833 | |
|
3833 | 3834 | $ hg log -r 0 -T '{dict(rev, rev=rev)}\n' |
|
3834 | 3835 | hg: parse error: duplicated dict key 'rev' inferred |
|
3835 | 3836 | [255] |
|
3836 | 3837 | $ hg log -r 0 -T '{dict(node, node|short)}\n' |
|
3837 | 3838 | hg: parse error: duplicated dict key 'node' inferred |
|
3838 | 3839 | [255] |
|
3839 | 3840 | $ hg log -r 0 -T '{dict(1 + 2)}' |
|
3840 | 3841 | hg: parse error: dict key cannot be inferred |
|
3841 | 3842 | [255] |
|
3842 | 3843 | |
|
3843 | 3844 | $ hg log -r 0 -T '{dict(x=rev, x=node)}' |
|
3844 | 3845 | hg: parse error: dict got multiple values for keyword argument 'x' |
|
3845 | 3846 | [255] |
|
3846 | 3847 | |
|
3847 | 3848 | Test get function: |
|
3848 | 3849 | |
|
3849 | 3850 | $ hg log -r 0 --template '{get(extras, "branch")}\n' |
|
3850 | 3851 | default |
|
3851 | 3852 | $ hg log -r 0 --template '{get(extras, "br{"anch"}")}\n' |
|
3852 | 3853 | default |
|
3853 | 3854 | $ hg log -r 0 --template '{get(files, "should_fail")}\n' |
|
3854 |
hg: parse error: |
|
|
3855 | hg: parse error: not a dictionary | |
|
3856 | (get() expects a dict as first argument) | |
|
3855 | 3857 | [255] |
|
3856 | 3858 | |
|
3857 | 3859 | Test json filter applied to hybrid object: |
|
3858 | 3860 | |
|
3859 | 3861 | $ hg log -r0 -T '{files|json}\n' |
|
3860 | 3862 | ["a"] |
|
3861 | 3863 | $ hg log -r0 -T '{extras|json}\n' |
|
3862 | 3864 | {"branch": "default"} |
|
3863 | 3865 | |
|
3864 | 3866 | Test json filter applied to map result: |
|
3865 | 3867 | |
|
3866 | 3868 | $ hg log -r0 -T '{json(extras % "{key}")}\n' |
|
3867 | 3869 | ["branch"] |
|
3868 | 3870 | |
|
3869 | 3871 | Test localdate(date, tz) function: |
|
3870 | 3872 | |
|
3871 | 3873 | $ TZ=JST-09 hg log -r0 -T '{date|localdate|isodate}\n' |
|
3872 | 3874 | 1970-01-01 09:00 +0900 |
|
3873 | 3875 | $ TZ=JST-09 hg log -r0 -T '{localdate(date, "UTC")|isodate}\n' |
|
3874 | 3876 | 1970-01-01 00:00 +0000 |
|
3875 | 3877 | $ TZ=JST-09 hg log -r0 -T '{localdate(date, "blahUTC")|isodate}\n' |
|
3876 | 3878 | hg: parse error: localdate expects a timezone |
|
3877 | 3879 | [255] |
|
3878 | 3880 | $ TZ=JST-09 hg log -r0 -T '{localdate(date, "+0200")|isodate}\n' |
|
3879 | 3881 | 1970-01-01 02:00 +0200 |
|
3880 | 3882 | $ TZ=JST-09 hg log -r0 -T '{localdate(date, "0")|isodate}\n' |
|
3881 | 3883 | 1970-01-01 00:00 +0000 |
|
3882 | 3884 | $ TZ=JST-09 hg log -r0 -T '{localdate(date, 0)|isodate}\n' |
|
3883 | 3885 | 1970-01-01 00:00 +0000 |
|
3884 | 3886 | $ hg log -r0 -T '{localdate(date, "invalid")|isodate}\n' |
|
3885 | 3887 | hg: parse error: localdate expects a timezone |
|
3886 | 3888 | [255] |
|
3887 | 3889 | $ hg log -r0 -T '{localdate(date, date)|isodate}\n' |
|
3888 | 3890 | hg: parse error: localdate expects a timezone |
|
3889 | 3891 | [255] |
|
3890 | 3892 | |
|
3891 | 3893 | Test shortest(node) function: |
|
3892 | 3894 | |
|
3893 | 3895 | $ echo b > b |
|
3894 | 3896 | $ hg ci -qAm b |
|
3895 | 3897 | $ hg log --template '{shortest(node)}\n' |
|
3896 | 3898 | e777 |
|
3897 | 3899 | bcc7 |
|
3898 | 3900 | f776 |
|
3899 | 3901 | $ hg log --template '{shortest(node, 10)}\n' |
|
3900 | 3902 | e777603221 |
|
3901 | 3903 | bcc7ff960b |
|
3902 | 3904 | f7769ec2ab |
|
3903 | 3905 | $ hg log --template '{node|shortest}\n' -l1 |
|
3904 | 3906 | e777 |
|
3905 | 3907 | |
|
3906 | 3908 | $ hg log -r 0 -T '{shortest(node, "1{"0"}")}\n' |
|
3907 | 3909 | f7769ec2ab |
|
3908 | 3910 | $ hg log -r 0 -T '{shortest(node, "not an int")}\n' |
|
3909 | 3911 | hg: parse error: shortest() expects an integer minlength |
|
3910 | 3912 | [255] |
|
3911 | 3913 | |
|
3912 | 3914 | $ hg log -r 'wdir()' -T '{node|shortest}\n' |
|
3913 | 3915 | ffff |
|
3914 | 3916 | |
|
3915 | 3917 | $ hg log --template '{shortest("f")}\n' -l1 |
|
3916 | 3918 | f |
|
3917 | 3919 | |
|
3918 | 3920 | $ hg log --template '{shortest("0123456789012345678901234567890123456789")}\n' -l1 |
|
3919 | 3921 | 0123456789012345678901234567890123456789 |
|
3920 | 3922 | |
|
3921 | 3923 | $ hg log --template '{shortest("01234567890123456789012345678901234567890123456789")}\n' -l1 |
|
3922 | 3924 | 01234567890123456789012345678901234567890123456789 |
|
3923 | 3925 | |
|
3924 | 3926 | $ hg log --template '{shortest("not a hex string")}\n' -l1 |
|
3925 | 3927 | not a hex string |
|
3926 | 3928 | |
|
3927 | 3929 | $ hg log --template '{shortest("not a hex string, but it'\''s 40 bytes long")}\n' -l1 |
|
3928 | 3930 | not a hex string, but it's 40 bytes long |
|
3929 | 3931 | |
|
3930 | 3932 | $ hg log --template '{shortest("ffffffffffffffffffffffffffffffffffffffff")}\n' -l1 |
|
3931 | 3933 | ffff |
|
3932 | 3934 | |
|
3933 | 3935 | $ hg log --template '{shortest("fffffff")}\n' -l1 |
|
3934 | 3936 | ffff |
|
3935 | 3937 | |
|
3936 | 3938 | $ hg log --template '{shortest("ff")}\n' -l1 |
|
3937 | 3939 | ffff |
|
3938 | 3940 | |
|
3939 | 3941 | $ cd .. |
|
3940 | 3942 | |
|
3941 | 3943 | Test shortest(node) with the repo having short hash collision: |
|
3942 | 3944 | |
|
3943 | 3945 | $ hg init hashcollision |
|
3944 | 3946 | $ cd hashcollision |
|
3945 | 3947 | $ cat <<EOF >> .hg/hgrc |
|
3946 | 3948 | > [experimental] |
|
3947 | 3949 | > evolution.createmarkers=True |
|
3948 | 3950 | > EOF |
|
3949 | 3951 | $ echo 0 > a |
|
3950 | 3952 | $ hg ci -qAm 0 |
|
3951 | 3953 | $ for i in 17 129 248 242 480 580 617 1057 2857 4025; do |
|
3952 | 3954 | > hg up -q 0 |
|
3953 | 3955 | > echo $i > a |
|
3954 | 3956 | > hg ci -qm $i |
|
3955 | 3957 | > done |
|
3956 | 3958 | $ hg up -q null |
|
3957 | 3959 | $ hg log -r0: -T '{rev}:{node}\n' |
|
3958 | 3960 | 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a |
|
3959 | 3961 | 1:11424df6dc1dd4ea255eae2b58eaca7831973bbc |
|
3960 | 3962 | 2:11407b3f1b9c3e76a79c1ec5373924df096f0499 |
|
3961 | 3963 | 3:11dd92fe0f39dfdaacdaa5f3997edc533875cfc4 |
|
3962 | 3964 | 4:10776689e627b465361ad5c296a20a487e153ca4 |
|
3963 | 3965 | 5:a00be79088084cb3aff086ab799f8790e01a976b |
|
3964 | 3966 | 6:a0b0acd79b4498d0052993d35a6a748dd51d13e6 |
|
3965 | 3967 | 7:a0457b3450b8e1b778f1163b31a435802987fe5d |
|
3966 | 3968 | 8:c56256a09cd28e5764f32e8e2810d0f01e2e357a |
|
3967 | 3969 | 9:c5623987d205cd6d9d8389bfc40fff9dbb670b48 |
|
3968 | 3970 | 10:c562ddd9c94164376c20b86b0b4991636a3bf84f |
|
3969 | 3971 | $ hg debugobsolete a00be79088084cb3aff086ab799f8790e01a976b |
|
3970 | 3972 | obsoleted 1 changesets |
|
3971 | 3973 | $ hg debugobsolete c5623987d205cd6d9d8389bfc40fff9dbb670b48 |
|
3972 | 3974 | obsoleted 1 changesets |
|
3973 | 3975 | $ hg debugobsolete c562ddd9c94164376c20b86b0b4991636a3bf84f |
|
3974 | 3976 | obsoleted 1 changesets |
|
3975 | 3977 | |
|
3976 | 3978 | nodes starting with '11' (we don't have the revision number '11' though) |
|
3977 | 3979 | |
|
3978 | 3980 | $ hg log -r 1:3 -T '{rev}:{shortest(node, 0)}\n' |
|
3979 | 3981 | 1:1142 |
|
3980 | 3982 | 2:1140 |
|
3981 | 3983 | 3:11d |
|
3982 | 3984 | |
|
3983 | 3985 | '5:a00' is hidden, but still we have two nodes starting with 'a0' |
|
3984 | 3986 | |
|
3985 | 3987 | $ hg log -r 6:7 -T '{rev}:{shortest(node, 0)}\n' |
|
3986 | 3988 | 6:a0b |
|
3987 | 3989 | 7:a04 |
|
3988 | 3990 | |
|
3989 | 3991 | node '10' conflicts with the revision number '10' even if it is hidden |
|
3990 | 3992 | (we could exclude hidden revision numbers, but currently we don't) |
|
3991 | 3993 | |
|
3992 | 3994 | $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' |
|
3993 | 3995 | 4:107 |
|
3994 | 3996 | $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden |
|
3995 | 3997 | 4:107 |
|
3996 | 3998 | |
|
3997 | 3999 | node 'c562' should be unique if the other 'c562' nodes are hidden |
|
3998 | 4000 | (but we don't try the slow path to filter out hidden nodes for now) |
|
3999 | 4001 | |
|
4000 | 4002 | $ hg log -r 8 -T '{rev}:{node|shortest}\n' |
|
4001 | 4003 | 8:c5625 |
|
4002 | 4004 | $ hg log -r 8:10 -T '{rev}:{node|shortest}\n' --hidden |
|
4003 | 4005 | 8:c5625 |
|
4004 | 4006 | 9:c5623 |
|
4005 | 4007 | 10:c562d |
|
4006 | 4008 | |
|
4007 | 4009 | $ cd .. |
|
4008 | 4010 | |
|
4009 | 4011 | Test pad function |
|
4010 | 4012 | |
|
4011 | 4013 | $ cd r |
|
4012 | 4014 | |
|
4013 | 4015 | $ hg log --template '{pad(rev, 20)} {author|user}\n' |
|
4014 | 4016 | 2 test |
|
4015 | 4017 | 1 {node|short} |
|
4016 | 4018 | 0 test |
|
4017 | 4019 | |
|
4018 | 4020 | $ hg log --template '{pad(rev, 20, " ", True)} {author|user}\n' |
|
4019 | 4021 | 2 test |
|
4020 | 4022 | 1 {node|short} |
|
4021 | 4023 | 0 test |
|
4022 | 4024 | |
|
4023 | 4025 | $ hg log --template '{pad(rev, 20, "-", False)} {author|user}\n' |
|
4024 | 4026 | 2------------------- test |
|
4025 | 4027 | 1------------------- {node|short} |
|
4026 | 4028 | 0------------------- test |
|
4027 | 4029 | |
|
4028 | 4030 | Test template string in pad function |
|
4029 | 4031 | |
|
4030 | 4032 | $ hg log -r 0 -T '{pad("\{{rev}}", 10)} {author|user}\n' |
|
4031 | 4033 | {0} test |
|
4032 | 4034 | |
|
4033 | 4035 | $ hg log -r 0 -T '{pad(r"\{rev}", 10)} {author|user}\n' |
|
4034 | 4036 | \{rev} test |
|
4035 | 4037 | |
|
4036 | 4038 | Test width argument passed to pad function |
|
4037 | 4039 | |
|
4038 | 4040 | $ hg log -r 0 -T '{pad(rev, "1{"0"}")} {author|user}\n' |
|
4039 | 4041 | 0 test |
|
4040 | 4042 | $ hg log -r 0 -T '{pad(rev, "not an int")}\n' |
|
4041 | 4043 | hg: parse error: pad() expects an integer width |
|
4042 | 4044 | [255] |
|
4043 | 4045 | |
|
4044 | 4046 | Test invalid fillchar passed to pad function |
|
4045 | 4047 | |
|
4046 | 4048 | $ hg log -r 0 -T '{pad(rev, 10, "")}\n' |
|
4047 | 4049 | hg: parse error: pad() expects a single fill character |
|
4048 | 4050 | [255] |
|
4049 | 4051 | $ hg log -r 0 -T '{pad(rev, 10, "--")}\n' |
|
4050 | 4052 | hg: parse error: pad() expects a single fill character |
|
4051 | 4053 | [255] |
|
4052 | 4054 | |
|
4053 | 4055 | Test boolean argument passed to pad function |
|
4054 | 4056 | |
|
4055 | 4057 | no crash |
|
4056 | 4058 | |
|
4057 | 4059 | $ hg log -r 0 -T '{pad(rev, 10, "-", "f{"oo"}")}\n' |
|
4058 | 4060 | ---------0 |
|
4059 | 4061 | |
|
4060 | 4062 | string/literal |
|
4061 | 4063 | |
|
4062 | 4064 | $ hg log -r 0 -T '{pad(rev, 10, "-", "false")}\n' |
|
4063 | 4065 | ---------0 |
|
4064 | 4066 | $ hg log -r 0 -T '{pad(rev, 10, "-", false)}\n' |
|
4065 | 4067 | 0--------- |
|
4066 | 4068 | $ hg log -r 0 -T '{pad(rev, 10, "-", "")}\n' |
|
4067 | 4069 | 0--------- |
|
4068 | 4070 | |
|
4069 | 4071 | unknown keyword is evaluated to '' |
|
4070 | 4072 | |
|
4071 | 4073 | $ hg log -r 0 -T '{pad(rev, 10, "-", unknownkeyword)}\n' |
|
4072 | 4074 | 0--------- |
|
4073 | 4075 | |
|
4074 | 4076 | Test separate function |
|
4075 | 4077 | |
|
4076 | 4078 | $ hg log -r 0 -T '{separate("-", "", "a", "b", "", "", "c", "")}\n' |
|
4077 | 4079 | a-b-c |
|
4078 | 4080 | $ hg log -r 0 -T '{separate(" ", "{rev}:{node|short}", author|user, branch)}\n' |
|
4079 | 4081 | 0:f7769ec2ab97 test default |
|
4080 | 4082 | $ hg log -r 0 --color=always -T '{separate(" ", "a", label(red, "b"), "c", label(red, ""), "d")}\n' |
|
4081 | 4083 | a \x1b[0;31mb\x1b[0m c d (esc) |
|
4082 | 4084 | |
|
4083 | 4085 | Test boolean expression/literal passed to if function |
|
4084 | 4086 | |
|
4085 | 4087 | $ hg log -r 0 -T '{if(rev, "rev 0 is True")}\n' |
|
4086 | 4088 | rev 0 is True |
|
4087 | 4089 | $ hg log -r 0 -T '{if(0, "literal 0 is True as well")}\n' |
|
4088 | 4090 | literal 0 is True as well |
|
4089 | 4091 | $ hg log -r 0 -T '{if("", "", "empty string is False")}\n' |
|
4090 | 4092 | empty string is False |
|
4091 | 4093 | $ hg log -r 0 -T '{if(revset(r"0 - 0"), "", "empty list is False")}\n' |
|
4092 | 4094 | empty list is False |
|
4093 | 4095 | $ hg log -r 0 -T '{if(true, "true is True")}\n' |
|
4094 | 4096 | true is True |
|
4095 | 4097 | $ hg log -r 0 -T '{if(false, "", "false is False")}\n' |
|
4096 | 4098 | false is False |
|
4097 | 4099 | $ hg log -r 0 -T '{if("false", "non-empty string is True")}\n' |
|
4098 | 4100 | non-empty string is True |
|
4099 | 4101 | |
|
4100 | 4102 | Test ifcontains function |
|
4101 | 4103 | |
|
4102 | 4104 | $ hg log --template '{rev} {ifcontains(rev, "2 two 0", "is in the string", "is not")}\n' |
|
4103 | 4105 | 2 is in the string |
|
4104 | 4106 | 1 is not |
|
4105 | 4107 | 0 is in the string |
|
4106 | 4108 | |
|
4107 | 4109 | $ hg log -T '{rev} {ifcontains(rev, "2 two{" 0"}", "is in the string", "is not")}\n' |
|
4108 | 4110 | 2 is in the string |
|
4109 | 4111 | 1 is not |
|
4110 | 4112 | 0 is in the string |
|
4111 | 4113 | |
|
4112 | 4114 | $ hg log --template '{rev} {ifcontains("a", file_adds, "added a", "did not add a")}\n' |
|
4113 | 4115 | 2 did not add a |
|
4114 | 4116 | 1 did not add a |
|
4115 | 4117 | 0 added a |
|
4116 | 4118 | |
|
4117 | 4119 | $ hg log --debug -T '{rev}{ifcontains(1, parents, " is parent of 1")}\n' |
|
4118 | 4120 | 2 is parent of 1 |
|
4119 | 4121 | 1 |
|
4120 | 4122 | 0 |
|
4121 | 4123 | |
|
4122 | 4124 | Test revset function |
|
4123 | 4125 | |
|
4124 | 4126 | $ hg log --template '{rev} {ifcontains(rev, revset("."), "current rev", "not current rev")}\n' |
|
4125 | 4127 | 2 current rev |
|
4126 | 4128 | 1 not current rev |
|
4127 | 4129 | 0 not current rev |
|
4128 | 4130 | |
|
4129 | 4131 | $ hg log --template '{rev} {ifcontains(rev, revset(". + .^"), "match rev", "not match rev")}\n' |
|
4130 | 4132 | 2 match rev |
|
4131 | 4133 | 1 match rev |
|
4132 | 4134 | 0 not match rev |
|
4133 | 4135 | |
|
4134 | 4136 | $ hg log -T '{ifcontains(desc, revset(":"), "", "type not match")}\n' -l1 |
|
4135 | 4137 | type not match |
|
4136 | 4138 | |
|
4137 | 4139 | $ hg log --template '{rev} Parents: {revset("parents(%s)", rev)}\n' |
|
4138 | 4140 | 2 Parents: 1 |
|
4139 | 4141 | 1 Parents: 0 |
|
4140 | 4142 | 0 Parents: |
|
4141 | 4143 | |
|
4142 | 4144 | $ cat >> .hg/hgrc <<EOF |
|
4143 | 4145 | > [revsetalias] |
|
4144 | 4146 | > myparents(\$1) = parents(\$1) |
|
4145 | 4147 | > EOF |
|
4146 | 4148 | $ hg log --template '{rev} Parents: {revset("myparents(%s)", rev)}\n' |
|
4147 | 4149 | 2 Parents: 1 |
|
4148 | 4150 | 1 Parents: 0 |
|
4149 | 4151 | 0 Parents: |
|
4150 | 4152 | |
|
4151 | 4153 | $ hg log --template 'Rev: {rev}\n{revset("::%s", rev) % "Ancestor: {revision}\n"}\n' |
|
4152 | 4154 | Rev: 2 |
|
4153 | 4155 | Ancestor: 0 |
|
4154 | 4156 | Ancestor: 1 |
|
4155 | 4157 | Ancestor: 2 |
|
4156 | 4158 | |
|
4157 | 4159 | Rev: 1 |
|
4158 | 4160 | Ancestor: 0 |
|
4159 | 4161 | Ancestor: 1 |
|
4160 | 4162 | |
|
4161 | 4163 | Rev: 0 |
|
4162 | 4164 | Ancestor: 0 |
|
4163 | 4165 | |
|
4164 | 4166 | $ hg log --template '{revset("TIP"|lower)}\n' -l1 |
|
4165 | 4167 | 2 |
|
4166 | 4168 | |
|
4167 | 4169 | $ hg log -T '{revset("%s", "t{"ip"}")}\n' -l1 |
|
4168 | 4170 | 2 |
|
4169 | 4171 | |
|
4170 | 4172 | a list template is evaluated for each item of revset/parents |
|
4171 | 4173 | |
|
4172 | 4174 | $ hg log -T '{rev} p: {revset("p1(%s)", rev) % "{rev}:{node|short}"}\n' |
|
4173 | 4175 | 2 p: 1:bcc7ff960b8e |
|
4174 | 4176 | 1 p: 0:f7769ec2ab97 |
|
4175 | 4177 | 0 p: |
|
4176 | 4178 | |
|
4177 | 4179 | $ hg log --debug -T '{rev} p:{parents % " {rev}:{node|short}"}\n' |
|
4178 | 4180 | 2 p: 1:bcc7ff960b8e -1:000000000000 |
|
4179 | 4181 | 1 p: 0:f7769ec2ab97 -1:000000000000 |
|
4180 | 4182 | 0 p: -1:000000000000 -1:000000000000 |
|
4181 | 4183 | |
|
4182 | 4184 | therefore, 'revcache' should be recreated for each rev |
|
4183 | 4185 | |
|
4184 | 4186 | $ hg log -T '{rev} {file_adds}\np {revset("p1(%s)", rev) % "{file_adds}"}\n' |
|
4185 | 4187 | 2 aa b |
|
4186 | 4188 | p |
|
4187 | 4189 | 1 |
|
4188 | 4190 | p a |
|
4189 | 4191 | 0 a |
|
4190 | 4192 | p |
|
4191 | 4193 | |
|
4192 | 4194 | $ hg log --debug -T '{rev} {file_adds}\np {parents % "{file_adds}"}\n' |
|
4193 | 4195 | 2 aa b |
|
4194 | 4196 | p |
|
4195 | 4197 | 1 |
|
4196 | 4198 | p a |
|
4197 | 4199 | 0 a |
|
4198 | 4200 | p |
|
4199 | 4201 | |
|
4200 | 4202 | a revset item must be evaluated as an integer revision, not an offset from tip |
|
4201 | 4203 | |
|
4202 | 4204 | $ hg log -l 1 -T '{revset("null") % "{rev}:{node|short}"}\n' |
|
4203 | 4205 | -1:000000000000 |
|
4204 | 4206 | $ hg log -l 1 -T '{revset("%s", "null") % "{rev}:{node|short}"}\n' |
|
4205 | 4207 | -1:000000000000 |
|
4206 | 4208 | |
|
4207 | 4209 | join() should pick '{rev}' from revset items: |
|
4208 | 4210 | |
|
4209 | 4211 | $ hg log -R ../a -T '{join(revset("parents(%d)", rev), ", ")}\n' -r6 |
|
4210 | 4212 | 4, 5 |
|
4211 | 4213 | |
|
4212 | 4214 | on the other hand, parents are formatted as '{rev}:{node|formatnode}' by |
|
4213 | 4215 | default. join() should agree with the default formatting: |
|
4214 | 4216 | |
|
4215 | 4217 | $ hg log -R ../a -T '{join(parents, ", ")}\n' -r6 |
|
4216 | 4218 | 5:13207e5a10d9, 4:bbe44766e73d |
|
4217 | 4219 | |
|
4218 | 4220 | $ hg log -R ../a -T '{join(parents, ",\n")}\n' -r6 --debug |
|
4219 | 4221 | 5:13207e5a10d9fd28ec424934298e176197f2c67f, |
|
4220 | 4222 | 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74 |
|
4221 | 4223 | |
|
4222 | 4224 | Invalid arguments passed to revset() |
|
4223 | 4225 | |
|
4224 | 4226 | $ hg log -T '{revset("%whatever", 0)}\n' |
|
4225 | 4227 | hg: parse error: unexpected revspec format character w |
|
4226 | 4228 | [255] |
|
4227 | 4229 | $ hg log -T '{revset("%lwhatever", files)}\n' |
|
4228 | 4230 | hg: parse error: unexpected revspec format character w |
|
4229 | 4231 | [255] |
|
4230 | 4232 | $ hg log -T '{revset("%s %s", 0)}\n' |
|
4231 | 4233 | hg: parse error: missing argument for revspec |
|
4232 | 4234 | [255] |
|
4233 | 4235 | $ hg log -T '{revset("", 0)}\n' |
|
4234 | 4236 | hg: parse error: too many revspec arguments specified |
|
4235 | 4237 | [255] |
|
4236 | 4238 | $ hg log -T '{revset("%s", 0, 1)}\n' |
|
4237 | 4239 | hg: parse error: too many revspec arguments specified |
|
4238 | 4240 | [255] |
|
4239 | 4241 | $ hg log -T '{revset("%", 0)}\n' |
|
4240 | 4242 | hg: parse error: incomplete revspec format character |
|
4241 | 4243 | [255] |
|
4242 | 4244 | $ hg log -T '{revset("%l", 0)}\n' |
|
4243 | 4245 | hg: parse error: incomplete revspec format character |
|
4244 | 4246 | [255] |
|
4245 | 4247 | $ hg log -T '{revset("%d", 'foo')}\n' |
|
4246 | 4248 | hg: parse error: invalid argument for revspec |
|
4247 | 4249 | [255] |
|
4248 | 4250 | $ hg log -T '{revset("%ld", files)}\n' |
|
4249 | 4251 | hg: parse error: invalid argument for revspec |
|
4250 | 4252 | [255] |
|
4251 | 4253 | $ hg log -T '{revset("%ls", 0)}\n' |
|
4252 | 4254 | hg: parse error: invalid argument for revspec |
|
4253 | 4255 | [255] |
|
4254 | 4256 | $ hg log -T '{revset("%b", 'foo')}\n' |
|
4255 | 4257 | hg: parse error: invalid argument for revspec |
|
4256 | 4258 | [255] |
|
4257 | 4259 | $ hg log -T '{revset("%lb", files)}\n' |
|
4258 | 4260 | hg: parse error: invalid argument for revspec |
|
4259 | 4261 | [255] |
|
4260 | 4262 | $ hg log -T '{revset("%r", 0)}\n' |
|
4261 | 4263 | hg: parse error: invalid argument for revspec |
|
4262 | 4264 | [255] |
|
4263 | 4265 | |
|
4264 | 4266 | Test 'originalnode' |
|
4265 | 4267 | |
|
4266 | 4268 | $ hg log -r 1 -T '{revset("null") % "{node|short} {originalnode|short}"}\n' |
|
4267 | 4269 | 000000000000 bcc7ff960b8e |
|
4268 | 4270 | $ hg log -r 0 -T '{manifest % "{node} {originalnode}"}\n' |
|
4269 | 4271 | a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 f7769ec2ab975ad19684098ad1ffd9b81ecc71a1 |
|
4270 | 4272 | |
|
4271 | 4273 | Test files function |
|
4272 | 4274 | |
|
4273 | 4275 | $ hg log -T "{rev}\n{join(files('*'), '\n')}\n" |
|
4274 | 4276 | 2 |
|
4275 | 4277 | a |
|
4276 | 4278 | aa |
|
4277 | 4279 | b |
|
4278 | 4280 | 1 |
|
4279 | 4281 | a |
|
4280 | 4282 | 0 |
|
4281 | 4283 | a |
|
4282 | 4284 | |
|
4283 | 4285 | $ hg log -T "{rev}\n{join(files('aa'), '\n')}\n" |
|
4284 | 4286 | 2 |
|
4285 | 4287 | aa |
|
4286 | 4288 | 1 |
|
4287 | 4289 | |
|
4288 | 4290 | 0 |
|
4289 | 4291 | |
|
4290 | 4292 | |
|
4291 | 4293 | Test relpath function |
|
4292 | 4294 | |
|
4293 | 4295 | $ hg log -r0 -T '{files % "{file|relpath}\n"}' |
|
4294 | 4296 | a |
|
4295 | 4297 | $ cd .. |
|
4296 | 4298 | $ hg log -R r -r0 -T '{files % "{file|relpath}\n"}' |
|
4297 | 4299 | r/a |
|
4298 | 4300 | $ cd r |
|
4299 | 4301 | |
|
4300 | 4302 | Test active bookmark templating |
|
4301 | 4303 | |
|
4302 | 4304 | $ hg book foo |
|
4303 | 4305 | $ hg book bar |
|
4304 | 4306 | $ hg log --template "{rev} {bookmarks % '{bookmark}{ifeq(bookmark, active, \"*\")} '}\n" |
|
4305 | 4307 | 2 bar* foo |
|
4306 | 4308 | 1 |
|
4307 | 4309 | 0 |
|
4308 | 4310 | $ hg log --template "{rev} {activebookmark}\n" |
|
4309 | 4311 | 2 bar |
|
4310 | 4312 | 1 |
|
4311 | 4313 | 0 |
|
4312 | 4314 | $ hg bookmarks --inactive bar |
|
4313 | 4315 | $ hg log --template "{rev} {activebookmark}\n" |
|
4314 | 4316 | 2 |
|
4315 | 4317 | 1 |
|
4316 | 4318 | 0 |
|
4317 | 4319 | $ hg book -r1 baz |
|
4318 | 4320 | $ hg log --template "{rev} {join(bookmarks, ' ')}\n" |
|
4319 | 4321 | 2 bar foo |
|
4320 | 4322 | 1 baz |
|
4321 | 4323 | 0 |
|
4322 | 4324 | $ hg log --template "{rev} {ifcontains('foo', bookmarks, 't', 'f')}\n" |
|
4323 | 4325 | 2 t |
|
4324 | 4326 | 1 f |
|
4325 | 4327 | 0 f |
|
4326 | 4328 | |
|
4327 | 4329 | Test namespaces dict |
|
4328 | 4330 | |
|
4329 | 4331 | $ hg --config extensions.revnamesext=$TESTDIR/revnamesext.py log -T '{rev}\n{namespaces % " {namespace} color={colorname} builtin={builtin}\n {join(names, ",")}\n"}\n' |
|
4330 | 4332 | 2 |
|
4331 | 4333 | bookmarks color=bookmark builtin=True |
|
4332 | 4334 | bar,foo |
|
4333 | 4335 | tags color=tag builtin=True |
|
4334 | 4336 | tip |
|
4335 | 4337 | branches color=branch builtin=True |
|
4336 | 4338 | text.{rev} |
|
4337 | 4339 | revnames color=revname builtin=False |
|
4338 | 4340 | r2 |
|
4339 | 4341 | |
|
4340 | 4342 | 1 |
|
4341 | 4343 | bookmarks color=bookmark builtin=True |
|
4342 | 4344 | baz |
|
4343 | 4345 | tags color=tag builtin=True |
|
4344 | 4346 | |
|
4345 | 4347 | branches color=branch builtin=True |
|
4346 | 4348 | text.{rev} |
|
4347 | 4349 | revnames color=revname builtin=False |
|
4348 | 4350 | r1 |
|
4349 | 4351 | |
|
4350 | 4352 | 0 |
|
4351 | 4353 | bookmarks color=bookmark builtin=True |
|
4352 | 4354 | |
|
4353 | 4355 | tags color=tag builtin=True |
|
4354 | 4356 | |
|
4355 | 4357 | branches color=branch builtin=True |
|
4356 | 4358 | default |
|
4357 | 4359 | revnames color=revname builtin=False |
|
4358 | 4360 | r0 |
|
4359 | 4361 | |
|
4360 | 4362 | $ hg log -r2 -T '{namespaces % "{namespace}: {names}\n"}' |
|
4361 | 4363 | bookmarks: bar foo |
|
4362 | 4364 | tags: tip |
|
4363 | 4365 | branches: text.{rev} |
|
4364 | 4366 | $ hg log -r2 -T '{namespaces % "{namespace}:\n{names % " {name}\n"}"}' |
|
4365 | 4367 | bookmarks: |
|
4366 | 4368 | bar |
|
4367 | 4369 | foo |
|
4368 | 4370 | tags: |
|
4369 | 4371 | tip |
|
4370 | 4372 | branches: |
|
4371 | 4373 | text.{rev} |
|
4372 | 4374 | $ hg log -r2 -T '{get(namespaces, "bookmarks") % "{name}\n"}' |
|
4373 | 4375 | bar |
|
4374 | 4376 | foo |
|
4375 | 4377 | $ hg log -r2 -T '{namespaces.bookmarks % "{bookmark}\n"}' |
|
4376 | 4378 | bar |
|
4377 | 4379 | foo |
|
4378 | 4380 | |
|
4379 | 4381 | Test stringify on sub expressions |
|
4380 | 4382 | |
|
4381 | 4383 | $ cd .. |
|
4382 | 4384 | $ hg log -R a -r 8 --template '{join(files, if("1", if("1", ", ")))}\n' |
|
4383 | 4385 | fourth, second, third |
|
4384 | 4386 | $ hg log -R a -r 8 --template '{strip(if("1", if("1", "-abc-")), if("1", if("1", "-")))}\n' |
|
4385 | 4387 | abc |
|
4386 | 4388 | |
|
4387 | 4389 | Test splitlines |
|
4388 | 4390 | |
|
4389 | 4391 | $ hg log -Gv -R a --template "{splitlines(desc) % 'foo {line}\n'}" |
|
4390 | 4392 | @ foo Modify, add, remove, rename |
|
4391 | 4393 | | |
|
4392 | 4394 | o foo future |
|
4393 | 4395 | | |
|
4394 | 4396 | o foo third |
|
4395 | 4397 | | |
|
4396 | 4398 | o foo second |
|
4397 | 4399 | |
|
4398 | 4400 | o foo merge |
|
4399 | 4401 | |\ |
|
4400 | 4402 | | o foo new head |
|
4401 | 4403 | | | |
|
4402 | 4404 | o | foo new branch |
|
4403 | 4405 | |/ |
|
4404 | 4406 | o foo no user, no domain |
|
4405 | 4407 | | |
|
4406 | 4408 | o foo no person |
|
4407 | 4409 | | |
|
4408 | 4410 | o foo other 1 |
|
4409 | 4411 | | foo other 2 |
|
4410 | 4412 | | foo |
|
4411 | 4413 | | foo other 3 |
|
4412 | 4414 | o foo line 1 |
|
4413 | 4415 | foo line 2 |
|
4414 | 4416 | |
|
4415 | 4417 | $ hg log -R a -r0 -T '{desc|splitlines}\n' |
|
4416 | 4418 | line 1 line 2 |
|
4417 | 4419 | $ hg log -R a -r0 -T '{join(desc|splitlines, "|")}\n' |
|
4418 | 4420 | line 1|line 2 |
|
4419 | 4421 | |
|
4420 | 4422 | Test startswith |
|
4421 | 4423 | $ hg log -Gv -R a --template "{startswith(desc)}" |
|
4422 | 4424 | hg: parse error: startswith expects two arguments |
|
4423 | 4425 | [255] |
|
4424 | 4426 | |
|
4425 | 4427 | $ hg log -Gv -R a --template "{startswith('line', desc)}" |
|
4426 | 4428 | @ |
|
4427 | 4429 | | |
|
4428 | 4430 | o |
|
4429 | 4431 | | |
|
4430 | 4432 | o |
|
4431 | 4433 | | |
|
4432 | 4434 | o |
|
4433 | 4435 | |
|
4434 | 4436 | o |
|
4435 | 4437 | |\ |
|
4436 | 4438 | | o |
|
4437 | 4439 | | | |
|
4438 | 4440 | o | |
|
4439 | 4441 | |/ |
|
4440 | 4442 | o |
|
4441 | 4443 | | |
|
4442 | 4444 | o |
|
4443 | 4445 | | |
|
4444 | 4446 | o |
|
4445 | 4447 | | |
|
4446 | 4448 | o line 1 |
|
4447 | 4449 | line 2 |
|
4448 | 4450 | |
|
4449 | 4451 | Test bad template with better error message |
|
4450 | 4452 | |
|
4451 | 4453 | $ hg log -Gv -R a --template '{desc|user()}' |
|
4452 | 4454 | hg: parse error: expected a symbol, got 'func' |
|
4453 | 4455 | [255] |
|
4454 | 4456 | |
|
4455 | 4457 | Test word function (including index out of bounds graceful failure) |
|
4456 | 4458 | |
|
4457 | 4459 | $ hg log -Gv -R a --template "{word('1', desc)}" |
|
4458 | 4460 | @ add, |
|
4459 | 4461 | | |
|
4460 | 4462 | o |
|
4461 | 4463 | | |
|
4462 | 4464 | o |
|
4463 | 4465 | | |
|
4464 | 4466 | o |
|
4465 | 4467 | |
|
4466 | 4468 | o |
|
4467 | 4469 | |\ |
|
4468 | 4470 | | o head |
|
4469 | 4471 | | | |
|
4470 | 4472 | o | branch |
|
4471 | 4473 | |/ |
|
4472 | 4474 | o user, |
|
4473 | 4475 | | |
|
4474 | 4476 | o person |
|
4475 | 4477 | | |
|
4476 | 4478 | o 1 |
|
4477 | 4479 | | |
|
4478 | 4480 | o 1 |
|
4479 | 4481 | |
|
4480 | 4482 | |
|
4481 | 4483 | Test word third parameter used as splitter |
|
4482 | 4484 | |
|
4483 | 4485 | $ hg log -Gv -R a --template "{word('0', desc, 'o')}" |
|
4484 | 4486 | @ M |
|
4485 | 4487 | | |
|
4486 | 4488 | o future |
|
4487 | 4489 | | |
|
4488 | 4490 | o third |
|
4489 | 4491 | | |
|
4490 | 4492 | o sec |
|
4491 | 4493 | |
|
4492 | 4494 | o merge |
|
4493 | 4495 | |\ |
|
4494 | 4496 | | o new head |
|
4495 | 4497 | | | |
|
4496 | 4498 | o | new branch |
|
4497 | 4499 | |/ |
|
4498 | 4500 | o n |
|
4499 | 4501 | | |
|
4500 | 4502 | o n |
|
4501 | 4503 | | |
|
4502 | 4504 | o |
|
4503 | 4505 | | |
|
4504 | 4506 | o line 1 |
|
4505 | 4507 | line 2 |
|
4506 | 4508 | |
|
4507 | 4509 | Test word error messages for not enough and too many arguments |
|
4508 | 4510 | |
|
4509 | 4511 | $ hg log -Gv -R a --template "{word('0')}" |
|
4510 | 4512 | hg: parse error: word expects two or three arguments, got 1 |
|
4511 | 4513 | [255] |
|
4512 | 4514 | |
|
4513 | 4515 | $ hg log -Gv -R a --template "{word('0', desc, 'o', 'h', 'b', 'o', 'y')}" |
|
4514 | 4516 | hg: parse error: word expects two or three arguments, got 7 |
|
4515 | 4517 | [255] |
|
4516 | 4518 | |
|
4517 | 4519 | Test word for integer literal |
|
4518 | 4520 | |
|
4519 | 4521 | $ hg log -R a --template "{word(2, desc)}\n" -r0 |
|
4520 | 4522 | line |
|
4521 | 4523 | |
|
4522 | 4524 | Test word for invalid numbers |
|
4523 | 4525 | |
|
4524 | 4526 | $ hg log -Gv -R a --template "{word('a', desc)}" |
|
4525 | 4527 | hg: parse error: word expects an integer index |
|
4526 | 4528 | [255] |
|
4527 | 4529 | |
|
4528 | 4530 | Test word for out of range |
|
4529 | 4531 | |
|
4530 | 4532 | $ hg log -R a --template "{word(10000, desc)}" |
|
4531 | 4533 | $ hg log -R a --template "{word(-10000, desc)}" |
|
4532 | 4534 | |
|
4533 | 4535 | Test indent and not adding to empty lines |
|
4534 | 4536 | |
|
4535 | 4537 | $ hg log -T "-----\n{indent(desc, '>> ', ' > ')}\n" -r 0:1 -R a |
|
4536 | 4538 | ----- |
|
4537 | 4539 | > line 1 |
|
4538 | 4540 | >> line 2 |
|
4539 | 4541 | ----- |
|
4540 | 4542 | > other 1 |
|
4541 | 4543 | >> other 2 |
|
4542 | 4544 | |
|
4543 | 4545 | >> other 3 |
|
4544 | 4546 | |
|
4545 | 4547 | Test with non-strings like dates |
|
4546 | 4548 | |
|
4547 | 4549 | $ hg log -T "{indent(date, ' ')}\n" -r 2:3 -R a |
|
4548 | 4550 | 1200000.00 |
|
4549 | 4551 | 1300000.00 |
|
4550 | 4552 | |
|
4551 | 4553 | Test broken string escapes: |
|
4552 | 4554 | |
|
4553 | 4555 | $ hg log -T "bogus\\" -R a |
|
4554 | 4556 | hg: parse error: trailing \ in string |
|
4555 | 4557 | [255] |
|
4556 | 4558 | $ hg log -T "\\xy" -R a |
|
4557 | 4559 | hg: parse error: invalid \x escape* (glob) |
|
4558 | 4560 | [255] |
|
4559 | 4561 | |
|
4560 | 4562 | json filter should escape HTML tags so that the output can be embedded in hgweb: |
|
4561 | 4563 | |
|
4562 | 4564 | $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1 |
|
4563 | 4565 | "\u003cfoo@example.org\u003e" |
|
4564 | 4566 | |
|
4565 | 4567 | Templater supports aliases of symbol and func() styles: |
|
4566 | 4568 | |
|
4567 | 4569 | $ hg clone -q a aliases |
|
4568 | 4570 | $ cd aliases |
|
4569 | 4571 | $ cat <<EOF >> .hg/hgrc |
|
4570 | 4572 | > [templatealias] |
|
4571 | 4573 | > r = rev |
|
4572 | 4574 | > rn = "{r}:{node|short}" |
|
4573 | 4575 | > status(c, files) = files % "{c} {file}\n" |
|
4574 | 4576 | > utcdate(d) = localdate(d, "UTC") |
|
4575 | 4577 | > EOF |
|
4576 | 4578 | |
|
4577 | 4579 | $ hg debugtemplate -vr0 '{rn} {utcdate(date)|isodate}\n' |
|
4578 | 4580 | (template |
|
4579 | 4581 | (symbol 'rn') |
|
4580 | 4582 | (string ' ') |
|
4581 | 4583 | (| |
|
4582 | 4584 | (func |
|
4583 | 4585 | (symbol 'utcdate') |
|
4584 | 4586 | (symbol 'date')) |
|
4585 | 4587 | (symbol 'isodate')) |
|
4586 | 4588 | (string '\n')) |
|
4587 | 4589 | * expanded: |
|
4588 | 4590 | (template |
|
4589 | 4591 | (template |
|
4590 | 4592 | (symbol 'rev') |
|
4591 | 4593 | (string ':') |
|
4592 | 4594 | (| |
|
4593 | 4595 | (symbol 'node') |
|
4594 | 4596 | (symbol 'short'))) |
|
4595 | 4597 | (string ' ') |
|
4596 | 4598 | (| |
|
4597 | 4599 | (func |
|
4598 | 4600 | (symbol 'localdate') |
|
4599 | 4601 | (list |
|
4600 | 4602 | (symbol 'date') |
|
4601 | 4603 | (string 'UTC'))) |
|
4602 | 4604 | (symbol 'isodate')) |
|
4603 | 4605 | (string '\n')) |
|
4604 | 4606 | 0:1e4e1b8f71e0 1970-01-12 13:46 +0000 |
|
4605 | 4607 | |
|
4606 | 4608 | $ hg debugtemplate -vr0 '{status("A", file_adds)}' |
|
4607 | 4609 | (template |
|
4608 | 4610 | (func |
|
4609 | 4611 | (symbol 'status') |
|
4610 | 4612 | (list |
|
4611 | 4613 | (string 'A') |
|
4612 | 4614 | (symbol 'file_adds')))) |
|
4613 | 4615 | * expanded: |
|
4614 | 4616 | (template |
|
4615 | 4617 | (% |
|
4616 | 4618 | (symbol 'file_adds') |
|
4617 | 4619 | (template |
|
4618 | 4620 | (string 'A') |
|
4619 | 4621 | (string ' ') |
|
4620 | 4622 | (symbol 'file') |
|
4621 | 4623 | (string '\n')))) |
|
4622 | 4624 | A a |
|
4623 | 4625 | |
|
4624 | 4626 | A unary function alias can be called as a filter: |
|
4625 | 4627 | |
|
4626 | 4628 | $ hg debugtemplate -vr0 '{date|utcdate|isodate}\n' |
|
4627 | 4629 | (template |
|
4628 | 4630 | (| |
|
4629 | 4631 | (| |
|
4630 | 4632 | (symbol 'date') |
|
4631 | 4633 | (symbol 'utcdate')) |
|
4632 | 4634 | (symbol 'isodate')) |
|
4633 | 4635 | (string '\n')) |
|
4634 | 4636 | * expanded: |
|
4635 | 4637 | (template |
|
4636 | 4638 | (| |
|
4637 | 4639 | (func |
|
4638 | 4640 | (symbol 'localdate') |
|
4639 | 4641 | (list |
|
4640 | 4642 | (symbol 'date') |
|
4641 | 4643 | (string 'UTC'))) |
|
4642 | 4644 | (symbol 'isodate')) |
|
4643 | 4645 | (string '\n')) |
|
4644 | 4646 | 1970-01-12 13:46 +0000 |
|
4645 | 4647 | |
|
4646 | 4648 | Aliases should be applied only to command arguments and templates in hgrc. |
|
4647 | 4649 | Otherwise, our stock styles and web templates could be corrupted: |
|
4648 | 4650 | |
|
4649 | 4651 | $ hg log -r0 -T '{rn} {utcdate(date)|isodate}\n' |
|
4650 | 4652 | 0:1e4e1b8f71e0 1970-01-12 13:46 +0000 |
|
4651 | 4653 | |
|
4652 | 4654 | $ hg log -r0 --config ui.logtemplate='"{rn} {utcdate(date)|isodate}\n"' |
|
4653 | 4655 | 0:1e4e1b8f71e0 1970-01-12 13:46 +0000 |
|
4654 | 4656 | |
|
4655 | 4657 | $ cat <<EOF > tmpl |
|
4656 | 4658 | > changeset = 'nothing expanded:{rn}\n' |
|
4657 | 4659 | > EOF |
|
4658 | 4660 | $ hg log -r0 --style ./tmpl |
|
4659 | 4661 | nothing expanded: |
|
4660 | 4662 | |
|
4661 | 4663 | Aliases in formatter: |
|
4662 | 4664 | |
|
4663 | 4665 | $ hg branches -T '{pad(branch, 7)} {rn}\n' |
|
4664 | 4666 | default 6:d41e714fe50d |
|
4665 | 4667 | foo 4:bbe44766e73d |
|
4666 | 4668 | |
|
4667 | 4669 | Aliases should honor HGPLAIN: |
|
4668 | 4670 | |
|
4669 | 4671 | $ HGPLAIN= hg log -r0 -T 'nothing expanded:{rn}\n' |
|
4670 | 4672 | nothing expanded: |
|
4671 | 4673 | $ HGPLAINEXCEPT=templatealias hg log -r0 -T '{rn}\n' |
|
4672 | 4674 | 0:1e4e1b8f71e0 |
|
4673 | 4675 | |
|
4674 | 4676 | Unparsable alias: |
|
4675 | 4677 | |
|
4676 | 4678 | $ hg debugtemplate --config templatealias.bad='x(' -v '{bad}' |
|
4677 | 4679 | (template |
|
4678 | 4680 | (symbol 'bad')) |
|
4679 | 4681 | abort: bad definition of template alias "bad": at 2: not a prefix: end |
|
4680 | 4682 | [255] |
|
4681 | 4683 | $ hg log --config templatealias.bad='x(' -T '{bad}' |
|
4682 | 4684 | abort: bad definition of template alias "bad": at 2: not a prefix: end |
|
4683 | 4685 | [255] |
|
4684 | 4686 | |
|
4685 | 4687 | $ cd .. |
|
4686 | 4688 | |
|
4687 | 4689 | Set up repository for non-ascii encoding tests: |
|
4688 | 4690 | |
|
4689 | 4691 | $ hg init nonascii |
|
4690 | 4692 | $ cd nonascii |
|
4691 | 4693 | $ $PYTHON <<EOF |
|
4692 | 4694 | > open('latin1', 'wb').write(b'\xe9') |
|
4693 | 4695 | > open('utf-8', 'wb').write(b'\xc3\xa9') |
|
4694 | 4696 | > EOF |
|
4695 | 4697 | $ HGENCODING=utf-8 hg branch -q `cat utf-8` |
|
4696 | 4698 | $ HGENCODING=utf-8 hg ci -qAm "non-ascii branch: `cat utf-8`" utf-8 |
|
4697 | 4699 | |
|
4698 | 4700 | json filter should try round-trip conversion to utf-8: |
|
4699 | 4701 | |
|
4700 | 4702 | $ HGENCODING=ascii hg log -T "{branch|json}\n" -r0 |
|
4701 | 4703 | "\u00e9" |
|
4702 | 4704 | $ HGENCODING=ascii hg log -T "{desc|json}\n" -r0 |
|
4703 | 4705 | "non-ascii branch: \u00e9" |
|
4704 | 4706 | |
|
4705 | 4707 | json filter should take input as utf-8 if it was converted from utf-8: |
|
4706 | 4708 | |
|
4707 | 4709 | $ HGENCODING=latin-1 hg log -T "{branch|json}\n" -r0 |
|
4708 | 4710 | "\u00e9" |
|
4709 | 4711 | $ HGENCODING=latin-1 hg log -T "{desc|json}\n" -r0 |
|
4710 | 4712 | "non-ascii branch: \u00e9" |
|
4711 | 4713 | |
|
4712 | 4714 | json filter takes input as utf-8b: |
|
4713 | 4715 | |
|
4714 | 4716 | $ HGENCODING=ascii hg log -T "{'`cat utf-8`'|json}\n" -l1 |
|
4715 | 4717 | "\u00e9" |
|
4716 | 4718 | $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1 |
|
4717 | 4719 | "\udce9" |
|
4718 | 4720 | |
|
4719 | 4721 | utf8 filter: |
|
4720 | 4722 | |
|
4721 | 4723 | $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0 |
|
4722 | 4724 | round-trip: c3a9 |
|
4723 | 4725 | $ HGENCODING=latin1 hg log -T "decoded: {'`cat latin1`'|utf8|hex}\n" -l1 |
|
4724 | 4726 | decoded: c3a9 |
|
4725 | 4727 | $ HGENCODING=ascii hg log -T "replaced: {'`cat latin1`'|utf8|hex}\n" -l1 |
|
4726 | 4728 | abort: decoding near * (glob) |
|
4727 | 4729 | [255] |
|
4728 | 4730 | $ hg log -T "coerced to string: {rev|utf8}\n" -r0 |
|
4729 | 4731 | coerced to string: 0 |
|
4730 | 4732 | |
|
4731 | 4733 | pad width: |
|
4732 | 4734 | |
|
4733 | 4735 | $ HGENCODING=utf-8 hg debugtemplate "{pad('`cat utf-8`', 2, '-')}\n" |
|
4734 | 4736 | \xc3\xa9- (esc) |
|
4735 | 4737 | |
|
4736 | 4738 | $ cd .. |
|
4737 | 4739 | |
|
4738 | 4740 | Test that template function in extension is registered as expected |
|
4739 | 4741 | |
|
4740 | 4742 | $ cd a |
|
4741 | 4743 | |
|
4742 | 4744 | $ cat <<EOF > $TESTTMP/customfunc.py |
|
4743 | 4745 | > from mercurial import registrar |
|
4744 | 4746 | > |
|
4745 | 4747 | > templatefunc = registrar.templatefunc() |
|
4746 | 4748 | > |
|
4747 | 4749 | > @templatefunc(b'custom()') |
|
4748 | 4750 | > def custom(context, mapping, args): |
|
4749 | 4751 | > return b'custom' |
|
4750 | 4752 | > EOF |
|
4751 | 4753 | $ cat <<EOF > .hg/hgrc |
|
4752 | 4754 | > [extensions] |
|
4753 | 4755 | > customfunc = $TESTTMP/customfunc.py |
|
4754 | 4756 | > EOF |
|
4755 | 4757 | |
|
4756 | 4758 | $ hg log -r . -T "{custom()}\n" --config customfunc.enabled=true |
|
4757 | 4759 | custom |
|
4758 | 4760 | |
|
4759 | 4761 | $ cd .. |
|
4760 | 4762 | |
|
4761 | 4763 | Test 'graphwidth' in 'hg log' on various topologies. The key here is that the |
|
4762 | 4764 | printed graphwidths 3, 5, 7, etc. should all line up in their respective |
|
4763 | 4765 | columns. We don't care about other aspects of the graph rendering here. |
|
4764 | 4766 | |
|
4765 | 4767 | $ hg init graphwidth |
|
4766 | 4768 | $ cd graphwidth |
|
4767 | 4769 | |
|
4768 | 4770 | $ wrappabletext="a a a a a a a a a a a a" |
|
4769 | 4771 | |
|
4770 | 4772 | $ printf "first\n" > file |
|
4771 | 4773 | $ hg add file |
|
4772 | 4774 | $ hg commit -m "$wrappabletext" |
|
4773 | 4775 | |
|
4774 | 4776 | $ printf "first\nsecond\n" > file |
|
4775 | 4777 | $ hg commit -m "$wrappabletext" |
|
4776 | 4778 | |
|
4777 | 4779 | $ hg checkout 0 |
|
4778 | 4780 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
4779 | 4781 | $ printf "third\nfirst\n" > file |
|
4780 | 4782 | $ hg commit -m "$wrappabletext" |
|
4781 | 4783 | created new head |
|
4782 | 4784 | |
|
4783 | 4785 | $ hg merge |
|
4784 | 4786 | merging file |
|
4785 | 4787 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
4786 | 4788 | (branch merge, don't forget to commit) |
|
4787 | 4789 | |
|
4788 | 4790 | $ hg log --graph -T "{graphwidth}" |
|
4789 | 4791 | @ 3 |
|
4790 | 4792 | | |
|
4791 | 4793 | | @ 5 |
|
4792 | 4794 | |/ |
|
4793 | 4795 | o 3 |
|
4794 | 4796 | |
|
4795 | 4797 | $ hg commit -m "$wrappabletext" |
|
4796 | 4798 | |
|
4797 | 4799 | $ hg log --graph -T "{graphwidth}" |
|
4798 | 4800 | @ 5 |
|
4799 | 4801 | |\ |
|
4800 | 4802 | | o 5 |
|
4801 | 4803 | | | |
|
4802 | 4804 | o | 5 |
|
4803 | 4805 | |/ |
|
4804 | 4806 | o 3 |
|
4805 | 4807 | |
|
4806 | 4808 | |
|
4807 | 4809 | $ hg checkout 0 |
|
4808 | 4810 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
4809 | 4811 | $ printf "third\nfirst\nsecond\n" > file |
|
4810 | 4812 | $ hg commit -m "$wrappabletext" |
|
4811 | 4813 | created new head |
|
4812 | 4814 | |
|
4813 | 4815 | $ hg log --graph -T "{graphwidth}" |
|
4814 | 4816 | @ 3 |
|
4815 | 4817 | | |
|
4816 | 4818 | | o 7 |
|
4817 | 4819 | | |\ |
|
4818 | 4820 | +---o 7 |
|
4819 | 4821 | | | |
|
4820 | 4822 | | o 5 |
|
4821 | 4823 | |/ |
|
4822 | 4824 | o 3 |
|
4823 | 4825 | |
|
4824 | 4826 | |
|
4825 | 4827 | $ hg log --graph -T "{graphwidth}" -r 3 |
|
4826 | 4828 | o 5 |
|
4827 | 4829 | |\ |
|
4828 | 4830 | ~ ~ |
|
4829 | 4831 | |
|
4830 | 4832 | $ hg log --graph -T "{graphwidth}" -r 1 |
|
4831 | 4833 | o 3 |
|
4832 | 4834 | | |
|
4833 | 4835 | ~ |
|
4834 | 4836 | |
|
4835 | 4837 | $ hg merge |
|
4836 | 4838 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
4837 | 4839 | (branch merge, don't forget to commit) |
|
4838 | 4840 | $ hg commit -m "$wrappabletext" |
|
4839 | 4841 | |
|
4840 | 4842 | $ printf "seventh\n" >> file |
|
4841 | 4843 | $ hg commit -m "$wrappabletext" |
|
4842 | 4844 | |
|
4843 | 4845 | $ hg log --graph -T "{graphwidth}" |
|
4844 | 4846 | @ 3 |
|
4845 | 4847 | | |
|
4846 | 4848 | o 5 |
|
4847 | 4849 | |\ |
|
4848 | 4850 | | o 5 |
|
4849 | 4851 | | | |
|
4850 | 4852 | o | 7 |
|
4851 | 4853 | |\ \ |
|
4852 | 4854 | | o | 7 |
|
4853 | 4855 | | |/ |
|
4854 | 4856 | o / 5 |
|
4855 | 4857 | |/ |
|
4856 | 4858 | o 3 |
|
4857 | 4859 | |
|
4858 | 4860 | |
|
4859 | 4861 | The point of graphwidth is to allow wrapping that accounts for the space taken |
|
4860 | 4862 | by the graph. |
|
4861 | 4863 | |
|
4862 | 4864 | $ COLUMNS=10 hg log --graph -T "{fill(desc, termwidth - graphwidth)}" |
|
4863 | 4865 | @ a a a a |
|
4864 | 4866 | | a a a a |
|
4865 | 4867 | | a a a a |
|
4866 | 4868 | o a a a |
|
4867 | 4869 | |\ a a a |
|
4868 | 4870 | | | a a a |
|
4869 | 4871 | | | a a a |
|
4870 | 4872 | | o a a a |
|
4871 | 4873 | | | a a a |
|
4872 | 4874 | | | a a a |
|
4873 | 4875 | | | a a a |
|
4874 | 4876 | o | a a |
|
4875 | 4877 | |\ \ a a |
|
4876 | 4878 | | | | a a |
|
4877 | 4879 | | | | a a |
|
4878 | 4880 | | | | a a |
|
4879 | 4881 | | | | a a |
|
4880 | 4882 | | o | a a |
|
4881 | 4883 | | |/ a a |
|
4882 | 4884 | | | a a |
|
4883 | 4885 | | | a a |
|
4884 | 4886 | | | a a |
|
4885 | 4887 | | | a a |
|
4886 | 4888 | o | a a a |
|
4887 | 4889 | |/ a a a |
|
4888 | 4890 | | a a a |
|
4889 | 4891 | | a a a |
|
4890 | 4892 | o a a a a |
|
4891 | 4893 | a a a a |
|
4892 | 4894 | a a a a |
|
4893 | 4895 | |
|
4894 | 4896 | Something tricky happens when there are elided nodes; the next drawn row of |
|
4895 | 4897 | edges can be more than one column wider, but the graph width only increases by |
|
4896 | 4898 | one column. The remaining columns are added in between the nodes. |
|
4897 | 4899 | |
|
4898 | 4900 | $ hg log --graph -T "{graphwidth}" -r "0|2|4|5" |
|
4899 | 4901 | o 5 |
|
4900 | 4902 | |\ |
|
4901 | 4903 | | \ |
|
4902 | 4904 | | :\ |
|
4903 | 4905 | o : : 7 |
|
4904 | 4906 | :/ / |
|
4905 | 4907 | : o 5 |
|
4906 | 4908 | :/ |
|
4907 | 4909 | o 3 |
|
4908 | 4910 | |
|
4909 | 4911 | |
|
4910 | 4912 | $ cd .. |
|
4911 | 4913 |
General Comments 0
You need to be logged in to leave comments.
Login now