[PATCH] convert-repo: --ignore and --usermap for CVS

Matt Mackall mpm at selenic.com
Fri May 18 19:36:12 UTC 2007


On Fri, May 18, 2007 at 09:56:12PM +0300, Timo Sirainen wrote:
> --usermap=file takes a file in CVSROOT/users file format
> 
> --ignore=file ignores a file completely in conversion. With CVS I was
> generating a ChangeLog file and committing it all the time. I really
> didn't want those 7000 changesets into Mercurial repository.

Firstly, this should be two patches.

> If the changes have something stupid in them, it's because I'm not a
> real Python programmer.

Your Python looks fine, except for inconsistent indent levels.
 
> # HG changeset patch
> # User Timo Sirainen <tss at iki.fi>
> # Date 1179513790 -10800
> # Node ID d6c1406103506efe8c86f639b1d311a19d10a187
> # Parent  3900f684a150ba9a847c499dd7bf6bf139070866
> Added --ignore=<file> and --usermap=<file> options for CVS converter.
> 
> diff -r 3900f684a150 -r d6c140610350 contrib/convert-repo
> --- a/contrib/convert-repo	Thu May 17 09:29:30 2007 -0700
> +++ b/contrib/convert-repo	Fri May 18 21:43:10 2007 +0300
> @@ -58,11 +58,21 @@ def recode(s):
>  
>  # CVS conversion code inspired by hg-cvs-import and git-cvsimport
>  class convert_cvs:
> -    def __init__(self, path):
> +    def __init__(self, path, opts):
>          self.path = path
>          cvs = os.path.join(path, "CVS")
>          if not os.path.exists(cvs):
>              raise NoRepo("couldn't open CVS repo %s" % path)
> +
> +        self.usermap = {}
> +        if opts.get('usermap'):
> +            for l in file(opts['usermap']):
> +                user, name = l[:-1].split(":")
> +                self.usermap[user] = name
> +
> +        self.file_ignores = {}
> +        if opts.get('ignore'):
> +            self.file_ignores[opts['ignore']] = True

I think both of these features could be implemented globally. We just
have to fiddle with the changeset from the source repo before passing
it off to the destination. Then they'd automatically work for CVS,
git, SVN, and whatever else we might add.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial mailing list