"Push creates new remote heads" and my humble workflow (kind of dummy question)

Victor Sudakov vas at sibptus.ru
Thu Jul 16 09:28:21 UTC 2020


Manuel Jacob wrote:

[dd]

> > > 
> > > Before the merge, you had two heads. To get one head, you can merge
> > > them.
> > 
> > Where did I have the two heads physically? There was one head at home,
> > and
> > one head at work, that's true. But I never allowed to create two heads
> > in the cloud.
> 
> Suppose we start in a situation where you have only one head X in the home,
> work and cloud repos.
> 
> Then, in the work repo, you create A on X. A is now the single head in the
> work repo. Before driving home, you forget to push.

OK, I see.

> 
> Then, in the home repo, you create B on X. B is now the single head in the
> home repo. You push to the central repo, which then also has a single head
> B.
> 
> Then, in the work repo, you pull. Now you have two heads A and B in the
> repo.

If I "pull -u" in the work repo, will my working directory be updated to
B? Probably it will, because i've pulled from the central repo, right?
Is it a good idea to always run "pull -u"? (which I do).

> 
> > I want to fix my workflow somehow so that only one head (in all the
> > repos) exists at a time.
> 
> In your case, as the only person working on the repo, you could avoid the
> situation by always pulling before committing and always pushing before
> switching machines.

Can I enforce this discipline?

> 
> If you have the rebase extension enabled, you can pass "--rebase" to "hg
> pull", which will linearize the changesets after pulling.

This sounds interesting. Can you please explain on the X,A,B example
above, what "pull --rebase" will do?

"rebase working directory to branch head" does not sound exactly clear.
Which branch? I don't have branches, just accidentally create two heads
from time to time.

[dd]

> 
> > For now I see that "hg diff -c 134" and "hg diff -c 132" look identical.
> > The same can be said about "hg log -r132 -p" and "hg log -r134 -p" -
> > identical except for the commit message and some metadata.  This is
> > confusing, the final tree (viewed with "hg log -p" or whatever) looks
> > like
> > the changes were applied twice but in fact they were not.
> 
> I don’t know how you created the merge changesets, but when using a commit
> message like "Merge heads.", there will be no duplication in the message.

It's not the duplication in the message that I object to, it's the
duplication in the diff ("hg log -p" output and such become confusing).

> 
> In the future, hopefully Mercurial gets more useful diffs for merges. I know
> that work on this was started, but I don’t think there’s something ready to
> use.

-- 
Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
2:5005/49 at fidonet http://vas.tomsk.ru/



More information about the Mercurial mailing list