简体   繁体   English

如何使用Mercurial合并在存储库之外进行的更改?

[英]How do I use Mercurial to merge in changes made outside the repository?

I joined a team with greenfield code. 我加入了具有未开发代码的团队。 When I joined, they did not have a common repository, and they emailed me a tarball of his latest. 当我加入时,他们没有一个公用的存储库,他们通过电子邮件将他最新的档案发送给我。 (yeah, I know...) I've been working off that tarball, making changes and adding files. (是的,我知道...)我一直在研究压缩包,进行更改并添加文件。 Now the team has a Mercurial repository (hooray!), and it's been populated with the same code containing more recent changes by other people. 现在,该团队有了一个Mercurial存储库(hooray!),并且使用相同的代码填充了该代码,其中包含其他人的最新更改。 In other words, I have the original tarballed code in on directory, my changes in another directory, and an hg clone in a third directory, where the original tarballed code is the common ancestor. 换句话说,我在目录中有原始的压缩代码,在另一个目录中有更改,在第三个目录中有一个hg克隆,原始的压缩代码是共同的祖先。

What is a good way to merge my changes into the Mercurial repository? 将更改合并到Mercurial存储库中的好方法是什么? Mercurial has no history of the common ancestor. 水星没有共同祖先的历史。 I am brand new to Mercurial. 我是Mercurial的新手。 My VCS experience is with CVS, Perforce, and some SVN. 我的VCS经验是CVS,Perforce和某些SVN。 Can I create two more local hg clones and rewrite one with the original code, the other with my changed code, and use Mercurial to merge them somehow? 我可以再创建两个本地hg克隆,然后用原始代码重写一个,然后用更改后的代码重写另一个,然后使用Mercurial以某种方式合并它们吗? (and if so, how?) Or should I consider using an independant merge tool and then copying the merged version into my clone's directory? (如果是,如何?)还是应该考虑使用独立的合并工具,然后将合并的版本复制到克隆目录中? Or something else? 或者是其他东西?

This is all on RHE Linux. 这一切都在RHE Linux上。

Thank you. 谢谢。

One option to try is something like this: 可以尝试的一种选择是这样的:

diff -urN your-original-tarball your-current-code > mychanges.patch
hg clone their-current-repo your-local-clone
cd your-local-clone
hg update -r 0 # go to their oldest item in history
hg import --no-commit ../mychanges.patch
# check it out, test, fix any rejected changes, etc.
hg commit -m 'my changes'  # <-- you'll be warned this creates new heads
hg merge # merge your changes with their changes since they started using mercurial
hg commit -m 'merged my solo work with yours'

That's taking all your work to date, importing it as a new changeset based on the oldest revision they do have, and then merging that work with their work in mercurial since they started using it. 那就是将您的所有工作到目前为止的内容,根据他们所拥有的最旧的修订版本将其作为新的变更集导入,然后将这些工作与他们开始使用以来的大量工作进行合并。

Ideally their r0 would be the tarball they gave you, but one hope's it's not too different. 理想情况下,它们的r0是他们给您的压缩包,但一个希望是,它并没有太大不同。

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

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