简体   繁体   English

创造新的头颅

[英]Create new heads in mercurial

In my current workflow whenever I need a branch I use bookmarks, but in order to create a new head from the current revision I have to commit some dummy changes and go back one revision, then commit to that, otherwise the commits will be made to the same head, no matter how many bookmarks I had. 在当前工作流程中,每当我需要一个分支时,我都会使用书签,但是为了从当前修订版本创建一个新的标题,我必须提交一些虚拟更改并返回一个修订版本,然后再提交该修订,否则将提交到同一头,无论我有多少个书签。

For example, suppose I'm on rev 40: 例如,假设我的修订版为40:

hg bookmark main
hg ci somefile -m 'dummy commit' # on rev 41 now
hg up -r 40
# make some changes
hg ci -A -m 'changes in bookmark' # created new head
hg bookmark test

Is this common or there's some shorcut to force the creation of a new head? 这很常见吗?还是有一些捷径可以强迫创建新的负责人?

I think you want to practise nvie's workflow, so you want to merge with up-stream with --no-ff. 我认为您想练习nvie的工作流程,因此想通过--no-ff与上游合并。

So far as I can recall, hg doesn't support merge with up-stream in the same branch. 据我所知,hg不支持与同一分支中的上游合并。 As this post said, hg's head/bookmark is git't branch, while hg's branch is lineage. 正如这篇文章所说,hg的标题/书签是git't分支,而hg的分支是沿袭。

Therefore, the solution is at the forking point, you change both bookmark and branch, then later you can merge the branch because they are different lineage. 因此,解决方案是在分叉点,同时更改书签和分支,然后再合并分支,因为它们是不同的世系。

You can easily hg branch -f dev in my example, reopen the branch even they are not connected. 在我的示例中,您可以轻松地创建hg branch -f dev ,即使它们未连接也可以重新打开分支。

So you can have branches like: 因此,您可以拥有如下分支:

  • default 默认
  • stable 稳定
  • feature 特征
  • hotfix 修补程序

Then the bookmarks should be prefix as: 然后,书签的前缀应为:

  • feature-* 特征-*
  • hotfix-* hotfix- *

And they should be branched off corresponding branches. 它们应该从相应的分支中分支出来。

Then they can be 然后他们可以

我的示例的Graphlog

There is no need for a second head to be created in your example and you shouldn't force its creation. 在您的示例中无需创建第二个头部,并且您不应该强制其创建。

The advantage with your workflow is that you can stop work on feature test to do a more urgent change on the main branch like this: 工作流程的优势在于,您可以停止功能test工作,以便在主分支上进行更紧急的更改,如下所示:

> hg bookmark main
> hg bookmark test         # Start work on feature test

 ... do some code ...

> hg commit -m "Working on feature test"
> hg update main           # Stop working on test, start working on main

 ... do an urgent fix ...

> hg commit -m "Urgent fix"
> hg update test           # Back to work on feature test

 ... do some more code ...

> hg update main           # Finished the work so back to main
> hg merge test            # Merge the work into main
> hg commit -m "Merge in feature test"

When that's done, you will have completed the new feature and merged it back into the main development branch. 完成后,您将完成新功能并将其合并回主开发分支。

If you don't make any changes to the main branch when you have finished working on feature test then you can't merge the changes in as you can't merge a changeset into an ancestor so you would need to move the main bookmark to the test bookmark as follows: 如果完成功能test后没有对main分支进行任何更改,则无法合并更改,因为无法将更改集合并到祖先中,因此需要将main书签移至test书签如下:

> hg update test
> hg bookmark main -f

(I believe that this is called a fast-forward merge in git and that you can force the merge if you want but there is no mercurial equivalent as far as I know) (我认为,这就是所谓的快进合并的git ,并且可以强制合并,如果你想,但没有mercurial相当于据我所知)

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

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