Search code examples
mercurialtransplanthg-log

Printing transplant source changeset hash


We've transplanted a changeset from another repository to the current one. It seems to us that the transplant extensions stores the original changset hash in an extra field which can be shown with hg log --debug, like:

changeset:   720:092506
tag:         tip
parent:      ...
parent:      ...
manifest:    ...
user:        ...
date:        ...
files:       ...
extra:       branch=default
extra:       transplant_source=\xe3>\xa7py\xff\xcda\x93d\xde\xa5\xb5\xa6\xf7\xed\xc0\x16\x82\xa3
description:
Bugfix, ...

Here the original changset hash (transplant_source) is not too readable and usable. How can we print the transplant_source in a readable format with hg log command?

I've played with ifeq and the list operator without success.


Solution

  • Disgusting, and doesn't answer the question, but seems to work (Python 2): :)

    hg log --debug | python -c "import sys, re; x=re.compile(r'^extra:\\s+transplant_source='); print '\\n'.join([l.split('=',1)[0]+'='+eval('\"'+l.split('=',1)[1].strip()+'\"').encode('hex') if x.match(l) else l.rstrip('\\n') for l in sys.stdin])"