# HG changeset patch # User Benoit Allard # Date 1226669777 -3600 # Node ID e17dbf14003512f0429818977ec4e508fdeaf95e # Parent 6ad2b914acbd219eeb15250ef22da7d37a559ba5 pull: update to branch tip if there is only one head on the current branch On pull, if the current named branch has only one head, update to it. diff -r 6ad2b914acbd -r e17dbf140035 mercurial/commands.py --- a/mercurial/commands.py Fri Nov 14 13:48:23 2008 +0100 +++ b/mercurial/commands.py Fri Nov 14 14:36:17 2008 +0100 @@ -2091,7 +2091,7 @@ if modheads == 0: return if optupdate: - if modheads <= 1 or checkout: + if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout: return hg.update(repo, checkout) else: ui.status(_("not updating, since new heads added\n")) diff -r 6ad2b914acbd -r e17dbf140035 tests/test-pull-branch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-pull-branch Fri Nov 14 14:36:17 2008 +0100 @@ -0,0 +1,75 @@ +#!/bin/sh + +hg init t +cd t +echo 1 > foo +hg ci -Am1 # 0 +hg branch branchA +echo a1 > foo +hg ci -ma1 # 1 + +cd .. +hg init tt +cd tt +hg pull ../t +hg up branchA + +cd ../t +echo a2 > foo +hg ci -ma2 # 2 +echo % create branch B +hg up 0 +hg branch branchB +echo b1 > foo +hg ci -mb1 # 3 + +cd ../tt +echo % a new branch is there +hg pull -u ../t + +echo % develop both branch +cd ../t +hg up branchA +echo a3 > foo +hg ci -ma3 # 4 +hg up branchB +echo b2 > foo +hg ci -mb2 # 5 + +cd ../tt +echo % should succeed, no new heads +hg pull -u ../t + +echo % add an head on other branch +cd ../t +hg up branchA +echo a4 > foo +hg ci -ma4 # 6 +hg up branchB +echo b3.1 > foo +hg ci -m b3.1 # 7 +hg up 5 +echo b3.2 > foo +hg ci -m b3.2 # 8 + +cd ../tt +echo % should succeed only one head on our branch +hg pull -u ../t + +cd ../t +hg up -C branchA +echo a5.1 > foo +hg ci -ma5.1 # 9 +hg up 6 +echo a5.2 > foo +hg ci -ma5.2 # 10 +hg up 7 +echo b4.1 > foo +hg ci -m b4.1 # 11 +hg up -C 8 +echo b4.2 > foo +hg ci -m b4.2 # 12 + +cd ../tt +echo % should fail new head in our branch +hg pull -u ../t diff -r 6ad2b914acbd -r e17dbf140035 tests/test-pull-branch.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-pull-branch.out Fri Nov 14 14:36:17 2008 +0100 @@ -0,0 +1,60 @@ +adding foo +marked working directory as branch branchA +pulling from ../t +requesting all changes +adding changesets +adding manifests +adding file changes +added 2 changesets with 2 changes to 1 files +(run 'hg update' to get a working copy) +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +% create branch B +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +marked working directory as branch branchB +created new head +% a new branch is there +pulling from ../t +searching for changes +adding changesets +adding manifests +adding file changes +added 2 changesets with 2 changes to 1 files (+1 heads) +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +% develop both branch +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +% should succeed, no new heads +pulling from ../t +searching for changes +adding changesets +adding manifests +adding file changes +added 2 changesets with 2 changes to 1 files +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +% add an head on other branch +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +created new head +% should succeed only one head on our branch +pulling from ../t +searching for changes +adding changesets +adding manifests +adding file changes +added 3 changesets with 3 changes to 1 files (+1 heads) +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +created new head +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +% should fail new head in our branch +pulling from ../t +searching for changes +adding changesets +adding manifests +adding file changes +added 4 changesets with 4 changes to 1 files (+1 heads) +not updating, since new heads added +(run 'hg heads' to see heads, 'hg merge' to merge)