简体   繁体   English

使用移动和重新定位的提交迁移git svn提交

[英]Migrating git svn commits with moved and relocated commits

We are trying to migrate our main source repository from svn to git My first try was to simply do an git svn clone. 我们正在尝试将主要的源存储库从svn迁移到git。我的第一步是简单地进行git svn克隆。 After cloning was done I find that the first commit is in november 2012. I know for a fact that the code is a couple of years old Examining the svn repo it looks like the first commit to the main directory took place in november 2012, while several files inside the repo have been committed years before that. 克隆完成后,我发现第一次提交是在2012年11月。我知道一个事实,即代码已经存在了两年之久。检查svn repo看起来就像第一次提交到主目录是在2012年11月,而在此之前,仓库中已提交了多个文件。 So how can files inside a directory be committed before the parent directory.. 那么如何将目录中的文件提交到父目录之前。

I asked around as I'm new in the company, and no one knows for sure, but this repo has experienced a couple of svn relocate and svn move in an unusal way, for example they developed into a branch then moved that branch as a directory inside trunk, or developed into a branch, then renamed that branch as trunk and so on. 我是公司的新手,我四处询问,但没人知道,但是这个仓库经历了几次svn搬迁和svn移动,这是一种不常见的方式,例如,他们发展成为一个分支,然后将该分支作为在主干内的目录中,或发展成一个分支,然后将该分支重命名为主干,依此类推。

I picked one of those old commits that happened before november 2012 and can be queried using git log and tried 我选择了2012年11月之前发生的旧提交之一,可以使用git log查询并尝试

svn up -r 599 http://myrepo/trunk

and received the error: 并收到错误:

svn: E195012: Unable to find repository location for 'http://myrepo/trunk' in revision 559

This error is reproducible for all committs before november 2012, ie those that can be queried using svn log, but cannot be checked out 对于2012年11月之前的所有提交,都可以重现此错误,即可以使用svn log查询但无法检出的那些提交

The good news is that I'm able to do something like: 好消息是我可以执行以下操作:

svn diff -r 599 http://myrepo/trunk

My next approach is to run through all commits using svn diff, create patches and applies them to git using the original author, date, etc... 我的下一个方法是使用svn diff运行所有提交,创建补丁,然后使用原始作者,日期等将其应用于git。

Any better ideas how to extract such corrupted commits? 有更好的主意如何提取此类损坏的提交吗?

I do not have physical access to the repo, and I can't use svnadmin 我无权访问该存储库,因此无法使用svnadmin

Edit 1: 编辑1:

It turned out I was not querying the root directory, but one level down the tree, that's why I was getting such errors. 原来,我不是在查询根目录,而是在树的下一级查询,这就是为什么我会得到这样的错误。 Anyways I did an svnrdump and succeeded in dumping the whole repository (> 32K commits), also the repo contained corrupted commits which I had to skip. 无论如何,我都做了一个svnrdump并成功转储了整个存储库(> 32K提交),而且仓库包含了我不得不跳过的损坏的提交。

Further it has been imported locally. 此外,它已本地导入。 This helped me further understand what has happened 这有助于我进一步了解发生了什么

Basicaly, the repo used to have a very chaotic structure, something like 基本上,回购交易曾经具有非常混乱的结构,例如

svn 
   |_Project1 
         |_subproject1 
               |_branches 
                      |_branch1 
                      |_branch2 
               |_trunk 
               |_tags 
                      |_tagv1 
   |_Non-JavaProject 
         |_subproject 
   |_Project2 
          |_AnotherSubproject 
               |_SubSubproject 
          |_Subproject2 
               |_branches 
               |_tags 
          |_Subproject3 
               |_trunk 
          |_Subproject4 
               |_Subsubproject 
                       |_branches 
                       |_tags 
                       |_trunk

What happened afterwards, is that using a mixture of svn mv and copy, the structure was refined a bit 之后发生的事情是,使用svn mv和copy的混合物,对结构进行了一些改进

svn |_mainProject |_trunk |_branches |_tags svn | _mainProject | _trunk | _branches | _tags

So now we have paths like 所以现在我们有了像

mainProject/trunk/_Project1
mainProject/trunk/_Project1/subproject1
mainProject/trunk/Project2/AnotherSubproject/SubSubproject 

and the same goes for branches/tags 分支机构/标签也是如此

In other words, I need to to define in .git/config in the fetch and other headers a method so that different directories from mainProject will follow different (multiple) old paths 换句话说,我需要在fetch和其他标头中的.git / config中定义一个方法,以便来自mainProject的不同目录将遵循不同的(多个)旧路径

Is this possible? 这可能吗?

In SVN branches, including trunks are essentially just directories in a repository. 在SVN分支中,包括中继在内的分支实际上只是存储库中的目录。 One way you can figure out where your files were before r599 is by running log on the root of SVN repo in verbose mode. 您可以通过详细模式在SVN存储库根目录上运行log来确定r599之前文件的位置的一种方法。 Ie svn log -v http://myrepo/@599 It will show you all commits and the paths they touched before r599 in that repository, including commits to branches, renames, etc. One of those will be the commit that moved directories around. svn log -v http://myrepo/@599它将向您显示所有提交以及它们在r599之前在该存储库中涉及的路径 ,包括对分支,重命名等的提交。其中之一就是将目录移动到周围的提交。 。 This will help you where the files were before that commit and you could checkout previous revision from its old location. 这将帮助您提交之前文件所在的位置,并且可以从旧版本中检出以前的修订。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM