Mercurial > hg
comparison mercurial/scmutil.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 | 7b17f9de6d3e |
comparison
equal
deleted
inserted
replaced
32657:9fbd8ad398aa | 32658:55ff67ffcead |
---|---|
13 import os | 13 import os |
14 import re | 14 import re |
15 import socket | 15 import socket |
16 | 16 |
17 from .i18n import _ | 17 from .i18n import _ |
18 from .node import wdirrev | 18 from .node import ( |
19 wdirid, | |
20 wdirrev, | |
21 ) | |
22 | |
19 from . import ( | 23 from . import ( |
20 encoding, | 24 encoding, |
21 error, | 25 error, |
22 match as matchmod, | 26 match as matchmod, |
23 pathutil, | 27 pathutil, |
374 yield hgname | 378 yield hgname |
375 else: | 379 else: |
376 newdirs.append(d) | 380 newdirs.append(d) |
377 dirs[:] = newdirs | 381 dirs[:] = newdirs |
378 | 382 |
383 def binnode(ctx): | |
384 """Return binary node id for a given basectx""" | |
385 node = ctx.node() | |
386 if node is None: | |
387 return wdirid | |
388 return node | |
389 | |
379 def intrev(ctx): | 390 def intrev(ctx): |
380 """Return integer for a given basectx that can be used in comparison or | 391 """Return integer for a given basectx that can be used in comparison or |
381 arithmetic operation""" | 392 arithmetic operation""" |
382 rev = ctx.rev() | 393 rev = ctx.rev() |
383 if rev is None: | 394 if rev is None: |