允许hgsubversion SVN克隆回退所需的步骤 [英] Steps needed to allow hgsubversion SVN clone to push back

查看:76
本文介绍了允许hgsubversion SVN克隆回退所需的步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个主要使用SVN的团队中工作,而我更愿意在可能的情况下使用Mercurial.我使用hgsubversion设置了SVN存储库的hg克隆,并且几个基本的pull/commit/pushes似乎都可以正常工作.

I am working on a team that uses SVN primarily, whereas I prefer to use Mercurial when possible. I set up an hg clone of the SVN repo using hgsubversion, and several basic pulls/commits/pushes seemed to function fine.

现在,在进行了两周的本地开发(在这段时间内,我已经合并了来自外部hg存储库的更改,并多次合并了来自SVN存储库的更改),我尝试推送到SVN存储库,但是失败,并显示以下消息:

Now after 2 weeks of local development (during which time I've merged in changes from an external hg repo, and merged in changes from the SVN repo multiple times), I've attempted to push to the SVN repo, but failed with this message:

中止:对不起,找不到合并修订的svn父级.

abort: Sorry, can't find svn parent of a merge revision.

我发现其他用户也遇到了相同的问题,并介绍了如何避免该问题的解决方法,但是我还没有遇到任何似乎可以解决的问题,这些问题涉及解决多个并行提交以清理现有hgsubversion存储库的问题.

I've found other users encountering the same problem, with how-tos on how to avoid this issue going forward, but I haven't encountered anything that seems to address condensing multiple parallel commits to clean up an existing hgsubversion repo.

在不丢失自己提交的情况下纠正问题的最佳方法是什么? (有分步说明吗?)

What is the best way that I can rectify matters without losing my own commits? (With step-by-step instructions?)

推荐答案

由于SVN无法理解hg合并,因此无法将其合并到Subversion存储库中.您需要在最新的SVN提交基础上重新进行更改.

You can't push hg merges into a subversion repository, since SVN can't understand them. You need to rebase your changes on top of the latest SVN commit.

编辑:整理历史记录的步骤:

Edit Steps to flatten the history:

警告,准备好进行很多合并冲突

Warning, be prepared to do have lots of merge conflicts

您需要激活mq和rebase扩展

You need the mq and rebase extension activated

第一步是创建一个备份仓库,因为您将需要它作为即将发生的合并冲突的参考(可能会遇到许多冲突).

The first step is to create a backup repo, since you will need it as a reference for the upcoming merge conflicts (expect many of them).

说您的图形如下:

C1--C2--C3------M1--C5--C6--C7---M2--
  \            / \              /
   \--B1--B2--/   \--B3--B4-B5-/

然后第二步是将B1 + B2重新建立在C3的基础上:hg rebase -b B2 -d C3

Then the second step is to rebase B1+B2 on top of C3: hg rebase -b B2 -d C3

-b使用两个分支的公共基数作为要重定分支的起点,因此,mercurial发现B1是第一个偏差提交,即使您说要重定B2也使用它. -d指定重新分支的目的地.

-b use the common base of both branches as the start for the branch to rebase, so mercurial finds that B1 is the first deviation commit und uses this even when you say B2 to rebase. -d specifies the destination of the rebased branch.

一旦遇到合并冲突,然后确保B2'= M1的结果,否则在以下版本中您会遇到很多冲突.

Wen you encounter merge conflicts then ensure that the result of B2' = M1, else you will get lots of conflicts in the following revisions.

此后,合并M1消失了,您的图形如下所示:

Afterwards Merge M1 is gone and your graph looks like this:

C1--C2--C3--B1'--B2'--C5'--C6'--C7'---M2'--
                   \                 /
                    \--B3'--B4'-B5'-/

现在,您对第二个合并执行相同的操作:hg rebase -b B3' -d C7',这使您的存储库如下所示:

and now you do the same for the second merge: hg rebase -b B3' -d C7', which makes your repo look like this:

C1--C2--C3--B1'--B2'--C5'--C6'--C7'--B3''--B4''--B5''

重复此操作,直到获得所有线性版本历史记录为止.

Repeat until you have an all linear version history.

拉平历史记录后,您需要在svn提交的基础上对提交进行重新排序. 假设您的仓库现在看起来像这样(S = subversion提交,C = local提交):

After you have flattened the history you need to reorder your commits on top of the svn commits. Say your repo now looks like this (S=subversion commit, C=local commit):

S1--S2--S3--C1--C2--S4--S5--C3-C4--C5--C6--C7--S6--S7

现在,您将所有内容(包括C1)导入Mercurial队列(hg qimport -rC1:).要查看所有已创建的补丁,请使用hg qseries.

Now you import everything from (including) C1 into a mercurial queue (hg qimport -rC1:). To view all created patches use hg qseries.

然后取消应用所有修补程序(hg qgoto C1.diff [this is the first one in qseries],然后是hg qpop).然后您删除颠覆者(hg qdelete S4.diff S5.diff S6.diff S7.diff).

Then you unapply all patches (hg qgoto C1.diff [this is the first one in qseries], followed by hg qpop). Then you remove the subversion ones (hg qdelete S4.diff S5.diff S6.diff S7.diff).

现在是时候重新获取svn提交(hg pull »svn-remote«)了.然后,您重新应用所有本地修补程序,并使用hg qpush逐一进行,并修复所有正在发生的合并冲突.完成一次冲突后,可以使用hg qfinish -a将当前补丁移至尾部提交,并使用hg push »svn-remote«发送当前状态.

Now is the time to re-fetch the svn commits (hg pull »svn-remote«). Then you reapply all local patches, one by one with hg qpush, and fix all merge conflicts which are now occurring. When you are done with one conflict, you can move the current patch into a mercurial commit with hg qfinish -a, and send your current state with hg push »svn-remote«.

这篇关于允许hgsubversion SVN克隆回退所需的步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆