Mercurial > hg
comparison mercurial/templatekw.py @ 17357:bd605568c5a0
templatekw: add p1rev, p1node, p2rev, p2node keywords
The {parents} template is cumbersome for some uses, as it does not show
anything if there's only one "natural" parent and you can't use it to get the
full 40 digit node hashes for parents unless you rely on the behavior of
the --debug flag.
Introduce four new template keywords: {p1rev}, {p2rev}, {p1node} and
{p2node}. The "node" flavors of these always show full 40 digit hashes,
but users can get the short version with a filter construction like
'{p1node|short}'.
author | epriestley <hg@yghe.net> |
---|---|
date | Tue, 10 Jul 2012 08:43:32 -0700 |
parents | 293dd81e4601 |
children | 2917f82f6040 |
comparison
equal
deleted
inserted
replaced
17354:c87ba0a6fb79 | 17357:bd605568c5a0 |
---|---|
273 """:node: String. The changeset identification hash, as a 40 hexadecimal | 273 """:node: String. The changeset identification hash, as a 40 hexadecimal |
274 digit string. | 274 digit string. |
275 """ | 275 """ |
276 return ctx.hex() | 276 return ctx.hex() |
277 | 277 |
278 def showp1rev(repo, ctx, templ, **args): | |
279 """:p1rev: Integer. The repository-local revision number of the changeset's | |
280 first parent, or -1 if the changeset has no parents.""" | |
281 return ctx.p1().rev() | |
282 | |
283 def showp2rev(repo, ctx, templ, **args): | |
284 """:p2rev: Integer. The repository-local revision number of the changeset's | |
285 second parent, or -1 if the changeset has no second parent.""" | |
286 return ctx.p2().rev() | |
287 | |
288 def showp1node(repo, ctx, templ, **args): | |
289 """:p1node: String. The identification hash of the changeset's first parent, | |
290 as a 40 digit hexadecimal string. If the changeset has no parents, all | |
291 digits are 0.""" | |
292 return ctx.p1().hex() | |
293 | |
294 def showp2node(repo, ctx, templ, **args): | |
295 """:p2node: String. The identification hash of the changeset's second | |
296 parent, as a 40 digit hexadecimal string. If the changeset has no second | |
297 parent, all digits are 0.""" | |
298 return ctx.p2().hex() | |
299 | |
278 def showphase(repo, ctx, templ, **args): | 300 def showphase(repo, ctx, templ, **args): |
279 """:phase: String. The changeset phase name.""" | 301 """:phase: String. The changeset phase name.""" |
280 return ctx.phasestr() | 302 return ctx.phasestr() |
281 | 303 |
282 def showphaseidx(repo, ctx, templ, **args): | 304 def showphaseidx(repo, ctx, templ, **args): |
318 'files': showfiles, | 340 'files': showfiles, |
319 'latesttag': showlatesttag, | 341 'latesttag': showlatesttag, |
320 'latesttagdistance': showlatesttagdistance, | 342 'latesttagdistance': showlatesttagdistance, |
321 'manifest': showmanifest, | 343 'manifest': showmanifest, |
322 'node': shownode, | 344 'node': shownode, |
345 'p1rev': showp1rev, | |
346 'p1node': showp1node, | |
347 'p2rev': showp2rev, | |
348 'p2node': showp2node, | |
323 'phase': showphase, | 349 'phase': showphase, |
324 'phaseidx': showphaseidx, | 350 'phaseidx': showphaseidx, |
325 'rev': showrev, | 351 'rev': showrev, |
326 'tags': showtags, | 352 'tags': showtags, |
327 } | 353 } |