--- a/hgext/fetch.py Mon Sep 22 14:47:21 2008 +0200
+++ b/hgext/fetch.py Wed Sep 24 13:22:11 2008 +0200
@@ -33,8 +33,9 @@
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)'))
--- a/tests/test-fetch Mon Sep 22 14:47:21 2008 +0200
+++ b/tests/test-fetch Wed Sep 24 13:22:11 2008 +0200
@@ -156,4 +156,17 @@
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
--- a/tests/test-fetch.out Mon Sep 22 14:47:21 2008 +0200
+++ b/tests/test-fetch.out Wed Sep 24 13:22:11 2008 +0200
@@ -170,3 +170,11 @@
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