# HG changeset patch # User Sune Foldager # Date 2009-11-30 13:58:52 # Node ID d6a307719ccbfbb3bf7f2c44d18b678281de5b9f # Parent 5b149c88d9e8d2eb1ac2aeffaee3e8d9e7383a72 fix bug in prepush logic involving merge changesets When creating new branches and merging them into existing ones, you would sometimes be able to push some changesets (the existing branches) without using --force, even when that creates a new head on the remote. A test which triggers the error has been added. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1505,7 +1505,7 @@ class localrepository(repo.repository): if not rheads: # new branch requires --force self.ui.warn(_("abort: push creates new" " remote branch '%s'!\n") % - self[updatelb[0]].branch()) + self[lheads[0]].branch()) else: self.ui.warn(_("abort: push creates new remote heads!\n")) @@ -1548,11 +1548,7 @@ class localrepository(repo.repository): else: rheads = [] lheads = localhds[lh] - updatelb = [upd for upd in update - if self[upd].branch() == lh] - if not updatelb: - continue - if not checkbranch(lheads, rheads, updatelb): + if not checkbranch(lheads, rheads, update): return None, 0 else: if not checkbranch(heads, remote_heads, update): diff --git a/tests/test-push-warn b/tests/test-push-warn --- a/tests/test-push-warn +++ b/tests/test-push-warn @@ -140,4 +140,21 @@ hg -R i ci -Am c hg -R i push h echo +echo % check prepush logic with merged branches +hg init j +hg -R j branch a +echo init > j/foo +hg -R j ci -Am init +hg clone j k +echo a1 > j/foo +hg -R j ci -m a1 +hg -R k branch b +echo b > k/foo +hg -R k ci -m b +hg -R k up 0 +hg -R k merge b +hg -R k ci -m merge +hg -R k push -r a j +echo + exit 0 diff --git a/tests/test-push-warn.out b/tests/test-push-warn.out --- a/tests/test-push-warn.out +++ b/tests/test-push-warn.out @@ -140,3 +140,17 @@ searching for changes abort: push creates new remote heads! (did you forget to merge? use push -f to force) +% check prepush logic with merged branches +marked working directory as branch a +adding foo +updating to branch a +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +marked working directory as branch b +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +(branch merge, don't forget to commit) +pushing to j +searching for changes +abort: push creates new remote heads! +(did you forget to merge? use push -f to force) +