Merge lp:~thumper/launchpad/deleting-individual-branch-revisions into lp:launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Paul Hummer
Approved revision: no longer in the source branch.
Merged at revision: 11534
Proposed branch: lp:~thumper/launchpad/deleting-individual-branch-revisions
Merge into: lp:launchpad
Diff against target: 443 lines (+109/-88)
10 files modified
lib/canonical/config/schema-lazr.conf (+1/-0)
lib/lp/code/configure.zcml (+0/-11)
lib/lp/code/doc/revision.txt (+5/-18)
lib/lp/code/interfaces/branch.py (+6/-0)
lib/lp/code/interfaces/branchrevision.py (+3/-8)
lib/lp/code/model/branch.py (+13/-9)
lib/lp/code/model/branchrevision.py (+4/-18)
lib/lp/code/model/tests/test_branch.py (+56/-2)
lib/lp/codehosting/scanner/bzrsync.py (+20/-17)
lib/lp/codehosting/scanner/tests/test_bzrsync.py (+1/-5)
To merge this branch: bzr merge lp:~thumper/launchpad/deleting-individual-branch-revisions
Reviewer Review Type Date Requested Status
Paul Hummer (community) Approve
Review via email: mp+34943@code.launchpad.net

Commit message

Stop deleting branch revision objects by their ids.

Description of the change

This is a pre-branch branch.

The work coming is to remove the BranchRevision.id column. In order to do this we need to update the code that is currently using it.

The only place it is really used is in the branch scanner where it is used to remove BranchRevision rows for revisions that are no longer in the ancestry of a branch due to `push --overwrite`.

The way to delete branch revision objects has been moved onto the branch object itself, and it now handles deleting multiple branch revisions at once.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Diff is a little extreme as I thought that db-stable had been merged back into devel already.

Revision history for this message
Paul Hummer (rockstar) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/config/schema-lazr.conf'
--- lib/canonical/config/schema-lazr.conf 2010-08-30 00:51:55 +0000
+++ lib/canonical/config/schema-lazr.conf 2010-09-09 20:24:49 +0000
@@ -41,6 +41,7 @@
4141
4242
43[branchscanner]43[branchscanner]
44branch_revision_delete_count: 100
44# The database user which will be used by this process.45# The database user which will be used by this process.
45# datatype: string46# datatype: string
46dbuser: branchscanner47dbuser: branchscanner
4748
=== modified file 'lib/lp/code/configure.zcml'
--- lib/lp/code/configure.zcml 2010-09-01 20:59:44 +0000
+++ lib/lp/code/configure.zcml 2010-09-09 20:24:49 +0000
@@ -642,17 +642,6 @@
642 <allow interface="lp.code.interfaces.branchrevision.IBranchRevision"/>642 <allow interface="lp.code.interfaces.branchrevision.IBranchRevision"/>
643 </class>643 </class>
644644
645 <!-- BranchRevisionSet -->
646
647 <class class="lp.code.model.branchrevision.BranchRevisionSet">
648 <allow interface="lp.code.interfaces.branchrevision.IBranchRevisionSet"/>
649 </class>
650 <securedutility
651 class="lp.code.model.branchrevision.BranchRevisionSet"
652 provides="lp.code.interfaces.branchrevision.IBranchRevisionSet">
653 <allow interface="lp.code.interfaces.branchrevision.IBranchRevisionSet"/>
654 </securedutility>
655
656 <!-- CodeReviewComment -->645 <!-- CodeReviewComment -->
657646
658 <class class="lp.code.model.codereviewcomment.CodeReviewComment">647 <class class="lp.code.model.codereviewcomment.CodeReviewComment">
659648
=== modified file 'lib/lp/code/doc/revision.txt'
--- lib/lp/code/doc/revision.txt 2010-07-14 14:50:58 +0000
+++ lib/lp/code/doc/revision.txt 2010-09-09 20:24:49 +0000
@@ -130,7 +130,7 @@
130In particular, IBranch.getScannerData efficiently retrieves the BranchRevision130In particular, IBranch.getScannerData efficiently retrieves the BranchRevision
131data needed by the branch-scanner script.131data needed by the branch-scanner script.
132132
133 >>> ancestry, history, mapping = branch.getScannerData()133 >>> ancestry, history = branch.getScannerData()
134134
135The first return value is a set of revision_id strings for the full ancestry135The first return value is a set of revision_id strings for the full ancestry
136of the branch.136of the branch.
@@ -158,19 +158,6 @@
158 foo@localhost-20051031170239-5fce7d6bd3f01efc158 foo@localhost-20051031170239-5fce7d6bd3f01efc
159 foo@localhost-20051031170357-1301ad6d387feb23159 foo@localhost-20051031170357-1301ad6d387feb23
160160
161The third return value is a mapping from revision_id strings to database ids
162integers of the corresponding BranchRevision rows for this branch.
163
164 >>> for revision_id, db_id in sorted(mapping.iteritems()):
165 ... print revision_id, db_id
166 foo@localhost-20051031165758-48acedf2b6a2e898 12
167 foo@localhost-20051031170008-098959758bf79803 13
168 foo@localhost-20051031170239-5fce7d6bd3f01efc 14
169 foo@localhost-20051031170357-1301ad6d387feb23 15
170 test@canonical.com-20051031165248-6f1bb97973c2b4f4 10
171 test@canonical.com-20051031165338-5f2f3d6b10bb3bf0 11
172 test@canonical.com-20051031165532-3113df343e494daa 18
173 test@canonical.com-20051031165901-43b9644ec2eacc4e 19
174161
175=== Deleting BranchRevisions ===162=== Deleting BranchRevisions ===
176163
@@ -180,7 +167,7 @@
180of the branch, then some of BranchRevision records will need to be167of the branch, then some of BranchRevision records will need to be
181removed.168removed.
182169
183BranchRevision records are deleted using the `BranchRevisionSet.delete`170BranchRevision records are deleted using the `Branch.removeBranchRevisions`
184method.171method.
185172
186173
@@ -197,14 +184,14 @@
197 6184 6
198 >>> revno_6.branch == branch185 >>> revno_6.branch == branch
199 True186 True
200 >>> print revno_6.revision.revision_id187 >>> rev_id = revno_6.revision.revision_id
188 >>> print rev_id
201 foo@localhost-20051031170357-1301ad6d387feb23189 foo@localhost-20051031170357-1301ad6d387feb23
202190
203We remove the last revision from the branch. This is similar to what191We remove the last revision from the branch. This is similar to what
204"bzr uncommit" does.192"bzr uncommit" does.
205193
206 >>> from lp.code.interfaces.branchrevision import IBranchRevisionSet194 >>> branch.removeBranchRevisions(rev_id)
207 >>> getUtility(IBranchRevisionSet).delete(revno_6.id)
208195
209Afterwards, the last commit on the branch has revision number 5.196Afterwards, the last commit on the branch has revision number 5.
210197
211198
=== modified file 'lib/lp/code/interfaces/branch.py'
--- lib/lp/code/interfaces/branch.py 2010-09-03 11:54:23 +0000
+++ lib/lp/code/interfaces/branch.py 2010-09-09 20:24:49 +0000
@@ -803,6 +803,12 @@
803 def createBranchRevision(sequence, revision):803 def createBranchRevision(sequence, revision):
804 """Create a new `BranchRevision` for this branch."""804 """Create a new `BranchRevision` for this branch."""
805805
806 def removeBranchRevisions(revision_ids):
807 """Remove the specified revision_ids from this Branch's revisions.
808
809 :param revision_ids: Either a single revision_id or an iterable.
810 """
811
806 def createBranchRevisionFromIDs(revision_id_sequence_pairs):812 def createBranchRevisionFromIDs(revision_id_sequence_pairs):
807 """Create a batch of BranchRevision objects.813 """Create a batch of BranchRevision objects.
808814
809815
=== modified file 'lib/lp/code/interfaces/branchrevision.py'
--- lib/lp/code/interfaces/branchrevision.py 2010-08-20 20:31:18 +0000
+++ lib/lp/code/interfaces/branchrevision.py 2010-09-09 20:24:49 +0000
@@ -6,7 +6,9 @@
6"""BranchRevision interfaces."""6"""BranchRevision interfaces."""
77
8__metaclass__ = type8__metaclass__ = type
9__all__ = ['IBranchRevision', 'IBranchRevisionSet']9__all__ = [
10 'IBranchRevision',
11 ]
1012
11from zope.interface import (13from zope.interface import (
12 Attribute,14 Attribute,
@@ -32,10 +34,3 @@
32 " None for merged revisions which are not part of the history."))34 " None for merged revisions which are not part of the history."))
33 branch = Attribute("The branch this revision is included in.")35 branch = Attribute("The branch this revision is included in.")
34 revision = Attribute("A revision that is included in the branch.")36 revision = Attribute("A revision that is included in the branch.")
35
36
37class IBranchRevisionSet(Interface):
38 """The set of all branch-revision associations."""
39
40 def delete(branch_revision_id):
41 """Delete the BranchRevision."""
4237
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2010-09-03 11:54:23 +0000
+++ lib/lp/code/model/branch.py 2010-09-09 20:24:49 +0000
@@ -26,7 +26,6 @@
26 And,26 And,
27 Count,27 Count,
28 Desc,28 Desc,
29 Max,
30 NamedFunc,29 NamedFunc,
31 Not,30 Not,
32 Or,31 Or,
@@ -58,12 +57,8 @@
58 ILaunchpadCelebrities,57 ILaunchpadCelebrities,
59 IPrivacy,58 IPrivacy,
60 )59 )
60from canonical.launchpad.interfaces.lpstorm import IMasterStore
61from canonical.launchpad.webapp import urlappend61from canonical.launchpad.webapp import urlappend
62from canonical.launchpad.webapp.interfaces import (
63 IStoreSelector,
64 MAIN_STORE,
65 SLAVE_FLAVOR,
66 )
67from lp.app.errors import UserCannotUnsubscribePerson62from lp.app.errors import UserCannotUnsubscribePerson
68from lp.buildmaster.model.buildqueue import BuildQueue63from lp.buildmaster.model.buildqueue import BuildQueue
69from lp.code.bzr import (64from lp.code.bzr import (
@@ -804,6 +799,17 @@
804 BranchRevision.branch == self,799 BranchRevision.branch == self,
805 query).one()800 query).one()
806801
802 def removeBranchRevisions(self, revision_ids):
803 """See `IBranch`."""
804 if isinstance(revision_ids, basestring):
805 revision_ids = [revision_ids]
806 IMasterStore(BranchRevision).find(
807 BranchRevision,
808 BranchRevision.branch == self,
809 BranchRevision.revision_id.is_in(
810 Select(Revision.id,
811 Revision.revision_id.is_in(revision_ids)))).remove()
812
807 def createBranchRevision(self, sequence, revision):813 def createBranchRevision(self, sequence, revision):
808 """See `IBranch`."""814 """See `IBranch`."""
809 branch_revision = BranchRevision(815 branch_revision = BranchRevision(
@@ -921,13 +927,11 @@
921 rows = rows.order_by(BranchRevision.sequence)927 rows = rows.order_by(BranchRevision.sequence)
922 ancestry = set()928 ancestry = set()
923 history = []929 history = []
924 branch_revision_map = {}
925 for branch_revision_id, sequence, revision_id in rows:930 for branch_revision_id, sequence, revision_id in rows:
926 ancestry.add(revision_id)931 ancestry.add(revision_id)
927 branch_revision_map[revision_id] = branch_revision_id
928 if sequence is not None:932 if sequence is not None:
929 history.append(revision_id)933 history.append(revision_id)
930 return ancestry, history, branch_revision_map934 return ancestry, history
931935
932 def getPullURL(self):936 def getPullURL(self):
933 """See `IBranch`."""937 """See `IBranch`."""
934938
=== modified file 'lib/lp/code/model/branchrevision.py'
--- lib/lp/code/model/branchrevision.py 2010-08-20 20:31:18 +0000
+++ lib/lp/code/model/branchrevision.py 2010-09-09 20:24:49 +0000
@@ -4,7 +4,9 @@
4# pylint: disable-msg=E0611,W02124# pylint: disable-msg=E0611,W0212
55
6__metaclass__ = type6__metaclass__ = type
7__all__ = ['BranchRevision', 'BranchRevisionSet']7__all__ = [
8 'BranchRevision',
9 ]
810
9from storm.locals import (11from storm.locals import (
10 Int,12 Int,
@@ -13,11 +15,7 @@
13 )15 )
14from zope.interface import implements16from zope.interface import implements
1517
16from canonical.launchpad.interfaces.lpstorm import IMasterStore18from lp.code.interfaces.branchrevision import IBranchRevision
17from lp.code.interfaces.branchrevision import (
18 IBranchRevision,
19 IBranchRevisionSet,
20 )
2119
2220
23class BranchRevision(Storm):21class BranchRevision(Storm):
@@ -40,15 +38,3 @@
40 self.branch = branch38 self.branch = branch
41 self.revision = revision39 self.revision = revision
42 self.sequence = sequence40 self.sequence = sequence
43
44
45class BranchRevisionSet:
46 """See `IBranchRevisionSet`."""
47
48 implements(IBranchRevisionSet)
49
50 def delete(self, branch_revision_id):
51 """See `IBranchRevisionSet`."""
52 match = IMasterStore(BranchRevision).find(
53 BranchRevision, BranchRevision.id == branch_revision_id)
54 match.remove()
5541
=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py 2010-09-03 00:25:53 +0000
+++ lib/lp/code/model/tests/test_branch.py 2010-09-09 20:24:49 +0000
@@ -29,6 +29,7 @@
29from canonical.database.constants import UTC_NOW29from canonical.database.constants import UTC_NOW
30from canonical.launchpad import _30from canonical.launchpad import _
31from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities31from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
32from canonical.launchpad.interfaces.lpstorm import IStore
32from canonical.launchpad.webapp.interfaces import IOpenLaunchBag33from canonical.launchpad.webapp.interfaces import IOpenLaunchBag
33from canonical.testing import (34from canonical.testing import (
34 DatabaseFunctionalLayer,35 DatabaseFunctionalLayer,
@@ -100,16 +101,16 @@
100 ReclaimBranchSpaceJob,101 ReclaimBranchSpaceJob,
101 )102 )
102from lp.code.model.branchmergeproposal import BranchMergeProposal103from lp.code.model.branchmergeproposal import BranchMergeProposal
104from lp.code.model.branchrevision import BranchRevision
103from lp.code.model.codeimport import (105from lp.code.model.codeimport import (
104 CodeImport,106 CodeImport,
105 CodeImportSet,107 CodeImportSet,
106 )108 )
107from lp.code.model.codereviewcomment import CodeReviewComment109from lp.code.model.codereviewcomment import CodeReviewComment
110from lp.code.model.revision import Revision
108from lp.code.tests.helpers import add_revision_to_branch111from lp.code.tests.helpers import add_revision_to_branch
109from lp.codehosting.bzrutils import UnsafeUrlSeen112from lp.codehosting.bzrutils import UnsafeUrlSeen
110from lp.registry.interfaces.person import IPersonSet
111from lp.registry.interfaces.pocket import PackagePublishingPocket113from lp.registry.interfaces.pocket import PackagePublishingPocket
112from lp.registry.model.product import ProductSet
113from lp.registry.model.sourcepackage import SourcePackage114from lp.registry.model.sourcepackage import SourcePackage
114from lp.services.osutils import override_environ115from lp.services.osutils import override_environ
115from lp.testing import (116from lp.testing import (
@@ -252,6 +253,59 @@
252 branch.repository_format))253 branch.repository_format))
253254
254255
256class TestBranchRevisionMethods(TestCaseWithFactory):
257 """Test the branch methods for adding and removing branch revisions."""
258
259 layer = DatabaseFunctionalLayer
260
261 def _getBranchRevision(self, branch, rev_id):
262 """Get the branch revision for the specified branch and rev_id."""
263 resultset = IStore(BranchRevision).find(
264 BranchRevision,
265 BranchRevision.branch == branch,
266 BranchRevision.revision == Revision.id,
267 Revision.revision_id == rev_id)
268 return resultset.one()
269
270 def test_createBranchRevision(self):
271 # createBranchRevision adds the link for the revision to the branch.
272 branch = self.factory.makeBranch()
273 rev = self.factory.makeRevision()
274 # Nothing there to start with.
275 self.assertIs(None, self._getBranchRevision(branch, rev.revision_id))
276 branch.createBranchRevision(1, rev)
277 # Now there is one.
278 br = self._getBranchRevision(branch, rev.revision_id)
279 self.assertEqual(branch, br.branch)
280 self.assertEqual(rev, br.revision)
281
282 def test_removeBranchRevisions(self):
283 # removeBranchRevisions can remove a single linked revision.
284 branch = self.factory.makeBranch()
285 rev = self.factory.makeRevision()
286 branch.createBranchRevision(1, rev)
287 # Now remove the branch revision.
288 branch.removeBranchRevisions(rev.revision_id)
289 # Revision not there now.
290 self.assertIs(None, self._getBranchRevision(branch, rev.revision_id))
291
292 def test_removeBranchRevisions_multiple(self):
293 # removeBranchRevisions can remove multiple revision links at once.
294 branch = self.factory.makeBranch()
295 rev1 = self.factory.makeRevision()
296 rev2 = self.factory.makeRevision()
297 rev3 = self.factory.makeRevision()
298 branch.createBranchRevision(1, rev1)
299 branch.createBranchRevision(2, rev2)
300 branch.createBranchRevision(3, rev3)
301 # Now remove the branch revision.
302 branch.removeBranchRevisions(
303 [rev1.revision_id, rev2.revision_id, rev3.revision_id])
304 # No mainline revisions there now.
305 # The revision_history attribute is tested above.
306 self.assertEqual([], list(branch.revision_history))
307
308
255class TestBranchGetRevision(TestCaseWithFactory):309class TestBranchGetRevision(TestCaseWithFactory):
256 """Make sure that `Branch.getBranchRevision` works as expected."""310 """Make sure that `Branch.getBranchRevision` works as expected."""
257311
258312
=== modified file 'lib/lp/codehosting/scanner/bzrsync.py'
--- lib/lp/codehosting/scanner/bzrsync.py 2010-08-20 20:31:18 +0000
+++ lib/lp/codehosting/scanner/bzrsync.py 2010-09-09 20:24:49 +0000
@@ -21,8 +21,9 @@
21from zope.component import getUtility21from zope.component import getUtility
22from zope.event import notify22from zope.event import notify
2323
24from canonical.config import config
25
24from lp.code.interfaces.branchjob import IRosettaUploadJobSource26from lp.code.interfaces.branchjob import IRosettaUploadJobSource
25from lp.code.interfaces.branchrevision import IBranchRevisionSet
26from lp.code.interfaces.revision import IRevisionSet27from lp.code.interfaces.revision import IRevisionSet
27from lp.codehosting import iter_list_chunks28from lp.codehosting import iter_list_chunks
28from lp.codehosting.scanner import events29from lp.codehosting.scanner import events
@@ -82,13 +83,11 @@
82 # written to by the branch-scanner, so they are not subject to83 # written to by the branch-scanner, so they are not subject to
83 # write-lock contention. Update them all in a single transaction to84 # write-lock contention. Update them all in a single transaction to
84 # improve the performance and allow garbage collection in the future.85 # improve the performance and allow garbage collection in the future.
85 db_ancestry, db_history, db_branch_revision_map = (86 db_ancestry, db_history = self.retrieveDatabaseAncestry()
86 self.retrieveDatabaseAncestry())
8787
88 (added_ancestry, branchrevisions_to_delete,88 (added_ancestry, branchrevisions_to_delete,
89 revids_to_insert) = self.planDatabaseChanges(89 revids_to_insert) = self.planDatabaseChanges(
90 bzr_branch, bzr_ancestry, bzr_history, db_ancestry, db_history,90 bzr_branch, bzr_ancestry, bzr_history, db_ancestry, db_history)
91 db_branch_revision_map)
92 added_ancestry.difference_update(91 added_ancestry.difference_update(
93 getUtility(IRevisionSet).onlyPresent(added_ancestry))92 getUtility(IRevisionSet).onlyPresent(added_ancestry))
94 self.logger.info("Adding %s new revisions.", len(added_ancestry))93 self.logger.info("Adding %s new revisions.", len(added_ancestry))
@@ -129,9 +128,8 @@
129 def retrieveDatabaseAncestry(self):128 def retrieveDatabaseAncestry(self):
130 """Efficiently retrieve ancestry from the database."""129 """Efficiently retrieve ancestry from the database."""
131 self.logger.info("Retrieving ancestry from database.")130 self.logger.info("Retrieving ancestry from database.")
132 db_ancestry, db_history, db_branch_revision_map = (131 db_ancestry, db_history = self.db_branch.getScannerData()
133 self.db_branch.getScannerData())132 return db_ancestry, db_history
134 return db_ancestry, db_history, db_branch_revision_map
135133
136 def retrieveBranchDetails(self, bzr_branch):134 def retrieveBranchDetails(self, bzr_branch):
137 """Retrieve ancestry from the the bzr branch on disk."""135 """Retrieve ancestry from the the bzr branch on disk."""
@@ -147,7 +145,7 @@
147 return bzr_ancestry, bzr_history145 return bzr_ancestry, bzr_history
148146
149 def planDatabaseChanges(self, bzr_branch, bzr_ancestry, bzr_history,147 def planDatabaseChanges(self, bzr_branch, bzr_ancestry, bzr_history,
150 db_ancestry, db_history, db_branch_revision_map):148 db_ancestry, db_history):
151 """Plan database changes to synchronize with bzrlib data.149 """Plan database changes to synchronize with bzrlib data.
152150
153 Use the data retrieved by `retrieveDatabaseAncestry` and151 Use the data retrieved by `retrieveDatabaseAncestry` and
@@ -190,9 +188,8 @@
190188
191 # We must delete BranchRevision rows for all revisions which where189 # We must delete BranchRevision rows for all revisions which where
192 # removed from the ancestry or whose sequence value has changed.190 # removed from the ancestry or whose sequence value has changed.
193 branchrevisions_to_delete = set(191 branchrevisions_to_delete = list(
194 db_branch_revision_map[revid]192 removed_merged.union(removed_history))
195 for revid in removed_merged.union(removed_history))
196193
197 # We must insert BranchRevision rows for all revisions which were194 # We must insert BranchRevision rows for all revisions which were
198 # added to the ancestry or whose sequence value has changed.195 # added to the ancestry or whose sequence value has changed.
@@ -244,13 +241,19 @@
244 for revision_id in revision_subset.difference(set(bzr_history)):241 for revision_id in revision_subset.difference(set(bzr_history)):
245 yield revision_id, None242 yield revision_id, None
246243
247 def deleteBranchRevisions(self, branchrevisions_to_delete):244 def deleteBranchRevisions(self, revision_ids_to_delete):
248 """Delete a batch of BranchRevision rows."""245 """Delete a batch of BranchRevision rows."""
249 self.logger.info("Deleting %d branchrevision records.",246 self.logger.info("Deleting %d branchrevision records.",
250 len(branchrevisions_to_delete))247 len(revision_ids_to_delete))
251 branch_revision_set = getUtility(IBranchRevisionSet)248 # Use a config value to work out how many to delete at a time.
252 for branchrevision in sorted(branchrevisions_to_delete):249 # Deleting more than one at a time is significantly more efficient
253 branch_revision_set.delete(branchrevision)250 # than doing one at a time, but the actual optimal count is a bit up
251 # in the air.
252 batch_size = config.branchscanner.branch_revision_delete_count
253 while revision_ids_to_delete:
254 batch = revision_ids_to_delete[:batch_size]
255 revision_ids_to_delete[:batch_size] = []
256 self.db_branch.removeBranchRevisions(batch)
254257
255 def insertBranchRevisions(self, bzr_branch, revids_to_insert):258 def insertBranchRevisions(self, bzr_branch, revids_to_insert):
256 """Insert a batch of BranchRevision rows."""259 """Insert a batch of BranchRevision rows."""
257260
=== modified file 'lib/lp/codehosting/scanner/tests/test_bzrsync.py'
--- lib/lp/codehosting/scanner/tests/test_bzrsync.py 2010-08-20 20:31:18 +0000
+++ lib/lp/codehosting/scanner/tests/test_bzrsync.py 2010-09-09 20:24:49 +0000
@@ -490,18 +490,14 @@
490 expected_history = [branch_revision.revision.revision_id490 expected_history = [branch_revision.revision.revision_id
491 for branch_revision in sampledata491 for branch_revision in sampledata
492 if branch_revision.sequence is not None]492 if branch_revision.sequence is not None]
493 expected_mapping = dict(
494 (branch_revision.revision.revision_id, branch_revision.id)
495 for branch_revision in sampledata)
496493
497 self.create_branch_and_tree(db_branch=branch)494 self.create_branch_and_tree(db_branch=branch)
498495
499 bzrsync = self.makeBzrSync(branch)496 bzrsync = self.makeBzrSync(branch)
500 db_ancestry, db_history, db_branch_revision_map = (497 db_ancestry, db_history = (
501 bzrsync.retrieveDatabaseAncestry())498 bzrsync.retrieveDatabaseAncestry())
502 self.assertEqual(expected_ancestry, set(db_ancestry))499 self.assertEqual(expected_ancestry, set(db_ancestry))
503 self.assertEqual(expected_history, list(db_history))500 self.assertEqual(expected_history, list(db_history))
504 self.assertEqual(expected_mapping, db_branch_revision_map)
505501
506502
507class TestBzrSyncOneRevision(BzrSyncTestCase):503class TestBzrSyncOneRevision(BzrSyncTestCase):