[darcs-users] How to separate some files from a repository

Rob Moss rob.rgm at gmail.com
Thu May 17 16:56:06 UTC 2012


On 17 May 2012 16:56, Lele Gaifax <lele at metapensiero.it> wrote:
> Last time I did something like that, for exactly the same reasons, I
> used tailor, using its pre-commit hook to filter out unwanted entries
> from the changesets.
>
> Nowadays I'd probably try to exercise the new fast-import/export way,
> at least that's what I successfully used to do similar tweaks exporting
> from a bzr repo to git.

Thanks for the suggestion. I've successfully used darcs-fastconvert to
create a git repository, then I used git filter-branch to rewrite the
history, and then used darcs-fastconvert again to create a new darcs
repository. It was certainly much easier than doing things by hand!

If anyone else is interested, here are the steps I took:

# Create a git repository with identical contents
cd original_repo/..
mkdir git_repo && cd git_repo && git init
(cd ../original_repo; darcs-fastconvert export) | git fast-import
git checkout

# Remove all other files from every commit
git filter-branch --tree-filter "rm -rf $SKIP_FILES"

# Create a new darcs repository with the modified patches
git fast-export -M -C --progress=1 HEAD -- | darcs-fastconvert import
../new_repo

# Keep only the relevant (non-empty) patches
cd ../new_repo
darcs unrecord --matches 'not touch file1 && ... && not touch fileN' --all

> Either way, you must be of course aware that the resulting repository
> won't be “compatible” with the original, because as you says it will
> contain *modified version* of the patches.

Yes, certainly. My intention is to split out a one or two modules into
a separate library, which I can then use across multiple projects (and
delete the modules from the original project's repository). I simply
wanted to retain the incremental history (bug-fixes, test cases, new
features) in the library repository.

Many thanks for your advice,
Rob


More information about the darcs-users mailing list