防止不稳定的代码进入默认行

发布于 2024-10-08 02:08:43 字数 785 浏览 3 评论 0原文

目前,我有 2 个存储库。一个存储库名为jstock,其中包含所有稳定的源代码。

另一个名为jstock-refactor-calendar-to-joda的存储库,它是从jstock克隆的,它包含所有不稳定的实验功能代码。

红色矩形中的所有更改集都是不稳定的实验功能代码。他们还没有完成。因此,我无意将其与绿色矩形中的更改集合并(绿色矩形表示这些是稳定的更改集)

jstock-refactor-calendar-to-joda 从 < code>jstock,如下所示。 alt text

现在,我想让实验代码对 jstock 可见(但不会进入默认行,因为它们不稳定)

因此,当我从 jstock-refactor-calendar-to-joda 执行推送到 jstock 时,这就是我得到的。 alt text

现在所有不稳定的代码都属于默认行!

这不是我想要的。在jstock中,我希望稳定代码(绿色矩形)保留在默认值(左侧),不稳定代码(红色矩形)保留在右侧。请注意,我还不希望将它们合并,但我希望两条开发线(稳定和不稳定)都可见。

难道是我哪一步做错了?

Currently, I have 2 repository. One repository is named jstock, which contains all the stable source code.

Another repository named jstock-refactor-calendar-to-joda, which is cloned from jstock, and it contains all the unstable experimental feature code.

All the change-set in red rectangle is unstable experimental feature code. They are not finished yet. Hence, I do not have intent to make it merge with the change-set in green rectangle (Green rectangle indicates those are stable change-set)

After jstock-refactor-calendar-to-joda pulls from jstock, here is how it looks like.
alt text

Now, I would like to let the experimental code visible to jstock (But not going into default line, as they are unstable)

Hence, when I perform push from jstock-refactor-calendar-to-joda to jstock, here is what I get.
alt text

Now all unstable code are belongs to default line!

This not what I want. In jstock, I wish the stable code (in green rectangle) remains in default (left side), unstable code (in red rectangle) remains in right side. Note that, I do not want them to be merged yet, but I would like to have both development lines (stable and unstable) being visible.

Is there any step I had done wrong?

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

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

发布评论

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

评论(4

诗笺 2024-10-15 02:08:43

这也发布在 Mercurial 邮件列表上,下面是我的回复

两者的位置(匿名) )日志查看器中的分支并不重要:没有左侧或右侧,顺序仅取决于您进行拉动和推送的顺序。

您需要的是一种方法来标记稳定和不稳定分支的变更集,以便您可以跟踪哪个是哪个。有三种主要方法可以做到这一点:

  • 单独的克隆:这是您已经使用过的简单方法,为不同的分支保留单独的克隆。

    它的优点是您只需删除克隆即可轻松丢弃变更集。

    它的缺点是,由于变更集保持隔离,因此您无法真正全面了解正在发生的情况。

  • 命名分支:如果您还没有这样做,请在此处查看我的指南:

    http://mercurial.aragost.com/kick-start/en/tasks /

    命名分支的优点是它们将标签放入每个变更集中,以便您可以跟踪它们的来源。如果您有一个名为“refactor-calendar-to-joda”的命名分支,那么您可以这样做

    hg 更新 refactor-calendar-to-joda
    

    为了将工作副本更新到该分支的尖端。当在分支上进行新提交时,分支尖端会随之移动,因此您可以将“refactor-calendar-to-joda”视为浮动标记。

    要返回默认分支,请执行

     hg 更新默认值
    

    这是正常开发应该发生的地方。

    命名分支适用于长期稳定的分支或多年后名称也有意义的分支。例如,如果您使用错误跟踪器,那么我建议创建一个错误来跟踪重构,然后调用分支“bug XX”。这样人们将来就可以查找正确的错误编号。

  • 书签:书签为变更集提供名称,与命名分支一样,您可以更新为书签:

    hg 更新 refactor-calendar-to-joda
    

    但是,与命名分支不同,书签位于变更集图之外。因为书签本身不是变更集的一部分,所以可以移动、删除、重命名等。您可以在存储库之间推送和拉出书签。

因此,请使用命名分支作为长期持久名称,使用书签作为短期分支,如果您希望将事物分开,则可以使用单独的存储库。

最后,请参阅本指南以了解有关此主题的更多信息:

http ://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/

This was also posted on the Mercurial mailinglist and below is my reply:

The location of the two (anonymous) branches in the log viewer is not important: there is no left or right side, the order only depends on the order in which you have made the the pulls and pushes.

What you need is a way to label the changesets from the stable and unstable branches so that you can keep track of which is which. There are three main ways to do this:

  • separate clones: This is the trivial way which you have already used where you keep a separate clone for the different branches.

    It has the advantage that you can throw away the changesets easily by just deleting the clone.

    It has the disadvantage that you don't really get a full overview of what is happening since the changesets are kept isolated.

  • named branches: See my guide here if you haven't already done so:

    http://mercurial.aragost.com/kick-start/en/tasks/

    The advantage of named branches is that they put a label into each changeset so that you can track where they come from. If you have a named branch called 'refactor-calendar-to-joda', then you can do

    hg update refactor-calendar-to-joda
    

    in order to update the working copy to the tip of that branch. When new commits are made on the branch, the branch tip moves along, and so you can think of 'refactor-calendar-to-joda' as a floating tag.

    To get back to the default branch, you execute

     hg update default
    

    This is where the normal development ought to take place.

    Named branches are good for branches that are stable over longer time or where the name also makes sense years later. For example, if you use a bug tracker, then I suggest creating a bug to track the refactoring and then calling branch 'bug XX'. That way people can lookup the right bug number in the future.

  • bookmarks: Bookmarks give names to changesets and as with named branches, you can update to a bookmark:

    hg update refactor-calendar-to-joda
    

    However, unlike named branches, the bookmarks live outside of the changeset graph. Because they are not part of the changesets themselves, bookmarks can be moved, deleted, renamed etc. You can push and pull bookmarks between repositories.

So use named branches for long-term persistent names, use bookmarks for short-lived branches, and use separate repositories if you like to have things separated.

Finally, see this guide for more on this topic:

http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/

玉环 2024-10-15 02:08:43

在这种情况下,当您创建多个头时,您必须施加“力”。 这两个头都位于“默认”分支上。这样做没有问题,但您担心的问题是您的新头(具有不稳定的代码)是默认分支的“尖端”。

来自 Mercurial 常见问题解答

尖端始终是头部。如果有
一个存储库中有多个头,仅
其中之一就是小费。在一个
存储库,变更集已编号
依次,所以尖端有
最高序列号。这个词
“tip”作为一个特殊标签
表示提示变更集,它可以
可在变更集 ID 或标签的任何地方使用
有效。

最好将这些更改推送到指定分支,正如莱塞所建议的,但你就在你所在的地方。在这种情况下,您(或第一次拉取此存储库的任何人)需要将工作副本更新为默认分支的稳定部分。

hg update -r 12345

(其中 12345 是“而不是限制货币...”的修订号,

对于已经拥有此存储库的开发人员,当他们拉取不稳定的更改时,他们将看到多个头,但他们的工作副本不会自动更新到您的新版本分支。

In this case you must have "force" pushed as you've created multiple heads. Both these heads are on the "default" branch. No problem with this as such but the issue you're worrying about is that your new head (with unstable code) is the "tip" of the default branch.

From the Mercurial FAQ:

The tip is always a head. If there are
multiple heads in a repository, only
one of them is the tip. Within a
repository, changesets are numbered
sequentially, so the tip has the
highest sequence number. The word
"tip" functions as a special tag to
denote the tip changeset, and it can
be used anywhere a changeset ID or tag
is valid.

It would have been better to have pushed these changes to a named branch, as Lasse suggests, but you are where you are. In this case, you (or anyone pulling this repository for the first time) need to update the working copy to be on the stable part of your default branch.

hg update -r 12345

(where 12345 is the revision number of "Instead of limiting currency..."

For developers that already have this repository, when they pull your unstable changes they will see the multiple heads but their working copy won't automatically be updated to your new branch.

故事还在继续 2024-10-15 02:08:43

你所做的一切都很好。您在同一个命名分支“default”上有两个头。这是一种完全正常的工作方式。这是对正在发生的事情的相当不错的描述:

http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/#branching-anonymously

正如尼克建议的那样,已经拥有克隆的人将获得新的头部当他们拉动时,新克隆的人将同时获得两者——这很好。

当人们 hg update default 或只是 hg update 时,他们会移至 default 分支上的最新变更集,因此只需使用“再进行一次提交”而不是限制货币小数位...”变更集作为其父级,如下所示:

hg update REVSION
...edit
hg commit

并且当它们克隆/更新时,它们将自动更新到您想要的匿名分支。

需要记住的是,mercurial 在命名分支之前已经存在了很长一段时间,因此您可以使用命名分支执行的所有操作都可以使用匿名分支执行。

如果您认为该存储库中有两个未区分的头太令人困惑,请考虑查看书签。它们是跟踪匿名分支尖端的粘性标签——比命名分支更灵活,因为它们不是永久性的。

http://stevelosh。 com/blog/2009/08/a-guide-to-branching-in-mercurial/#branching-with-bookmarks

What you've done is perfectly fine. You have two heads on the same named branch 'default'. This is a completely normal way to work. Here's a pretty decent description of what's happening:

http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/#branching-anonymously

As Nick suggests, people who already have a clone will get the new head when they pull and people who newly clone will get both -- and that's just fine.

When people hg update default or just hg update they moved to the newest changeset on the default branch, so just do one more commit with the "Instead of limiting currency decimal places..." changeset as its parent like this:

hg update REVSION
...edit
hg commit

And they'll be automatically updated to the anonymous branch you want when they clone/update.

The thing to keep in mind is that mercurial existed for a long while before it had named branches, so everything you can do with named branches you can do with anonymous branches.

If you decide having two undifferentiated heads in that repo is too confusing consider giving bookmarks a look at. They're sticky labels that track the tips of anonymous branches -- more flexible than named branches in that they're not permanent.

http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/#branching-with-bookmarks

遗失的美好 2024-10-15 02:08:43

在这种情况下,您可能应该等待推送,并使整个存储库可用。

或者,当您启动该分支时,您应该给它一个名称。您可以有多个未命名分支,所有分支都属于同一个命名分支。

换句话说,您看到的所有变更集都是 default 分支的一部分,但标签仅显示该分支的尖端。由于新的变更集现在是提示,因此这就是 UI 中显示标签的位置。

如果您给了它一个名称,默认值仍然会位于默认分支上最顶端的变更集上。

要解决这个问题,您必须一一“重播”这些变更集。我不知道最好的方法,但足以说他们会得到新的哈希值,因此任何提取这些变更集的人都已经冒险将它们推回到默认分支的一部分。

In this case you probably should have waited with pushing, and make the whole repository available.

Or, when you started that branch, you should've given it a name. You can have multiple unnamed branches all belonging to the same named branch.

In other words, all of the changesets you're seeing there is part of the default branch, however the label is only shown for the tip of that branch. Since the new changesets are now the tip, that's where the label is shown in the UI.

If you had given it a name, default would've still been down on your tipmost changeset on the default branch.

To fix that, you would have to "replay" those changesets one by one. I don't know the best way to do that, but suffice to say they would get new hashes, so anyone that has pulled those changesets already risk pushing them back in as part of the default branch.

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