Merge lp:~dobey/tarmac/full-authors into lp:tarmac

Proposed by dobey
Status: Merged
Approved by: Paul Hummer
Approved revision: 356
Merged at revision: 357
Proposed branch: lp:~dobey/tarmac/full-authors
Merge into: lp:tarmac
Diff against target: 124 lines (+46/-18)
3 files modified
tarmac/bin/commands.py (+1/-1)
tarmac/branch.py (+34/-12)
tarmac/tests/test_branch.py (+11/-5)
To merge this branch: bzr merge lp:~dobey/tarmac/full-authors
Reviewer Review Type Date Requested Status
Paul Hummer Approve
Review via email: mp+35869@code.launchpad.net

Commit message

Get all the authors for all unique changes in the source branch

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tarmac/bin/commands.py'
--- tarmac/bin/commands.py 2010-09-02 15:18:07 +0000
+++ tarmac/bin/commands.py 2010-09-17 19:29:50 +0000
@@ -143,7 +143,7 @@
143 u'Preparing to merge %(source_branch)s' % {143 u'Preparing to merge %(source_branch)s' % {
144 'source_branch': proposal.source_branch.bzr_identity})144 'source_branch': proposal.source_branch.bzr_identity})
145 source = Branch.create(145 source = Branch.create(
146 proposal.source_branch, self.config)146 proposal.source_branch, self.config, target)
147147
148 try:148 try:
149 approved = proposal.reviewed_revid149 approved = proposal.reviewed_revid
150150
=== modified file 'tarmac/branch.py'
--- tarmac/branch.py 2010-09-02 15:04:52 +0000
+++ tarmac/branch.py 2010-09-17 19:29:50 +0000
@@ -35,7 +35,7 @@
3535
36class Branch(object):36class Branch(object):
3737
38 def __init__(self, lp_branch, config=False):38 def __init__(self, lp_branch, config=False, target=None):
39 self.lp_branch = lp_branch39 self.lp_branch = lp_branch
40 self.bzr_branch = bzr_branch.Branch.open(self.lp_branch.bzr_identity)40 self.bzr_branch = bzr_branch.Branch.open(self.lp_branch.bzr_identity)
41 if config:41 if config:
@@ -43,15 +43,14 @@
43 else:43 else:
44 self.config = None44 self.config = None
4545
46 self.target = target
46 self.logger = logging.getLogger('tarmac')47 self.logger = logging.getLogger('tarmac')
4748
48 @classmethod49 @classmethod
49 def create(cls, lp_branch, config, create_tree=False):50 def create(cls, lp_branch, config, create_tree=False, target=None):
51 clazz = cls(lp_branch, config, target)
50 if create_tree:52 if create_tree:
51 clazz = cls(lp_branch, config)
52 clazz.create_tree()53 clazz.create_tree()
53 else:
54 clazz = cls(lp_branch)
55 return clazz54 return clazz
5655
57 def create_tree(self):56 def create_tree(self):
@@ -133,15 +132,38 @@
133132
134 @property133 @property
135 def authors(self):134 def authors(self):
136 last_rev = self.bzr_branch.last_revision()
137 author_list = []135 author_list = []
138136
139 # Only query for authors if last_rev is not null:137 if self.target:
140 if last_rev != 'null:':138 self.bzr_branch.lock_read()
141 rev = self.bzr_branch.repository.get_revision(last_rev)139 self.target.bzr_branch.lock_read()
142 apparent_authors = rev.get_apparent_authors()140
143 author_list.extend(141 graph = self.bzr_branch.repository.get_graph(
144 [a.replace('\n', '') for a in apparent_authors])142 self.target.bzr_branch.repository)
143
144 unique_ids = graph.find_unique_ancestors(
145 self.bzr_branch.last_revision(),
146 [self.target.bzr_branch.last_revision()])
147
148 revs = self.bzr_branch.repository._iter_revisions(unique_ids)
149 for rev in revs:
150 apparent_authors = rev[1].get_apparent_authors()
151 for author in apparent_authors:
152 author.replace('\n', '')
153 if author not in author_list:
154 author_list.append(author)
155
156 self.target.bzr_branch.unlock()
157 self.bzr_branch.unlock()
158 else:
159 last_rev = self.bzr_branch.last_revision()
160 if last_rev != 'null:':
161 rev = self.bzr_branch.repository.get_revision(last_rev)
162 apparent_authors = rev.get_apparent_authors()
163 author_list.extend(
164 [a.replace('\n', '') for a in apparent_authors])
165
166
145 return author_list167 return author_list
146168
147 @property169 @property
148170
=== modified file 'tarmac/tests/test_branch.py'
--- tarmac/tests/test_branch.py 2010-09-14 16:53:54 +0000
+++ tarmac/tests/test_branch.py 2010-09-17 19:29:50 +0000
@@ -58,7 +58,8 @@
58 branch1.lp_branch.revision_count += 158 branch1.lp_branch.revision_count += 1
5959
60 mock2 = MockLPBranch(branch2_dir, source_branch=branch1.lp_branch)60 mock2 = MockLPBranch(branch2_dir, source_branch=branch1.lp_branch)
61 branch2 = branch.Branch.create(mock2, self.config, create_tree=True)61 branch2 = branch.Branch.create(mock2, self.config, create_tree=True,
62 target=branch1)
62 branch2.commit('ABC...')63 branch2.commit('ABC...')
6364
64 added_file = os.path.join(branch2.lp_branch.tree_dir, 'README')65 added_file = os.path.join(branch2.lp_branch.tree_dir, 'README')
@@ -124,10 +125,15 @@
124 def test_merge_with_authors(self):125 def test_merge_with_authors(self):
125 '''A merge from a branch with authors'''126 '''A merge from a branch with authors'''
126 authors = ['author1', 'author2']127 authors = ['author1', 'author2']
127 self.branch1.commit('Authors test', authors=authors)128 self.branch2.commit('Authors test', authors=authors)
128 self.branch2.merge(self.branch1)129 self.branch2.commit('Another author', authors=['author3'])
129 self.branch2.commit('Authors Merge test', authors=self.branch1.authors)130 self.branch2.lp_branch.revision_count += 2
130 self.assertEqual(self.branch2.authors.sort(), authors.sort())131 orig_authors = self.branch2.authors
132 self.branch1.merge(self.branch2)
133 self.branch1.commit('Authors Merge test', authors=self.branch2.authors)
134 self.branch1.lp_branch.revision_count += 1
135 self.assertEqual(sorted(orig_authors),
136 sorted(self.branch1.authors))
131137
132 def test_merge_with_bugs(self):138 def test_merge_with_bugs(self):
133 '''A merge from a branch with authors'''139 '''A merge from a branch with authors'''

Subscribers

People subscribed via source and target branches