Move folder / files between repositories without losing Change history

5
  

Context:
  I have a versioning environment in Mercurial using TortoiseHG for viewing and commits and files. I want to move a folder from one repository to another and without losing the change history , I would like to know if it is possible and how.

     

For the purpose of explanation, let's assume that I have the A and B repositories, both of which have been used for years, and with hundreds of changes .

Goal:
In the A repository I have the folder (and with about 200 files and various formats):

C:\Repositorios\A\projetos\projeto1\artefatos

I would then move the artifacts folder with your content to the B repository, which has a different folder structure:

C:\Repositorios\B\objetos\arquitetura\etc\etc\artefatos

Thank you.

    
asked by anonymous 09.10.2015 / 17:15

3 answers

2

Two repositories, the Old , and New . They are totally different.

We need to add the contents of the old repository to the new repository. But each one has its default branch. What can we do to help Mercurial?

The solution seems simple: Create a new branch in the old repository (one that does not exist in the new repository), synchronize with the new repository, and merge ( merge ) this branch with the% . Check below the steps below:

  • Initial state of the repositories Old and the New . InOldweonlyhavethedirectorydefault InNewwehavethestructurex1
  • Changefilesintheoldrepository,followingthesamestructureasthenewrepository.Deletefilesthatarenotwanted.Detectthechangescorrectly.
  • CreatenewbranchintheOldrepository,herecalleda\b\c. Afterthenewbranchiscreated,makevelhodefault(withallthechangesmadeinstep2).
  • Intheoldrepository,addconnectiontothenewrepository.Itmaybealocalpath,usingcommitprotocol.
  • Tosynchronize,choosetherepository(thepushbuttonsidebox),andpressthesubmitbutton(twoyellowcylindericon,andagreenarrowpointingup). AtthistimeMercurialwillnotaccepttosendthecontent.Asmentionedearlier,theyaretwodistinctrepositories.Wewillhavetoforcesynchronization. Toforce,pressthefile://button,locatedintheopçõessection.ChoosetheSincronizaroptionandpresstheForçapushoupullbutton. NoticethattheGravar Trytosyncagain.CheckouthowthecontentwasintheNewrepository.
  • Atthispointyoujustneedtomergethecontentsoftheoldrepository,choosingtherightbranch. PresstheOpçõesSelecionadas:--forcebutton. PresstheAvançarbutton. PresstheAvançarbutton. Themergeiscomplete.
  • Ifeverythingwentwell,thefinalstateoftherepositorywillbelikethis.ItcanbeseenthatwehavetheConsolidarAgorabranchoccurringtwice.Sincethedefaultbranchisthelinkbetweenthem.
  • Feelfreetoclonetherepositories Old and New , and do your experiments.

        
    01.12.2015 / 04:10
    2

    You can use the ConvertExtension extension to export only that 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 ConvertExtension

    touch myfilemap
    

    Add the line to your content:

    include caminho/para/arquivo
    

    Then type:

    hg convert caminho/para/arquivo/original caminho/para/arquivo/destino --filemap "myfilemap"

    to create the temporary repository. Then, in the destination repository, type:

    hg pull -f caminho/para/temporario

    to pull this file with your history. This will create a new HEAD. Use

    hg merge

    to merge it with the HEAD of your target repository.

        
    09.10.2015 / 19:16
    1

    I do not use Tortoise, but I use GIT and VSTS and I've been through something like that.

    I decided to create a new Branch of the project in a different path, and this new branch became the main branch. So we started working on the new path.

    After all% s are done, we exclude the original / old folder on the developers' machines, since versioning continues on the server.

        
    26.11.2015 / 20:25