Mercurial > hg
comparison mercurial/templatekw.py @ 32658:55ff67ffcead
scmutil: introduce binnode(ctx) as paired function with intrev(ctx)
It seemed silly to convert ctx.hex() back to binary to use node.hex/short(),
or to use [:12] instead of node.short() because ctx.node() could be None.
Eventually I want to change wctx.rev() and wctx.node() to return wdirrev and
wdirid respectively, but that's quite big API breakage and can't be achieved
without some compatibility wrappers.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 03 Jun 2017 19:12:01 +0900 |
parents | 4bec8cce6a09 |
children | 1858fc2327ef |
comparison
equal
deleted
inserted
replaced
32657:9fbd8ad398aa | 32658:55ff67ffcead |
---|---|
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 from .i18n import _ | 10 from .i18n import _ |
11 from .node import hex, nullid | 11 from .node import ( |
12 hex, | |
13 nullid, | |
14 short, | |
15 ) | |
16 | |
12 from . import ( | 17 from . import ( |
13 encoding, | 18 encoding, |
14 error, | 19 error, |
15 hbisect, | 20 hbisect, |
16 patch, | 21 patch, |
156 def _formatrevnode(ctx): | 161 def _formatrevnode(ctx): |
157 """Format changeset as '{rev}:{node|formatnode}', which is the default | 162 """Format changeset as '{rev}:{node|formatnode}', which is the default |
158 template provided by cmdutil.changeset_templater""" | 163 template provided by cmdutil.changeset_templater""" |
159 repo = ctx.repo() | 164 repo = ctx.repo() |
160 if repo.ui.debugflag: | 165 if repo.ui.debugflag: |
161 hexnode = ctx.hex() | 166 hexfunc = hex |
162 else: | 167 else: |
163 hexnode = ctx.hex()[:12] | 168 hexfunc = short |
164 return '%d:%s' % (scmutil.intrev(ctx), hexnode) | 169 return '%d:%s' % (scmutil.intrev(ctx), hexfunc(scmutil.binnode(ctx))) |
165 | 170 |
166 def getfiles(repo, ctx, revcache): | 171 def getfiles(repo, ctx, revcache): |
167 if 'files' not in revcache: | 172 if 'files' not in revcache: |
168 revcache['files'] = repo.status(ctx.p1(), ctx)[:3] | 173 revcache['files'] = repo.status(ctx.p1(), ctx)[:3] |
169 return revcache['files'] | 174 return revcache['files'] |