def latest(self, vcdir, rev1, rev2, abortOnError=True):
#hg log -r 'heads(ancestors(26030a079b91) and ancestors(6245feb71195))' --template '{node}\n'
self.check_for_hg()
try:
revs = [rev1, rev2]
revsetIntersectAncestors = ' or '.join(('ancestors({})'.format(rev) for rev in revs))
revset = 'heads({})'.format(revsetIntersectAncestors)
out = subprocess.check_output(['hg', '-R', vcdir, 'log', '-r', revset, '--template', '{node}\n'])
parents = out.rstrip('\n').split('\n')
if len(parents) != 1:
if abortOnError:
abort('hg log returned {} possible latest (expected 1)'.format(len(parents)))
return None
return parents[0]
except subprocess.CalledProcessError:
if abortOnError:
abort('latest failed')
else:
return None
评论列表
文章目录