--- a/mercurial/scmutil.py Sat Sep 02 23:13:54 2017 +0900
+++ b/mercurial/scmutil.py Sun Sep 24 12:43:57 2017 +0900
@@ -19,6 +19,7 @@
from .node import (
hex,
nullid,
+ short,
wdirid,
wdirrev,
)
@@ -405,6 +406,20 @@
return wdirrev
return rev
+def formatchangeid(ctx):
+ """Format changectx as '{rev}:{node|formatnode}', which is the default
+ template provided by cmdutil.changeset_templater"""
+ repo = ctx.repo()
+ return formatrevnode(repo.ui, intrev(ctx), binnode(ctx))
+
+def formatrevnode(ui, rev, node):
+ """Format given revision and node depending on the current verbosity"""
+ if ui.debugflag:
+ hexfunc = hex
+ else:
+ hexfunc = short
+ return '%d:%s' % (rev, hexfunc(node))
+
def revsingle(repo, revspec, default='.', localalias=None):
if not revspec and revspec != 0:
return repo[default]