comparison hgext/show.py @ 37680:e743b8524d60

scmutil: introduce shortesthexnodeidprefix() We have scmutil.resolvehexnodeidprefix() for resolving a prefix to a full nodeid, so it makes sense to have the inverse method next to it. For now it just delegates to changelog.shortest(), but it will soon also make sure it's called on the unfiltered repo, to match resolvehexnodeidprefix(). Note that the change in show.py also makes it so the conversion from revnum to nodeid is done on the filtered repo, but that should be inconsequential since the revs are all from the filtered repo anyway. Differential Revision: https://phab.mercurial-scm.org/D3370
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 13 Apr 2018 22:55:01 -0700
parents 6890b7e991a4
children 8e8541610d85
comparison
equal deleted inserted replaced
37679:ab828755e1ea 37680:e743b8524d60
43 phases, 43 phases,
44 pycompat, 44 pycompat,
45 registrar, 45 registrar,
46 revset, 46 revset,
47 revsetlang, 47 revsetlang,
48 scmutil,
48 ) 49 )
49 50
50 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for 51 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
51 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should 52 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
52 # be specifying the version(s) of Mercurial they are tested with, or 53 # be specifying the version(s) of Mercurial they are tested with, or
445 revision 10023 or node ``10023abc...``. 446 revision 10023 or node ``10023abc...``.
446 """ 447 """
447 if not revs: 448 if not revs:
448 return minlen 449 return minlen
449 # don't use filtered repo because it's slow. see templater.shortest(). 450 # don't use filtered repo because it's slow. see templater.shortest().
450 cl = repo.unfiltered().changelog 451 cl = repo.changelog
451 return max(len(cl.shortest(hex(cl.node(r)), minlen)) for r in revs) 452 return max(len(scmutil.shortesthexnodeidprefix(repo.unfiltered(),
453 hex(cl.node(r)),
454 minlen)) for r in revs)
452 455
453 # Adjust the docstring of the show command so it shows all registered views. 456 # Adjust the docstring of the show command so it shows all registered views.
454 # This is a bit hacky because it runs at the end of module load. When moved 457 # This is a bit hacky because it runs at the end of module load. When moved
455 # into core or when another extension wants to provide a view, we'll need 458 # into core or when another extension wants to provide a view, we'll need
456 # to do this more robustly. 459 # to do this more robustly.