Mercurial: How to push bookmarks with changes that create a new remote head, as if I push a new branch?

The general question.

I am trying to use bookmarks instead of branches in mercurial. The reason for this is because I don't want to have many unnecessary fixed constant elements in branches .

The problem arises when I use a separate bookmark to develop a new function, and I want to pull it into an external repository. Well, hg doesn't let me click if it creates a "new remote head". What should I do to make such a push as if I were creating a new branch?

Example (a way to reproduce the problem).

Alice creates a repository:

C:\TestHg>mkdir Alice C:\TestHg>cd Alice C:\TestHg\Alice>hg init C:\TestHg\Alice>echo line1>>file.txt C:\TestHg\Alice>hg addremove adding file.txt C:\TestHg\Alice>hg commit -m "Initial commit." 

Bob clones Alice's repository:

 C:\TestHg\Alice>cd .. C:\TestHg>hg clone Alice Bob updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved 

Alice makes some changes to the project code:

 C:\TestHg>cd Alice C:\TestHg\Alice>echo line2 by Alice>>file.txt C:\TestHg\Alice>hg commit -m "Alice continues her work on the project." 

Bob begins his work on the New Cool Feature, using a separate bookmark to identify his independent work branch:

 C:\TestHg\Alice>cd ..\Bob C:\TestHg\Bob>hg bookmarks no bookmarks set C:\TestHg\Bob>hg bookmark NewCoolFeature C:\TestHg\Bob>hg bookmarks * NewCoolFeature 0:792db6cfc262 C:\TestHg\Bob>echo line2 by Bob (as a part of New Cool Feature implementation)>>file.txt C:\TestHg\Bob>hg commit -m "Bob starts his work on New Cool Feature" 

Bob is trying to make changes to Alice's directory:

 C:\TestHg\Bob>hg push -B NewCoolFeature pushing to C:\TestHg\Alice searching for changes abort: push creates new remote head 38506e28a438! (you should pull and merge or use push -f to force) 

Ok, first Bob has to pull Alice's changes into his own repository:

 C:\TestHg\Bob>hg pull pulling from C:\TestHg\Alice searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) (run 'hg heads' to see heads, 'hg merge' to merge) 

Ok, now Bob has two heads in his repository, which is fine.

 C:\TestHg\Bob>hg glog o changeset: 2:66beef200ba4 | tag: tip | parent: 0:792db6cfc262 | user: Alice | date: Sun May 20 13:10:04 2012 +0400 | summary: Alice continues her work on the project. | | @ changeset: 1:38506e28a438 |/ bookmark: NewCoolFeature | user: Bob | date: Sun May 20 13:12:26 2012 +0400 | summary: Bob starts his work on New Cool Feature | o changeset: 0:792db6cfc262 user: Alice date: Sun May 20 13:08:39 2012 +0400 summary: Initial commit. 

After trying to make another attempt, Bob will be asked to merge. Bob does not want to merge, because his results on the New Cool Feature are not yet ready for the merger.

 C:\TestHg\Bob>hg push -B NewCoolFeature pushing to C:\TestHg\Alice searching for changes abort: push creates new remote head 38506e28a438! (did you forget to merge? use push -f to force) 

An example of a related question.

What should Bob do to make his changes to Alice's repository, as if his changes are in a separate branch?

Update

UPD1: in a real situation, Alice repo is used as the central synchronization point for all members of the development team.

+8
merge push mercurial bookmarks
source share
1 answer

He must either:

  • Do not click. Why does he want his unfinished changes on some other machine?
  • Forced. He was asked if he had forgotten to merge. He did not. He needs a new head, therefore strength.

There is a message, because it is often easy to create a new head without being aware. However, sometimes this is exactly what you want, and therefore there is an override switch.

+9
source share

All Articles