# HG changeset patch # User Augie Fackler # Date 1230052232 21600 # Node ID 6fa97cfbf62fa2e798d9facad0ecd0ed05cba51f # Parent 46f6b872c9889da463a8543dc9135385799dee5d fetch: Refactor extra creation to be shared by real and diff replay. Add convert-compatible meta information to extra. diff --git a/fetch_command.py b/fetch_command.py --- a/fetch_command.py +++ b/fetch_command.py @@ -502,9 +502,7 @@ def stupid_svn_server_pull_rev(ui, svn, files_touched, filectxfn = stupid_fetch_branchrev( svn, hg_editor, b, branches[b], r, parentctx) - extra = {} - if b: - extra['branch'] = b + extra = util.build_extra(r.revnum, b, svn.uuid, svn.subdir) if '' in files_touched: files_touched.remove('') if parentctx.node() != node.nullid or files_touched: diff --git a/hg_delta_editor.py b/hg_delta_editor.py --- a/hg_delta_editor.py +++ b/hg_delta_editor.py @@ -395,18 +395,20 @@ class HgChangeReceiver(delta.Editor): for branch, files in branch_batches.iteritems(): if branch in self.commit_branches_empty and files: del self.commit_branches_empty[branch] - extra = {} files = dict(files) parents = (self.get_parent_revision(rev.revnum, branch), revlog.nullid) if parents[0] in closed_revs and branch in self.branches_to_delete: continue + # TODO this needs to be fixed with the new revmap + extra = our_util.build_extra(rev.revnum, branch, + open(self.uuid_file).read(), + self.subdir) if branch is not None: if (branch not in self.branches and branch not in self.repo.branchtags()): continue - extra['branch'] = branch parent_ctx = self.repo.changectx(parents[0]) def filectxfn(repo, memctx, path): current_file = files[path] @@ -451,9 +453,9 @@ class HgChangeReceiver(delta.Editor): # True here meant nuke all files, shouldn't happen with branch closing if self.commit_branches_empty[branch]: #pragma: no cover assert False, 'Got asked to commit non-closed branch as empty with no files. Please report this issue.' - extra = {} - if branch: - extra['branch'] = branch + extra = our_util.build_extra(rev.revnum, branch, + open(self.uuid_file).read(), + self.subdir) current_ctx = context.memctx(self.repo, (ha, node.nullid), rev.message or ' ', 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 @@ -35,7 +35,7 @@ class TestFetchBranches(test_util.TestBa repo = self._load_fixture_and_fetch('branch_rename_to_trunk.svndump', stupid) self.assertEqual(node.hex(repo['default'].node()), - 'b479347c1f56d1fafe5e32a7ce0d1b7099637784') + '14d252aef315857df241dd3fa4bc7833b09bd2f5') self.assertEqual(repo['tip'].parents()[0].branch(), 'dev_branch') self.assertEqual(repo['old_trunk'].parents()[0].branch(), 'default') @@ -47,9 +47,9 @@ class TestFetchBranches(test_util.TestBa stupid) self.assertEqual(repo['default'].parents()[0].branch(), 'test') self.assertEqual(node.hex(repo['closed-branches'].parents()[0].node()), - 'f46d6f10e6329a069503af6c0c12903994c083b2') + '2cd09772e0f6ddf2d13c60ef3c1be11ad5a7dfae') self.assertEqual(node.hex(repo['default'].node()), - '7bb5386f1a8e752888183cd86e43bdaf9abd1a95') + '8a525ca0671f456e6b1417187bf86c6115d2cb78') def test_replace_trunk_with_branch_stupid(self): self.test_replace_trunk_with_branch(stupid=True) diff --git a/tests/test_fetch_command.py b/tests/test_fetch_command.py --- a/tests/test_fetch_command.py +++ b/tests/test_fetch_command.py @@ -11,40 +11,46 @@ class TestBasicRepoLayout(test_util.Test def test_fresh_fetch_single_rev(self): repo = self._load_fixture_and_fetch('single_rev.svndump') self.assertEqual(node.hex(repo['tip'].node()), - 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') + '434ed487136c1b47c1e8f952edb4dc5a8e6328df') + self.assertEqual(repo['tip'].extra()['convert_revision'], + 'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/trunk@2') self.assertEqual(repo['tip'], repo[0]) def test_fresh_fetch_two_revs(self): repo = self._load_fixture_and_fetch('two_revs.svndump') # TODO there must be a better way than repo[0] for this check self.assertEqual(node.hex(repo[0].node()), - 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') + '434ed487136c1b47c1e8f952edb4dc5a8e6328df') self.assertEqual(node.hex(repo['tip'].node()), - 'bf3767835b3b32ecc775a298c2fa27134dd91c11') + 'c95251e0dd04697deee99b79cc407d7db76e6a5f') self.assertEqual(repo['tip'], repo[1]) def test_branches(self): repo = self._load_fixture_and_fetch('simple_branch.svndump') # TODO there must be a better way than repo[0] for this check self.assertEqual(node.hex(repo[0].node()), - 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') + '434ed487136c1b47c1e8f952edb4dc5a8e6328df') self.assertEqual(node.hex(repo['tip'].node()), - '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') + 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109') self.assertEqual(len(repo['tip'].parents()), 1) self.assertEqual(repo['tip'].parents()[0], repo['default']) + self.assertEqual(repo['tip'].extra()['convert_revision'], + 'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/branches/the_branch@4') + self.assertEqual(repo['default'].extra()['convert_revision'], + 'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/trunk@3') self.assertEqual(len(repo.heads()), 1) def test_two_branches_with_heads(self): repo = self._load_fixture_and_fetch('two_heads.svndump') # TODO there must be a better way than repo[0] for this check self.assertEqual(node.hex(repo[0].node()), - 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') + '434ed487136c1b47c1e8f952edb4dc5a8e6328df') self.assertEqual(node.hex(repo['tip'].node()), - 'a595c77cfcaa3d1ba9e04b2c55c68bc6bf2b0fbf') + '1083037b18d85cd84fa211c5adbaeff0fea2cd9f') self.assertEqual(node.hex(repo['the_branch'].node()), - '8ccaba5f0eae124487e413abd904a013f7f6fdeb') + '4e256962fc5df545e2e0a51d0d1dc61c469127e6') self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()), - '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') + 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109') self.assertEqual(len(repo['tip'].parents()), 1) self.assertEqual(repo['tip'], repo['default']) self.assertEqual(len(repo.heads()), 2) @@ -63,13 +69,13 @@ class TestBasicRepoLayout(test_util.Test def _many_special_cases_checks(self, repo): self.assertEqual(node.hex(repo[0].node()), - 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') + '434ed487136c1b47c1e8f952edb4dc5a8e6328df') self.assertEqual(node.hex(repo['tip'].node()), - '179fb7d9bc77eef78288661f0430e0c1dff56b6f') + 'b7bdc73041b1852563deb1ef3f4153c2fe4484f2') self.assertEqual(node.hex(repo['the_branch'].node()), - '8ccaba5f0eae124487e413abd904a013f7f6fdeb') + '4e256962fc5df545e2e0a51d0d1dc61c469127e6') self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()), - '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') + 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109') self.assertEqual(len(repo['tip'].parents()), 1) self.assertEqual(repo['tip'], repo['default']) self.assertEqual(len(repo.heads()), 2) @@ -77,14 +83,14 @@ class TestBasicRepoLayout(test_util.Test def test_file_mixed_with_branches(self): repo = self._load_fixture_and_fetch('file_mixed_with_branches.svndump') self.assertEqual(node.hex(repo['tip'].node()), - 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') + '434ed487136c1b47c1e8f952edb4dc5a8e6328df') assert 'README' not in repo def test_files_copied_from_outside_btt(self): repo = self._load_fixture_and_fetch( 'test_files_copied_from_outside_btt.svndump') self.assertEqual(node.hex(repo['tip'].node()), - 'c4e669a763a70f751c71d4534a34a65f398d71d4') + '3c78170e30ddd35f2c32faa0d8646ab75bba4f73') self.assertEqual(len(repo.changelog), 2) def test_file_renamed_in_from_outside_btt(self): @@ -96,7 +102,7 @@ class TestBasicRepoLayout(test_util.Test repo = self._load_fixture_and_fetch( 'fetch_missing_files_subdir.svndump', subdir='foo') self.assertEqual(node.hex(repo['tip'].node()), - '2fae2544a5858d0bc6c04976683b3dcc0416d6e3') + '269dcdd4361b2847e9f4288d4500e55d35df1f52') self.assert_('bar/alpha' in repo['tip']) self.assert_('foo' in repo['tip']) self.assert_('bar/alpha' not in repo['tip'].parents()[0]) @@ -106,11 +112,11 @@ class TestBasicRepoLayout(test_util.Test repo = self._load_fixture_and_fetch( 'tagged_vendor_and_oldest_not_trunk.svndump') self.assertEqual(node.hex(repo['oldest'].node()), - 'd73002bcdeffe389a8df81ee43303d36e79e8ca4') + '926671740dec045077ab20f110c1595f935334fa') self.assertEqual(repo['tip'].parents()[0].parents()[0], repo['oldest']) self.assertEqual(node.hex(repo['tip'].node()), - '9cf09e6ff7fa938188c3bcc9dd87abd7842c080c') + '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') def test_propedit_with_nothing_else(self, stupid=False): repo = self._load_fixture_and_fetch('branch_prop_edit.svndump', @@ -139,14 +145,18 @@ class TestStupidPull(test_util.TestBase) True) # TODO there must be a better way than repo[0] for this check self.assertEqual(node.hex(repo[0].node()), - 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') + '434ed487136c1b47c1e8f952edb4dc5a8e6328df') self.assertEqual(node.hex(repo['tip'].node()), - 'a595c77cfcaa3d1ba9e04b2c55c68bc6bf2b0fbf') + '1083037b18d85cd84fa211c5adbaeff0fea2cd9f') self.assertEqual(node.hex(repo['the_branch'].node()), - '8ccaba5f0eae124487e413abd904a013f7f6fdeb') + '4e256962fc5df545e2e0a51d0d1dc61c469127e6') + self.assertEqual(repo['the_branch'].extra()['convert_revision'], + 'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/branches/the_branch@5') self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()), - '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') + 'f1ff5b860f5dbb9a59ad0921a79da77f10f25109') self.assertEqual(len(repo['tip'].parents()), 1) + self.assertEqual(repo['default'].extra()['convert_revision'], + 'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/trunk@6') self.assertEqual(repo['tip'], repo['default']) self.assertEqual(len(repo.heads()), 2) @@ -158,11 +168,11 @@ class TestStupidPull(test_util.TestBase) True) repo = hg.repository(ui.ui(), self.wc_path) self.assertEqual(node.hex(repo['oldest'].node()), - 'd73002bcdeffe389a8df81ee43303d36e79e8ca4') + '926671740dec045077ab20f110c1595f935334fa') self.assertEqual(repo['tip'].parents()[0].parents()[0], repo['oldest']) self.assertEqual(node.hex(repo['tip'].node()), - '9cf09e6ff7fa938188c3bcc9dd87abd7842c080c') + '1a6c3f30911d57abb67c257ec0df3e7bc44786f7') def suite(): all = [unittest.TestLoader().loadTestsFromTestCase(TestBasicRepoLayout), diff --git a/tests/test_fetch_exec.py b/tests/test_fetch_exec.py --- a/tests/test_fetch_exec.py +++ b/tests/test_fetch_exec.py @@ -27,7 +27,7 @@ class TestFetchExec(test_util.TestBase): def test_empty_prop_val_executable(self, stupid=False): repo = self._load_fixture_and_fetch('executable_file_empty_prop.svndump', stupid) self.assertEqual(node.hex(repo['tip'].node()), - 'b19e2bdd93da30b09c2396cfdb987cc85271249a') + '08e6b380bf291b361a418203a1cb9427213cd1fd') self.assertEqual(repo['tip']['foo'].flags(), 'x') def test_empty_prop_val_executable_stupid(self): diff --git a/tests/test_tags.py b/tests/test_tags.py --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -22,9 +22,9 @@ class TestTags(test_util.TestBase): def _test_tag_revision_info(self, repo): self.assertEqual(node.hex(repo[0].node()), - 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') + '434ed487136c1b47c1e8f952edb4dc5a8e6328df') self.assertEqual(node.hex(repo['tip'].node()), - 'bf3767835b3b32ecc775a298c2fa27134dd91c11') + 'c95251e0dd04697deee99b79cc407d7db76e6a5f') self.assertEqual(repo['tip'], repo[1]) def test_tags(self, stupid=False): @@ -79,12 +79,12 @@ class TestTags(test_util.TestBase): repo = self.getrepo() self.assertEqual(repo['tip'], repo['closed-branches']) self.assertEqual(node.hex(repo['tip'].node()), - 'dd2dccc3180631192f058468ec7215899223a6d8') + '2f0a3abe2004c0fa01f5f6074a8b5441e9c80c2a') taggedrev = repo['tip'].parents()[0] self.assertEqual(node.hex(taggedrev.node()), - '68f5f7d82b00a2efe3aca28b615ebab98235d55f') + '50c67c73267987de705ee335183c5486641e56e9') self.assertEqual(node.hex(repo['tag/dummy'].node()), - '68f5f7d82b00a2efe3aca28b615ebab98235d55f') + '50c67c73267987de705ee335183c5486641e56e9') def test_tag_by_renaming_branch_stupid(self): self.test_tag_by_renaming_branch(stupid=True) diff --git a/util.py b/util.py --- a/util.py +++ b/util.py @@ -99,6 +99,24 @@ def outgoing_revisions(ui, repo, hg_edit if sourcerev.node() != node.nullid: return outgoing_rev_hashes +def build_extra(revnum, branch, uuid, subdir): + # TODO this needs to be fixed with the new revmap + extra = {} + branchpath = 'trunk' + if branch: + extra['branch'] = branch + branchpath = 'branches/%s' % branch + if subdir and subdir[-1] == '/': + subdir = subdir[:-1] + if subdir and subdir[0] != '/': + subdir = '/' + subdir + extra['convert_revision'] = 'svn:%(uuid)s%(path)s@%(rev)s' % { + 'uuid': uuid, + 'path': '%s/%s' % (subdir , branchpath), + 'rev': revnum, + } + return extra + def is_svn_repo(repo): return os.path.exists(os.path.join(repo.path, 'svn'))