Slide 37
Slide 37 text
"""printparents
Prints the parents of a given revision.
"""
from mercurial import util
def printparents(ui, repo, node, **opts):
"""Print parent information"""
ctx = repo[node]
parents = ctx.parents()
try:
if opts['short']:
ui.write('short %s %s\n' % (parents[0], parents[1]))
elif opts['long']:
ui.write('long %s %s\n' % (parents[0].hex(), parents[1].hex()))
else:
ui.write('default %s %s\n' % (parents[0], parents[1]))
except IndexError:
raise util.Abort('revision %s has only one parent' % node)
cmdtable = {
'print-parents': (printparents,
[('s', 'short', None, 'print short form'),
('l', 'long', None, 'print long form')],
'[options] REV')
}
printparents.py