Mercurial > hg
changeset 20372:45562379ce4e
convert: replace old sha1s in the description
This is a simple find-and-replace strategy for matching anything in the
old description of a converted commit and, if that matched sha1 exists
in the mapping, replacing it with the new sha1.
In particular, this is helpful for descriptions that contain tags with
messages such as, "Added tag 1.0 for commit abcde1234567" which will now
be automatically converted.
Tests have been updated accordingly.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Thu, 18 Apr 2013 10:05:50 -0500 |
parents | 6f3fb6a974e0 |
children | e8203629371b |
files | hgext/convert/hg.py tests/test-convert-hg-sink.t |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/hg.py Wed Feb 05 20:22:28 2014 -0800 +++ b/hgext/convert/hg.py Thu Apr 18 10:05:50 2013 -0500 @@ -25,6 +25,9 @@ from common import NoRepo, commit, converter_source, converter_sink +import re +sha1re = re.compile(r'\b[0-9a-f]{6,40}\b') + class mercurial_sink(converter_sink): def __init__(self, ui, path): converter_sink.__init__(self, ui, path) @@ -157,6 +160,14 @@ p2 = parents.pop(0) text = commit.desc + + sha1s = re.findall(sha1re, text) + for sha1 in sha1s: + oldrev = source.lookuprev(sha1) + newrev = revmap.get(oldrev) + if newrev is not None: + text = text.replace(sha1, newrev[:len(sha1)]) + extra = commit.extra.copy() if self.branchnames and commit.branch: extra['branch'] = commit.branch