How does Hg do file renames?

Matt Schulte matts at commtech-fastcom.com
Tue Jul 13 18:24:42 UTC 2010


  On 7/13/2010 11:40 AM, Giorgos Keramidas wrote:
> On Tue, 13 Jul 2010 09:33:58 -0500, Matt Schulte<matts at commtech-fastcom.com>  wrote:
>>   On 7/13/2010 1:41 AM, Giorgos Keramidas wrote:
>>> On Mon, 12 Jul 2010 10:23:42 -0500, Matt Schulte<matts at commtech-fastcom.com>   wrote:
>>>> Another scenario (which I am currently struggling with): I had
>>>> a large repo that was converted over from CVS.  Large repos are
>>>> not very nice in hg so we decided to break them out into
>>>> smaller, manageable repos.  This was going just fine using hg
>>>> convert for an hg-to-hg conversion.  Then I come to a project
>>>> that has been renamed.  If I convert the project folder into
>>>> its own new repo, all of the history from before the rename is
>>>> gone.  hg log -f only shows me the history SINCE the rename and
>>>> everything BEFORE the rename is essentially lost to the new
>>>> repo.  This means that my original intention of shelving the
>>>> original huge repo is no longer possible because I will have to
>>>> keep it around just to see the history of files/folders that
>>>> were renamed.
>>> FWIW, you can graft the history of two separate hg repositories
>>> using the splicemap feature of convert.  It's not a pretty UI,
>>> it's a bit low-level work, but starting from two CVS sub-projects
>>> with histories:
>>>
>>>       A1 -- A2 -- A3
>>>
>>>       B1 -- B2 -- B3
>>>
>>> You should be able to "join" the two histories by importing a
>>> snapshot of B1 on top of A3 using "hg addremove" to create:
>>>
>>>       A1 -- A2 -- A3 -- B1'
>>>
>>> Then convert can use a splicemap can graft B2 -- B3 on top of
>>> change B1' to create:
>>>
>>>       A1 -- A2 -- A3 -- B1' -- B2' -- B3'
>>>
>>> If you use "hg addremove" for B1' then any renames between A3 and
>>> B1' that simply move stuff around in the CVS module code will
>>> DTRT and "hg log --follow" on the final history will IMO make
>>> more sense.
>> I'm looking at "hg addremove" and I am not seeing how it can do what you
>> describe.  Could you possibly provide more details as to what you mean?
> Hi Matt,
>
> Sure; I can do that.  Just a clarification before I go away and do work
> that is not needed...
>
> If I understood the question correctly, you had a module A in the root
> of the CVS repository that was later copied/renamed to module B.
>
> Converting both from a single CVS checkout of both modules doesn't work,
> because the copy/rename operation done through CVS is not recorded at
> all in the history (CVS doesn't record explicit renames).  So you want
> to "join" the histories of two CVS module conversions to one coherent
> set of mercurial commits.
>
> If this is a correct understanding of what you are trying to do, I'll
> try to set up a small CVS sample repository, do a few test commits,
> rename the toplevel module and then do a few more commits.  Then write a
> description of the steps to join the two hg-converted modules and post
> it here or on the Wiki.

Not quite.  I actually did the rename from A to B in hg after I 
converted the repo out of CVS.  We have officially left CVS in the past 
and are trying to make our new hg repos a bit more hg/distributed friendly.

You can see the steps that I used to reproduce my problem back a few 
emails.  In that I can make it happen purely in hg with no CVS involvement.

Matt Schulte





More information about the Mercurial mailing list