can't push even if branch merged

Piers Barber piers at stonesflock.co.uk
Thu Aug 5 23:54:20 UTC 2010


On Thursday 05 Aug 2010 23:34:19 Mads Kiilerich wrote:
>   Piers Barber wrote, On 08/05/2010 10:08 PM:
> > hi
> >
> > i suspect my problem here is my understanding of how Hg works
> >
> > i make a repo and commit a couple of changes:
> >
> > fatcat[pb] mkdir hack
> > fatcat[pb] cd hack
> > fatcat[pb] hg init source1
> > fatcat[pb] cd source1
> > fatcat[pb] echo a>  a
> > fatcat[pb] hg add a
> > fatcat[pb] hg ci -m"a1" a
> > fatcat[pb] echo b>>  a
> > fatcat[pb] hg ci -m"a2"
> >
> > now i clone the repo in source1 and have a source2 and immediately work on mybranch in source2
> >
> > fatcat[pb] cd ..
> > fatcat[pb] hg clone source1 source2
> > updating to branch default
> > 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> > fatcat[pb] cd source2
> > fatcat[pb] hg branch mybranch
> > marked working directory as branch mybranch
> > fatcat[pb] echo c>>  a
> > fatcat[pb] hg ci -m"c1"
> > fatcat[pb] echo d>>  a
> > fatcat[pb] hg ci -m"c2"
> >
> > i switch back to default and merge mybranch. i commit.
> >
> > fatcat[pb] hg up default
> > 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> > fatcat[pb] hg merge mybranch
> > 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> > (branch merge, don't forget to commit)
> > fatcat[pb] hg ci -m"merged mybranch"
> > fatcat[pb] hg push
> > pushing to /home/pb/hack/source1
> > searching for changes
> > abort: push creates new remote branch 'mybranch'!
> > (did you forget to merge? use push -f to force)
> > fatcat[pb] cat a
> > a
> > b
> > c
> > d
> > fatcat[pb] hg heads
> > changeset:   4:aa91f18a56e8
> > tag:         tip
> > parent:      1:9faa11d934ce
> > parent:      3:356092e516ea
> > user:        Piers Barber<piers.barber at imgtec.com>
> > date:        Thu Aug 05 20:52:42 2010 +0100
> > summary:     merged mybranch
> >
> > why do i get the push error? i did merge and i did commit.
> 
> Well ... it wasn't really a push error. Mercurial just didn't push 
> because it wasn't a simple push. But Mercurial told you that it didn't 
> push and it told you what you could do to push anyway.
> 
> (You didn't tell what version of Mercurial you are using, but in the 
> latest version it should tell you "use 'hg push --new-branch' to create 
> new remote branches" instead.)
> 
> When you use anonymous branches where each branch just is a head then 
> Mercurial counts heads, and merging and committing reduces the head 
> count so a simple push can be used. It seems like this is what you 
> expect, but you are using named branches and do thus have a different 
> situation.
> 
> Names branches do permanently record the branch name in the repositorys 
> history, so a merge isn't enough to make it "go away". In this case 
> Mercurial warns you that the push isn't completely trivial and asks for 
> more specific instructions about what to do.

Mads - thanks for the explanation. 

fatcat[pb] hg --version
Mercurial Distributed SCM (version 1.4.3)

Copyright (C) 2005-2010 Matt Mackall <mpm at selenic.com> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

on our central repo at work i was worried about adding a new head that would propagate to all users (when i perceived it as purely local to my repo and nobody else's concern) i did not want to break anyone else's pulls

so i press ahead with my dummy example...

fatcat[pb] hg push
pushing to /home/pb/hack/source1
searching for changes
abort: push creates new remote branch 'mybranch'!
(did you forget to merge? use push -f to force)
fatcat[pb] hg push -f
pushing to /home/pb/hack/source1
searching for changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 2 changes to 1 files

ok, so i've done it - i'll make another change in the original repo...

fatcat[pb] cd ../source1
fatcat[pb] hg up
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
fatcat[pb] echo e >> a
fatcat[pb] hg ci -m"a3" a

and now i check and see that everything was indeed fine...

fatcat[pb] hg glog
@  changeset:   5:3fc09c9829e6
|  tag:         tip
|  user:        Piers Barber <piers.barber at adotdot.com>
|  date:        Fri Aug 06 00:31:55 2010 +0100
|  summary:     a3
|
o    changeset:   4:aa91f18a56e8
|\   parent:      1:9faa11d934ce
| |  parent:      3:356092e516ea
| |  user:        Piers Barber <piers.barber at adotdot.com>
| |  date:        Thu Aug 05 20:52:42 2010 +0100
| |  summary:     merged mybranch
| |
| o  changeset:   3:356092e516ea
| |  branch:      mybranch
| |  user:        Piers Barber <piers.barber at adotdot.com>
| |  date:        Thu Aug 05 20:51:40 2010 +0100
| |  summary:     c2
| |
| o  changeset:   2:d666a9f13679
|/   branch:      mybranch
|    user:        Piers Barber <piers.barber at adotdot.com>
|    date:        Thu Aug 05 20:51:24 2010 +0100
|    summary:     c1
|
o  changeset:   1:9faa11d934ce
|  user:        Piers Barber <piers.barber at adotdot.com>
|  date:        Thu Aug 05 20:49:09 2010 +0100
|  summary:     a2
|
o  changeset:   0:6743d1989c8f
   user:        Piers Barber <piers.barber at adotdot.com>
   date:        Thu Aug 05 20:48:40 2010 +0100
   summary:     a1

so the problem is a message delivery issue:

1)  i did not forget to merge, yet hg made me worry that i had not done it correctly.
2)  it also implied that a remote branch may be a bad thing (use of the words abort, -f and ! scared me) even though the branch has been merged with the mainline

thanks again for the explanation

--
Piers Barber



More information about the Mercurial mailing list