Mercurial > hg
changeset 5556:61fdf2558c0a
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.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Tue, 27 Nov 2007 09:44:09 -0800 |
parents | 86405ff6d74b |
children | c47484fab02e 7c1a9a21dcd7 |
files | hgext/convert/__init__.py hgext/convert/common.py hgext/convert/filemap.py hgext/convert/hg.py tests/test-convert tests/test-convert-cvs.out tests/test-convert-hg-sink tests/test-convert-hg-sink.out tests/test-convert-hg-source tests/test-convert-svn-source.out tests/test-convert.out |
diffstat | 11 files changed, 75 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- 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'
--- 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
--- 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
--- 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):
--- 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 <<EOF +[extensions] +convert= +[convert] +hg.saverev=False +EOF hg help convert
--- a/tests/test-convert-cvs.out Mon Nov 26 17:24:21 2007 -0800 +++ b/tests/test-convert-cvs.out Tue Nov 27 09:44:09 2007 -0800 @@ -44,7 +44,6 @@ checking in src/a,v checking in src/b/c,v % convert again -destination src-hg is a Mercurial repository connecting to cvsrepo scanning source... sorting... @@ -56,7 +55,6 @@ c c % convert again with --filemap -destination src-filemap is a Mercurial repository connecting to cvsrepo scanning source... sorting...
--- a/tests/test-convert-hg-sink Mon Nov 26 17:24:21 2007 -0800 +++ b/tests/test-convert-hg-sink Tue Nov 27 09:44:09 2007 -0800 @@ -1,7 +1,11 @@ #!/bin/sh -echo "[extensions]" >> $HGRCPATH -echo "hgext.convert=" >> $HGRCPATH +cat >> $HGRCPATH <<EOF +[extensions] +convert= +[convert] +hg.saverev=False +EOF hg init orig cd orig
--- a/tests/test-convert-hg-sink.out Mon Nov 26 17:24:21 2007 -0800 +++ b/tests/test-convert-hg-sink.out Tue Nov 27 09:44:09 2007 -0800 @@ -37,7 +37,6 @@ a 0 -1 unset baz copy: bar -> baz % add a new revision in the original repo -destination new is a Mercurial repository scanning source... sorting... converting...
--- 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 <<EOF +[extensions] +convert= +[convert] +hg.saverev=False +EOF hg init orig cd orig
--- a/tests/test-convert-svn-source.out Mon Nov 26 17:24:21 2007 -0800 +++ b/tests/test-convert-svn-source.out Tue Nov 27 09:44:09 2007 -0800 @@ -25,7 +25,6 @@ Committed revision 3. % test incremental conversion assuming destination trunk-hg -destination trunk-hg is a Mercurial repository scanning source... sorting... converting... @@ -86,7 +85,6 @@ Transmitting file data . Committed revision 11. % test incremental conversion -destination A-hg is a Mercurial repository scanning source... sorting... converting...
--- a/tests/test-convert.out Mon Nov 26 17:24:21 2007 -0800 +++ b/tests/test-convert.out Tue Nov 27 09:44:09 2007 -0800 @@ -55,6 +55,24 @@ 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 + options: -A --authors username mapping filename