Merge ~canonical-launchpad-branches/launchpad/+git/launchpad-old:git-fixes into ~canonical-launchpad-branches/launchpad/+git/launchpad-old:master

Proposed by William Grant
Status: Work in progress
Proposed branch: ~canonical-launchpad-branches/launchpad/+git/launchpad-old:git-fixes
Merge into: ~canonical-launchpad-branches/launchpad/+git/launchpad-old:master
Diff against target: 103 lines (+20/-19)
4 files modified
lib/lp/code/interfaces/branch.py (+4/-3)
lib/lp/code/model/branch.py (+3/-1)
lib/lp/code/model/codereviewcomment.py (+2/-2)
lib/lp/code/model/diff.py (+11/-13)
Reviewer Review Type Date Requested Status
Canonical Launchpad Branches Pending
Review via email: mp+258043@code.launchpad.net

Description of the change

Fix everything.

To post a comment you must log in.

Unmerged commits

cb1a8ce... by William Grant

Fix Git JSON previewdiff rendering.

f845dc9... by William Grant

Fix non-ASCII git diffs.

65f027f... by William Grant

Fix codereviewcomment rendering OOPS for git MPs.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/code/interfaces/branch.py b/lib/lp/code/interfaces/branch.py
2index 0dce432..e96bb82 100644
3--- a/lib/lp/code/interfaces/branch.py
4+++ b/lib/lp/code/interfaces/branch.py
5@@ -358,11 +358,12 @@ class IBranchView(IHasOwner, IHasBranchTarget, IHasMergeProposals,
6 description=_("Unique name of the branch, including the "
7 "owner and project names.")))
8
9- displayname = exported(
10+ display_name = exported(
11 Text(title=_('Display name'), readonly=True,
12 description=_(
13- "The branch unique_name.")),
14- exported_as='display_name')
15+ "The branch unique_name.")))
16+
17+ displayname = Attribute("Display name (deprecated)")
18
19 code_reviewer = Attribute(
20 "The reviewer if set, otherwise the owner of the branch.")
21diff --git a/lib/lp/code/model/branch.py b/lib/lp/code/model/branch.py
22index db2a16e..3528b9e 100644
23--- a/lib/lp/code/model/branch.py
24+++ b/lib/lp/code/model/branch.py
25@@ -675,10 +675,12 @@ class Branch(SQLBase, BzrIdentityMixin):
26 return safe_open('lp-internal', self.getInternalBzrUrl())
27
28 @property
29- def displayname(self):
30+ def display_name(self):
31 """See `IBranch`."""
32 return self.bzr_identity
33
34+ displayname = display_name
35+
36 @property
37 def code_reviewer(self):
38 """See `IBranch`."""
39diff --git a/lib/lp/code/model/codereviewcomment.py b/lib/lp/code/model/codereviewcomment.py
40index 04177c0..623cbb3 100644
41--- a/lib/lp/code/model/codereviewcomment.py
42+++ b/lib/lp/code/model/codereviewcomment.py
43@@ -95,8 +95,8 @@ class CodeReviewComment(SQLBase):
44 @property
45 def title(self):
46 return ('Comment on proposed merge of %(source)s into %(target)s' %
47- {'source': self.branch_merge_proposal.source_branch.displayname,
48- 'target': self.branch_merge_proposal.target_branch.displayname,
49+ {'source': self.branch_merge_proposal.merge_source.display_name,
50+ 'target': self.branch_merge_proposal.merge_source.display_name,
51 })
52
53 @property
54diff --git a/lib/lp/code/model/diff.py b/lib/lp/code/model/diff.py
55index e809ee2..9b72dfc 100644
56--- a/lib/lp/code/model/diff.py
57+++ b/lib/lp/code/model/diff.py
58@@ -12,6 +12,7 @@ __all__ = [
59
60 from contextlib import nested
61 from cStringIO import StringIO
62+from operator import attrgetter
63 import sys
64 from uuid import uuid1
65
66@@ -471,8 +472,9 @@ class PreviewDiff(Storm):
67 conflicts = u"".join(
68 u"Conflict in %s\n" % path for path in response['conflicts'])
69 preview = cls.create(
70- bmp, response['patch'], source_revision_id, target_revision_id,
71- prerequisite_revision_id, conflicts, strip_prefix_segments=1)
72+ bmp, response['patch'].encode('utf-8'), source_revision_id,
73+ target_revision_id, prerequisite_revision_id, conflicts,
74+ strip_prefix_segments=1)
75 del get_property_cache(bmp).preview_diffs
76 del get_property_cache(bmp).preview_diff
77 return preview
78@@ -513,18 +515,14 @@ class PreviewDiff(Storm):
79 # A preview diff is stale if the revision ids used to make the diff
80 # are different from the tips of the source or target branches.
81 bmp = self.branch_merge_proposal
82- if (self.source_revision_id != bmp.source_branch.last_scanned_id or
83- self.target_revision_id != bmp.target_branch.last_scanned_id):
84- # This is the simple frequent case.
85+ get_id = attrgetter(
86+ 'last_scanned_id' if bmp.source_branch else 'commit_sha1')
87+ if (self.source_revision_id != get_id(bmp.merge_source) or
88+ self.target_revision_id != get_id(bmp.merge_target)):
89 return True
90-
91- # More complex involves the prerequisite branch too.
92- if (bmp.prerequisite_branch is not None and
93- (self.prerequisite_revision_id !=
94- bmp.prerequisite_branch.last_scanned_id)):
95- return True
96- else:
97- return False
98+ return (
99+ bmp.merge_prerequisite is not None and
100+ self.prerequisite_revision_id != get_id(bmp.merge_prerequisite))
101
102 def getFileByName(self, filename):
103 """See `IPreviewDiff`."""

Subscribers

People subscribed via source and target branches