# HG changeset patch # User Bryan O'Sullivan # Date 1196185449 28800 # Node ID 61fdf2558c0ada2307f13d6c80bda2b2017959cc # Parent 86405ff6d74b541e1ffa1e8d85f128ec127c5682 convert: some tidyups, doc improvements, and test fixes The various back end options are now documented. The hg source can now be configured not to hand out a revision ID. diff -r 86405ff6d74b -r 61fdf2558c0a hgext/convert/__init__.py --- a/hgext/convert/__init__.py Mon Nov 26 17:24:21 2007 -0800 +++ b/hgext/convert/__init__.py Tue Nov 27 09:44:09 2007 -0800 @@ -332,6 +332,24 @@ The 'rename' directive renames a file or directory. To rename from a subdirectory into the root of the repository, use '.' as the path to rename to. + + Back end options: + + --config convert.hg.clonebranches=False (boolean) + hg target: XXX not documented + --config convert.hg.saverev=True (boolean) + hg source: allow target to preserve source revision ID + --config convert.hg.tagsbranch=default (branch name) + hg target: XXX not documented + --config convert.hg.usebranchnames=True (boolean) + hg target: preserve branch names + + --config convert.svn.branches=branches (directory name) + svn source: specify the directory containing branches + --config convert.svn.tags=tags (directory name) + svn source: specify the directory containing tags + --config convert.svn.trunk=trunk (directory name) + svn source: specify the name of the trunk branch """ util._encoding = 'UTF-8' diff -r 86405ff6d74b -r 61fdf2558c0a hgext/convert/common.py --- a/hgext/convert/common.py Mon Nov 26 17:24:21 2007 -0800 +++ b/hgext/convert/common.py Tue Nov 27 09:44:09 2007 -0800 @@ -40,7 +40,7 @@ class converter_source(object): """Conversion source interface""" - def __init__(self, ui, path, rev=None): + def __init__(self, ui, path=None, rev=None): """Initialize conversion source (or raise NoRepo("message") exception if path is not a valid repository)""" self.ui = ui diff -r 86405ff6d74b -r 61fdf2558c0a hgext/convert/filemap.py --- a/hgext/convert/filemap.py Mon Nov 26 17:24:21 2007 -0800 +++ b/hgext/convert/filemap.py Tue Nov 27 09:44:09 2007 -0800 @@ -7,7 +7,7 @@ import shlex from mercurial.i18n import _ from mercurial import util -from common import SKIPREV +from common import SKIPREV, converter_source def rpairs(name): e = len(name) @@ -110,9 +110,9 @@ # touch files we're interested in, but also merges that merge two # or more interesting revisions. -class filemap_source(object): +class filemap_source(converter_source): def __init__(self, ui, baseconverter, filemap): - self.ui = ui + super(filemap_source, self).__init__(ui) self.base = baseconverter self.filemapper = filemapper(ui, filemap) self.commits = {} @@ -344,9 +344,3 @@ def gettags(self): return self.base.gettags() - - def before(self): - pass - - def after(self): - pass diff -r 86405ff6d74b -r 61fdf2558c0a hgext/convert/hg.py --- a/hgext/convert/hg.py Mon Nov 26 17:24:21 2007 -0800 +++ b/hgext/convert/hg.py Tue Nov 27 09:44:09 2007 -0800 @@ -1,10 +1,16 @@ # hg backend for convert extension -# Note for hg->hg conversion: Old versions of Mercurial didn't trim -# the whitespace from the ends of commit messages, but new versions -# do. Changesets created by those older versions, then converted, may -# thus have different hashes for changesets that are otherwise -# identical. +# Notes for hg->hg conversion: +# +# * Old versions of Mercurial didn't trim the whitespace from the ends +# of commit messages, but new versions do. Changesets created by +# those older versions, then converted, may thus have different +# hashes for changesets that are otherwise identical. +# +# * By default, the source revision is stored in the converted +# revision. This will cause the converted revision to have a +# different identity than the source. To avoid this, use the +# following option: "--config convert.hg.saverev=false" import os, time @@ -181,6 +187,7 @@ class mercurial_source(converter_source): def __init__(self, ui, path, rev=None): converter_source.__init__(self, ui, path, rev) + self.saverev = ui.configbool('convert', 'hg.saverev', True) try: self.repo = hg.repository(self.ui, path) # try to provoke an exception if this isn't really a hg @@ -239,8 +246,12 @@ def getcommit(self, rev): ctx = self.changectx(rev) parents = [hex(p.node()) for p in ctx.parents() if p.node() != nullid] + if self.saverev: + crev = rev + else: + crev = None return commit(author=ctx.user(), date=util.datestr(ctx.date()), - desc=ctx.description(), rev=rev, parents=parents, + desc=ctx.description(), rev=crev, parents=parents, branch=ctx.branch(), extra=ctx.extra()) def gettags(self): diff -r 86405ff6d74b -r 61fdf2558c0a tests/test-convert --- a/tests/test-convert Mon Nov 26 17:24:21 2007 -0800 +++ b/tests/test-convert Tue Nov 27 09:44:09 2007 -0800 @@ -1,7 +1,11 @@ #!/bin/sh -echo "[extensions]" >> $HGRCPATH -echo "convert=" >> $HGRCPATH +cat >> $HGRCPATH <> $HGRCPATH -echo "hgext.convert=" >> $HGRCPATH +cat >> $HGRCPATH < baz % add a new revision in the original repo -destination new is a Mercurial repository scanning source... sorting... converting... diff -r 86405ff6d74b -r 61fdf2558c0a tests/test-convert-hg-source --- a/tests/test-convert-hg-source Mon Nov 26 17:24:21 2007 -0800 +++ b/tests/test-convert-hg-source Tue Nov 27 09:44:09 2007 -0800 @@ -1,7 +1,11 @@ #!/bin/sh -echo "[extensions]" >> $HGRCPATH -echo "hgext.convert=" >> $HGRCPATH +cat >> $HGRCPATH <