简体   繁体   English

提交Hg更改回SVN

[英]Submitting Hg changes back to SVN

I've began work in an SVN repository. 我已经开始在SVN存储库中工作了。 I've cloned a subfolder of it into a local Hg repo with hg clone . 我已将其子文件夹克隆到带有hg clone的本地Hg repo中。

Afterwards, I wanted to share this with a colleague who does not have access to the SVN repository. 之后,我想与一位无权访问SVN存储库的同事分享。 I've created a private BitBucket repository, and we occasionally pushed the changes, and hence I had to pull them. 我已经创建了一个私有BitBucket存储库,我们偶尔会推动这些更改,因此我不得不将它们拉出来。

hgsubversion does some nasty things to changesets, such as changing their committer (and I believe even the hash). hgsubversion为变更集做了一些讨厌的事情,比如改变他们的提交者(我甚至相信哈希)。 When I tried pushing and pulling to the BitBucket repo, I had to do a merge. 当我尝试推送到BitBucket仓库时,我不得不进行合并。

Now I am unable to push changes back into the Subversion repository due to our beloved friend, abort: Sorry, can't find svn parent of a merge revision. 由于我们敬爱的朋友,我现在无法将更改推回Subversion存储库, abort: Sorry, can't find svn parent of a merge revision. .

How would one pull the BitBucket-targetting Mercurial repository with the svn-targetting Mercurial repository, while staying compatible with hgsubversion (that is, without importing the merge revisions)? 如何使用svn-targeteding Mercurial存储库拉出BitBucket目标Mercurial存储库,同时保持与hgsubversion兼容(即,不导入合并修订版)?

Some automated way to do this would be appreciated, of course, but if there is no such thing/easy way to do this, I'd be grateful for any solution. 当然,一些自动化的方法可以理解,但如果没有这样的事情/简单的方法,我会感激任何解决方案。

I use hgsubversion , not hgsvn ; 我使用hgsubversion ,而不是hgsvn ; that is, the extension in which one does hg clone svn://repo/url . 也就是说, hg clone svn://repo/url的扩展名。 I am open to switching, though, if necessary. 不过,如果有必要,我愿意转换。

When you use Mercurial on a subversion repository, you have to still think like SVN does, so a lot of features part of the basic mercurial workflow just won't work. 当你在subversion存储库上使用Mercurial时,你仍然必须像SVN一样思考,因此基本的mercurial工作流的许多功能部分都无法工作。 Merging the way mercurial does it is impossible on a svn depot. 合并mercurial的方式在svn仓库中是不可能的。 If you have merged your work with the pulled svn branch, you'll get the infamous about message you're getting now :( 如果你已经将你的工作与拉动的svn分支合并,那么你将获得臭名昭着的关于你现在得到的消息:(

I suggest you read durin42's answer to this question . 我建议你阅读durin42对这个问题的回答。

EDIT : To get out of your current mess, I suggest you create a patch (or a series of patches) from the point you checkout from the SVN repo. 编辑:为了摆脱目前的混乱局面,我建议你从SVN仓库结账时创建一个补丁(或一系列补丁)。 Get a new fresh copy from the subversion repository and apply the patch(es). 从subversion存储库获取新的新副本并应用补丁。 I am not sure you'll be able to do it from your current repo. 我不确定你是否可以从你目前的回购中做到这一点。 You could explore the hg diff command. 你可以探索hg diff命令。

hg diff -g -r tip -r XXX > patch

with XXX being your original SVN checkout (I haven't tested it yet.) XXX是你原来的SVN结账(我还没有测试过。)

Yes, hgsubversion does change the committer name because it must reflect the name assigned by Subversion. 是的,hgsubversion确实会更改提交者名称,因为它必须反映Subversion指定的名称。 Hgsubversion must then also change the changeset hash. 然后,Hgsubversion还必须更改变更集散列。 It is not really something that hgsubversion can decide -- it's built into the design of Mercurial that the changeset hash is based on all information in the changeset and that included the name of the committer. 它不是hgsubversion可以决定的东西 - 它在Mercurial的设计中内置,变更集散列基于变更集中的所有信息,包括提交者的名称。

Please read my hgsubversion guide for information on how to work correctly with hgsubversion. 请阅读我的hgsubversion指南 ,了解有关如何正确使用hgsubversion的信息。 The important points to remember is that hgsubversion turns hg into a better svn , but it is still Subversion that is the master. 需要记住的重点是hgsubversion将hg转换为更好的svn ,但它仍然是Subversion的主人。 This means that you must linearize your history before pushing it back to Subversion so no merges or other funny DVCS things. 这意味着您必须线性化您的历史记录,然后再将其推回到Subversion,这样才能进行合并或其他有趣的DVCS事情。

If you do want to take advantage of the distributed features in Mercurial, then do it in small iterations: do some collaboration in Mercurial, linearize the changesets and push back to Subversion, destroy the non-linear part of your clones, pull from Subversion. 如果你想利用Mercurial中的分布式功能,那么可以在小迭代中进行:在Mercurial中进行一些协作,线性化变更集并推回Subversion,销毁克隆的非线性部分,从Subversion中获取。 You can then repeat with a new iterations of collaboration in Mercurial. 然后,您可以在Mercurial中重复进行新的协作迭代。

I just hit a similar problem, which basically was: 我刚刚遇到了类似的问题,基本上是:

  • cloning a SVN repo with HgSubversion 使用HgSubversion克隆SVN repo
  • working it out with some merges 通过一些合并来解决这个问题
  • trying to pull it back to the former SVN repo 试图把它拉回原SVN回购

and ran into the dreadful Sorry, can't find svn parent of a merge revision message. 并遇到了可怕的Sorry, can't find svn parent of a merge revision消息的Sorry, can't find svn parent of a merge revision

That's what I did to fix it without too much hassle: 这就是我在没有太多麻烦的情况下解决它的问题:

  1. Download TortoiseSVN from this link and install it. 从此链接下载TortoiseSVN并进行安装。
  2. Check-out the SVN repo to a new folder using SVN Checkout... command from the contextual Windows Explorer menu (right-click to access it). 使用上下文Windows资源管理器菜单中的SVN Checkout...命令将SVN repo SVN Checkout...出到新文件夹(右键单击以访问它)。
  3. Copy the content of the local HG folder (excluding the .hg subfolder only) to the newly-created SVN folder, overwriting all files. 将本地HG文件夹的内容(仅限.hg子文件夹)复制到新创建的SVN文件夹,覆盖所有文件。
  4. Right-click to that folder and do SVN Commit... . 右键单击该文件夹并执行SVN Commit...
  5. Trash your HG repo and pull it back from the now-updated SVN repo. 将你的HG仓库收集起来并从现在更新的SVN仓库中撤回。

It takes 2 minutes and everything should start working again. 它需要2分钟,一切都应该重新开始工作。 You'll lose some merge & commit info, but it shouldn't be an issue since the SVN/HgSubversion combo can't track them anyway. 你会丢失一些合并和提交信息,但它不应该是一个问题,因为SVN / HgSubversion组合无论如何都无法跟踪它们。

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

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