Mercurial 推送某些修改

发布于 2024-10-02 09:55:40 字数 466 浏览 1 评论 0原文

我在这里搜索过,但没有发现任何与此相关的问题。我在 Mercurial 中遇到了这样的问题: 我在 bitbucket 中管理开源项目,因此我在本地克隆了源代码。但我也将该项目用于我自己的实时站点,所以我制作了 Bitbucket 存储库的 2 个克隆

Bitbucket Repo
|
==local_clone1
|
==local_clone2-> commit1            => commit2    => commit3
                (personalization)     (bug fix)     (add feature)

问题是,我想将 commit2 和 commit3 推送回 local_clone1,以便稍后我可以推送到 Bitbucket 存储库。但不想推送 commit1,因为它有我的个人数据。

想知道我们如何在 Mercurial 中做到这一点?

I have searched here, but haven't found any question related to this. I got a problem like this in mercurial:
I manage open source project in bitbucket, so i have clone of the source code in my local. But I also using that project for my own live site, so I made 2 clone of bitbucket repo

Bitbucket Repo
|
==local_clone1
|
==local_clone2-> commit1            => commit2    => commit3
                (personalization)     (bug fix)     (add feature)

The question is, I want to push commit2 and commit3 back to local_clone1, so later on I can push to Bitbucket repo. But don't want to push commit1, since it has my personal data.

Wondering how we do that in mercurial?

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

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

发布评论

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

评论(2

屌丝范 2024-10-09 09:55:40

在这种情况下,这可以毫无困难地完成。有关详细信息,请参阅 Mercurial 指南中的删除历史记录

以下是您需要执行的基本操作:

  • 转至 local_clone2
  • 从当前版本号获取修订号(hg Tip 将向您显示)。我们将其称为 731。
  • hg export 730-731 > ../local_clone1/changes.diff (或任何您喜欢的位置)
  • 转到 local_clone1
  • hg importchanges.diff

您可能需要手动编辑内容;在这种情况下,请参阅该指南以获取更多信息。

This can be done without too much difficulty in this case. See Removing history in the Mercurial guide for more information.

Here's the basics of what you'll need to do:

  • Go to local_clone2
  • Get the revision number (hg tip will show you) from the current number. We'll call it 731.
  • hg export 730-731 > ../local_clone1/changes.diff (or wherever you like)
  • Go to local_clone1
  • hg import changes.diff

You may need to edit things manually; refer to that guide for more info in that case.

墨小墨 2024-10-09 09:55:40

这里有几个选项:

回退

给定一个历史记录,构造如下:

hg init db
cd db
echo >file1
hg ci -Am clone              # rev 0
echo >file2
hg ci -Am personalization    # rev 1
echo >file3
hg ci -Am bugfix             # rev 2
echo >file4
hg ci -Am feature            # rev 3 <tip>

那么如果当前工作目录是提示,以下命令将“撤消”个性化修订:

hg backout 1
hg ci -m backout

优点是历史记录保持不可变,但显示历史记录的添加和回退个性化变更集。

Mercurial 队列

通过 mq 扩展,可以编辑历史记录以删除变更集:

hg qimport -r 1:3  # convert changesets 1-3 to patches
hg qpop -a         # remove all patches (can't delete an applied patch)
hg qdel 1.diff     # delete rev 1's patch
hg qpush -a        # reapply remaining patches
hg qfin -a         # convert all applied patches back to changesets.

优点是个性化变更集消失。缺点是变更集哈希值会因历史编辑而发生变化,因此永远不要对已经推送给其他人的变更集执行此操作。还存在编辑历史记录错误的风险。

Here are a couple of options:

backout

Given a history constructed as:

hg init db
cd db
echo >file1
hg ci -Am clone              # rev 0
echo >file2
hg ci -Am personalization    # rev 1
echo >file3
hg ci -Am bugfix             # rev 2
echo >file4
hg ci -Am feature            # rev 3 <tip>

Then if the current working directory is the tip, the following commands will "undo" the personalization revision:

hg backout 1
hg ci -m backout

The advantage is history remains immutable, but shows the addition and backout of the personalization changeset.

Mercurial Queues

With the mq extension, history can be edited to remove a changeset:

hg qimport -r 1:3  # convert changesets 1-3 to patches
hg qpop -a         # remove all patches (can't delete an applied patch)
hg qdel 1.diff     # delete rev 1's patch
hg qpush -a        # reapply remaining patches
hg qfin -a         # convert all applied patches back to changesets.

The advantage is the personalization changeset disappears. The disadvantage is the changeset hashes change due to the history edit, so this should never be done to changesets that have already been pushed to others. There is also the risk of a mistake editing history.

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