Mercurial > hg
annotate mercurial/templatekw.py @ 42283:d137a3d5ad41
automation: add --version argument to build-all-windows-packages
This lets us pass a version string through when building all
Windows packages, just like we can do with the individual commands
which produce installers.
Differential Revision: https://phab.mercurial-scm.org/D6317
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 19 Apr 2019 09:18:23 -0700 |
parents | e9b9ee9af4a9 |
children | b47e9712000b |
rev | line source |
---|---|
10053
5c5c6295533d
cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
1 # templatekw.py - common changeset template keywords |
5c5c6295533d
cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
2 # |
5c5c6295533d
cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> |
5c5c6295533d
cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
4 # |
5c5c6295533d
cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10264 | 6 # GNU General Public License version 2 or any later version. |
10053
5c5c6295533d
cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
7 |
25984
c57509e88922
templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25740
diff
changeset
|
8 from __future__ import absolute_import |
c57509e88922
templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25740
diff
changeset
|
9 |
31807
e6eb86b154c5
templater: provide loop counter as "index" keyword
Yuya Nishihara <yuya@tcha.org>
parents:
31699
diff
changeset
|
10 from .i18n import _ |
32658
55ff67ffcead
scmutil: introduce binnode(ctx) as paired function with intrev(ctx)
Yuya Nishihara <yuya@tcha.org>
parents:
32656
diff
changeset
|
11 from .node import ( |
55ff67ffcead
scmutil: introduce binnode(ctx) as paired function with intrev(ctx)
Yuya Nishihara <yuya@tcha.org>
parents:
32656
diff
changeset
|
12 hex, |
55ff67ffcead
scmutil: introduce binnode(ctx) as paired function with intrev(ctx)
Yuya Nishihara <yuya@tcha.org>
parents:
32656
diff
changeset
|
13 nullid, |
39796
94ca3579e84e
log: fill in pseudo rev and node as wdir() manifest identifiers
Yuya Nishihara <yuya@tcha.org>
parents:
39623
diff
changeset
|
14 wdirid, |
94ca3579e84e
log: fill in pseudo rev and node as wdir() manifest identifiers
Yuya Nishihara <yuya@tcha.org>
parents:
39623
diff
changeset
|
15 wdirrev, |
32658
55ff67ffcead
scmutil: introduce binnode(ctx) as paired function with intrev(ctx)
Yuya Nishihara <yuya@tcha.org>
parents:
32656
diff
changeset
|
16 ) |
55ff67ffcead
scmutil: introduce binnode(ctx) as paired function with intrev(ctx)
Yuya Nishihara <yuya@tcha.org>
parents:
32656
diff
changeset
|
17 |
25984
c57509e88922
templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25740
diff
changeset
|
18 from . import ( |
38588
1c93e0237a24
diffutil: move the module out of utils package
Yuya Nishihara <yuya@tcha.org>
parents:
38587
diff
changeset
|
19 diffutil, |
28239
7279e0132347
templatekw: workaround for utf-8 round-trip of {desc}
Yuya Nishihara <yuya@tcha.org>
parents:
28178
diff
changeset
|
20 encoding, |
25984
c57509e88922
templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25740
diff
changeset
|
21 error, |
c57509e88922
templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25740
diff
changeset
|
22 hbisect, |
35212
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
23 i18n, |
32879
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
32658
diff
changeset
|
24 obsutil, |
25984
c57509e88922
templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25740
diff
changeset
|
25 patch, |
32972
26e710f0468f
py3: convert keys of kwargs in template keywords functions to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32970
diff
changeset
|
26 pycompat, |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
27 registrar, |
25984
c57509e88922
templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25740
diff
changeset
|
28 scmutil, |
36921
32f9b7e3f056
templater: move hybrid class and functions to templateutil module
Yuya Nishihara <yuya@tcha.org>
parents:
36634
diff
changeset
|
29 templateutil, |
25984
c57509e88922
templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25740
diff
changeset
|
30 util, |
c57509e88922
templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25740
diff
changeset
|
31 ) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37074
diff
changeset
|
32 from .utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37074
diff
changeset
|
33 stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37074
diff
changeset
|
34 ) |
10053
5c5c6295533d
cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
35 |
36921
32f9b7e3f056
templater: move hybrid class and functions to templateutil module
Yuya Nishihara <yuya@tcha.org>
parents:
36634
diff
changeset
|
36 _hybrid = templateutil.hybrid |
32f9b7e3f056
templater: move hybrid class and functions to templateutil module
Yuya Nishihara <yuya@tcha.org>
parents:
36634
diff
changeset
|
37 hybriddict = templateutil.hybriddict |
32f9b7e3f056
templater: move hybrid class and functions to templateutil module
Yuya Nishihara <yuya@tcha.org>
parents:
36634
diff
changeset
|
38 hybridlist = templateutil.hybridlist |
32f9b7e3f056
templater: move hybrid class and functions to templateutil module
Yuya Nishihara <yuya@tcha.org>
parents:
36634
diff
changeset
|
39 compatdict = templateutil.compatdict |
32f9b7e3f056
templater: move hybrid class and functions to templateutil module
Yuya Nishihara <yuya@tcha.org>
parents:
36634
diff
changeset
|
40 compatlist = templateutil.compatlist |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
41 _showcompatlist = templateutil._showcompatlist |
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
42 |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
43 def getlatesttags(context, mapping, pattern=None): |
10057
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
44 '''return date, distance and name for the latest tag of rev''' |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
45 repo = context.resource(mapping, 'repo') |
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
46 ctx = context.resource(mapping, 'ctx') |
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
47 cache = context.resource(mapping, 'cache') |
10057
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
48 |
26482
d2e69584e330
templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents:
26437
diff
changeset
|
49 cachename = 'latesttags' |
d2e69584e330
templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents:
26437
diff
changeset
|
50 if pattern is not None: |
d2e69584e330
templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents:
26437
diff
changeset
|
51 cachename += '-' + pattern |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37074
diff
changeset
|
52 match = stringutil.stringmatcher(pattern)[2] |
26482
d2e69584e330
templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents:
26437
diff
changeset
|
53 else: |
d2e69584e330
templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents:
26437
diff
changeset
|
54 match = util.always |
d2e69584e330
templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents:
26437
diff
changeset
|
55 |
d2e69584e330
templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents:
26437
diff
changeset
|
56 if cachename not in cache: |
10057
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
57 # Cache mapping from rev to a tuple with tag date, tag |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
58 # distance and tag name |
26482
d2e69584e330
templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents:
26437
diff
changeset
|
59 cache[cachename] = {-1: (0, 0, ['null'])} |
d2e69584e330
templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents:
26437
diff
changeset
|
60 latesttags = cache[cachename] |
10057
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
61 |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
62 rev = ctx.rev() |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
63 todo = [rev] |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
64 while todo: |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
65 rev = todo.pop() |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
66 if rev in latesttags: |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
67 continue |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
68 ctx = repo[rev] |
20218
0c22257388d6
templatekw: allow tagtypes other than global in getlatesttags
Andrew Shadura <andrew@shadura.me>
parents:
20183
diff
changeset
|
69 tags = [t for t in ctx.tags() |
26482
d2e69584e330
templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents:
26437
diff
changeset
|
70 if (repo.tagtype(t) and repo.tagtype(t) != 'local' |
d2e69584e330
templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents:
26437
diff
changeset
|
71 and match(t))] |
10057
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
72 if tags: |
25700
0fca47b206f6
templatekw: use a list of tags in getlatesttags() instead of joining them
Matt Harbison <matt_harbison@yahoo.com>
parents:
25663
diff
changeset
|
73 latesttags[rev] = ctx.date()[0], 0, [t for t in sorted(tags)] |
10057
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
74 continue |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
75 try: |
33862
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
76 ptags = [latesttags[p.rev()] for p in ctx.parents()] |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
77 if len(ptags) > 1: |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
78 if ptags[0][2] == ptags[1][2]: |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
79 # The tuples are laid out so the right one can be found by |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
80 # comparison in this case. |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
81 pdate, pdist, ptag = max(ptags) |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
82 else: |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
83 def key(x): |
41300
66102f6fa10a
templatekw: fix crash on multiple latesttags resolution at wdir (issue6055)
Yuya Nishihara <yuya@tcha.org>
parents:
41129
diff
changeset
|
84 tag = x[2][0] |
66102f6fa10a
templatekw: fix crash on multiple latesttags resolution at wdir (issue6055)
Yuya Nishihara <yuya@tcha.org>
parents:
41129
diff
changeset
|
85 if ctx.rev() is None: |
66102f6fa10a
templatekw: fix crash on multiple latesttags resolution at wdir (issue6055)
Yuya Nishihara <yuya@tcha.org>
parents:
41129
diff
changeset
|
86 # only() doesn't support wdir |
66102f6fa10a
templatekw: fix crash on multiple latesttags resolution at wdir (issue6055)
Yuya Nishihara <yuya@tcha.org>
parents:
41129
diff
changeset
|
87 prevs = [c.rev() for c in ctx.parents()] |
66102f6fa10a
templatekw: fix crash on multiple latesttags resolution at wdir (issue6055)
Yuya Nishihara <yuya@tcha.org>
parents:
41129
diff
changeset
|
88 changes = repo.revs('only(%ld, %s)', prevs, tag) |
66102f6fa10a
templatekw: fix crash on multiple latesttags resolution at wdir (issue6055)
Yuya Nishihara <yuya@tcha.org>
parents:
41129
diff
changeset
|
89 changessincetag = len(changes) + 1 |
66102f6fa10a
templatekw: fix crash on multiple latesttags resolution at wdir (issue6055)
Yuya Nishihara <yuya@tcha.org>
parents:
41129
diff
changeset
|
90 else: |
66102f6fa10a
templatekw: fix crash on multiple latesttags resolution at wdir (issue6055)
Yuya Nishihara <yuya@tcha.org>
parents:
41129
diff
changeset
|
91 changes = repo.revs('only(%d, %s)', ctx.rev(), tag) |
66102f6fa10a
templatekw: fix crash on multiple latesttags resolution at wdir (issue6055)
Yuya Nishihara <yuya@tcha.org>
parents:
41129
diff
changeset
|
92 changessincetag = len(changes) |
33862
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
93 # Smallest number of changes since tag wins. Date is |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
94 # used as tiebreaker. |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
95 return [-changessincetag, x[0]] |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
96 pdate, pdist, ptag = max(ptags, key=key) |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
97 else: |
fb672eac2702
templatekw: choose {latesttag} by len(changes), not date (issue5659)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33476
diff
changeset
|
98 pdate, pdist, ptag = ptags[0] |
10057
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
99 except KeyError: |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
100 # Cache miss - recurse |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
101 todo.append(rev) |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
102 todo.extend(p.rev() for p in ctx.parents()) |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
103 continue |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
104 latesttags[rev] = pdate, pdist + 1, ptag |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
105 return latesttags[rev] |
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
106 |
35212
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
107 def getlogcolumns(): |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
108 """Return a dict of log column labels""" |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
109 _ = pycompat.identity # temporarily disable gettext |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
110 # i18n: column positioning for "hg log" |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
111 columns = _('bookmark: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
112 'branch: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
113 'changeset: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
114 'copies: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
115 'date: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
116 'extra: %s=%s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
117 'files+: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
118 'files-: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
119 'files: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
120 'instability: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
121 'manifest: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
122 'obsolete: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
123 'parent: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
124 'phase: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
125 'summary: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
126 'tag: %s\n' |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
127 'user: %s\n') |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
128 return dict(zip([s.split(':', 1)[0] for s in columns.splitlines()], |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
129 i18n._(columns).splitlines(True))) |
c7b45db8f317
log: translate column labels at once (issue5750)
Yuya Nishihara <yuya@tcha.org>
parents:
35143
diff
changeset
|
130 |
40474
2891ee3fcb86
templatekw: extract internal "{rev}:{node|formatnode}" template to constant
Yuya Nishihara <yuya@tcha.org>
parents:
39796
diff
changeset
|
131 # basic internal templates |
2891ee3fcb86
templatekw: extract internal "{rev}:{node|formatnode}" template to constant
Yuya Nishihara <yuya@tcha.org>
parents:
39796
diff
changeset
|
132 _changeidtmpl = '{rev}:{node|formatnode}' |
2891ee3fcb86
templatekw: extract internal "{rev}:{node|formatnode}" template to constant
Yuya Nishihara <yuya@tcha.org>
parents:
39796
diff
changeset
|
133 |
31171
1ec89cf0ea49
templatekw: move defaulttmpl constant from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
134 # default templates internally used for rendering of lists |
1ec89cf0ea49
templatekw: move defaulttmpl constant from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
135 defaulttempl = { |
40474
2891ee3fcb86
templatekw: extract internal "{rev}:{node|formatnode}" template to constant
Yuya Nishihara <yuya@tcha.org>
parents:
39796
diff
changeset
|
136 'parent': _changeidtmpl + ' ', |
2891ee3fcb86
templatekw: extract internal "{rev}:{node|formatnode}" template to constant
Yuya Nishihara <yuya@tcha.org>
parents:
39796
diff
changeset
|
137 'manifest': _changeidtmpl, |
31171
1ec89cf0ea49
templatekw: move defaulttmpl constant from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
138 'file_copy': '{name} ({source})', |
1ec89cf0ea49
templatekw: move defaulttmpl constant from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
139 'envvar': '{key}={value}', |
1ec89cf0ea49
templatekw: move defaulttmpl constant from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
140 'extra': '{key}={value|stringescape}' |
1ec89cf0ea49
templatekw: move defaulttmpl constant from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
141 } |
1ec89cf0ea49
templatekw: move defaulttmpl constant from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
142 # filecopy is preserved for compatibility reasons |
1ec89cf0ea49
templatekw: move defaulttmpl constant from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
143 defaulttempl['filecopy'] = defaulttempl['file_copy'] |
1ec89cf0ea49
templatekw: move defaulttmpl constant from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
144 |
36445
e8d37838f5df
templatekw: add 'requires' flag to switch to exception-safe interface
Yuya Nishihara <yuya@tcha.org>
parents:
36442
diff
changeset
|
145 # keywords are callables (see registrar.templatekeyword for details) |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
146 keywords = {} |
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
147 templatekeyword = registrar.templatekeyword(keywords) |
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
148 |
36445
e8d37838f5df
templatekw: add 'requires' flag to switch to exception-safe interface
Yuya Nishihara <yuya@tcha.org>
parents:
36442
diff
changeset
|
149 @templatekeyword('author', requires={'ctx'}) |
e8d37838f5df
templatekw: add 'requires' flag to switch to exception-safe interface
Yuya Nishihara <yuya@tcha.org>
parents:
36442
diff
changeset
|
150 def showauthor(context, mapping): |
38948
390287321b4b
templatekw: copy {author} to {user} and document {author} as an alias
Yuya Nishihara <yuya@tcha.org>
parents:
38774
diff
changeset
|
151 """Alias for ``{user}``""" |
390287321b4b
templatekw: copy {author} to {user} and document {author} as an alias
Yuya Nishihara <yuya@tcha.org>
parents:
38774
diff
changeset
|
152 return showuser(context, mapping) |
10054
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10053
diff
changeset
|
153 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
154 @templatekeyword('bisect', requires={'repo', 'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
155 def showbisect(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
156 """String. The changeset bisection status.""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
157 repo = context.resource(mapping, 'repo') |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
158 ctx = context.resource(mapping, 'ctx') |
15155
f4a8d754cd0a
templates: add 'bisect' keyword to return a cset's bisect status
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
14437
diff
changeset
|
159 return hbisect.label(repo, ctx.node()) |
f4a8d754cd0a
templates: add 'bisect' keyword to return a cset's bisect status
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
14437
diff
changeset
|
160 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
161 @templatekeyword('branch', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
162 def showbranch(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
163 """String. The name of the branch on which the changeset was |
13585
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
164 committed. |
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
165 """ |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
166 ctx = context.resource(mapping, 'ctx') |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
167 return ctx.branch() |
13156
d79fdff55627
template: add showbranch template for {branch}
Eric Eisner <ede@mit.edu>
parents:
13114
diff
changeset
|
168 |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
169 @templatekeyword('branches', requires={'ctx'}) |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
170 def showbranches(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
171 """List of strings. The name of the branch on which the |
13585
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
172 changeset was committed. Will be empty if the branch name was |
26437
4628b26f040e
templatekw: hide help of "branches" by DEPRECATED marker
Yuya Nishihara <yuya@tcha.org>
parents:
26436
diff
changeset
|
173 default. (DEPRECATED) |
13585
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
174 """ |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
175 ctx = context.resource(mapping, 'ctx') |
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
176 branch = ctx.branch() |
10054
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10053
diff
changeset
|
177 if branch != 'default': |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
178 return compatlist(context, mapping, 'branch', [branch], |
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
179 plural='branches') |
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
180 return compatlist(context, mapping, 'branch', [], plural='branches') |
10054
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10053
diff
changeset
|
181 |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
182 @templatekeyword('bookmarks', requires={'repo', 'ctx'}) |
36598
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36597
diff
changeset
|
183 def showbookmarks(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
184 """List of strings. Any bookmarks associated with the |
25348
f26efa4f0eff
templatekw: introduce active subkeyword from bookmarks keyword
Ryan McElroy <rmcelroy@fb.com>
parents:
25013
diff
changeset
|
185 changeset. Also sets 'active', the name of the active bookmark. |
13592
ad2ee188f4a5
templates: document missing keywords or filters
Patrick Mezard <pmezard@gmail.com>
parents:
13585
diff
changeset
|
186 """ |
36598
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36597
diff
changeset
|
187 repo = context.resource(mapping, 'repo') |
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36597
diff
changeset
|
188 ctx = context.resource(mapping, 'ctx') |
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36597
diff
changeset
|
189 bookmarks = ctx.bookmarks() |
25348
f26efa4f0eff
templatekw: introduce active subkeyword from bookmarks keyword
Ryan McElroy <rmcelroy@fb.com>
parents:
25013
diff
changeset
|
190 active = repo._activebookmark |
f26efa4f0eff
templatekw: introduce active subkeyword from bookmarks keyword
Ryan McElroy <rmcelroy@fb.com>
parents:
25013
diff
changeset
|
191 makemap = lambda v: {'bookmark': v, 'active': active, 'current': active} |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
192 f = _showcompatlist(context, mapping, 'bookmark', bookmarks) |
34328
dd28b1f55eb8
templatekw: just pass underlying value (or key) to joinfmt() function
Yuya Nishihara <yuya@tcha.org>
parents:
34327
diff
changeset
|
193 return _hybrid(f, bookmarks, makemap, pycompat.identity) |
13386
f78bc5ddbe4f
templater: add bookmarks to templates and default output
David Soria Parra <dsp@php.net>
parents:
13156
diff
changeset
|
194 |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
195 @templatekeyword('children', requires={'ctx'}) |
36521
c3692364b344
templatekw: add compatlist() as a replacement for showlist()
Yuya Nishihara <yuya@tcha.org>
parents:
36520
diff
changeset
|
196 def showchildren(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
197 """List of strings. The children of the changeset.""" |
36521
c3692364b344
templatekw: add compatlist() as a replacement for showlist()
Yuya Nishihara <yuya@tcha.org>
parents:
36520
diff
changeset
|
198 ctx = context.resource(mapping, 'ctx') |
36401
d65642840c6f
templatekw: use ctx.rev() instead of casting context to int
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36247
diff
changeset
|
199 childrevs = ['%d:%s' % (cctx.rev(), cctx) for cctx in ctx.children()] |
36521
c3692364b344
templatekw: add compatlist() as a replacement for showlist()
Yuya Nishihara <yuya@tcha.org>
parents:
36520
diff
changeset
|
200 return compatlist(context, mapping, 'children', childrevs, element='child') |
11655
6faf015e0ba0
templates: 'children' keyword
Jason Harris <jason@jasonfharris.com>
parents:
10394
diff
changeset
|
201 |
25013
277aba2c151a
templatekw: introduce activebookmark keyword
Ryan McElroy <rmcelroy@fb.com>
parents:
25012
diff
changeset
|
202 # Deprecated, but kept alive for help generation a purpose. |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
203 @templatekeyword('currentbookmark', requires={'repo', 'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
204 def showcurrentbookmark(context, mapping): |
34656
eb7fffdc6e5b
help: fix formatting of template keywords
Yuya Nishihara <yuya@tcha.org>
parents:
34581
diff
changeset
|
205 """String. The active bookmark, if it is associated with the changeset. |
eb7fffdc6e5b
help: fix formatting of template keywords
Yuya Nishihara <yuya@tcha.org>
parents:
34581
diff
changeset
|
206 (DEPRECATED)""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
207 return showactivebookmark(context, mapping) |
25013
277aba2c151a
templatekw: introduce activebookmark keyword
Ryan McElroy <rmcelroy@fb.com>
parents:
25012
diff
changeset
|
208 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
209 @templatekeyword('activebookmark', requires={'repo', 'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
210 def showactivebookmark(context, mapping): |
34656
eb7fffdc6e5b
help: fix formatting of template keywords
Yuya Nishihara <yuya@tcha.org>
parents:
34581
diff
changeset
|
211 """String. The active bookmark, if it is associated with the changeset.""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
212 repo = context.resource(mapping, 'repo') |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
213 ctx = context.resource(mapping, 'ctx') |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
214 active = repo._activebookmark |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
215 if active and active in ctx.bookmarks(): |
25387
390a10b7843b
templatekw: display active bookmark more consistently (issue4552) (BC)
Ryan McElroy <rmcelroy@fb.com>
parents:
25348
diff
changeset
|
216 return active |
21896
2b41ee1b5ea1
templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20683
diff
changeset
|
217 return '' |
2b41ee1b5ea1
templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20683
diff
changeset
|
218 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
219 @templatekeyword('date', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
220 def showdate(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
221 """Date information. The date when the changeset was committed.""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
222 ctx = context.resource(mapping, 'ctx') |
38299
88e7105b5cd9
templater: restore the original string format of {date}
Yuya Nishihara <yuya@tcha.org>
parents:
38285
diff
changeset
|
223 # the default string format is '<float(unixtime)><tzoffset>' because |
88e7105b5cd9
templater: restore the original string format of {date}
Yuya Nishihara <yuya@tcha.org>
parents:
38285
diff
changeset
|
224 # python-hglib splits date at decimal separator. |
88e7105b5cd9
templater: restore the original string format of {date}
Yuya Nishihara <yuya@tcha.org>
parents:
38285
diff
changeset
|
225 return templateutil.date(ctx.date(), showfmt='%d.0%d') |
10054
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10053
diff
changeset
|
226 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
227 @templatekeyword('desc', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
228 def showdescription(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
229 """String. The text of the changeset description.""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
230 ctx = context.resource(mapping, 'ctx') |
28239
7279e0132347
templatekw: workaround for utf-8 round-trip of {desc}
Yuya Nishihara <yuya@tcha.org>
parents:
28178
diff
changeset
|
231 s = ctx.description() |
7279e0132347
templatekw: workaround for utf-8 round-trip of {desc}
Yuya Nishihara <yuya@tcha.org>
parents:
28178
diff
changeset
|
232 if isinstance(s, encoding.localstr): |
7279e0132347
templatekw: workaround for utf-8 round-trip of {desc}
Yuya Nishihara <yuya@tcha.org>
parents:
28178
diff
changeset
|
233 # try hard to preserve utf-8 bytes |
7279e0132347
templatekw: workaround for utf-8 round-trip of {desc}
Yuya Nishihara <yuya@tcha.org>
parents:
28178
diff
changeset
|
234 return encoding.tolocal(encoding.fromlocal(s).strip()) |
37947
3ea3c96ada54
encoding: introduce tagging type for non-lossy non-ASCII string
Yuya Nishihara <yuya@tcha.org>
parents:
37908
diff
changeset
|
235 elif isinstance(s, encoding.safelocalstr): |
3ea3c96ada54
encoding: introduce tagging type for non-lossy non-ASCII string
Yuya Nishihara <yuya@tcha.org>
parents:
37908
diff
changeset
|
236 return encoding.safelocalstr(s.strip()) |
28239
7279e0132347
templatekw: workaround for utf-8 round-trip of {desc}
Yuya Nishihara <yuya@tcha.org>
parents:
28178
diff
changeset
|
237 else: |
7279e0132347
templatekw: workaround for utf-8 round-trip of {desc}
Yuya Nishihara <yuya@tcha.org>
parents:
28178
diff
changeset
|
238 return s.strip() |
10054
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10053
diff
changeset
|
239 |
38583
4bc96c755c17
templatekw: obtain ui directly from the template context
Yuya Nishihara <yuya@tcha.org>
parents:
38564
diff
changeset
|
240 @templatekeyword('diffstat', requires={'ui', 'ctx'}) |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
241 def showdiffstat(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
242 """String. Statistics of changes with the following format: |
13585
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
243 "modified files: +added/-removed lines" |
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
244 """ |
38583
4bc96c755c17
templatekw: obtain ui directly from the template context
Yuya Nishihara <yuya@tcha.org>
parents:
38564
diff
changeset
|
245 ui = context.resource(mapping, 'ui') |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
246 ctx = context.resource(mapping, 'ctx') |
38587
b62000a28812
diffutil: remove diffopts() in favor of diffallopts()
Yuya Nishihara <yuya@tcha.org>
parents:
38583
diff
changeset
|
247 diffopts = diffutil.diffallopts(ui, {'noprefix': False}) |
38564
64f15e22f4f8
template: directly instantiate diff options for diffstat
Boris Feld <boris.feld@octobus.net>
parents:
38555
diff
changeset
|
248 diff = ctx.diff(opts=diffopts) |
38519
4455e5d4d59c
context: explicitly take diffopts in `context.diff` (API)
Boris Feld <boris.feld@octobus.net>
parents:
38306
diff
changeset
|
249 stats = patch.diffstatdata(util.iterlines(diff)) |
14437
cbe13e6bdc34
patch: restore the previous output of 'diff --stat'
Steven Brown <StevenGBrown@gmail.com>
parents:
14403
diff
changeset
|
250 maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats) |
36499
77f681f11003
py3: use '%d' to format diffstat sum
Yuya Nishihara <yuya@tcha.org>
parents:
36456
diff
changeset
|
251 return '%d: +%d/-%d' % (len(stats), adds, removes) |
10055
e400a511e63a
cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10054
diff
changeset
|
252 |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
253 @templatekeyword('envvars', requires={'ui'}) |
36520
a7fbe11a5d59
templatekw: add compatdict() as a replacement for showdict()
Yuya Nishihara <yuya@tcha.org>
parents:
36519
diff
changeset
|
254 def showenvvars(context, mapping): |
30833
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
30811
diff
changeset
|
255 """A dictionary of environment variables. (EXPERIMENTAL)""" |
36520
a7fbe11a5d59
templatekw: add compatdict() as a replacement for showdict()
Yuya Nishihara <yuya@tcha.org>
parents:
36519
diff
changeset
|
256 ui = context.resource(mapping, 'ui') |
36442
e46b24582fa0
templatekw: minimize resource dependency of {envvars} and {termwidth}
Yuya Nishihara <yuya@tcha.org>
parents:
36441
diff
changeset
|
257 env = ui.exportableenviron() |
30833
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
30811
diff
changeset
|
258 env = util.sortdict((k, env[k]) for k in sorted(env)) |
36520
a7fbe11a5d59
templatekw: add compatdict() as a replacement for showdict()
Yuya Nishihara <yuya@tcha.org>
parents:
36519
diff
changeset
|
259 return compatdict(context, mapping, 'envvar', env, plural='envvars') |
30833
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
30811
diff
changeset
|
260 |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
261 @templatekeyword('extras', requires={'ctx'}) |
36598
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36597
diff
changeset
|
262 def showextras(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
263 """List of dicts with key, value entries of the 'extras' |
20015
ad27cdacc743
help: document about {extras} template keyword
Matthew Turk <matthewturk@gmail.com>
parents:
18970
diff
changeset
|
264 field of this changeset.""" |
36598
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36597
diff
changeset
|
265 ctx = context.resource(mapping, 'ctx') |
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36597
diff
changeset
|
266 extras = ctx.extra() |
24237
9ad02823dc5b
templatekw: convert list of key/value pairs to sortdict
Yuya Nishihara <yuya@tcha.org>
parents:
24157
diff
changeset
|
267 extras = util.sortdict((k, extras[k]) for k in sorted(extras)) |
24238
49cee6d8573d
templatekw: give name to lambda that constructs variables map of templater
Yuya Nishihara <yuya@tcha.org>
parents:
24237
diff
changeset
|
268 makemap = lambda k: {'key': k, 'value': extras[k]} |
49cee6d8573d
templatekw: give name to lambda that constructs variables map of templater
Yuya Nishihara <yuya@tcha.org>
parents:
24237
diff
changeset
|
269 c = [makemap(k) for k in extras] |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
270 f = _showcompatlist(context, mapping, 'extra', c, plural='extras') |
24239
31f9b1b16d1e
templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents:
24238
diff
changeset
|
271 return _hybrid(f, extras, makemap, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37074
diff
changeset
|
272 lambda k: '%s=%s' % (k, stringutil.escapestr(extras[k]))) |
10054
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10053
diff
changeset
|
273 |
39599
a5da906306c9
templatekw: add option to include ignored/clean/unknown files in cache
Yuya Nishihara <yuya@tcha.org>
parents:
39598
diff
changeset
|
274 def _getfilestatus(context, mapping, listall=False): |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
275 ctx = context.resource(mapping, 'ctx') |
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
276 revcache = context.resource(mapping, 'revcache') |
39599
a5da906306c9
templatekw: add option to include ignored/clean/unknown files in cache
Yuya Nishihara <yuya@tcha.org>
parents:
39598
diff
changeset
|
277 if 'filestatus' not in revcache or revcache['filestatusall'] < listall: |
a5da906306c9
templatekw: add option to include ignored/clean/unknown files in cache
Yuya Nishihara <yuya@tcha.org>
parents:
39598
diff
changeset
|
278 stat = ctx.p1().status(ctx, listignored=listall, listclean=listall, |
a5da906306c9
templatekw: add option to include ignored/clean/unknown files in cache
Yuya Nishihara <yuya@tcha.org>
parents:
39598
diff
changeset
|
279 listunknown=listall) |
a5da906306c9
templatekw: add option to include ignored/clean/unknown files in cache
Yuya Nishihara <yuya@tcha.org>
parents:
39598
diff
changeset
|
280 revcache['filestatus'] = stat |
a5da906306c9
templatekw: add option to include ignored/clean/unknown files in cache
Yuya Nishihara <yuya@tcha.org>
parents:
39598
diff
changeset
|
281 revcache['filestatusall'] = listall |
39598
42209f55c599
templatekw: keep status tuple in cache dict and rename cache key accordingly
Yuya Nishihara <yuya@tcha.org>
parents:
39597
diff
changeset
|
282 return revcache['filestatus'] |
39597
164827563426
templatekw: extract function that computes and caches file status
Yuya Nishihara <yuya@tcha.org>
parents:
39587
diff
changeset
|
283 |
39600
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
284 def _getfilestatusmap(context, mapping, listall=False): |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
285 revcache = context.resource(mapping, 'revcache') |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
286 if 'filestatusmap' not in revcache or revcache['filestatusall'] < listall: |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
287 stat = _getfilestatus(context, mapping, listall=listall) |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
288 revcache['filestatusmap'] = statmap = {} |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
289 for char, files in zip(pycompat.iterbytestr('MAR!?IC'), stat): |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
290 statmap.update((f, char) for f in files) |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
291 return revcache['filestatusmap'] # {path: statchar} |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
292 |
39597
164827563426
templatekw: extract function that computes and caches file status
Yuya Nishihara <yuya@tcha.org>
parents:
39587
diff
changeset
|
293 def _showfilesbystat(context, mapping, name, index): |
164827563426
templatekw: extract function that computes and caches file status
Yuya Nishihara <yuya@tcha.org>
parents:
39587
diff
changeset
|
294 stat = _getfilestatus(context, mapping) |
164827563426
templatekw: extract function that computes and caches file status
Yuya Nishihara <yuya@tcha.org>
parents:
39587
diff
changeset
|
295 files = stat[index] |
39367
83f8f7b9fa60
templatekw: alias {file} of files list to {path}
Yuya Nishihara <yuya@tcha.org>
parents:
38948
diff
changeset
|
296 return templateutil.compatfileslist(context, mapping, name, files) |
36515
e71a3c0a90b0
templatekw: factor out function to build a list of files per status
Yuya Nishihara <yuya@tcha.org>
parents:
36514
diff
changeset
|
297 |
38774
87a581d1391c
templatekw: use ctx1.status(ctx2) instead of repo.status(ctx1, ctx2)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38588
diff
changeset
|
298 @templatekeyword('file_adds', requires={'ctx', 'revcache'}) |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
299 def showfileadds(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
300 """List of strings. Files added by this changeset.""" |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
301 return _showfilesbystat(context, mapping, 'file_add', 1) |
10056
1a114aca93fa
cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10055
diff
changeset
|
302 |
36590
0083e373e5f5
templatekw: switch showdict template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36574
diff
changeset
|
303 @templatekeyword('file_copies', |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
304 requires={'repo', 'ctx', 'cache', 'revcache'}) |
36590
0083e373e5f5
templatekw: switch showdict template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36574
diff
changeset
|
305 def showfilecopies(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
306 """List of strings. Files copied in this changeset with |
13585
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
307 their sources. |
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
308 """ |
36590
0083e373e5f5
templatekw: switch showdict template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36574
diff
changeset
|
309 repo = context.resource(mapping, 'repo') |
0083e373e5f5
templatekw: switch showdict template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36574
diff
changeset
|
310 ctx = context.resource(mapping, 'ctx') |
0083e373e5f5
templatekw: switch showdict template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36574
diff
changeset
|
311 cache = context.resource(mapping, 'cache') |
0083e373e5f5
templatekw: switch showdict template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36574
diff
changeset
|
312 copies = context.resource(mapping, 'revcache').get('copies') |
10060
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10058
diff
changeset
|
313 if copies is None: |
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10058
diff
changeset
|
314 if 'getrenamed' not in cache: |
41781
e9b9ee9af4a9
templatekw: move getrenamedfn() to scmutil (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41772
diff
changeset
|
315 cache['getrenamed'] = scmutil.getrenamedfn(repo) |
10060
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10058
diff
changeset
|
316 copies = [] |
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10058
diff
changeset
|
317 getrenamed = cache['getrenamed'] |
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10058
diff
changeset
|
318 for fn in ctx.files(): |
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10058
diff
changeset
|
319 rename = getrenamed(fn, ctx.rev()) |
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10058
diff
changeset
|
320 if rename: |
38167
ec37df9042f9
templatekw: make getrenamed() return only filename, not nodeid
Martin von Zweigbergk <martinvonz@google.com>
parents:
37963
diff
changeset
|
321 copies.append((fn, rename)) |
39368
5b1d406b39f1
templatekw: alias {name} of file copies dict to {path}
Yuya Nishihara <yuya@tcha.org>
parents:
39367
diff
changeset
|
322 return templateutil.compatfilecopiesdict(context, mapping, 'file_copy', |
5b1d406b39f1
templatekw: alias {name} of file copies dict to {path}
Yuya Nishihara <yuya@tcha.org>
parents:
39367
diff
changeset
|
323 copies) |
10060
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10058
diff
changeset
|
324 |
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10058
diff
changeset
|
325 # showfilecopiesswitch() displays file copies only if copy records are |
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10058
diff
changeset
|
326 # provided before calling the templater, usually with a --copies |
f780b1098efc
templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents:
10058
diff
changeset
|
327 # command line switch. |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
328 @templatekeyword('file_copies_switch', requires={'revcache'}) |
36590
0083e373e5f5
templatekw: switch showdict template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36574
diff
changeset
|
329 def showfilecopiesswitch(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
330 """List of strings. Like "file_copies" but displayed |
13585
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
331 only if the --copied switch is set. |
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
332 """ |
36590
0083e373e5f5
templatekw: switch showdict template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36574
diff
changeset
|
333 copies = context.resource(mapping, 'revcache').get('copies') or [] |
39368
5b1d406b39f1
templatekw: alias {name} of file copies dict to {path}
Yuya Nishihara <yuya@tcha.org>
parents:
39367
diff
changeset
|
334 return templateutil.compatfilecopiesdict(context, mapping, 'file_copy', |
5b1d406b39f1
templatekw: alias {name} of file copies dict to {path}
Yuya Nishihara <yuya@tcha.org>
parents:
39367
diff
changeset
|
335 copies) |
10058
c829563b3118
cmdutil: extract file copies closure into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10057
diff
changeset
|
336 |
38774
87a581d1391c
templatekw: use ctx1.status(ctx2) instead of repo.status(ctx1, ctx2)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38588
diff
changeset
|
337 @templatekeyword('file_dels', requires={'ctx', 'revcache'}) |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
338 def showfiledels(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
339 """List of strings. Files removed by this changeset.""" |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
340 return _showfilesbystat(context, mapping, 'file_del', 2) |
10056
1a114aca93fa
cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10055
diff
changeset
|
341 |
38774
87a581d1391c
templatekw: use ctx1.status(ctx2) instead of repo.status(ctx1, ctx2)
Martin von Zweigbergk <martinvonz@google.com>
parents:
38588
diff
changeset
|
342 @templatekeyword('file_mods', requires={'ctx', 'revcache'}) |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
343 def showfilemods(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
344 """List of strings. Files modified by this changeset.""" |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
345 return _showfilesbystat(context, mapping, 'file_mod', 0) |
10056
1a114aca93fa
cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10055
diff
changeset
|
346 |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
347 @templatekeyword('files', requires={'ctx'}) |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
348 def showfiles(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
349 """List of strings. All files modified, added, or removed by this |
13585
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
350 changeset. |
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
351 """ |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
352 ctx = context.resource(mapping, 'ctx') |
39367
83f8f7b9fa60
templatekw: alias {file} of files list to {path}
Yuya Nishihara <yuya@tcha.org>
parents:
38948
diff
changeset
|
353 return templateutil.compatfileslist(context, mapping, 'file', ctx.files()) |
10054
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10053
diff
changeset
|
354 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
355 @templatekeyword('graphnode', requires={'repo', 'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
356 def showgraphnode(context, mapping): |
34656
eb7fffdc6e5b
help: fix formatting of template keywords
Yuya Nishihara <yuya@tcha.org>
parents:
34581
diff
changeset
|
357 """String. The character representing the changeset node in an ASCII |
eb7fffdc6e5b
help: fix formatting of template keywords
Yuya Nishihara <yuya@tcha.org>
parents:
34581
diff
changeset
|
358 revision graph.""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
359 repo = context.resource(mapping, 'repo') |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
360 ctx = context.resource(mapping, 'ctx') |
36513
6ad140dc4269
templatekw: extract non-templatekw function as getgraphnode()
Yuya Nishihara <yuya@tcha.org>
parents:
36501
diff
changeset
|
361 return getgraphnode(repo, ctx) |
6ad140dc4269
templatekw: extract non-templatekw function as getgraphnode()
Yuya Nishihara <yuya@tcha.org>
parents:
36501
diff
changeset
|
362 |
6ad140dc4269
templatekw: extract non-templatekw function as getgraphnode()
Yuya Nishihara <yuya@tcha.org>
parents:
36501
diff
changeset
|
363 def getgraphnode(repo, ctx): |
37908
8808d5d401ee
templates: split getgraphnode() body into two functions
Anton Shestakov <av6@dwimlabs.net>
parents:
37707
diff
changeset
|
364 return getgraphnodecurrent(repo, ctx) or getgraphnodesymbol(ctx) |
8808d5d401ee
templates: split getgraphnode() body into two functions
Anton Shestakov <av6@dwimlabs.net>
parents:
37707
diff
changeset
|
365 |
8808d5d401ee
templates: split getgraphnode() body into two functions
Anton Shestakov <av6@dwimlabs.net>
parents:
37707
diff
changeset
|
366 def getgraphnodecurrent(repo, ctx): |
27215
5b8da5643a8a
templatekw: avoid slow creation of changectx objects in showgraphnode()
Yuya Nishihara <yuya@tcha.org>
parents:
27214
diff
changeset
|
367 wpnodes = repo.dirstate.parents() |
5b8da5643a8a
templatekw: avoid slow creation of changectx objects in showgraphnode()
Yuya Nishihara <yuya@tcha.org>
parents:
27214
diff
changeset
|
368 if wpnodes[1] == nullid: |
5b8da5643a8a
templatekw: avoid slow creation of changectx objects in showgraphnode()
Yuya Nishihara <yuya@tcha.org>
parents:
27214
diff
changeset
|
369 wpnodes = wpnodes[:1] |
27214
60af96494a76
graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents:
26486
diff
changeset
|
370 if ctx.node() in wpnodes: |
60af96494a76
graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents:
26486
diff
changeset
|
371 return '@' |
37908
8808d5d401ee
templates: split getgraphnode() body into two functions
Anton Shestakov <av6@dwimlabs.net>
parents:
37707
diff
changeset
|
372 else: |
8808d5d401ee
templates: split getgraphnode() body into two functions
Anton Shestakov <av6@dwimlabs.net>
parents:
37707
diff
changeset
|
373 return '' |
8808d5d401ee
templates: split getgraphnode() body into two functions
Anton Shestakov <av6@dwimlabs.net>
parents:
37707
diff
changeset
|
374 |
8808d5d401ee
templates: split getgraphnode() body into two functions
Anton Shestakov <av6@dwimlabs.net>
parents:
37707
diff
changeset
|
375 def getgraphnodesymbol(ctx): |
8808d5d401ee
templates: split getgraphnode() body into two functions
Anton Shestakov <av6@dwimlabs.net>
parents:
37707
diff
changeset
|
376 if ctx.obsolete(): |
27214
60af96494a76
graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents:
26486
diff
changeset
|
377 return 'x' |
35508
9b3f95d9783d
graphlog: add another graph node type, unstable, using character "*" (BC)
Anton Shestakov <av6@dwimlabs.net>
parents:
35212
diff
changeset
|
378 elif ctx.isunstable(): |
9b3f95d9783d
graphlog: add another graph node type, unstable, using character "*" (BC)
Anton Shestakov <av6@dwimlabs.net>
parents:
35212
diff
changeset
|
379 return '*' |
27214
60af96494a76
graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents:
26486
diff
changeset
|
380 elif ctx.closesbranch(): |
60af96494a76
graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents:
26486
diff
changeset
|
381 return '_' |
60af96494a76
graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents:
26486
diff
changeset
|
382 else: |
60af96494a76
graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents:
26486
diff
changeset
|
383 return 'o' |
60af96494a76
graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents:
26486
diff
changeset
|
384 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
385 @templatekeyword('graphwidth', requires=()) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
386 def showgraphwidth(context, mapping): |
33858
6f6c87888b22
log: add a "graphwidth" template variable
Danny Hooper <hooper@google.com>
parents:
33851
diff
changeset
|
387 """Integer. The width of the graph drawn by 'log --graph' or zero.""" |
36441
27cd83152d31
templatekw: simply override {graphwidth} function by mapping variable
Yuya Nishihara <yuya@tcha.org>
parents:
36401
diff
changeset
|
388 # just hosts documentation; should be overridden by template mapping |
27cd83152d31
templatekw: simply override {graphwidth} function by mapping variable
Yuya Nishihara <yuya@tcha.org>
parents:
36401
diff
changeset
|
389 return 0 |
33858
6f6c87888b22
log: add a "graphwidth" template variable
Danny Hooper <hooper@google.com>
parents:
33851
diff
changeset
|
390 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
391 @templatekeyword('index', requires=()) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
392 def showindex(context, mapping): |
31807
e6eb86b154c5
templater: provide loop counter as "index" keyword
Yuya Nishihara <yuya@tcha.org>
parents:
31699
diff
changeset
|
393 """Integer. The current iteration of the loop. (0 indexed)""" |
e6eb86b154c5
templater: provide loop counter as "index" keyword
Yuya Nishihara <yuya@tcha.org>
parents:
31699
diff
changeset
|
394 # just hosts documentation; should be overridden by template mapping |
e6eb86b154c5
templater: provide loop counter as "index" keyword
Yuya Nishihara <yuya@tcha.org>
parents:
31699
diff
changeset
|
395 raise error.Abort(_("can't use index in this context")) |
e6eb86b154c5
templater: provide loop counter as "index" keyword
Yuya Nishihara <yuya@tcha.org>
parents:
31699
diff
changeset
|
396 |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
397 @templatekeyword('latesttag', requires={'repo', 'ctx', 'cache'}) |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
398 def showlatesttag(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
399 """List of strings. The global tags on the most recent globally |
31850
f0d719e513fc
templatekw: clarify the result of {latesttag} when no tag exists
Matt Harbison <matt_harbison@yahoo.com>
parents:
31807
diff
changeset
|
400 tagged ancestor of this changeset. If no such tags exist, the list |
f0d719e513fc
templatekw: clarify the result of {latesttag} when no tag exists
Matt Harbison <matt_harbison@yahoo.com>
parents:
31807
diff
changeset
|
401 consists of the single string "null". |
13585
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
402 """ |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
403 return showlatesttags(context, mapping, None) |
10057
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
404 |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
405 def showlatesttags(context, mapping, pattern): |
26484
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
406 """helper method for the latesttag keyword and function""" |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
407 latesttags = getlatesttags(context, mapping, pattern) |
26484
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
408 |
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
409 # latesttag[0] is an implementation detail for sorting csets on different |
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
410 # branches in a stable manner- it is the date the tagged cset was created, |
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
411 # not the date the tag was created. Therefore it isn't made visible here. |
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
412 makemap = lambda v: { |
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
413 'changes': _showchangessincetag, |
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
414 'distance': latesttags[1], |
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
415 'latesttag': v, # BC with {latesttag % '{latesttag}'} |
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
416 'tag': v |
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
417 } |
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
418 |
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
419 tags = latesttags[2] |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
420 f = _showcompatlist(context, mapping, 'latesttag', tags, separator=':') |
34328
dd28b1f55eb8
templatekw: just pass underlying value (or key) to joinfmt() function
Yuya Nishihara <yuya@tcha.org>
parents:
34327
diff
changeset
|
421 return _hybrid(f, tags, makemap, pycompat.identity) |
26484
93c80e7ed8c8
templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents:
26483
diff
changeset
|
422 |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
423 @templatekeyword('latesttagdistance', requires={'repo', 'ctx', 'cache'}) |
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
424 def showlatesttagdistance(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
425 """Integer. Longest path to the latest tag.""" |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
426 return getlatesttags(context, mapping)[1] |
10057
babc00a82c5e
cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10056
diff
changeset
|
427 |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
428 @templatekeyword('changessincelatesttag', requires={'repo', 'ctx', 'cache'}) |
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
429 def showchangessincelatesttag(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
430 """Integer. All ancestors not in the latest tag.""" |
37074
2891079fb0c0
templater: factor out function to create mapping dict for nested evaluation
Yuya Nishihara <yuya@tcha.org>
parents:
37071
diff
changeset
|
431 tag = getlatesttags(context, mapping)[2][0] |
2891079fb0c0
templater: factor out function to create mapping dict for nested evaluation
Yuya Nishihara <yuya@tcha.org>
parents:
37071
diff
changeset
|
432 mapping = context.overlaymap(mapping, {'tag': tag}) |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
433 return _showchangessincetag(context, mapping) |
26483
e94f93043a4e
templatekw: factor out the changessincetag calculation to a private method
Matt Harbison <matt_harbison@yahoo.com>
parents:
26482
diff
changeset
|
434 |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
435 def _showchangessincetag(context, mapping): |
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
436 repo = context.resource(mapping, 'repo') |
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
437 ctx = context.resource(mapping, 'ctx') |
25724
4474a750413f
templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents:
25700
diff
changeset
|
438 offset = 0 |
4474a750413f
templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents:
25700
diff
changeset
|
439 revs = [ctx.rev()] |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
440 tag = context.symbol(mapping, 'tag') |
25724
4474a750413f
templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents:
25700
diff
changeset
|
441 |
4474a750413f
templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents:
25700
diff
changeset
|
442 # The only() revset doesn't currently support wdir() |
4474a750413f
templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents:
25700
diff
changeset
|
443 if ctx.rev() is None: |
4474a750413f
templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents:
25700
diff
changeset
|
444 offset = 1 |
4474a750413f
templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents:
25700
diff
changeset
|
445 revs = [p.rev() for p in ctx.parents()] |
4474a750413f
templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents:
25700
diff
changeset
|
446 |
26483
e94f93043a4e
templatekw: factor out the changessincetag calculation to a private method
Matt Harbison <matt_harbison@yahoo.com>
parents:
26482
diff
changeset
|
447 return len(repo.revs('only(%ld, %s)', revs, tag)) + offset |
25724
4474a750413f
templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents:
25700
diff
changeset
|
448 |
36596
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
449 # teach templater latesttags.changes is switched to (context, mapping) API |
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
450 _showchangessincetag._requires = {'repo', 'ctx'} |
b5d39a09656a
templatekw: switch latesttags template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36595
diff
changeset
|
451 |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
452 @templatekeyword('manifest', requires={'repo', 'ctx'}) |
36597
d57f383516f6
templatekw: switch manifest template keyword to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36596
diff
changeset
|
453 def showmanifest(context, mapping): |
d57f383516f6
templatekw: switch manifest template keyword to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36596
diff
changeset
|
454 repo = context.resource(mapping, 'repo') |
d57f383516f6
templatekw: switch manifest template keyword to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36596
diff
changeset
|
455 ctx = context.resource(mapping, 'ctx') |
24676
13c42a883e8b
templatekw: have {manifest} use ctx.manifestnode() for consistency
Yuya Nishihara <yuya@tcha.org>
parents:
24337
diff
changeset
|
456 mnode = ctx.manifestnode() |
25736
8854ca3fa675
templatekw: apply manifest template only if ctx.manifestnode() exists
Yuya Nishihara <yuya@tcha.org>
parents:
25727
diff
changeset
|
457 if mnode is None: |
39796
94ca3579e84e
log: fill in pseudo rev and node as wdir() manifest identifiers
Yuya Nishihara <yuya@tcha.org>
parents:
39623
diff
changeset
|
458 mnode = wdirid |
94ca3579e84e
log: fill in pseudo rev and node as wdir() manifest identifiers
Yuya Nishihara <yuya@tcha.org>
parents:
39623
diff
changeset
|
459 mrev = wdirrev |
94ca3579e84e
log: fill in pseudo rev and node as wdir() manifest identifiers
Yuya Nishihara <yuya@tcha.org>
parents:
39623
diff
changeset
|
460 else: |
94ca3579e84e
log: fill in pseudo rev and node as wdir() manifest identifiers
Yuya Nishihara <yuya@tcha.org>
parents:
39623
diff
changeset
|
461 mrev = repo.manifestlog.rev(mnode) |
34330
89aec1834a86
templatekw: add new-style template expansion to {manifest}
Yuya Nishihara <yuya@tcha.org>
parents:
34328
diff
changeset
|
462 mhex = hex(mnode) |
37074
2891079fb0c0
templater: factor out function to create mapping dict for nested evaluation
Yuya Nishihara <yuya@tcha.org>
parents:
37071
diff
changeset
|
463 mapping = context.overlaymap(mapping, {'rev': mrev, 'node': mhex}) |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
464 f = context.process('manifest', mapping) |
38283
0e0d03d09ecd
templater: rename mappable to hybriditem as it is the primary use case
Yuya Nishihara <yuya@tcha.org>
parents:
38167
diff
changeset
|
465 return templateutil.hybriditem(f, None, f, |
0e0d03d09ecd
templater: rename mappable to hybriditem as it is the primary use case
Yuya Nishihara <yuya@tcha.org>
parents:
38167
diff
changeset
|
466 lambda x: {'rev': mrev, 'node': mhex}) |
10055
e400a511e63a
cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10054
diff
changeset
|
467 |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
468 @templatekeyword('obsfate', requires={'ui', 'repo', 'ctx'}) |
36594
59ee648870a7
templatekw: switch obsfate-related template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36593
diff
changeset
|
469 def showobsfate(context, mapping): |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34657
diff
changeset
|
470 # this function returns a list containing pre-formatted obsfate strings. |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34657
diff
changeset
|
471 # |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34657
diff
changeset
|
472 # This function will be replaced by templates fragments when we will have |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34657
diff
changeset
|
473 # the verbosity templatekw available. |
36594
59ee648870a7
templatekw: switch obsfate-related template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36593
diff
changeset
|
474 succsandmarkers = showsuccsandmarkers(context, mapping) |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34657
diff
changeset
|
475 |
36594
59ee648870a7
templatekw: switch obsfate-related template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36593
diff
changeset
|
476 ui = context.resource(mapping, 'ui') |
37328
11d51e518808
obsutil: make obsfateprinter() less dependent on templater
Yuya Nishihara <yuya@tcha.org>
parents:
37274
diff
changeset
|
477 repo = context.resource(mapping, 'repo') |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34657
diff
changeset
|
478 values = [] |
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34657
diff
changeset
|
479 |
37503
49a8c2cc7978
templatekw: fix return type of {succsandmarkers} (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
37328
diff
changeset
|
480 for x in succsandmarkers.tovalue(context, mapping): |
37328
11d51e518808
obsutil: make obsfateprinter() less dependent on templater
Yuya Nishihara <yuya@tcha.org>
parents:
37274
diff
changeset
|
481 v = obsutil.obsfateprinter(ui, repo, x['successors'], x['markers'], |
11d51e518808
obsutil: make obsfateprinter() less dependent on templater
Yuya Nishihara <yuya@tcha.org>
parents:
37274
diff
changeset
|
482 scmutil.formatchangeid) |
11d51e518808
obsutil: make obsfateprinter() less dependent on templater
Yuya Nishihara <yuya@tcha.org>
parents:
37274
diff
changeset
|
483 values.append(v) |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34657
diff
changeset
|
484 |
36594
59ee648870a7
templatekw: switch obsfate-related template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36593
diff
changeset
|
485 return compatlist(context, mapping, "fate", values) |
34847
e27f1f04c2cf
templatekw: introduce obsfate keyword
Boris Feld <boris.feld@octobus.net>
parents:
34657
diff
changeset
|
486 |
36593
900e5ee44307
templatekw: switch namespace template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36591
diff
changeset
|
487 def shownames(context, mapping, namespace): |
27893
b42b2e86ef02
templatekw: move shownames() helper to be sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
27891
diff
changeset
|
488 """helper method to generate a template keyword for a namespace""" |
36593
900e5ee44307
templatekw: switch namespace template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36591
diff
changeset
|
489 repo = context.resource(mapping, 'repo') |
900e5ee44307
templatekw: switch namespace template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36591
diff
changeset
|
490 ctx = context.resource(mapping, 'ctx') |
27893
b42b2e86ef02
templatekw: move shownames() helper to be sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
27891
diff
changeset
|
491 ns = repo.names[namespace] |
b42b2e86ef02
templatekw: move shownames() helper to be sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
27891
diff
changeset
|
492 names = ns.names(repo, ctx.node()) |
36593
900e5ee44307
templatekw: switch namespace template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36591
diff
changeset
|
493 return compatlist(context, mapping, ns.templatename, names, |
900e5ee44307
templatekw: switch namespace template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36591
diff
changeset
|
494 plural=namespace) |
27893
b42b2e86ef02
templatekw: move shownames() helper to be sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
27891
diff
changeset
|
495 |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
496 @templatekeyword('namespaces', requires={'repo', 'ctx'}) |
36593
900e5ee44307
templatekw: switch namespace template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36591
diff
changeset
|
497 def shownamespaces(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
498 """Dict of lists. Names attached to this changeset per |
27894
a94f7eef3199
templatekw: add {namespaces} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
27893
diff
changeset
|
499 namespace.""" |
36593
900e5ee44307
templatekw: switch namespace template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36591
diff
changeset
|
500 repo = context.resource(mapping, 'repo') |
900e5ee44307
templatekw: switch namespace template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36591
diff
changeset
|
501 ctx = context.resource(mapping, 'ctx') |
33047
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
502 |
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
503 namespaces = util.sortdict() |
34541
0a0a72c043ac
templatekw: allow accessing to nested namespace item by its template name
Yuya Nishihara <yuya@tcha.org>
parents:
34540
diff
changeset
|
504 def makensmapfn(ns): |
0a0a72c043ac
templatekw: allow accessing to nested namespace item by its template name
Yuya Nishihara <yuya@tcha.org>
parents:
34540
diff
changeset
|
505 # 'name' for iterating over namespaces, templatename for local reference |
0a0a72c043ac
templatekw: allow accessing to nested namespace item by its template name
Yuya Nishihara <yuya@tcha.org>
parents:
34540
diff
changeset
|
506 return lambda v: {'name': v, ns.templatename: v} |
33047
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
507 |
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
508 for k, ns in repo.names.iteritems(): |
34541
0a0a72c043ac
templatekw: allow accessing to nested namespace item by its template name
Yuya Nishihara <yuya@tcha.org>
parents:
34540
diff
changeset
|
509 names = ns.names(repo, ctx.node()) |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
510 f = _showcompatlist(context, mapping, 'name', names) |
34541
0a0a72c043ac
templatekw: allow accessing to nested namespace item by its template name
Yuya Nishihara <yuya@tcha.org>
parents:
34540
diff
changeset
|
511 namespaces[k] = _hybrid(f, names, makensmapfn(ns), pycompat.identity) |
33047
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
512 |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
513 f = _showcompatlist(context, mapping, 'namespace', list(namespaces)) |
33047
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
514 |
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
515 def makemap(ns): |
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
516 return { |
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
517 'namespace': ns, |
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
518 'names': namespaces[ns], |
34540
1c7c4445686f
templatekw: get rid of temporary dicts from shownamespaces()
Yuya Nishihara <yuya@tcha.org>
parents:
34539
diff
changeset
|
519 'builtin': repo.names[ns].builtin, |
1c7c4445686f
templatekw: get rid of temporary dicts from shownamespaces()
Yuya Nishihara <yuya@tcha.org>
parents:
34539
diff
changeset
|
520 'colorname': repo.names[ns].colorname, |
33047
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
521 } |
de8e3681c402
templatekw: expose color name in {namespaces} entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33017
diff
changeset
|
522 |
34328
dd28b1f55eb8
templatekw: just pass underlying value (or key) to joinfmt() function
Yuya Nishihara <yuya@tcha.org>
parents:
34327
diff
changeset
|
523 return _hybrid(f, namespaces, makemap, pycompat.identity) |
27894
a94f7eef3199
templatekw: add {namespaces} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
27893
diff
changeset
|
524 |
41722
37b33c34bf4f
templatekw: add a {negrev} keyword
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
41397
diff
changeset
|
525 @templatekeyword('negrev', requires={'repo', 'ctx'}) |
37b33c34bf4f
templatekw: add a {negrev} keyword
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
41397
diff
changeset
|
526 def shownegrev(context, mapping): |
37b33c34bf4f
templatekw: add a {negrev} keyword
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
41397
diff
changeset
|
527 """Integer. The repository-local changeset negative revision number, |
37b33c34bf4f
templatekw: add a {negrev} keyword
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
41397
diff
changeset
|
528 which counts in the opposite direction.""" |
37b33c34bf4f
templatekw: add a {negrev} keyword
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
41397
diff
changeset
|
529 ctx = context.resource(mapping, 'ctx') |
41728
36b62a522814
templatekw: make negrev return empty for wdir() and nullrev
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
41722
diff
changeset
|
530 rev = ctx.rev() |
36b62a522814
templatekw: make negrev return empty for wdir() and nullrev
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
41722
diff
changeset
|
531 if rev is None or rev < 0: # wdir() or nullrev? |
36b62a522814
templatekw: make negrev return empty for wdir() and nullrev
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
41722
diff
changeset
|
532 return None |
41722
37b33c34bf4f
templatekw: add a {negrev} keyword
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
41397
diff
changeset
|
533 repo = context.resource(mapping, 'repo') |
41728
36b62a522814
templatekw: make negrev return empty for wdir() and nullrev
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
41722
diff
changeset
|
534 return rev - len(repo) |
41722
37b33c34bf4f
templatekw: add a {negrev} keyword
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
41397
diff
changeset
|
535 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
536 @templatekeyword('node', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
537 def shownode(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
538 """String. The changeset identification hash, as a 40 hexadecimal |
13585
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
539 digit string. |
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
540 """ |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
541 ctx = context.resource(mapping, 'ctx') |
10054
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10053
diff
changeset
|
542 return ctx.hex() |
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10053
diff
changeset
|
543 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
544 @templatekeyword('obsolete', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
545 def showobsolete(context, mapping): |
34657
bfb6fd93b637
help: hide template keywords of obsolescence as they are still experimental
Yuya Nishihara <yuya@tcha.org>
parents:
34656
diff
changeset
|
546 """String. Whether the changeset is obsolete. (EXPERIMENTAL)""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
547 ctx = context.resource(mapping, 'ctx') |
31699
568c4e7437b2
templatekw: add an "obsolete" keyword
Denis Laxalde <denis@laxalde.org>
parents:
31452
diff
changeset
|
548 if ctx.obsolete(): |
568c4e7437b2
templatekw: add an "obsolete" keyword
Denis Laxalde <denis@laxalde.org>
parents:
31452
diff
changeset
|
549 return 'obsolete' |
568c4e7437b2
templatekw: add an "obsolete" keyword
Denis Laxalde <denis@laxalde.org>
parents:
31452
diff
changeset
|
550 return '' |
568c4e7437b2
templatekw: add an "obsolete" keyword
Denis Laxalde <denis@laxalde.org>
parents:
31452
diff
changeset
|
551 |
39371
3cd977d5a16b
templatekw: add {path} keyword to host documentation
Yuya Nishihara <yuya@tcha.org>
parents:
39368
diff
changeset
|
552 @templatekeyword('path', requires={'fctx'}) |
3cd977d5a16b
templatekw: add {path} keyword to host documentation
Yuya Nishihara <yuya@tcha.org>
parents:
39368
diff
changeset
|
553 def showpath(context, mapping): |
3cd977d5a16b
templatekw: add {path} keyword to host documentation
Yuya Nishihara <yuya@tcha.org>
parents:
39368
diff
changeset
|
554 """String. Repository-absolute path of the current file. (EXPERIMENTAL)""" |
3cd977d5a16b
templatekw: add {path} keyword to host documentation
Yuya Nishihara <yuya@tcha.org>
parents:
39368
diff
changeset
|
555 fctx = context.resource(mapping, 'fctx') |
3cd977d5a16b
templatekw: add {path} keyword to host documentation
Yuya Nishihara <yuya@tcha.org>
parents:
39368
diff
changeset
|
556 return fctx.path() |
3cd977d5a16b
templatekw: add {path} keyword to host documentation
Yuya Nishihara <yuya@tcha.org>
parents:
39368
diff
changeset
|
557 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
558 @templatekeyword('peerurls', requires={'repo'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
559 def showpeerurls(context, mapping): |
33414
16ed67164002
templatekw: export ui.paths as {peerpaths}
Yuya Nishihara <yuya@tcha.org>
parents:
33276
diff
changeset
|
560 """A dictionary of repository locations defined in the [paths] section |
34539
f30e59703d98
templatekw: rename peerpaths to peerurls per naming convention (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
34538
diff
changeset
|
561 of your configuration file.""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
562 repo = context.resource(mapping, 'repo') |
33414
16ed67164002
templatekw: export ui.paths as {peerpaths}
Yuya Nishihara <yuya@tcha.org>
parents:
33276
diff
changeset
|
563 # see commands.paths() for naming of dictionary keys |
34538
ac38e889b33a
templatekw: make experimental {peerpaths} return a single-level dict (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
34537
diff
changeset
|
564 paths = repo.ui.paths |
ac38e889b33a
templatekw: make experimental {peerpaths} return a single-level dict (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
34537
diff
changeset
|
565 urls = util.sortdict((k, p.rawloc) for k, p in sorted(paths.iteritems())) |
ac38e889b33a
templatekw: make experimental {peerpaths} return a single-level dict (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
34537
diff
changeset
|
566 def makemap(k): |
ac38e889b33a
templatekw: make experimental {peerpaths} return a single-level dict (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
34537
diff
changeset
|
567 p = paths[k] |
ac38e889b33a
templatekw: make experimental {peerpaths} return a single-level dict (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
34537
diff
changeset
|
568 d = {'name': k, 'url': p.rawloc} |
33414
16ed67164002
templatekw: export ui.paths as {peerpaths}
Yuya Nishihara <yuya@tcha.org>
parents:
33276
diff
changeset
|
569 d.update((o, v) for o, v in sorted(p.suboptions.iteritems())) |
34538
ac38e889b33a
templatekw: make experimental {peerpaths} return a single-level dict (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
34537
diff
changeset
|
570 return d |
ac38e889b33a
templatekw: make experimental {peerpaths} return a single-level dict (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
34537
diff
changeset
|
571 return _hybrid(None, urls, makemap, lambda k: '%s=%s' % (k, urls[k])) |
33414
16ed67164002
templatekw: export ui.paths as {peerpaths}
Yuya Nishihara <yuya@tcha.org>
parents:
33276
diff
changeset
|
572 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
573 @templatekeyword("predecessors", requires={'repo', 'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
574 def showpredecessors(context, mapping): |
41021
70e3e3da24be
templatekw: fix documentation typos
Matt Harbison <matt_harbison@yahoo.com>
parents:
39796
diff
changeset
|
575 """Returns the list of the closest visible successors. (EXPERIMENTAL)""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
576 repo = context.resource(mapping, 'repo') |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
577 ctx = context.resource(mapping, 'ctx') |
32879
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
32658
diff
changeset
|
578 predecessors = sorted(obsutil.closestpredecessors(repo, ctx.node())) |
38306
523f64466a05
py3: fix map() use in templatekw.showpredecessors()
Yuya Nishihara <yuya@tcha.org>
parents:
38299
diff
changeset
|
579 predecessors = pycompat.maplist(hex, predecessors) |
32879
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
32658
diff
changeset
|
580 |
32910
498e9dcc5fa9
templatekw: populate all keywords depending on predecessor in map operation
Yuya Nishihara <yuya@tcha.org>
parents:
32909
diff
changeset
|
581 return _hybrid(None, predecessors, |
37103
be3f33f5e232
templater: switch 'revcache' based on new mapping items
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
582 lambda x: {'ctx': repo[x]}, |
34328
dd28b1f55eb8
templatekw: just pass underlying value (or key) to joinfmt() function
Yuya Nishihara <yuya@tcha.org>
parents:
34327
diff
changeset
|
583 lambda x: scmutil.formatchangeid(repo[x])) |
32879
1858fc2327ef
template: add predecessors template
Boris Feld <boris.feld@octobus.net>
parents:
32658
diff
changeset
|
584 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
585 @templatekeyword('reporoot', requires={'repo'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
586 def showreporoot(context, mapping): |
36247
48a6b1a22ccf
templatekw: add {reporoot} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
36110
diff
changeset
|
587 """String. The root directory of the current repository.""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
588 repo = context.resource(mapping, 'repo') |
36247
48a6b1a22ccf
templatekw: add {reporoot} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
36110
diff
changeset
|
589 return repo.root |
48a6b1a22ccf
templatekw: add {reporoot} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
36110
diff
changeset
|
590 |
39587
918944f53aac
templatekw: add {size} keyword as an example of fctx-based keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39371
diff
changeset
|
591 @templatekeyword('size', requires={'fctx'}) |
918944f53aac
templatekw: add {size} keyword as an example of fctx-based keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39371
diff
changeset
|
592 def showsize(context, mapping): |
918944f53aac
templatekw: add {size} keyword as an example of fctx-based keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39371
diff
changeset
|
593 """Integer. Size of the current file in bytes. (EXPERIMENTAL)""" |
918944f53aac
templatekw: add {size} keyword as an example of fctx-based keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39371
diff
changeset
|
594 fctx = context.resource(mapping, 'fctx') |
918944f53aac
templatekw: add {size} keyword as an example of fctx-based keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39371
diff
changeset
|
595 return fctx.size() |
918944f53aac
templatekw: add {size} keyword as an example of fctx-based keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39371
diff
changeset
|
596 |
39600
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
597 # requires 'fctx' to denote {status} depends on (ctx, path) pair |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
598 @templatekeyword('status', requires={'ctx', 'fctx', 'revcache'}) |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
599 def showstatus(context, mapping): |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
600 """String. Status code of the current file. (EXPERIMENTAL)""" |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
601 path = templateutil.runsymbol(context, mapping, 'path') |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
602 path = templateutil.stringify(context, mapping, path) |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
603 if not path: |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
604 return |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
605 statmap = _getfilestatusmap(context, mapping) |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
606 if path not in statmap: |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
607 statmap = _getfilestatusmap(context, mapping, listall=True) |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
608 return statmap.get(path) |
87428152e820
templatekw: add experimental {status} keyword
Yuya Nishihara <yuya@tcha.org>
parents:
39599
diff
changeset
|
609 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
610 @templatekeyword("successorssets", requires={'repo', 'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
611 def showsuccessorssets(context, mapping): |
34656
eb7fffdc6e5b
help: fix formatting of template keywords
Yuya Nishihara <yuya@tcha.org>
parents:
34581
diff
changeset
|
612 """Returns a string of sets of successors for a changectx. Format used |
41021
70e3e3da24be
templatekw: fix documentation typos
Matt Harbison <matt_harbison@yahoo.com>
parents:
39796
diff
changeset
|
613 is: [ctx1, ctx2], [ctx3] if ctx has been split into ctx1 and ctx2 |
34657
bfb6fd93b637
help: hide template keywords of obsolescence as they are still experimental
Yuya Nishihara <yuya@tcha.org>
parents:
34656
diff
changeset
|
614 while also diverged into ctx3. (EXPERIMENTAL)""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
615 repo = context.resource(mapping, 'repo') |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
616 ctx = context.resource(mapping, 'ctx') |
33276
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
617 if not ctx.obsolete(): |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
618 return '' |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
619 |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
620 ssets = obsutil.successorssets(repo, ctx.node(), closest=True) |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
621 ssets = [[hex(n) for n in ss] for ss in ssets] |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
622 |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
623 data = [] |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
624 for ss in ssets: |
37103
be3f33f5e232
templater: switch 'revcache' based on new mapping items
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
625 h = _hybrid(None, ss, lambda x: {'ctx': repo[x]}, |
34328
dd28b1f55eb8
templatekw: just pass underlying value (or key) to joinfmt() function
Yuya Nishihara <yuya@tcha.org>
parents:
34327
diff
changeset
|
626 lambda x: scmutil.formatchangeid(repo[x])) |
33276
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
627 data.append(h) |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
628 |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
629 # Format the successorssets |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
630 def render(d): |
37274
45987e2b64f0
templatekw: do not directly call .gen
Yuya Nishihara <yuya@tcha.org>
parents:
37103
diff
changeset
|
631 return templateutil.stringify(context, mapping, d) |
33276
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
632 |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
633 def gen(data): |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
634 yield "; ".join(render(d) for d in data) |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
635 |
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
636 return _hybrid(gen(data), data, lambda x: {'successorset': x}, |
34328
dd28b1f55eb8
templatekw: just pass underlying value (or key) to joinfmt() function
Yuya Nishihara <yuya@tcha.org>
parents:
34327
diff
changeset
|
637 pycompat.identity) |
33276
89796a25d4bb
template: add successors template
Boris Feld <boris.feld@octobus.net>
parents:
33048
diff
changeset
|
638 |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
639 @templatekeyword("succsandmarkers", requires={'repo', 'ctx'}) |
36594
59ee648870a7
templatekw: switch obsfate-related template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36593
diff
changeset
|
640 def showsuccsandmarkers(context, mapping): |
34656
eb7fffdc6e5b
help: fix formatting of template keywords
Yuya Nishihara <yuya@tcha.org>
parents:
34581
diff
changeset
|
641 """Returns a list of dict for each final successor of ctx. The dict |
eb7fffdc6e5b
help: fix formatting of template keywords
Yuya Nishihara <yuya@tcha.org>
parents:
34581
diff
changeset
|
642 contains successors node id in "successors" keys and the list of |
eb7fffdc6e5b
help: fix formatting of template keywords
Yuya Nishihara <yuya@tcha.org>
parents:
34581
diff
changeset
|
643 obs-markers from ctx to the set of successors in "markers". |
33912
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
644 (EXPERIMENTAL) |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
645 """ |
36594
59ee648870a7
templatekw: switch obsfate-related template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36593
diff
changeset
|
646 repo = context.resource(mapping, 'repo') |
59ee648870a7
templatekw: switch obsfate-related template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36593
diff
changeset
|
647 ctx = context.resource(mapping, 'ctx') |
33912
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
648 |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
649 values = obsutil.successorsandmarkers(repo, ctx) |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
650 |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
651 if values is None: |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
652 values = [] |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
653 |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
654 # Format successors and markers to avoid exposing binary to templates |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
655 data = [] |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
656 for i in values: |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
657 # Format successors |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
658 successors = i['successors'] |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
659 |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
660 successors = [hex(n) for n in successors] |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
661 successors = _hybrid(None, successors, |
37103
be3f33f5e232
templater: switch 'revcache' based on new mapping items
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
662 lambda x: {'ctx': repo[x]}, |
34328
dd28b1f55eb8
templatekw: just pass underlying value (or key) to joinfmt() function
Yuya Nishihara <yuya@tcha.org>
parents:
34327
diff
changeset
|
663 lambda x: scmutil.formatchangeid(repo[x])) |
33912
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
664 |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
665 # Format markers |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
666 finalmarkers = [] |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
667 for m in i['markers']: |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
668 hexprec = hex(m[0]) |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
669 hexsucs = tuple(hex(n) for n in m[1]) |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
670 hexparents = None |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
671 if m[5] is not None: |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
672 hexparents = tuple(hex(n) for n in m[5]) |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
673 newmarker = (hexprec, hexsucs) + m[2:5] + (hexparents,) + m[6:] |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
674 finalmarkers.append(newmarker) |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
675 |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
676 data.append({'successors': successors, 'markers': finalmarkers}) |
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
677 |
37503
49a8c2cc7978
templatekw: fix return type of {succsandmarkers} (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
37328
diff
changeset
|
678 return templateutil.mappinglist(data) |
33912
e278d6d2d7d2
template: add minimal obsfate template function
Boris Feld <boris.feld@octobus.net>
parents:
33865
diff
changeset
|
679 |
40476
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
680 @templatekeyword('p1', requires={'ctx'}) |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
681 def showp1(context, mapping): |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
682 """Changeset. The changeset's first parent. ``{p1.rev}`` for the revision |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
683 number, and ``{p1.node}`` for the identification hash.""" |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
684 ctx = context.resource(mapping, 'ctx') |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
685 return templateutil.mappingdict({'ctx': ctx.p1()}, tmpl=_changeidtmpl) |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
686 |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
687 @templatekeyword('p2', requires={'ctx'}) |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
688 def showp2(context, mapping): |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
689 """Changeset. The changeset's second parent. ``{p2.rev}`` for the revision |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
690 number, and ``{p2.node}`` for the identification hash.""" |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
691 ctx = context.resource(mapping, 'ctx') |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
692 return templateutil.mappingdict({'ctx': ctx.p2()}, tmpl=_changeidtmpl) |
539efc88513b
templatekw: add p1/p2 keywords which switches the current ctx
Yuya Nishihara <yuya@tcha.org>
parents:
40474
diff
changeset
|
693 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
694 @templatekeyword('p1rev', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
695 def showp1rev(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
696 """Integer. The repository-local revision number of the changeset's |
40477
592feb3f88b1
templatekw: deprecate p1rev/p2rev/p1node/p2node in favor of p1/p2
Yuya Nishihara <yuya@tcha.org>
parents:
40476
diff
changeset
|
697 first parent, or -1 if the changeset has no parents. (DEPRECATED)""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
698 ctx = context.resource(mapping, 'ctx') |
17357
bd605568c5a0
templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents:
17187
diff
changeset
|
699 return ctx.p1().rev() |
17355
c25531ed58b0
templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents:
17187
diff
changeset
|
700 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
701 @templatekeyword('p2rev', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
702 def showp2rev(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
703 """Integer. The repository-local revision number of the changeset's |
40477
592feb3f88b1
templatekw: deprecate p1rev/p2rev/p1node/p2node in favor of p1/p2
Yuya Nishihara <yuya@tcha.org>
parents:
40476
diff
changeset
|
704 second parent, or -1 if the changeset has no second parent. (DEPRECATED)""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
705 ctx = context.resource(mapping, 'ctx') |
17357
bd605568c5a0
templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents:
17187
diff
changeset
|
706 return ctx.p2().rev() |
17355
c25531ed58b0
templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents:
17187
diff
changeset
|
707 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
708 @templatekeyword('p1node', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
709 def showp1node(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
710 """String. The identification hash of the changeset's first parent, |
17357
bd605568c5a0
templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents:
17187
diff
changeset
|
711 as a 40 digit hexadecimal string. If the changeset has no parents, all |
40477
592feb3f88b1
templatekw: deprecate p1rev/p2rev/p1node/p2node in favor of p1/p2
Yuya Nishihara <yuya@tcha.org>
parents:
40476
diff
changeset
|
712 digits are 0. (DEPRECATED)""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
713 ctx = context.resource(mapping, 'ctx') |
17357
bd605568c5a0
templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents:
17187
diff
changeset
|
714 return ctx.p1().hex() |
17355
c25531ed58b0
templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents:
17187
diff
changeset
|
715 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
716 @templatekeyword('p2node', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
717 def showp2node(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
718 """String. The identification hash of the changeset's second |
17357
bd605568c5a0
templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents:
17187
diff
changeset
|
719 parent, as a 40 digit hexadecimal string. If the changeset has no second |
40477
592feb3f88b1
templatekw: deprecate p1rev/p2rev/p1node/p2node in favor of p1/p2
Yuya Nishihara <yuya@tcha.org>
parents:
40476
diff
changeset
|
720 parent, all digits are 0. (DEPRECATED)""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
721 ctx = context.resource(mapping, 'ctx') |
17357
bd605568c5a0
templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents:
17187
diff
changeset
|
722 return ctx.p2().hex() |
17355
c25531ed58b0
templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents:
17187
diff
changeset
|
723 |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
724 @templatekeyword('parents', requires={'repo', 'ctx'}) |
36598
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36597
diff
changeset
|
725 def showparents(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
726 """List of strings. The parents of the changeset in "rev:node" |
26434
0a823de8d7b7
templatekw: reorder stub of showparents() function
Yuya Nishihara <yuya@tcha.org>
parents:
26234
diff
changeset
|
727 format. If the changeset has only one "natural" parent (the predecessor |
0a823de8d7b7
templatekw: reorder stub of showparents() function
Yuya Nishihara <yuya@tcha.org>
parents:
26234
diff
changeset
|
728 revision) nothing is shown.""" |
36598
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36597
diff
changeset
|
729 repo = context.resource(mapping, 'repo') |
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36597
diff
changeset
|
730 ctx = context.resource(mapping, 'ctx') |
28270
650c9f69a744
templatekw: switch ctx of list expression to rev of {parents} (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
28239
diff
changeset
|
731 pctxs = scmutil.meaningfulparents(repo, ctx) |
34581
ee0d74083a22
templater: store revisions as ints so min/max won't compare them as strings
Yuya Nishihara <yuya@tcha.org>
parents:
34541
diff
changeset
|
732 prevs = [p.rev() for p in pctxs] |
26435
882b170ae616
templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
26434
diff
changeset
|
733 parents = [[('rev', p.rev()), |
882b170ae616
templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
26434
diff
changeset
|
734 ('node', p.hex()), |
882b170ae616
templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents:
26434
diff
changeset
|
735 ('phase', p.phasestr())] |
28270
650c9f69a744
templatekw: switch ctx of list expression to rev of {parents} (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
28239
diff
changeset
|
736 for p in pctxs] |
37069
724f2e21d870
templatekw: stop using _showlist() which is about to be deprecated
Yuya Nishihara <yuya@tcha.org>
parents:
37068
diff
changeset
|
737 f = _showcompatlist(context, mapping, 'parent', parents) |
37103
be3f33f5e232
templater: switch 'revcache' based on new mapping items
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
738 return _hybrid(f, prevs, lambda x: {'ctx': repo[x]}, |
34581
ee0d74083a22
templater: store revisions as ints so min/max won't compare them as strings
Yuya Nishihara <yuya@tcha.org>
parents:
34541
diff
changeset
|
739 lambda x: scmutil.formatchangeid(repo[x]), keytype=int) |
26434
0a823de8d7b7
templatekw: reorder stub of showparents() function
Yuya Nishihara <yuya@tcha.org>
parents:
26234
diff
changeset
|
740 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
741 @templatekeyword('phase', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
742 def showphase(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
743 """String. The changeset phase name.""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
744 ctx = context.resource(mapping, 'ctx') |
15823
a1f818a2b50d
phases: ``{phase}`` template keyword display the phase name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15422
diff
changeset
|
745 return ctx.phasestr() |
a1f818a2b50d
phases: ``{phase}`` template keyword display the phase name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15422
diff
changeset
|
746 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
747 @templatekeyword('phaseidx', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
748 def showphaseidx(context, mapping): |
34991
29e6513856ee
help: hide phaseidx template keyword
Yuya Nishihara <yuya@tcha.org>
parents:
34847
diff
changeset
|
749 """Integer. The changeset phase index. (ADVANCED)""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
750 ctx = context.resource(mapping, 'ctx') |
15422
042e11c4e416
phases: add a phase template keyword
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15155
diff
changeset
|
751 return ctx.phase() |
042e11c4e416
phases: add a phase template keyword
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15155
diff
changeset
|
752 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
753 @templatekeyword('rev', requires={'ctx'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
754 def showrev(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
755 """Integer. The repository-local changeset revision number.""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
756 ctx = context.resource(mapping, 'ctx') |
32656
4bec8cce6a09
scmutil: pass ctx object to intrev()
Yuya Nishihara <yuya@tcha.org>
parents:
32038
diff
changeset
|
757 return scmutil.intrev(ctx) |
10054
1a85861f59af
cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents:
10053
diff
changeset
|
758 |
36595
2da414105809
templatekw: switch revset() to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36594
diff
changeset
|
759 def showrevslist(context, mapping, name, revs): |
26234
e4609ec959f8
templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
25984
diff
changeset
|
760 """helper to generate a list of revisions in which a mapped template will |
e4609ec959f8
templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
25984
diff
changeset
|
761 be evaluated""" |
36595
2da414105809
templatekw: switch revset() to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36594
diff
changeset
|
762 repo = context.resource(mapping, 'repo') |
40518
d11e2c5b287e
templater: compute revset lazily
Yuya Nishihara <yuya@tcha.org>
parents:
40477
diff
changeset
|
763 # revs may be a smartset; don't compute it until f() has to be evaluated |
d11e2c5b287e
templater: compute revset lazily
Yuya Nishihara <yuya@tcha.org>
parents:
40477
diff
changeset
|
764 def f(): |
d11e2c5b287e
templater: compute revset lazily
Yuya Nishihara <yuya@tcha.org>
parents:
40477
diff
changeset
|
765 srevs = ['%d' % r for r in revs] |
d11e2c5b287e
templater: compute revset lazily
Yuya Nishihara <yuya@tcha.org>
parents:
40477
diff
changeset
|
766 return _showcompatlist(context, mapping, name, srevs) |
26234
e4609ec959f8
templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
25984
diff
changeset
|
767 return _hybrid(f, revs, |
37103
be3f33f5e232
templater: switch 'revcache' based on new mapping items
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
768 lambda x: {name: x, 'ctx': repo[x]}, |
34581
ee0d74083a22
templater: store revisions as ints so min/max won't compare them as strings
Yuya Nishihara <yuya@tcha.org>
parents:
34541
diff
changeset
|
769 pycompat.identity, keytype=int) |
26234
e4609ec959f8
templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
25984
diff
changeset
|
770 |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
771 @templatekeyword('subrepos', requires={'ctx'}) |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
772 def showsubrepos(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
773 """List of strings. Updated subrepositories in the changeset.""" |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
774 ctx = context.resource(mapping, 'ctx') |
21897
764adc332f6e
templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21896
diff
changeset
|
775 substate = ctx.substate |
764adc332f6e
templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21896
diff
changeset
|
776 if not substate: |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
777 return compatlist(context, mapping, 'subrepo', []) |
41397
0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
Martin von Zweigbergk <martinvonz@google.com>
parents:
41300
diff
changeset
|
778 psubstate = ctx.p1().substate or {} |
21897
764adc332f6e
templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21896
diff
changeset
|
779 subrepos = [] |
764adc332f6e
templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21896
diff
changeset
|
780 for sub in substate: |
764adc332f6e
templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21896
diff
changeset
|
781 if sub not in psubstate or substate[sub] != psubstate[sub]: |
764adc332f6e
templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21896
diff
changeset
|
782 subrepos.append(sub) # modified or newly added in ctx |
764adc332f6e
templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21896
diff
changeset
|
783 for sub in psubstate: |
764adc332f6e
templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21896
diff
changeset
|
784 if sub not in substate: |
764adc332f6e
templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21896
diff
changeset
|
785 subrepos.append(sub) # removed in ctx |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
786 return compatlist(context, mapping, 'subrepo', sorted(subrepos)) |
21897
764adc332f6e
templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21896
diff
changeset
|
787 |
23977
0870bb93573c
templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23737
diff
changeset
|
788 # don't remove "showtags" definition, even though namespaces will put |
0870bb93573c
templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23737
diff
changeset
|
789 # a helper function for "tags" keyword into "keywords" map automatically, |
0870bb93573c
templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23737
diff
changeset
|
790 # because online help text is built without namespaces initialization |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
791 @templatekeyword('tags', requires={'repo', 'ctx'}) |
36593
900e5ee44307
templatekw: switch namespace template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36591
diff
changeset
|
792 def showtags(context, mapping): |
28539
119702a8b415
templatekw: use templatekeyword to mark a function as template keyword
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28538
diff
changeset
|
793 """List of strings. Any tags associated with the changeset.""" |
36593
900e5ee44307
templatekw: switch namespace template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36591
diff
changeset
|
794 return shownames(context, mapping, 'tags') |
23977
0870bb93573c
templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23737
diff
changeset
|
795 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
796 @templatekeyword('termwidth', requires={'ui'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
797 def showtermwidth(context, mapping): |
30088
d1f5f158768e
template: provide a termwidth keyword (issue5395)
Simon Farnsworth <simonfar@fb.com>
parents:
29669
diff
changeset
|
798 """Integer. The width of the current terminal.""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
799 ui = context.resource(mapping, 'ui') |
36442
e46b24582fa0
templatekw: minimize resource dependency of {envvars} and {termwidth}
Yuya Nishihara <yuya@tcha.org>
parents:
36441
diff
changeset
|
800 return ui.termwidth() |
30088
d1f5f158768e
template: provide a termwidth keyword (issue5395)
Simon Farnsworth <simonfar@fb.com>
parents:
29669
diff
changeset
|
801 |
38948
390287321b4b
templatekw: copy {author} to {user} and document {author} as an alias
Yuya Nishihara <yuya@tcha.org>
parents:
38774
diff
changeset
|
802 @templatekeyword('user', requires={'ctx'}) |
390287321b4b
templatekw: copy {author} to {user} and document {author} as an alias
Yuya Nishihara <yuya@tcha.org>
parents:
38774
diff
changeset
|
803 def showuser(context, mapping): |
390287321b4b
templatekw: copy {author} to {user} and document {author} as an alias
Yuya Nishihara <yuya@tcha.org>
parents:
38774
diff
changeset
|
804 """String. The unmodified author of the changeset.""" |
390287321b4b
templatekw: copy {author} to {user} and document {author} as an alias
Yuya Nishihara <yuya@tcha.org>
parents:
38774
diff
changeset
|
805 ctx = context.resource(mapping, 'ctx') |
390287321b4b
templatekw: copy {author} to {user} and document {author} as an alias
Yuya Nishihara <yuya@tcha.org>
parents:
38774
diff
changeset
|
806 return ctx.user() |
390287321b4b
templatekw: copy {author} to {user} and document {author} as an alias
Yuya Nishihara <yuya@tcha.org>
parents:
38774
diff
changeset
|
807 |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
37019
diff
changeset
|
808 @templatekeyword('instabilities', requires={'ctx'}) |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
809 def showinstabilities(context, mapping): |
33709
511d6ae462f3
template: rename troubles templatekw into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33476
diff
changeset
|
810 """List of strings. Evolution instabilities affecting the changeset. |
30712
5dde81de1e6d
templatekw: add a "troubles" template keyword
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30375
diff
changeset
|
811 (EXPERIMENTAL) |
5dde81de1e6d
templatekw: add a "troubles" template keyword
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30375
diff
changeset
|
812 """ |
36591
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
813 ctx = context.resource(mapping, 'ctx') |
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
814 return compatlist(context, mapping, 'instability', ctx.instabilities(), |
121a20e5da56
templatekw: switch most of showlist template keywords to new API (issue5779)
Yuya Nishihara <yuya@tcha.org>
parents:
36590
diff
changeset
|
815 plural='instabilities') |
30712
5dde81de1e6d
templatekw: add a "troubles" template keyword
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30375
diff
changeset
|
816 |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
817 @templatekeyword('verbosity', requires={'ui'}) |
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
818 def showverbosity(context, mapping): |
34993
625d5ebce066
templatekw: add verbosity keyword to select template by -q/-v/--debug flag
Yuya Nishihara <yuya@tcha.org>
parents:
34992
diff
changeset
|
819 """String. The current output verbosity in 'debug', 'quiet', 'verbose', |
625d5ebce066
templatekw: add verbosity keyword to select template by -q/-v/--debug flag
Yuya Nishihara <yuya@tcha.org>
parents:
34992
diff
changeset
|
820 or ''.""" |
36514
7b74afec6772
templatekw: switch non-showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36513
diff
changeset
|
821 ui = context.resource(mapping, 'ui') |
35888
c8e2d6ed1f9e
cmdutil: drop aliases for logcmdutil functions (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35508
diff
changeset
|
822 # see logcmdutil.changesettemplater for priority of these flags |
34993
625d5ebce066
templatekw: add verbosity keyword to select template by -q/-v/--debug flag
Yuya Nishihara <yuya@tcha.org>
parents:
34992
diff
changeset
|
823 if ui.debugflag: |
625d5ebce066
templatekw: add verbosity keyword to select template by -q/-v/--debug flag
Yuya Nishihara <yuya@tcha.org>
parents:
34992
diff
changeset
|
824 return 'debug' |
625d5ebce066
templatekw: add verbosity keyword to select template by -q/-v/--debug flag
Yuya Nishihara <yuya@tcha.org>
parents:
34992
diff
changeset
|
825 elif ui.quiet: |
625d5ebce066
templatekw: add verbosity keyword to select template by -q/-v/--debug flag
Yuya Nishihara <yuya@tcha.org>
parents:
34992
diff
changeset
|
826 return 'quiet' |
625d5ebce066
templatekw: add verbosity keyword to select template by -q/-v/--debug flag
Yuya Nishihara <yuya@tcha.org>
parents:
34992
diff
changeset
|
827 elif ui.verbose: |
625d5ebce066
templatekw: add verbosity keyword to select template by -q/-v/--debug flag
Yuya Nishihara <yuya@tcha.org>
parents:
34992
diff
changeset
|
828 return 'verbose' |
625d5ebce066
templatekw: add verbosity keyword to select template by -q/-v/--debug flag
Yuya Nishihara <yuya@tcha.org>
parents:
34992
diff
changeset
|
829 return '' |
625d5ebce066
templatekw: add verbosity keyword to select template by -q/-v/--debug flag
Yuya Nishihara <yuya@tcha.org>
parents:
34992
diff
changeset
|
830 |
37685
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
831 @templatekeyword('whyunstable', requires={'repo', 'ctx'}) |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
832 def showwhyunstable(context, mapping): |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
833 """List of dicts explaining all instabilities of a changeset. |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
834 (EXPERIMENTAL) |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
835 """ |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
836 repo = context.resource(mapping, 'repo') |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
837 ctx = context.resource(mapping, 'ctx') |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
838 |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
839 def formatnode(ctx): |
37707
24fee31fda05
templates: adjust white space amount in the output of {whyunstable}
Anton Shestakov <av6@dwimlabs.net>
parents:
37686
diff
changeset
|
840 return '%s (%s)' % (scmutil.formatchangeid(ctx), ctx.phasestr()) |
37685
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
841 |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
842 entries = obsutil.whyunstable(repo, ctx) |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
843 |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
844 for entry in entries: |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
845 if entry.get('divergentnodes'): |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
846 dnodes = entry['divergentnodes'] |
37686
b1b1b0626f59
templates: make divergentnodes in whyunstable keyword be a hybrid list
Anton Shestakov <av6@dwimlabs.net>
parents:
37685
diff
changeset
|
847 dnhybrid = _hybrid(None, [dnode.hex() for dnode in dnodes], |
b1b1b0626f59
templates: make divergentnodes in whyunstable keyword be a hybrid list
Anton Shestakov <av6@dwimlabs.net>
parents:
37685
diff
changeset
|
848 lambda x: {'ctx': repo[x]}, |
b1b1b0626f59
templates: make divergentnodes in whyunstable keyword be a hybrid list
Anton Shestakov <av6@dwimlabs.net>
parents:
37685
diff
changeset
|
849 lambda x: formatnode(repo[x])) |
b1b1b0626f59
templates: make divergentnodes in whyunstable keyword be a hybrid list
Anton Shestakov <av6@dwimlabs.net>
parents:
37685
diff
changeset
|
850 entry['divergentnodes'] = dnhybrid |
37685
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
851 |
37707
24fee31fda05
templates: adjust white space amount in the output of {whyunstable}
Anton Shestakov <av6@dwimlabs.net>
parents:
37686
diff
changeset
|
852 tmpl = ('{instability}:{if(divergentnodes, " ")}{divergentnodes} ' |
24fee31fda05
templates: adjust white space amount in the output of {whyunstable}
Anton Shestakov <av6@dwimlabs.net>
parents:
37686
diff
changeset
|
853 '{reason} {node|short}') |
37685
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
854 return templateutil.mappinglist(entries, tmpl=tmpl, sep='\n') |
76cd5816268e
templates: add whyunstable template keyword
Anton Shestakov <av6@dwimlabs.net>
parents:
37503
diff
changeset
|
855 |
34992
e2fc6cec0eff
templatekw: move loadkeyword() to bottom
Yuya Nishihara <yuya@tcha.org>
parents:
34991
diff
changeset
|
856 def loadkeyword(ui, extname, registrarobj): |
e2fc6cec0eff
templatekw: move loadkeyword() to bottom
Yuya Nishihara <yuya@tcha.org>
parents:
34991
diff
changeset
|
857 """Load template keyword from specified registrarobj |
e2fc6cec0eff
templatekw: move loadkeyword() to bottom
Yuya Nishihara <yuya@tcha.org>
parents:
34991
diff
changeset
|
858 """ |
e2fc6cec0eff
templatekw: move loadkeyword() to bottom
Yuya Nishihara <yuya@tcha.org>
parents:
34991
diff
changeset
|
859 for name, func in registrarobj._table.iteritems(): |
e2fc6cec0eff
templatekw: move loadkeyword() to bottom
Yuya Nishihara <yuya@tcha.org>
parents:
34991
diff
changeset
|
860 keywords[name] = func |
e2fc6cec0eff
templatekw: move loadkeyword() to bottom
Yuya Nishihara <yuya@tcha.org>
parents:
34991
diff
changeset
|
861 |
13585
2e80d495592a
templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
13386
diff
changeset
|
862 # tell hggettext to extract docstrings from these functions: |
26436
a2291c9c85a1
templatekw: remove dockeywords hack
Yuya Nishihara <yuya@tcha.org>
parents:
26435
diff
changeset
|
863 i18nfunctions = keywords.values() |