Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 32678: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 | 9d201b39ccd9 |
comparison
equal
deleted
inserted
replaced
32677:9fbd8ad398aa | 32678:55ff67ffcead |
---|---|
13 import re | 13 import re |
14 import tempfile | 14 import tempfile |
15 | 15 |
16 from .i18n import _ | 16 from .i18n import _ |
17 from .node import ( | 17 from .node import ( |
18 bin, | |
19 hex, | 18 hex, |
20 nullid, | 19 nullid, |
21 nullrev, | 20 nullrev, |
22 short, | 21 short, |
23 ) | 22 ) |
1347 hexfunc = hex | 1346 hexfunc = hex |
1348 else: | 1347 else: |
1349 hexfunc = short | 1348 hexfunc = short |
1350 # as of now, wctx.node() and wctx.rev() return None, but we want to | 1349 # as of now, wctx.node() and wctx.rev() return None, but we want to |
1351 # show the same values as {node} and {rev} templatekw | 1350 # show the same values as {node} and {rev} templatekw |
1352 revnode = (scmutil.intrev(ctx), hexfunc(bin(ctx.hex()))) | 1351 revnode = (scmutil.intrev(ctx), hexfunc(scmutil.binnode(ctx))) |
1353 | 1352 |
1354 if self.ui.quiet: | 1353 if self.ui.quiet: |
1355 self.ui.write("%d:%s\n" % revnode, label='log.node') | 1354 self.ui.write("%d:%s\n" % revnode, label='log.node') |
1356 return | 1355 return |
1357 | 1356 |