rename question

Patrick Mézard pmezard at gmail.com
Thu Feb 14 10:08:59 CST 2008


brianharris a écrit :
> Hi, I've got a simple use case which I don't like the results of.  Could
> someone offer an alternative method, or a post-processing suggestion?
> 
> I'm migrating a single cvs repository to a single hg repository.  One of the
> modules in the cvs repo is called X.  The big issue is wasted disk space in
> the process.
> 
> After converting X, I now have an hg repository in a directory X-hg such
> that du -sh X-hg shows 530M, fine.  However, considering that I'm trying to
> recreate the directory structure of CVS, I want to move the contents of X-hg
> to a subdir called X to allow for future merging of additional converted CVS
> modules into this hg repository.  If I do the following:
> 
> cd X-hg;  for x in *; do hg rename $x X/$x; done;  hg commit -m "rename";
> 
> du -sh X-hg now shows 741M.  Obviousily, as this step is simply to recreate
> the old directory structure, I don't care about having this history trail
> so...  Is there some way to avoid the extra storage while arriving in the
> same state?

Convert extension allow you to filter or rename repository parts while converting with --filemap. You can do it during your initial CVS conversion, or by converting from Mercurial to Mercurial. Here is an example of the latter:

# Create the source repository
$ hg init t
$ cd t
$ echo a > a
$ mkdir d
$ echo b > d/b
$ hg add
adding a
adding d/b
$ hg ci -m t
$ tree
.
|-- a
`-- d
    `-- b

1 directory, 2 files
$ cd ..

# Edit the filemap
$ cat > filemap <<EOF
rename . X
EOF

# Convert
$ hg convert --filemap filemap t t2
initializing destination t2 repository
scanning source...
sorting...
converting...
0 t

# Check converted repository
$ cd t2
$ tree
.
`-- X
    |-- a
    `-- d
        `-- b

2 directories, 2 files
$ hg manifest
X/a
X/d/b
$ hg log
changeset:   0:7d4814cddf28
tag:         tip
user:        Patrick Mezard <pmezard at gmail.com>
date:        Thu Feb 14 17:01:34 2008 +0100
summary:     t


--
Patrick Mézard


More information about the Mercurial mailing list