tags:

views:

86

answers:

2

Well, the title says it all.

I'm wondering if I can copy one file and its history from one repository to another, without having to import the whole other repository.

A: 

That's not how Mercurial/Git/etc work - changesets are snapshots of the entire repository at any given point in time, rather than tracking changes to individual files separately.

Amber
+5  A: 

You can use the ConvertExtension to export just that one file from the first repository into a new temporary repository, then use hg pull -f to import the new repository into the target repository.

Create a filemap for the ConvertExtension with the single line:

include path/to/file

Then use:

hg convert path/to/original path/to/temporary --filemap filemap

to create the temporary repository. Next, in the target repository, do:

hg pull -f path/to/temporary

to pull in that file with its history. This will create a new head, so use hg merge to merge it with the head in your target repository.

Niall C.
I don't get it: I've made a lot of tries, and almost every time Iget a repository with just two commits (but with the correct files). It worked just ONCE and I don't have the slightest idea on what I did different :|
Lo'oris
ffs I got it: it doesn't handle file renames! You have to explicitly "include" all the previous names of the files too (and I don't know if he will remember they were renames instead of new files)
Lo'oris