开发者

Converting subversion repository to mercurial converting revision IDs in commit logs

I'm converting a big (with about 9000 changesets) Subversion repository to Mercurial. It is coupled with Trac issue tracking system, so the commit logs have many cross-references to other revision IDs as well as ticket numbers.

I'm trying hgsubversion and convert extension. Both seems to work well with our repository, but the revision IDs referred in commit logs are not converted.

(The Trac part is rather simple -- we can just scan the database and c开发者_开发技巧onvert all occurrences of revision ID reference.)

So, I modified the source code of convert extension like this:

(mercurial_sink class in hg.py)

def _rewritedesc(self, desc, source, revmap):
    # Only for subversion source.
    # We assume that no future revision is mentioned in commit logs.
    rx_revision = re.compile(r'(r(\d+)|\[(\d+)\])') # it's actually defined in module header.
    def replacer(m):
        if m is None:
            return m.group(0)
        new_revid = revmap.get(source.source.revid(m.group(2) or m.group(3)))
        print 'converting commit log : %s -> [%s]' % (m.group(0), new_revid)
        if new_revid is None:
            return m.group(0)
        return '[%s]' % new_revid[:12]
    return rx_revision.sub(replacer, desc)

def putcommit(self, files, copies, parents, commit, source, revmap):
    ...
    text = self._rewritedesc(commit.desc, source, revmap)
    ...

It seems to work, but the problem is that conversion process does not scan changesets in which order they are committed. There are many missing conversion results.

Actually, convert extension provides several sorting options including "sourcesort" which processes the changesets in the commit order, but it's supported only for mercurial sources. "datesort" seems to work better in this way than "branchsort", but not as good as I want.

I surveyed whether I can modify commit logs after conversion process is complete (at that time, we have a complete revision ID map generated by the extension), but it's impossible--there are known hacks using mq and histedit extension but they changes the reivision ID.

Is there any folk who tried to do this or help me?


How about doing a two-step conversion? First convert the repository to Mercurial from SVN. Then run the convert extension again on your new Hg repository to convert all the descriptions? You should be able to use sourcesort then.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜