diff -r 66d954e76ffb -r 36b6b5ef7820 mercurial/localrepo.py --- a/mercurial/localrepo.py Sat Feb 06 10:51:50 2010 +0100 +++ b/mercurial/localrepo.py Sun Feb 07 00:43:22 2010 +0100 @@ -1558,25 +1558,18 @@ if remote_heads != [nullid]: if remote.capable('branchmap'): - localhds = {} + remotebrheads = remote.branchmap() + if not revs: - localhds = self.branchmap() + localbrheads = self.branchmap() else: + localbrheads = {} for n in heads: branch = self[n].branch() - if branch in localhds: - localhds[branch].append(n) - else: - localhds[branch] = [n] - - remotehds = remote.branchmap() + localbrheads.setdefault(branch, []).append(n) - for lh in localhds: - if lh in remotehds: - rheads = remotehds[lh] - else: - rheads = [] - lheads = localhds[lh] + for branch, lheads in localbrheads.iteritems(): + rheads = remotebrheads.get(branch, []) if not checkbranch(lheads, rheads, update): return None, 0 else: