# HG changeset patch # User Sune Foldager # Date 2008-09-24 11:22:11 # Node ID 6489ee64b52245136b6690f1c292dc1c930ad4c9 # Parent 25961e53a07ff57a28b10a837aa8fb98c27617e3 fetch: use dirstate branch instead of first parents diff --git a/hgext/fetch.py b/hgext/fetch.py --- a/hgext/fetch.py +++ b/hgext/fetch.py @@ -33,8 +33,9 @@ def fetch(ui, repo, source='default', ** opts['date'] = util.parsedate(date) parent, p2 = repo.dirstate.parents() - branch = repo[parent].branch() - if parent != repo[branch].node(): + branch = repo.dirstate.branch() + branchnode = repo.branchtags().get(branch) + if parent != branchnode: raise util.Abort(_('working dir not at branch tip ' '(use "hg update" to check out branch tip)')) diff --git a/tests/test-fetch b/tests/test-fetch --- a/tests/test-fetch +++ b/tests/test-fetch @@ -156,4 +156,17 @@ echo '% parent should be 3 (fetch did no hg -R n2 parents --template '{rev}\n' rm -fr n1 n2 +echo % pull in change on different branch than dirstate +hg init n1 +echo a > n1/a +hg -R n1 ci -Am initial +hg clone n1 n2 +echo b > n1/a +hg -R n1 ci -m next +hg -R n2 branch topic +hg -R n2 fetch -d '0 0' -m merge n1 +echo '% parent should be 0 (fetch did not update or merge anything)' +hg -R n2 parents --template '{rev}\n' +rm -fr n1 n2 + true diff --git a/tests/test-fetch.out b/tests/test-fetch.out --- a/tests/test-fetch.out +++ b/tests/test-fetch.out @@ -170,3 +170,11 @@ added 3 changesets with 2 changes to 1 f not merging with 1 other new branch heads (use "hg heads ." and "hg merge" to merge them) % parent should be 3 (fetch did not merge anything) 3 +% pull in change on different branch than dirstate +adding a +updating working directory +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +marked working directory as branch topic +abort: working dir not at branch tip (use "hg update" to check out branch tip) +% parent should be 0 (fetch did not update or merge anything) +0