launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04230
[Merge] lp:~stevenk/launchpad/db-remove-incremental-diff into lp:launchpad/db-devel
Steve Kowalik has proposed merging lp:~stevenk/launchpad/db-remove-incremental-diff into lp:launchpad/db-devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/db-remove-incremental-diff/+merge/67423
This branch removes the unused feature that supported showing inline diffs in a merge proposal, since it has been superseded by the work to pull the diffs from loggerhead.
--
https://code.launchpad.net/~stevenk/launchpad/db-remove-incremental-diff/+merge/67423
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/db-remove-incremental-diff into lp:launchpad/db-devel.
=== modified file 'database/schema/comments.sql'
--- database/schema/comments.sql 2011-07-08 17:12:15 +0000
+++ database/schema/comments.sql 2011-07-09 14:07:42 +0000
@@ -2436,14 +2436,6 @@
COMMENT ON COLUMN HWDMIValue.value IS 'The value';
COMMENT ON COLUMN HWDMIValue.handle IS 'The handle to which this key/value pair belongs.';
--- IncrementalDiff
-COMMENT ON TABLE IncrementalDiff IS 'Incremental diffs for merge proposals.';
-COMMENT ON COLUMN IncrementalDiff.diff IS 'The contents of the diff.';
-COMMENT ON COLUMN IncrementalDiff.branch_merge_proposal IS 'The merge proposal the diff is for.';
-COMMENT ON COLUMN IncrementalDiff.old_revision IS 'The revision the diff is from.';
-COMMENT ON COLUMN IncrementalDiff.new_revision IS 'The revision the diff is to.';
-
-
-- Job
COMMENT ON TABLE Job IS 'Common info about a job.';
=== added file 'database/schema/patch-2208-99-0.sql'
--- database/schema/patch-2208-99-0.sql 1970-01-01 00:00:00 +0000
+++ database/schema/patch-2208-99-0.sql 2011-07-09 14:07:42 +0000
@@ -0,0 +1,8 @@
+-- Copyright 2011 Canonical Ltd. This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+SET client_min_messages=ERROR;
+
+DROP TABLE IncrementalDiff;
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 99, 0);
+
=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
--- lib/lp/code/browser/branchmergeproposal.py 2011-07-04 15:48:18 +0000
+++ lib/lp/code/browser/branchmergeproposal.py 2011-07-09 14:07:42 +0000
@@ -115,7 +115,6 @@
IComment,
IConversation,
)
-from lp.services.features import getFeatureFlag
from lp.services.fields import (
Summary,
Whiteboard,
@@ -559,14 +558,13 @@
"""
implements(ICodeReviewNewRevisions)
- def __init__(self, revisions, date, branch, diff):
+ def __init__(self, revisions, date, branch):
self.revisions = revisions
self.branch = branch
self.has_body = False
self.has_footer = True
# The date attribute is used to sort the comments in the conversation.
self.date = date
- self.diff = diff
# Other standard IComment attributes are not used.
self.extra_css_class = None
@@ -617,21 +615,10 @@
"""Return a conversation that is to be rendered."""
# Sort the comments by date order.
merge_proposal = self.context
- groups = list(merge_proposal.getRevisionsSinceReviewStart())
+ groups = merge_proposal.getRevisionsSinceReviewStart()
source = DecoratedBranch(merge_proposal.source_branch)
- comments = []
- if getFeatureFlag('code.incremental_diffs.enabled'):
- ranges = [
- (revisions[0].revision.getLefthandParent(),
- revisions[-1].revision)
- for revisions in groups]
- diffs = merge_proposal.getIncrementalDiffs(ranges)
- else:
- diffs = [None] * len(groups)
- for revisions, diff in zip(groups, diffs):
- newrevs = CodeReviewNewRevisions(
- revisions, revisions[-1].revision.date_created, source, diff)
- comments.append(newrevs)
+ comments = [CodeReviewNewRevisions(list(revisions), date, source)
+ for date, revisions in groups]
while merge_proposal is not None:
from_superseded = merge_proposal != self.context
comments.extend(
=== modified file 'lib/lp/code/browser/tests/test_branchmergeproposal.py'
--- lib/lp/code/browser/tests/test_branchmergeproposal.py 2011-06-24 17:47:52 +0000
+++ lib/lp/code/browser/tests/test_branchmergeproposal.py 2011-07-09 14:07:42 +0000
@@ -3,8 +3,6 @@
# pylint: disable-msg=F0401
-from __future__ import with_statement
-
"""Unit tests for BranchMergeProposals."""
__metaclass__ = type
@@ -65,9 +63,7 @@
)
from lp.testing import (
BrowserTestCase,
- feature_flags,
login_person,
- set_feature_flag,
person_logged_in,
TestCaseWithFactory,
time_counter,
@@ -771,40 +767,6 @@
view = create_initialized_view(self.bmp, '+index')
self.assertEqual([bug.default_bugtask], view.linked_bugtasks)
- def makeRevisionGroups(self):
- review_date = datetime(2009, 9, 10, tzinfo=pytz.UTC)
- bmp = self.factory.makeBranchMergeProposal(
- date_created=review_date)
- first_commit = datetime(2009, 9, 9, tzinfo=pytz.UTC)
- add_revision_to_branch(
- self.factory, bmp.source_branch, first_commit)
- login_person(bmp.registrant)
- bmp.requestReview(review_date)
- revision_date = review_date + timedelta(days=1)
- revisions = []
- for date in range(2):
- revisions.append(
- add_revision_to_branch(
- self.factory, bmp.source_branch, revision_date))
- revisions.append(
- add_revision_to_branch(
- self.factory, bmp.source_branch, revision_date))
- revision_date += timedelta(days=1)
- return bmp, revisions
-
- def test_getRevisionsIncludesIncrementalDiffs(self):
- bmp, revisions = self.makeRevisionGroups()
- diff = self.factory.makeIncrementalDiff(merge_proposal=bmp,
- old_revision=revisions[1].revision.getLefthandParent(),
- new_revision=revisions[3].revision)
- self.useContext(feature_flags())
- set_feature_flag(u'code.incremental_diffs.enabled', u'enabled')
- view = create_initialized_view(bmp, '+index')
- comments = view.conversation.comments
- self.assertEqual(
- [diff],
- [comment.diff for comment in comments])
-
def test_CodeReviewNewRevisions_implements_ICodeReviewNewRevisions(self):
# The browser helper class implements its interface.
review_date = datetime(2009, 9, 10, tzinfo=pytz.UTC)
@@ -1018,27 +980,6 @@
self.assertEqual('Eric on 2008-09-10', view.status_title)
-class TestBranchMergeProposal(BrowserTestCase):
-
- layer = LaunchpadFunctionalLayer
-
- def test_conversation(self):
- source_branch = self.factory.makeBranch()
- parent = add_revision_to_branch(self.factory, source_branch,
- self.factory.getUniqueDate()).revision
- bmp = self.factory.makeBranchMergeProposal(registrant=self.user,
- date_created=self.factory.getUniqueDate(),
- source_branch=source_branch)
- revision = add_revision_to_branch(self.factory, bmp.source_branch,
- self.factory.getUniqueDate()).revision
- diff = self.factory.makeDiff()
- bmp.generateIncrementalDiff(parent, revision, diff)
- self.useContext(feature_flags())
- set_feature_flag(u'code.incremental_diffs.enabled', u'enabled')
- browser = self.getViewBrowser(bmp)
- assert 'unf_pbasyvpgf' in browser.contents
-
-
class TestLatestProposalsForEachBranch(TestCaseWithFactory):
"""Confirm that the latest branch is returned."""
=== modified file 'lib/lp/code/configure.zcml'
--- lib/lp/code/configure.zcml 2011-06-20 18:58:27 +0000
+++ lib/lp/code/configure.zcml 2011-07-09 14:07:42 +0000
@@ -248,7 +248,6 @@
review_diff
next_preview_diff_job
preview_diff
- getIncrementalDiffs
votes
all_comments
getRelatedBugTasks
@@ -261,8 +260,7 @@
isValidTransition
getUnlandedSourceBranchRevisions
root_message_id
- getUsersVoteReference
- generateIncrementalDiff"/>
+ getUsersVoteReference"/>
<allow interface="lp.code.interfaces.branchtarget.IHasBranchTarget"/>
<require
permission="launchpad.Edit"
@@ -316,11 +314,6 @@
<allow interface="lp.code.interfaces.branchmergeproposal.IBranchMergeProposalJobSource"/>
</securedutility>
- <class
- class="lp.code.model.branchmergeproposaljob.GenerateIncrementalDiffJob">
- <allow interface="lp.code.interfaces.branchmergeproposal.IGenerateIncrementalDiffJob"/>
- <allow interface="lp.code.interfaces.branchmergeproposal.IBranchMergeProposalJob" />
- </class>
<class class="lp.code.model.branchmergeproposaljob.UpdatePreviewDiffJob">
<allow interface="lp.code.interfaces.branchmergeproposal.IUpdatePreviewDiffJob" />
<allow interface="lp.code.interfaces.branchmergeproposal.IBranchMergeProposalJob" />
@@ -885,10 +878,6 @@
<class class="lp.code.model.diff.Diff">
<allow interface="lp.code.interfaces.diff.IDiff" />
</class>
- <class class="lp.code.model.diff.IncrementalDiff">
- <allow interface="lp.code.interfaces.diff.IDiff" />
- <allow interface="lp.code.interfaces.diff.IIncrementalDiff" />
- </class>
<class class="lp.code.model.diff.StaticDiff">
<allow interface="lp.code.interfaces.diff.IStaticDiff" />
</class>
=== modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
--- lib/lp/code/interfaces/branchmergeproposal.py 2011-03-23 16:28:51 +0000
+++ lib/lp/code/interfaces/branchmergeproposal.py 2011-07-09 14:07:42 +0000
@@ -17,8 +17,6 @@
'ICodeReviewCommentEmailJobSource',
'ICreateMergeProposalJob',
'ICreateMergeProposalJobSource',
- 'IGenerateIncrementalDiffJob',
- 'IGenerateIncrementalDiffJobSource',
'IMergeProposalNeedsReviewEmailJob',
'IMergeProposalNeedsReviewEmailJobSource',
'IMergeProposalUpdatedEmailJob',
@@ -576,10 +574,6 @@
"""A job source that will get all supported merge proposal jobs."""
-class IBranchMergeProposalJobSource(IJobSource):
- """A job source that will get all supported merge proposal jobs."""
-
-
class IBranchMergeProposalListingBatchNavigator(ITableBatchNavigator):
"""A marker interface for registering the appropriate listings."""
@@ -685,20 +679,6 @@
"""Return the UpdatePreviewDiffJob with this id."""
-class IGenerateIncrementalDiffJob(IRunnableJob):
- """Interface for the job to update the diff for a merge proposal."""
-
-
-class IGenerateIncrementalDiffJobSource(Interface):
- """Create or retrieve jobs that update preview diffs."""
-
- def create(bmp, old_revision_id, new_revision_id):
- """Create job to generate incremental diff for this merge proposal."""
-
- def get(id):
- """Return the GenerateIncrementalDiffJob with this id."""
-
-
class ICodeReviewCommentEmailJob(IRunnableJob):
"""Interface for the job to send code review comment email."""
=== modified file 'lib/lp/code/interfaces/diff.py'
--- lib/lp/code/interfaces/diff.py 2011-01-31 17:08:35 +0000
+++ lib/lp/code/interfaces/diff.py 2011-07-09 14:07:42 +0000
@@ -9,7 +9,6 @@
__all__ = [
'IDiff',
- 'IIncrementalDiff',
'IPreviewDiff',
'IStaticDiff',
'IStaticDiffSource',
@@ -30,7 +29,6 @@
)
from canonical.launchpad import _
-from lp.code.interfaces.revision import IRevision
class IDiff(Interface):
@@ -64,23 +62,6 @@
readonly=True))
-class IIncrementalDiff(Interface):
- """An incremental diff for a merge proposal."""
-
- diff = Reference(IDiff, title=_('The Diff object.'), readonly=True)
-
- # The schema for the Reference gets patched in _schema_circular_imports.
- branch_merge_proposal = Reference(
- Interface, readonly=True,
- title=_('The branch merge proposal that diff relates to.'))
-
- old_revision = Reference(
- IRevision, readonly=True, title=_('The old revision of the diff.'))
-
- new_revision = Reference(
- IRevision, readonly=True, title=_('The new revision of the diff.'))
-
-
class IStaticDiff(Interface):
"""A diff with a fixed value, i.e. between two revisions."""
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2011-06-24 18:08:18 +0000
+++ lib/lp/code/model/branch.py 2011-07-09 14:07:42 +0000
@@ -481,18 +481,10 @@
def scheduleDiffUpdates(self):
"""See `IBranch`."""
- from lp.code.model.branchmergeproposaljob import (
- GenerateIncrementalDiffJob,
- UpdatePreviewDiffJob,
- )
- jobs = []
- for merge_proposal in self.active_landing_targets:
- if merge_proposal.target_branch.last_scanned_id is None:
- continue
- jobs.append(UpdatePreviewDiffJob.create(merge_proposal))
- for old, new in merge_proposal.getMissingIncrementalDiffs():
- GenerateIncrementalDiffJob.create(
- merge_proposal, old.revision_id, new.revision_id)
+ from lp.code.model.branchmergeproposaljob import UpdatePreviewDiffJob
+ jobs = [UpdatePreviewDiffJob.create(target)
+ for target in self.active_landing_targets
+ if target.target_branch.last_scanned_id is not None]
return jobs
def addToLaunchBag(self, launchbag):
=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py 2011-06-24 15:54:12 +0000
+++ lib/lp/code/model/branchmergeproposal.py 2011-07-09 14:07:42 +0000
@@ -13,7 +13,7 @@
]
from email.Utils import make_msgid
-
+from itertools import groupby
from sqlobject import (
ForeignKey,
IntCol,
@@ -50,7 +50,6 @@
SQLBase,
sqlvalues,
)
-from canonical.launchpad.interfaces.lpstorm import IMasterStore
from lp.code.enums import (
BranchMergeProposalStatus,
CodeReviewVote,
@@ -75,17 +74,12 @@
IBranchMergeProposal,
IBranchMergeProposalGetter,
)
-from lp.code.interfaces.branchrevision import IBranchRevision
from lp.code.interfaces.branchtarget import IHasBranchTarget
from lp.code.mail.branch import RecipientReason
from lp.code.model.branchrevision import BranchRevision
from lp.code.model.codereviewcomment import CodeReviewComment
from lp.code.model.codereviewvote import CodeReviewVoteReference
-from lp.code.model.diff import (
- Diff,
- IncrementalDiff,
- PreviewDiff,
- )
+from lp.code.model.diff import PreviewDiff
from lp.registry.interfaces.person import (
IPerson,
validate_public_person,
@@ -810,51 +804,6 @@
Store.of(self).flush()
return self.preview_diff
- def getIncrementalDiffRanges(self):
- groups = self.getRevisionsSinceReviewStart()
- return [
- (group[0].revision.getLefthandParent(), group[-1].revision)
- for group in groups]
-
- def generateIncrementalDiff(self, old_revision, new_revision, diff=None):
- """Generate an incremental diff for the merge proposal.
-
- :param old_revision: The `Revision` to generate the diff from.
- :param new_revision: The `Revision` to generate the diff to.
- :param diff: If supplied, a pregenerated `Diff`.
- """
- if diff is None:
- source_branch = self.source_branch.getBzrBranch()
- ignore_branches = [self.target_branch.getBzrBranch()]
- if self.prerequisite_branch is not None:
- ignore_branches.append(
- self.prerequisite_branch.getBzrBranch())
- diff = Diff.generateIncrementalDiff(
- old_revision, new_revision, source_branch, ignore_branches)
- incremental_diff = IncrementalDiff()
- incremental_diff.diff = diff
- incremental_diff.branch_merge_proposal = self
- incremental_diff.old_revision = old_revision
- incremental_diff.new_revision = new_revision
- IMasterStore(IncrementalDiff).add(incremental_diff)
- return incremental_diff
-
- def getIncrementalDiffs(self, revision_list):
- """Return a list of diffs for the specified revisions.
-
- :param revision_list: A list of tuples of (`Revision`, `Revision`).
- The first revision in the tuple is the old revision. The second
- is the new revision.
- :return: A list of IncrementalDiffs in the same order as the supplied
- Revisions.
- """
- diffs = Store.of(self).find(IncrementalDiff,
- IncrementalDiff.branch_merge_proposal_id == self.id)
- diff_dict = dict(
- ((diff.old_revision, diff.new_revision), diff)
- for diff in diffs)
- return [diff_dict.get(revisions) for revisions in revision_list]
-
@property
def revision_end_date(self):
"""The cutoff date for showing revisions.
@@ -881,30 +830,12 @@
def getRevisionsSinceReviewStart(self):
"""Get the grouped revisions since the review started."""
- entries = [
- ((comment.date_created, -1), comment) for comment
- in self.all_comments]
- revisions = self._getNewerRevisions()
- entries.extend(
- ((revision.date_created, branch_revision.sequence),
- branch_revision)
- for branch_revision, revision in revisions)
- entries.sort()
- current_group = []
- for sortkey, entry in entries:
- if IBranchRevision.providedBy(entry):
- current_group.append(entry)
- else:
- if current_group != []:
- yield current_group
- current_group = []
- if current_group != []:
- yield current_group
-
- def getMissingIncrementalDiffs(self):
- ranges = self.getIncrementalDiffRanges()
- diffs = self.getIncrementalDiffs(ranges)
- return [range_ for range_, diff in zip(ranges, diffs) if diff is None]
+ resultset = self._getNewerRevisions()
+ # Work out the start of the review.
+ branch_revisions = (
+ branch_revision for branch_revision, revision in resultset)
+ # Now group by date created.
+ return groupby(branch_revisions, lambda r: r.revision.date_created)
class BranchMergeProposalGetter:
=== modified file 'lib/lp/code/model/branchmergeproposaljob.py'
--- lib/lp/code/model/branchmergeproposaljob.py 2011-07-04 15:48:18 +0000
+++ lib/lp/code/model/branchmergeproposaljob.py 2011-07-09 14:07:42 +0000
@@ -18,8 +18,6 @@
'BranchMergeProposalJobSource',
'BranchMergeProposalJobType',
'CodeReviewCommentEmailJob',
- 'CreateMergeProposalJob',
- 'GenerateIncrementalDiffJob',
'MergeProposalNeedsReviewEmailJob',
'MergeProposalUpdatedEmailJob',
'ReviewRequestedEmailJob',
@@ -83,8 +81,6 @@
ICodeReviewCommentEmailJobSource,
ICreateMergeProposalJob,
ICreateMergeProposalJobSource,
- IGenerateIncrementalDiffJob,
- IGenerateIncrementalDiffJobSource,
IMergeProposalNeedsReviewEmailJob,
IMergeProposalNeedsReviewEmailJobSource,
IMergeProposalUpdatedEmailJob,
@@ -94,7 +90,6 @@
IUpdatePreviewDiffJob,
IUpdatePreviewDiffJobSource,
)
-from lp.code.interfaces.revision import IRevisionSet
from lp.code.mail.branch import RecipientReason
from lp.code.mail.branchmergeproposal import BMPMailer
from lp.code.mail.codereviewcomment import CodeReviewCommentMailer
@@ -151,11 +146,6 @@
that have been changed on the merge proposal itself.
""")
- GENERATE_INCREMENTAL_DIFF = DBItem(5, """
- Generate incremental diff
-
- This job generates an incremental diff for a merge proposal.""")
-
class BranchMergeProposalJob(StormBase):
"""Base class for jobs related to branch merge proposals."""
@@ -612,7 +602,7 @@
def getMetadata(delta_text, editor):
metadata = {'delta_text': delta_text}
if editor is not None:
- metadata['editor'] = editor.name
+ metadata['editor'] = editor.name;
return metadata
@property
@@ -649,70 +639,6 @@
return 'emailing subscribers about merge proposal changes'
-class GenerateIncrementalDiffJob(BranchMergeProposalJobDerived):
- """A job to generate an incremental diff for a branch merge proposal.
-
- Provides class methods to create and retrieve such jobs.
- """
-
- implements(IGenerateIncrementalDiffJob)
-
- classProvides(IGenerateIncrementalDiffJobSource)
-
- class_job_type = BranchMergeProposalJobType.GENERATE_INCREMENTAL_DIFF
-
- def acquireLease(self, duration=600):
- return self.job.acquireLease(duration)
-
- def run(self):
- revision_set = getUtility(IRevisionSet)
- old_revision = revision_set.getByRevisionId(self.old_revision_id)
- new_revision = revision_set.getByRevisionId(self.new_revision_id)
- self.branch_merge_proposal.generateIncrementalDiff(
- old_revision, new_revision)
-
- @classmethod
- def create(cls, merge_proposal, old_revision_id, new_revision_id):
- metadata = cls.getMetadata(old_revision_id, new_revision_id)
- job = BranchMergeProposalJob(
- merge_proposal, cls.class_job_type, metadata)
- return cls(job)
-
- @staticmethod
- def getMetadata(old_revision_id, new_revision_id):
- return {
- 'old_revision_id': old_revision_id,
- 'new_revision_id': new_revision_id,
- }
-
- @property
- def old_revision_id(self):
- """The old revision id for the diff."""
- return self.metadata['old_revision_id']
-
- @property
- def new_revision_id(self):
- """The new revision id for the diff."""
- return self.metadata['new_revision_id']
-
- def getOopsVars(self):
- """See `IRunnableJob`."""
- vars = BranchMergeProposalJobDerived.getOopsVars(self)
- vars.extend([
- ('old_revision_id', self.metadata['old_revision_id']),
- ('new_revision_id', self.metadata['new_revision_id']),
- ])
- return vars
-
- def getOperationDescription(self):
- return ('generating an incremental diff for a merge proposal')
-
- def getErrorRecipients(self):
- """Return a list of email-ids to notify about user errors."""
- registrant = self.branch_merge_proposal.registrant
- return format_address_for_person(registrant)
-
-
class BranchMergeProposalJobFactory:
"""Construct a derived merge proposal job for a BranchMergeProposalJob."""
@@ -727,8 +653,6 @@
ReviewRequestedEmailJob,
BranchMergeProposalJobType.MERGE_PROPOSAL_UPDATED:
MergeProposalUpdatedEmailJob,
- BranchMergeProposalJobType.GENERATE_INCREMENTAL_DIFF:
- GenerateIncrementalDiffJob,
}
@classmethod
@@ -769,24 +693,21 @@
return BranchMergeProposalJobFactory.create(job)
@staticmethod
- def iterReady(job_type=None):
+ def iterReady():
from lp.code.model.branch import Branch
store = getUtility(IStoreSelector).get(MAIN_STORE, MASTER_FLAVOR)
SourceBranch = ClassAlias(Branch)
TargetBranch = ClassAlias(Branch)
- clauses = [
- BranchMergeProposalJob.job == Job.id,
- Job._status.is_in([JobStatus.WAITING, JobStatus.RUNNING]),
- BranchMergeProposalJob.branch_merge_proposal ==
- BranchMergeProposal.id, BranchMergeProposal.source_branch ==
- SourceBranch.id, BranchMergeProposal.target_branch ==
- TargetBranch.id,
- ]
- if job_type is not None:
- clauses.append(BranchMergeProposalJob.job_type == job_type)
jobs = store.find(
(BranchMergeProposalJob, Job, BranchMergeProposal,
- SourceBranch, TargetBranch), And(*clauses))
+ SourceBranch, TargetBranch),
+ And(BranchMergeProposalJob.job == Job.id,
+ Job._status.is_in([JobStatus.WAITING, JobStatus.RUNNING]),
+ BranchMergeProposalJob.branch_merge_proposal
+ == BranchMergeProposal.id,
+ BranchMergeProposal.source_branch == SourceBranch.id,
+ BranchMergeProposal.target_branch == TargetBranch.id,
+ ))
# Order by the job status first (to get running before waiting), then
# the date_created, then job type. This should give us all creation
# jobs before comment jobs.
=== modified file 'lib/lp/code/model/diff.py'
--- lib/lp/code/model/diff.py 2010-12-02 16:13:51 +0000
+++ lib/lp/code/model/diff.py 2011-07-09 14:07:42 +0000
@@ -4,9 +4,12 @@
"""Implementation classes for IDiff, etc."""
__metaclass__ = type
-__all__ = ['Diff', 'IncrementalDiff', 'PreviewDiff', 'StaticDiff']
+__all__ = [
+ 'Diff',
+ 'PreviewDiff',
+ 'StaticDiff'
+ ]
-from contextlib import nested
from cStringIO import StringIO
import sys
from uuid import uuid1
@@ -18,7 +21,6 @@
parse_patches,
Patch,
)
-from bzrlib.plugins.difftacular.generate_diff import diff_ignore_branches
from lazr.delegates import delegates
import simplejson
from sqlobject import (
@@ -45,12 +47,10 @@
from lp.app.errors import NotFoundError
from lp.code.interfaces.diff import (
IDiff,
- IIncrementalDiff,
IPreviewDiff,
IStaticDiff,
IStaticDiffSource,
)
-from lp.codehosting.bzrutils import read_locked
class Diff(SQLBase):
@@ -197,14 +197,9 @@
diff_content = StringIO()
show_diff_trees(from_tree, to_tree, diff_content, old_label='',
new_label='')
- return klass.fromFileAtEnd(diff_content, filename)
-
- @classmethod
- def fromFileAtEnd(cls, diff_content, filename=None):
- """Make a Diff from a file object that is currently at its end."""
size = diff_content.tell()
diff_content.seek(0)
- return cls.fromFile(diff_content, size, filename)
+ return klass.fromFile(diff_content, size, filename)
@classmethod
def fromFile(cls, diff_content, size, filename=None):
@@ -265,30 +260,6 @@
file_stats[path] = tuple(patch.stats_values()[:2])
return file_stats
- @classmethod
- def generateIncrementalDiff(cls, old_revision, new_revision,
- source_branch, ignore_branches):
- """Return a Diff whose contents are an incremental diff.
-
- The Diff's contents will show the changes made between old_revision
- and new_revision, except those changes introduced by the
- ignore_branches.
-
- :param old_revision: The `Revision` to show changes from.
- :param new_revision: The `Revision` to show changes to.
- :param source_branch: The bzr branch containing these revisions.
- :param ignore_brances: A collection of branches to ignore merges from.
- :return: a `Diff`.
- """
- diff_content = StringIO()
- read_locks = [read_locked(branch) for branch in [source_branch] +
- ignore_branches]
- with nested(*read_locks):
- diff_ignore_branches(
- source_branch, ignore_branches, old_revision.revision_id,
- new_revision.revision_id, diff_content)
- return cls.fromFileAtEnd(diff_content)
-
class StaticDiff(SQLBase):
"""A diff from one revision to another."""
@@ -337,36 +308,6 @@
diff.destroySelf()
-class IncrementalDiff(Storm):
- """See `IIncrementalDiff."""
-
- implements(IIncrementalDiff)
-
- delegates(IDiff, context='diff')
-
- __storm_table__ = 'IncrementalDiff'
-
- id = Int(primary=True, allow_none=False)
-
- diff_id = Int(name='diff', allow_none=False)
-
- diff = Reference(diff_id, 'Diff.id')
-
- branch_merge_proposal_id = Int(
- name='branch_merge_proposal', allow_none=False)
-
- branch_merge_proposal = Reference(
- branch_merge_proposal_id, "BranchMergeProposal.id")
-
- old_revision_id = Int(name='old_revision', allow_none=False)
-
- old_revision = Reference(old_revision_id, 'Revision.id')
-
- new_revision_id = Int(name='new_revision', allow_none=False)
-
- new_revision = Reference(new_revision_id, 'Revision.id')
-
-
class PreviewDiff(Storm):
"""See `IPreviewDiff`."""
implements(IPreviewDiff)
@@ -451,7 +392,6 @@
# A preview diff is stale if the revision ids used to make the diff
# are different from the tips of the source or target branches.
bmp = self.branch_merge_proposal
- is_stale = False
if (self.source_revision_id != bmp.source_branch.last_scanned_id or
self.target_revision_id != bmp.target_branch.last_scanned_id):
# This is the simple frequent case.
=== modified file 'lib/lp/code/model/tests/test_branchmergeproposal.py'
--- lib/lp/code/model/tests/test_branchmergeproposal.py 2011-06-24 19:51:18 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposal.py 2011-07-09 14:07:42 +0000
@@ -1884,7 +1884,8 @@
def assertRevisionGroups(self, bmp, expected_groups):
"""Get the groups for the merge proposal and check them."""
- revision_groups = list(bmp.getRevisionsSinceReviewStart())
+ groups = bmp.getRevisionsSinceReviewStart()
+ revision_groups = [list(revisions) for date, revisions in groups]
self.assertEqual(expected_groups, revision_groups)
def test_getRevisionsSinceReviewStart_no_revisions(self):
@@ -1899,8 +1900,8 @@
review_date = datetime(2009, 9, 10, tzinfo=UTC)
bmp = self.factory.makeBranchMergeProposal(
date_created=review_date)
- with person_logged_in(bmp.registrant):
- bmp.requestReview(review_date)
+ login_person(bmp.registrant)
+ bmp.requestReview(review_date)
revision_date = review_date + timedelta(days=1)
revisions = []
for date in range(2):
@@ -1912,76 +1913,9 @@
self.factory, bmp.source_branch, revision_date))
revision_date += timedelta(days=1)
expected_groups = [
- [revisions[0], revisions[1], revisions[2], revisions[3]]]
- self.assertRevisionGroups(bmp, expected_groups)
-
- def test_getRevisionsSinceReviewStart_groups_with_comments(self):
- # Revisions that were scanned at the same time have the same
- # date_created. These revisions are grouped together.
- bmp = self.factory.makeBranchMergeProposal(
- date_created=self.factory.getUniqueDate())
- revisions = []
- revisions.append(
- add_revision_to_branch(
- self.factory, bmp.source_branch,
- self.factory.getUniqueDate()))
- revisions.append(
- add_revision_to_branch(
- self.factory, bmp.source_branch,
- self.factory.getUniqueDate()))
- with person_logged_in(self.factory.makePerson()):
- self.factory.makeCodeReviewComment(
- merge_proposal=bmp,
- date_created=self.factory.getUniqueDate())
- revisions.append(
- add_revision_to_branch(
- self.factory, bmp.source_branch,
- self.factory.getUniqueDate()))
-
- expected_groups = [
- [revisions[0], revisions[1]], [revisions[2]]]
- self.assertRevisionGroups(bmp, expected_groups)
-
-
-class TestBranchMergeProposalGetIncrementalDiffs(TestCaseWithFactory):
-
- layer = LaunchpadFunctionalLayer
-
- def test_getIncrementalDiffs(self):
- """getIncrementalDiffs returns the requested values or None.
-
- None is returned if there is no IncrementalDiff for the requested
- revision pair and branch_merge_proposal.
- """
- bmp = self.factory.makeBranchMergeProposal()
- diff1 = self.factory.makeIncrementalDiff(merge_proposal=bmp)
- diff2 = self.factory.makeIncrementalDiff(merge_proposal=bmp)
- diff3 = self.factory.makeIncrementalDiff()
- result = bmp.getIncrementalDiffs([
- (diff1.old_revision, diff1.new_revision),
- (diff2.old_revision, diff2.new_revision),
- # Wrong merge proposal
- (diff3.old_revision, diff3.new_revision),
- # Mismatched revisions
- (diff1.old_revision, diff2.new_revision),
- ])
- self.assertEqual([diff1, diff2, None, None], result)
-
- def test_getIncrementalDiffs_respects_input_order(self):
- """The order of the output follows the input order."""
- bmp = self.factory.makeBranchMergeProposal()
- diff1 = self.factory.makeIncrementalDiff(merge_proposal=bmp)
- diff2 = self.factory.makeIncrementalDiff(merge_proposal=bmp)
- result = bmp.getIncrementalDiffs([
- (diff1.old_revision, diff1.new_revision),
- (diff2.old_revision, diff2.new_revision),
- ])
- self.assertEqual([diff1, diff2], result)
- result = bmp.getIncrementalDiffs([
- (diff2.old_revision, diff2.new_revision),
- (diff1.old_revision, diff1.new_revision),
- ])
- self.assertEqual([diff2, diff1], result)
+ [revisions[0], revisions[1]],
+ [revisions[2], revisions[3]]]
+ self.assertRevisionGroups(bmp, expected_groups)
class TestGetUnlandedSourceBranchRevisions(TestCaseWithFactory):
=== modified file 'lib/lp/code/model/tests/test_branchmergeproposaljobs.py'
--- lib/lp/code/model/tests/test_branchmergeproposaljobs.py 2010-12-02 16:13:51 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposaljobs.py 2011-07-09 14:07:42 +0000
@@ -32,8 +32,6 @@
IBranchMergeProposalJobSource,
ICodeReviewCommentEmailJob,
ICodeReviewCommentEmailJobSource,
- IGenerateIncrementalDiffJob,
- IGenerateIncrementalDiffJobSource,
IMergeProposalNeedsReviewEmailJob,
IMergeProposalUpdatedEmailJob,
IMergeProposalUpdatedEmailJobSource,
@@ -47,16 +45,12 @@
BranchMergeProposalJobDerived,
BranchMergeProposalJobType,
CodeReviewCommentEmailJob,
- GenerateIncrementalDiffJob,
MergeProposalNeedsReviewEmailJob,
MergeProposalUpdatedEmailJob,
ReviewRequestedEmailJob,
UpdatePreviewDiffJob,
)
-from lp.code.model.tests.test_diff import (
- create_example_merge,
- DiffTestCase,
- )
+from lp.code.model.tests.test_diff import DiffTestCase
from lp.code.subscribers.branchmergeproposal import merge_proposal_modified
from lp.services.job.model.job import Job
from lp.services.job.runner import JobRunner
@@ -198,7 +192,7 @@
def test_run(self):
self.useBzrBranches(direct_database=True)
- bmp = create_example_merge(self)[0]
+ bmp = self.createExampleMerge()[0]
job = UpdatePreviewDiffJob.create(bmp)
self.factory.makeRevisionsForBranch(bmp.source_branch, count=1)
bmp.source_branch.next_mirror_time = None
@@ -232,76 +226,13 @@
def test_10_minute_lease(self):
self.useBzrBranches(direct_database=True)
- bmp = create_example_merge(self)[0]
+ bmp = self.createExampleMerge()[0]
job = UpdatePreviewDiffJob.create(bmp)
job.acquireLease()
expiry_delta = job.lease_expires - datetime.now(pytz.UTC)
self.assertTrue(500 <= expiry_delta.seconds, expiry_delta)
-def make_runnable_incremental_diff_job(test_case):
- test_case.useBzrBranches(direct_database=True)
- bmp, source_rev_id, target_rev_id = create_example_merge(test_case)
- repository = bmp.source_branch.getBzrBranch().repository
- parent_id = repository.get_revision(source_rev_id).parent_ids[0]
- test_case.factory.makeRevision(rev_id=source_rev_id)
- test_case.factory.makeRevision(rev_id=parent_id)
- return GenerateIncrementalDiffJob.create(bmp, parent_id, source_rev_id)
-
-
-class TestGenerateIncrementalDiffJob(DiffTestCase):
-
- layer = LaunchpadZopelessLayer
-
- def test_implement_interface(self):
- """GenerateIncrementalDiffJob implements its interface."""
- verifyObject(
- IGenerateIncrementalDiffJobSource, GenerateIncrementalDiffJob)
-
- def test_providesInterface(self):
- """MergeProposalCreatedJob provides the expected interfaces."""
- bmp = self.factory.makeBranchMergeProposal()
- job = GenerateIncrementalDiffJob.create(bmp, 'old', 'new')
- verifyObject(IGenerateIncrementalDiffJob, job)
- verifyObject(IBranchMergeProposalJob, job)
-
- def test_getOperationDescription(self):
- """The description of the job is sane."""
- bmp = self.factory.makeBranchMergeProposal()
- job = GenerateIncrementalDiffJob.create(bmp, 'old', 'new')
- self.assertEqual(
- 'generating an incremental diff for a merge proposal',
- job.getOperationDescription())
-
- def test_run(self):
- """The job runs successfully, and its results can be committed."""
- job = make_runnable_incremental_diff_job(self)
- transaction.commit()
- self.layer.switchDbUser(config.merge_proposal_jobs.dbuser)
- job.run()
- transaction.commit()
-
- def test_run_all(self):
- """The job can be run under the JobRunner successfully."""
- job = make_runnable_incremental_diff_job(self)
- transaction.commit()
- self.layer.switchDbUser(config.merge_proposal_jobs.dbuser)
- runner = JobRunner([job])
- runner.runAll()
- self.assertEqual([job], runner.completed_jobs)
-
- def test_10_minute_lease(self):
- """Newly-created jobs have a ten-minute lease."""
- self.useBzrBranches(direct_database=True)
- bmp = create_example_merge(self)[0]
- job = GenerateIncrementalDiffJob.create(bmp, 'old', 'new')
- transaction.commit()
- self.layer.switchDbUser(config.merge_proposal_jobs.dbuser)
- job.acquireLease()
- expiry_delta = job.lease_expires - datetime.now(pytz.UTC)
- self.assertTrue(500 <= expiry_delta.seconds, expiry_delta)
-
-
class TestBranchMergeProposalJobSource(TestCaseWithFactory):
layer = LaunchpadZopelessLayer
=== modified file 'lib/lp/code/model/tests/test_diff.py'
--- lib/lp/code/model/tests/test_diff.py 2010-12-02 16:13:51 +0000
+++ lib/lp/code/model/tests/test_diff.py 2011-07-09 14:07:42 +0000
@@ -12,11 +12,6 @@
from unittest import TestLoader
from bzrlib import trace
-from bzrlib.patches import (
- InsertLine,
- parse_patches,
- RemoveLine,
- )
import transaction
from zope.security.proxy import removeSecurityProxy
@@ -29,7 +24,6 @@
from lp.app.errors import NotFoundError
from lp.code.interfaces.diff import (
IDiff,
- IIncrementalDiff,
IPreviewDiff,
IStaticDiff,
IStaticDiffSource,
@@ -58,41 +52,37 @@
self.records.append(record)
-def commit_file(branch, path, contents, merge_parents=None):
- """Create a commit that updates a file to specified contents.
-
- This will create or modify the file, as needed.
- """
- committer = DirectBranchCommit(
- removeSecurityProxy(branch), no_race_check=True,
- merge_parents=merge_parents)
- committer.writeFile(path, contents)
- try:
- return committer.commit('committing')
- finally:
- committer.unlock()
-
-
-def create_example_merge(test_case):
- """Create a merge proposal with conflicts and updates."""
- bmp = test_case.factory.makeBranchMergeProposal()
- # Make the branches of the merge proposal look good as far as the
- # model is concerned.
- test_case.factory.makeRevisionsForBranch(bmp.source_branch)
- test_case.factory.makeRevisionsForBranch(bmp.target_branch)
- bzr_target = test_case.createBzrBranch(bmp.target_branch)
- commit_file(bmp.target_branch, 'foo', 'a\n')
- test_case.createBzrBranch(bmp.source_branch, bzr_target)
- source_rev_id = commit_file(bmp.source_branch, 'foo', 'd\na\nb\n')
- target_rev_id = commit_file(bmp.target_branch, 'foo', 'c\na\n')
- return bmp, source_rev_id, target_rev_id
-
-
class DiffTestCase(TestCaseWithFactory):
+ @staticmethod
+ def commitFile(branch, path, contents, merge_parents=None):
+ """Create a commit that updates a file to specified contents.
+
+ This will create or modify the file, as needed.
+ """
+ committer = DirectBranchCommit(
+ removeSecurityProxy(branch), no_race_check=True,
+ merge_parents=merge_parents)
+ committer.writeFile(path, contents)
+ try:
+ return committer.commit('committing')
+ finally:
+ committer.unlock()
+
def createExampleMerge(self):
+ """Create a merge proposal with conflicts and updates."""
self.useBzrBranches(direct_database=True)
- return create_example_merge(self)
+ bmp = self.factory.makeBranchMergeProposal()
+ # Make the branches of the merge proposal look good as far as the
+ # model is concerned.
+ self.factory.makeRevisionsForBranch(bmp.source_branch)
+ self.factory.makeRevisionsForBranch(bmp.target_branch)
+ bzr_target = self.createBzrBranch(bmp.target_branch)
+ self.commitFile(bmp.target_branch, 'foo', 'a\n')
+ self.createBzrBranch(bmp.source_branch, bzr_target)
+ source_rev_id = self.commitFile(bmp.source_branch, 'foo', 'd\na\nb\n')
+ target_rev_id = self.commitFile(bmp.target_branch, 'foo', 'c\na\n')
+ return bmp, source_rev_id, target_rev_id
def checkExampleMerge(self, diff_text):
"""Ensure the diff text matches the values for ExampleMerge."""
@@ -119,12 +109,12 @@
source = bmp.source_branch
prerequisite = bmp.prerequisite_branch
target_bzr = self.createBzrBranch(target)
- commit_file(target, 'file', 'target text\n')
+ self.commitFile(target, 'file', 'target text\n')
prerequisite_bzr = self.createBzrBranch(prerequisite, target_bzr)
- commit_file(
+ self.commitFile(
prerequisite, 'file', 'target text\nprerequisite text\n')
source_bzr = self.createBzrBranch(source, prerequisite_bzr)
- source_rev_id = commit_file(
+ source_rev_id = self.commitFile(
source, 'file',
'target text\nprerequisite text\nsource text\n')
return (source_bzr, source_rev_id, target_bzr, prerequisite_bzr,
@@ -251,7 +241,7 @@
# affect the diff.
(source_bzr, source_rev_id, target_bzr, prerequisite_bzr,
prerequisite) = self.preparePrerequisiteMerge()
- commit_file(
+ self.commitFile(
prerequisite, 'file', 'prerequisite text2\n')
diff, conflicts = Diff.mergePreviewFromBranches(
source_bzr, source_rev_id, target_bzr, prerequisite_bzr)
@@ -467,10 +457,10 @@
self.useBzrBranches(direct_database=True)
bmp = self.factory.makeBranchMergeProposal()
bzr_target = self.createBzrBranch(bmp.target_branch)
- commit_file(bmp.target_branch, 'foo', 'a\n')
+ self.commitFile(bmp.target_branch, 'foo', 'a\n')
self.createBzrBranch(bmp.source_branch, bzr_target)
- source_rev_id = commit_file(bmp.source_branch, 'foo', 'a\nb\n')
- target_rev_id = commit_file(bmp.target_branch, 'foo', 'c\na\n')
+ self.commitFile(bmp.source_branch, 'foo', 'a\nb\n')
+ self.commitFile(bmp.target_branch, 'foo', 'c\na\n')
diff = PreviewDiff.fromBranchMergeProposal(bmp)
self.assertEqual('', diff.conflicts)
self.assertFalse(diff.has_conflicts)
@@ -511,7 +501,7 @@
logger = logging.getLogger('bzr')
logger.addHandler(handler)
try:
- preview = PreviewDiff.fromBranchMergeProposal(bmp)
+ PreviewDiff.fromBranchMergeProposal(bmp)
self.assertEqual(handler.records, [])
# check that our handler would normally intercept warnings.
trace.warning('foo!')
@@ -531,84 +521,5 @@
NotFoundError, diff.getFileByName, 'preview.diff')
-class TestIncrementalDiff(DiffTestCase):
- """Test that IncrementalDiff objects work."""
-
- layer = LaunchpadFunctionalLayer
-
- def test_providesInterface(self):
- incremental_diff = self.factory.makeIncrementalDiff()
- verifyObject(IIncrementalDiff, incremental_diff)
-
- @staticmethod
- def diff_changes(diff_bytes):
- inserted = []
- removed = []
- for patch in parse_patches(diff_bytes.splitlines(True)):
- for hunk in patch.hunks:
- for line in hunk.lines:
- if isinstance(line, InsertLine):
- inserted.append(line.contents)
- if isinstance(line, RemoveLine):
- removed.append(line.contents)
- return inserted, removed
-
- def test_generateIncrementalDiff(self):
- """generateIncrementalDiff works.
-
- Changes merged from the prerequisite and target are ignored in the
- diff.
-
- We generate an incremental diff from old_revision_id to
- new_revision_id.
-
- old_revision_id has:
- a
- b
- e
-
- new_revision_id has:
- d
- a
- c
- e
- f
-
- Because the prerequisite branch adds "d", this change is ignored.
- Because the target branch adds "f", this change is ignored.
- So the incremental diff shows that "c" was added and "b" was removed.
- """
- self.useBzrBranches(direct_database=True)
- prerequisite_branch = self.factory.makeAnyBranch()
- bmp = self.factory.makeBranchMergeProposal(
- prerequisite_branch=prerequisite_branch)
- target_branch = self.createBzrBranch(bmp.target_branch)
- old_revision_id = commit_file(bmp.target_branch, 'foo', 'a\nb\ne\n')
- old_revision = self.factory.makeRevision(rev_id=old_revision_id)
- source_branch = self.createBzrBranch(
- bmp.source_branch, target_branch)
- commit_file(bmp.source_branch, 'foo', 'a\nc\ne\n')
- prerequisite = self.createBzrBranch(
- bmp.prerequisite_branch, target_branch)
- prerequisite_revision = commit_file(
- bmp.prerequisite_branch, 'foo', 'd\na\nb\ne\n')
- merge_parent = commit_file(bmp.target_branch, 'foo', 'a\nb\ne\nf\n')
- source_branch.repository.fetch(target_branch.repository,
- revision_id=merge_parent)
- commit_file(bmp.source_branch, 'foo', 'a\nc\ne\nf\n', [merge_parent])
- source_branch.repository.fetch(prerequisite.repository,
- revision_id=prerequisite_revision)
- new_revision_id = commit_file(
- bmp.source_branch, 'foo', 'd\na\nc\ne\nf\n',
- [prerequisite_revision])
- new_revision = self.factory.makeRevision(rev_id=new_revision_id)
- incremental_diff = bmp.generateIncrementalDiff(
- old_revision, new_revision)
- transaction.commit()
- inserted, removed = self.diff_changes(incremental_diff.text)
- self.assertEqual(['c\n'], inserted)
- self.assertEqual(['b\n'], removed)
-
-
def test_suite():
return TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/code/scripts/tests/test_merge_proposal_jobs.py'
--- lib/lp/code/scripts/tests/test_merge_proposal_jobs.py 2010-12-02 16:13:51 +0000
+++ lib/lp/code/scripts/tests/test_merge_proposal_jobs.py 2011-07-09 14:07:42 +0000
@@ -7,14 +7,8 @@
import unittest
-import transaction
-
from canonical.launchpad.scripts.tests import run_script
from canonical.testing.layers import ZopelessAppServerLayer
-from lp.code.model.tests.test_branchmergeproposaljobs import (
- make_runnable_incremental_diff_job,
- )
-from lp.services.job.interfaces.job import JobStatus
from lp.testing import TestCaseWithFactory
@@ -24,8 +18,6 @@
def test_script_runs(self):
"""Ensure merge-proposal-jobs script runs."""
- job = make_runnable_incremental_diff_job(self)
- transaction.commit()
retcode, stdout, stderr = run_script(
'cronscripts/merge-proposal-jobs.py', [])
self.assertEqual(0, retcode)
@@ -33,10 +25,7 @@
self.assertEqual(
'INFO Creating lockfile:'
' /var/lock/launchpad-merge-proposal-jobs.lock\n'
- 'INFO Running through Twisted.\n'
- 'INFO Ran 1 GenerateIncrementalDiffJob jobs.\n', stderr)
- self.assertEqual(JobStatus.COMPLETED, job.status)
-
+ 'INFO Running through Twisted.\n', stderr)
def test_suite():
return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/code/stories/branches/xx-code-review-comments.txt'
--- lib/lp/code/stories/branches/xx-code-review-comments.txt 2011-06-30 17:33:37 +0000
+++ lib/lp/code/stories/branches/xx-code-review-comments.txt 2011-07-09 14:07:42 +0000
@@ -187,12 +187,16 @@
>>> print_tag_with_id(browser.contents, 'conversation')
lp://dev/... updated on 2009-09-12 ...
1. By ... on 2009-09-11
+ ...
Testing commits in conversation
2. By ... on 2009-09-11
+ ...
and it works!
3. By ... on 2009-09-12
+ ...
Testing commits in conversation
4. By ... on 2009-09-12
+ ...
and it works!
Clean up the feature flag.
=== modified file 'lib/lp/code/templates/codereviewnewrevisions-footer.pt'
--- lib/lp/code/templates/codereviewnewrevisions-footer.pt 2010-10-06 17:07:11 +0000
+++ lib/lp/code/templates/codereviewnewrevisions-footer.pt 2011-07-09 14:07:42 +0000
@@ -7,6 +7,5 @@
revisions context/revisions">
<metal:landing-target use-macro="branch/@@+macros/branch-revisions"/>
</tal:revisions>
- <tal:diff condition="context/diff" replace="structure context/diff/text/fmt:diff" />
</tal:root>
=== modified file 'lib/lp/codehosting/scanner/tests/test_bzrsync.py'
--- lib/lp/codehosting/scanner/tests/test_bzrsync.py 2011-06-15 13:21:37 +0000
+++ lib/lp/codehosting/scanner/tests/test_bzrsync.py 2011-07-09 14:07:42 +0000
@@ -30,17 +30,12 @@
from lp.code.interfaces.branchjob import IRosettaUploadJobSource
from lp.code.interfaces.branchlookup import IBranchLookup
from lp.code.interfaces.revision import IRevisionSet
-from lp.code.model.branchmergeproposaljob import (
- BranchMergeProposalJobSource,
- BranchMergeProposalJobType,
- )
from lp.code.model.branchrevision import BranchRevision
from lp.code.model.revision import (
Revision,
RevisionAuthor,
RevisionParent,
)
-from lp.code.model.tests.test_diff import commit_file
from lp.codehosting.bzrutils import (
read_locked,
write_locked,
@@ -690,40 +685,6 @@
self.assertIsNot(None, bmp.next_preview_diff_job)
-class TestGenerateIncrementalDiffJob(BzrSyncTestCase):
- """Test the scheduling of GenerateIncrementalDiffJobs."""
-
- def getPending(self):
- return list(
- BranchMergeProposalJobSource.iterReady(
- BranchMergeProposalJobType.GENERATE_INCREMENTAL_DIFF
- )
- )
-
- @run_as_db_user(config.launchpad.dbuser)
- def test_create_on_new_revision(self):
- """When branch tip changes, a job is created."""
- parent_id = commit_file(self.db_branch, 'foo', 'bar')
- self.factory.makeBranchRevision(self.db_branch, parent_id,
- revision_date=self.factory.getUniqueDate())
- self.db_branch.last_scanned_id = parent_id
- # Make sure that the merge proposal is created in the past.
- date_created = (
- datetime.datetime.now(pytz.UTC) - datetime.timedelta(days=7))
- bmp = self.factory.makeBranchMergeProposal(
- source_branch=self.db_branch,
- date_created=date_created)
- revision_id = commit_file(self.db_branch, 'foo', 'baz')
- removeSecurityProxy(bmp).target_branch.last_scanned_id = 'rev'
- self.assertEqual([], self.getPending())
- transaction.commit()
- LaunchpadZopelessLayer.switchDbUser(config.branchscanner.dbuser)
- self.makeBzrSync(self.db_branch).syncBranchAndClose()
- (job,) = self.getPending()
- self.assertEqual(revision_id, job.new_revision_id)
- self.assertEqual(parent_id, job.old_revision_id)
-
-
class TestSetRecipeStale(BzrSyncTestCase):
"""Test recipes associated with the branch are marked stale."""
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2011-07-07 15:47:36 +0000
+++ lib/lp/testing/factory.py 2011-07-09 14:07:42 +0000
@@ -1516,35 +1516,6 @@
preview_diff.target_revision_id = self.getUniqueUnicode()
return preview_diff
- def makeIncrementalDiff(self, merge_proposal=None, old_revision=None,
- new_revision=None):
- diff = self.makeDiff()
- if merge_proposal is None:
- source_branch = self.makeBranch()
- else:
- source_branch = merge_proposal.source_branch
-
- def make_revision(parent=None):
- sequence = source_branch.revision_history.count() + 1
- if parent is None:
- parent_ids = []
- else:
- parent_ids = [parent.revision_id]
- branch_revision = self.makeBranchRevision(
- source_branch, sequence=sequence,
- revision_date=self.getUniqueDate(), parent_ids=parent_ids)
- return branch_revision.revision
- if old_revision is None:
- old_revision = make_revision()
- if merge_proposal is None:
- merge_proposal = self.makeBranchMergeProposal(
- date_created=self.getUniqueDate(),
- source_branch=source_branch)
- if new_revision is None:
- new_revision = make_revision(old_revision)
- return merge_proposal.generateIncrementalDiff(
- old_revision, new_revision, diff)
-
def makeStaticDiff(self):
return StaticDiff.acquireFromText(
self.getUniqueUnicode(), self.getUniqueUnicode(),
@@ -1613,11 +1584,10 @@
'', parent.revision_id, None, None, None)
branch.updateScannedDetails(parent, sequence)
- def makeBranchRevision(self, branch, revision_id=None, sequence=None,
- parent_ids=None, revision_date=None):
+ def makeBranchRevision(self, branch, revision_id, sequence=None,
+ parent_ids=None):
revision = self.makeRevision(
- rev_id=revision_id, parent_ids=parent_ids,
- revision_date=revision_date)
+ rev_id=revision_id, parent_ids=parent_ids)
return branch.createBranchRevision(sequence, revision)
def makeBug(self, product=None, owner=None, bug_watch_url=None,
@@ -2233,7 +2203,7 @@
def makeCodeReviewComment(self, sender=None, subject=None, body=None,
vote=None, vote_tag=None, parent=None,
- merge_proposal=None, date_created=DEFAULT):
+ merge_proposal=None):
if sender is None:
sender = self.makePerson()
if subject is None:
@@ -2247,8 +2217,7 @@
merge_proposal = self.makeBranchMergeProposal(
registrant=sender)
return merge_proposal.createComment(
- sender, subject, body, vote, vote_tag, parent,
- _date_created=date_created)
+ sender, subject, body, vote, vote_tag, parent)
def makeCodeReviewVoteReference(self):
bmp = removeSecurityProxy(self.makeBranchMergeProposal())
=== modified file 'utilities/sourcedeps.conf'
--- utilities/sourcedeps.conf 2011-06-29 14:14:20 +0000
+++ utilities/sourcedeps.conf 2011-07-09 14:07:42 +0000
@@ -5,7 +5,6 @@
bzr-svn lp:~launchpad-pqm/bzr-svn/devel;revno=2713
cscvs lp:~launchpad-pqm/launchpad-cscvs/devel;revno=432
dulwich lp:~launchpad-pqm/dulwich/devel;revno=426
-difftacular lp:difftacular;revno=6
loggerhead lp:~loggerhead-team/loggerhead/trunk-rich;revno=452
lpreview lp:~launchpad-pqm/bzr-lpreview/devel;revno=23
mailman lp:~launchpad-pqm/mailman/2.1;revno=976
References