如何使用 Mercurial 合并存储库外部所做的更改?

发布于 2024-09-12 07:44:23 字数 513 浏览 1 评论 0原文

我加入了一个拥有绿地代码的团队。当我加入时,他们没有一个通用的存储库,他们通过电子邮件给我发送了他最新的 tarball。 (是的,我知道...)我一直在处理该 tarball,进行更改并添加文件。现在,团队拥有了 Mercurial 存储库(万岁!),并且它已填充了相同的代码,其中包含其他人最近所做的更改。换句话说,我的原始 tarball 代码位于一个目录中,我的更改位于另一个目录中,而 hg 克隆位于第三个目录中,其中原始 tarball 代码是共同的祖先。

将我的更改合并到 Mercurial 存储库的好方法是什么? Mercurial 没有共同祖先的历史。我是 Mercurial 的新手。我的 VCS 经验是使用 CVS、Perforce 和一些 SVN。我可以再创建两个本地 hg 克隆,并用原始代码重写一个,用我更改的代码重写另一个,然后使用 Mercurial 以某种方式合并它们吗? (如果是这样,如何?)或者我应该考虑使用独立的合并工具,然后将合并的版本复制到我的克隆目录中?还是别的什么?

这一切都在 RHE Linux 上。

谢谢。

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. 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.

What is a good way to merge my changes into the Mercurial repository? Mercurial has no history of the common ancestor. I am brand new to Mercurial. My VCS experience is with CVS, Perforce, and some 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? (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.

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

っ左 2024-09-19 07:44:23

可以尝试的一个选择是这样的:

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'

将您迄今为止的所有工作作为新的变更集导入,基于他们拥有的最旧的修订版,然后将该工作与他们开始使用后在 Mercurial 中的工作合并。

理想情况下,他们的 r0 应该是他们给你的 tarball,但希望它没有太大不同。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文