Merge lp:~mwhudson/launchpad/incremental-save-all-revs into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Tim Penhey
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~mwhudson/launchpad/incremental-save-all-revs
Merge into: lp:launchpad
Diff against target: 80 lines (+40/-5)
2 files modified
lib/lp/codehosting/codeimport/tests/test_worker.py (+25/-0)
lib/lp/codehosting/codeimport/worker.py (+15/-5)
To merge this branch: bzr merge lp:~mwhudson/launchpad/incremental-save-all-revs
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+20020@code.launchpad.net

Commit message

Preserve all revisions in an import branch's repository between runs, needed to make incremental imports work reliably.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

The attempt at importing the kernel incrementally failed because some revisions imported in the first step weren't preserved for the second. This branch changes the BazaarBranchStore to push/pull _all_ revisions in the branch's repository, not just those in the ancestry of the branch tip.

Revision history for this message
Tim Penhey (thumper) wrote :

Seems reasonable.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py'
--- lib/lp/codehosting/codeimport/tests/test_worker.py 2010-02-22 05:37:36 +0000
+++ lib/lp/codehosting/codeimport/tests/test_worker.py 2010-02-23 23:27:16 +0000
@@ -254,6 +254,31 @@
254 store._getMirrorURL(self.arbitrary_branch_id),254 store._getMirrorURL(self.arbitrary_branch_id),
255 sftp_prefix_noslash + '/' + '%08x' % self.arbitrary_branch_id)255 sftp_prefix_noslash + '/' + '%08x' % self.arbitrary_branch_id)
256256
257 def test_all_revisions_saved(self):
258 # All revisions in the branch's repo are transferred, not just those
259 # in the ancestry of the tip.
260 # Consider a branch with two heads in its repo:
261 # revid
262 # / \
263 # revid1 revid2 <- branch tip
264 # A naive push/pull would just store 'revid' and 'revid2' in the
265 # branch store -- we need to make sure all three revisions are stored
266 # and retrieved.
267 builder = self.make_branch_builder('tree')
268 revid = builder.build_snapshot(
269 None, None, [('add', ('', 'root-id', 'directory', ''))])
270 revid1 = builder.build_snapshot(None, [revid], [])
271 revid2 = builder.build_snapshot(None, [revid], [])
272 branch = builder.get_branch()
273 source_tree = branch.bzrdir.create_workingtree()
274 store = self.makeBranchStore()
275 store.push(self.arbitrary_branch_id, source_tree, default_format)
276 retrieved_tree = store.pull(
277 self.arbitrary_branch_id, 'pulled', default_format)
278 self.assertEqual(
279 set([revid, revid1, revid2]),
280 set(retrieved_tree.branch.repository.all_revision_ids()))
281
257282
258class TestImportDataStore(WorkerTest):283class TestImportDataStore(WorkerTest):
259 """Tests for `ImportDataStore`."""284 """Tests for `ImportDataStore`."""
260285
=== modified file 'lib/lp/codehosting/codeimport/worker.py'
--- lib/lp/codehosting/codeimport/worker.py 2010-02-19 03:32:39 +0000
+++ lib/lp/codehosting/codeimport/worker.py 2010-02-23 23:27:16 +0000
@@ -71,20 +71,26 @@
71 """71 """
72 remote_url = self._getMirrorURL(db_branch_id)72 remote_url = self._getMirrorURL(db_branch_id)
73 try:73 try:
74 bzr_dir = BzrDir.open(remote_url)74 remote_bzr_dir = BzrDir.open(remote_url)
75 except NotBranchError:75 except NotBranchError:
76 return BzrDir.create_standalone_workingtree(76 return BzrDir.create_standalone_workingtree(
77 target_path, required_format)77 target_path, required_format)
78 # XXX Tim Penhey 2009-09-18 bug 432217 Automatic upgrade of import78 # XXX Tim Penhey 2009-09-18 bug 432217 Automatic upgrade of import
79 # branches disabled. Need an orderly upgrade process.79 # branches disabled. Need an orderly upgrade process.
80 if False and bzr_dir.needs_format_conversion(format=required_format):80 if False and remote_bzr_dir.needs_format_conversion(
81 format=required_format):
81 try:82 try:
82 bzr_dir.root_transport.delete_tree('backup.bzr')83 remote_bzr_dir.root_transport.delete_tree('backup.bzr')
83 except NoSuchFile:84 except NoSuchFile:
84 pass85 pass
85 upgrade(remote_url, required_format)86 upgrade(remote_url, required_format)
86 bzr_dir.sprout(target_path)87 local_bzr_dir = remote_bzr_dir.sprout(target_path)
87 return BzrDir.open(target_path).open_workingtree()88 # Because of the way we do incremental imports, there may be revisions
89 # in the branch's repo that are not in the ancestry of the branch tip.
90 # We need to transfer them too.
91 local_bzr_dir.open_repository().fetch(
92 remote_bzr_dir.open_repository())
93 return local_bzr_dir.open_workingtree()
8894
89 def push(self, db_branch_id, bzr_tree, required_format):95 def push(self, db_branch_id, bzr_tree, required_format):
90 """Push up `bzr_tree` as the Bazaar branch for `code_import`.96 """Push up `bzr_tree` as the Bazaar branch for `code_import`.
@@ -101,6 +107,10 @@
101 branch_to = BzrDir.create_branch_and_repo(107 branch_to = BzrDir.create_branch_and_repo(
102 target_url, format=required_format)108 target_url, format=required_format)
103 pull_result = branch_to.pull(branch_from, overwrite=True)109 pull_result = branch_to.pull(branch_from, overwrite=True)
110 # Because of the way we do incremental imports, there may be revisions
111 # in the branch's repo that are not in the ancestry of the branch tip.
112 # We need to transfer them too.
113 branch_to.repository.fetch(branch_from.repository)
104 return pull_result.old_revid != pull_result.new_revid114 return pull_result.old_revid != pull_result.new_revid
105115
106116