# HG changeset patch # User Patrick Mezard # Date 1227979501 21600 # Node ID f508c1fa19a59ba0dea95d885ca70ab0401671f0 # Parent ea65fe2b0856942fd89b1c353f774e9a96845896 hg_delta_editor: do not assume branches are copied from trunk by default Here is what happen in jquery repository: - kelvin-dev branch is created in r1617 with an empty directory for the datePicker plugin - commits are done - datePicker plugin is merged in trunk Before the fix, the converter assumed the initial empty commit had for parent some other commit of trunk, therefore adding all its files, which was wrong. And we ended with 'alignDemo.html' in converted trunk@5946 while it was not in the source revision. diff --git a/hg_delta_editor.py b/hg_delta_editor.py --- a/hg_delta_editor.py +++ b/hg_delta_editor.py @@ -230,6 +230,8 @@ class HgChangeReceiver(delta.Editor): if branch in self.branches: parent_branch = self.branches[branch][0] parent_branch_rev = self.branches[branch][1] + if parent_branch_rev <= 0: + return None, None branch_created_rev = self.branches[branch][2] if parent_branch == 'trunk': parent_branch = None @@ -265,11 +267,9 @@ class HgChangeReceiver(delta.Editor): if not ((src_p and self._is_path_valid(src_p)) or (src_tag and src_tag in self.tags)): - # we'll imply you're a branch off of trunk - # if you have no path, but if you do, it must be valid - # or else we assume trunk as well + # The branch starts here and is not a copy src_branch = None - src_rev = revision.revnum + src_rev = 0 elif src_tag: # this is a branch created from a tag. Note that this # really does happen (see Django) diff --git a/tests/test_fetch_branches.py b/tests/test_fetch_branches.py --- a/tests/test_fetch_branches.py +++ b/tests/test_fetch_branches.py @@ -14,8 +14,8 @@ class TestFetchBranches(test_util.TestBa heads = [repo[n] for n in repo.heads()] heads = dict([(ctx.branch(), ctx) for ctx in heads]) # Let these tests disabled yet as the fix is not obvious - #self.assertEqual(heads['branch1'].manifest().keys(), ['b']) - #self.assertEqual(heads['branch2'].manifest().keys(), ['a', 'b']) + self.assertEqual(heads['branch1'].manifest().keys(), ['b']) + self.assertEqual(heads['branch2'].manifest().keys(), ['a', 'b']) def test_unrelatedbranch_stupid(self): self.test_unrelatedbranch(True)