PQM

Merge lp://staging/~oddbloke/pqm/merge-details into lp://staging/pqm

Proposed by Tim Penhey
Status: Merged
Merge reported by: Robert Collins
Merged at revision: not available
Proposed branch: lp://staging/~oddbloke/pqm/merge-details
Merge into: lp://staging/pqm
Diff against target: 106 lines (has conflicts)
Text conflict in pqm/tests/test_pqm.py
To merge this branch: bzr merge lp://staging/~oddbloke/pqm/merge-details
Reviewer Review Type Date Requested Status
Robert Collins Needs Fixing
Tim Penhey (community) Needs Fixing
Review via email: mp+1876@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

I'd like to propose against my integration branch, but until I land the scanner fix I have I don't want the status of the source branch to be set as merged.

Revision history for this message
Tim Penhey (thumper) wrote :
Download full text (3.2 KiB)

=== modified file 'pqm/__init__.py'
--- pqm/__init__.py 2008-09-29 08:57:02 +0000
+++ pqm/__init__.py 2008-11-24 20:09:58 +0000
@@ -233,6 +233,9 @@
     def make_local_dir(self, sender, branch, output_dir):
         raise PQMTlaFailure(sender, 'Unsupported operation')

+ def latest_revision_info(self, sender, branch):
+ raise PQMTlaFailure(sender, 'Unsupported operation')
+

 class ArchHandler(VCSHandler):

@@ -465,6 +468,11 @@
         branch = Branch.open(branch_spec)
         branch.create_checkout(output_dir, lightweight=True)

+ def latest_revision_info(self, sender, branch_location):
+ from bzrlib.branch import Branch
+ branch = Branch.open(branch_location)
+ return branch.revno(), branch.repository.get_revision(branch.last_revision()).message
+

 class BranchSpecOptionHandler:
     """Configuration mechanism for a branch specifications.

=== modified file 'pqm/script.py'
--- pqm/script.py 2008-09-29 08:57:02 +0000
+++ pqm/script.py 2008-11-24 20:09:58 +0000
@@ -402,6 +402,20 @@
         self.successful.append(line)
         self.output += self._success_output(merge_name, start_time)
         self.get_vcs().commit(sender, dir, self.commitmsg, to_repo_revision, config)
+ # Now that we've committed to the branch, let's include the
+ # commit details in the output
+ try:
+ revno, commit_msg = self.get_vcs().latest_revision_info(sender, to_repo_revision)
+ self.successful[-1] = ("%s\n"
+ "Revision: %s \n"
+ "Commit Message: %s"
+ % (line, revno, commit_msg))
+ self.output += ["\n", "Revision Details:", "\n",
+ "Revision: %s" % revno, "\n",
+ "Commit Message: %s" % commit_msg, "\n"]
+ except PQMTlaFailure:
+ # If the latest_revision_info function isn't implemented
+ pass

     def get_arch_impl(self):
         # TODO: Tim Penhey, 2008-05-28

=== modified file 'pqm/tests/test_pqm.py'
--- pqm/tests/test_pqm.py 2008-09-29 08:58:53 +0000
+++ pqm/tests/test_pqm.py 2008-11-24 20:09:58 +0000
@@ -574,6 +574,12 @@
             return
         self.fail("Merge conflict not raised.")

+ def test_latest_revision_info(self):
+ handler = pqm.Bazaar2Handler()
+ revno, message = handler.latest_revision_info("me", "...

Read more...

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

Damn! How did that loose all the whitespace?

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

Crap. No pre!!!

Revision history for this message
Tim Penhey (thumper) wrote :
Download full text (3.4 KiB)

 vote needs_fixing

On Tue, 25 Nov 2008 09:10:28 Tim Penhey wrote:
> === modified file 'pqm/__init__.py'
> --- pqm/__init__.py 2008-09-29 08:57:02 +0000
> +++ pqm/__init__.py 2008-11-24 20:09:58 +0000
> @@ -233,6 +233,9 @@
> def make_local_dir(self, sender, branch, output_dir):
> raise PQMTlaFailure(sender, 'Unsupported operation')
>
> + def latest_revision_info(self, sender, branch):
> + raise PQMTlaFailure(sender, 'Unsupported operation')

Why pass in the sender here? It doesn't make sense to me.

Also I'd like to see a docstring explaining what the expected
return values are.

>
> class ArchHandler(VCSHandler):
>
> @@ -465,6 +468,11 @@
> branch = Branch.open(branch_spec)
> branch.create_checkout(output_dir, lightweight=True)
>
> + def latest_revision_info(self, sender, branch_location):
> + from bzrlib.branch import Branch
> + branch = Branch.open(branch_location)
> + return branch.revno(), branch.repository.get_revision(branch.last_revision()).message
> +
>
> class BranchSpecOptionHandler:
> """Configuration mechanism for a branch specifications.
>
> === modified file 'pqm/script.py'
> --- pqm/script.py 2008-09-29 08:57:02 +0000
> +++ pqm/script.py 2008-11-24 20:09:58 +0000
> @@ -402,6 +402,20 @@
> self.successful.append(line)
> self.output += self._success_output(merge_name, start_time)
> self.get_vcs().commit(sender, dir, self.commitmsg, to_repo_revision, config)
> + # Now that we've committed to the branch, let's include the
> + # commit details in the output
> + try:
> + revno, commit_msg = self.get_vcs().latest_revision_info(sender, to_repo_revision)
> + self.successful[-1] = ("%s\n"
> + "Revision: %s \n"
> + "Commit Message: %s"
> + % (line, revno, commit_msg))
> + self.output += ["\n", "Revision Details:", "\n",

I think extend is better than += for list appending.
Also I think that "Revision Details" is not really needed
here as the next two lines say "Revision" and "Commit Message".
It is fairly obvious that they are the revision details.

> + "Revision: %s" % revno, "\n",
> + "Commit Message: %s" % commit_msg, "\n"]

Wouldn't it be nicer to calculate the revision details once?

   revision_details = "Revision: %s\nCommit Message: %s" % (revno, commit_msg)

Then use that to update the successful string and the output:

   self.successful[-1] = '%s\n%s' % (line, revision_details)
   self.output.append('\n%s\n' % revision_details)

> + except PQMTlaFailure:
> + # If the latest_revision_info function isn't implemented
> + pass
>
> def get_arch_impl(self):
> # TODO: Tim Penhey, 2008-05-28
>
> === modified file 'pqm/tests/test_pqm.py'
> --- pqm/tests/test_pqm.py 2008-09-29 08:58:53 +0000
> +++ pqm/tests/test_pqm.py 2008-11-24 20:09:58 +0000
> @@ -574,6 +574,12 @@
> return
> self.fail("Merge conflict not raised.")
>
> + def test_latest_revision_info(self):

A docstring or comm...

Read more...

review: Needs Fixing
Revision history for this message
Dan Watkins (oddbloke) wrote :

On Wed, 2008-11-26 at 02:39 +0000, Tim Penhey wrote:
> <snip>

This is mthaddon's code, I just tidied it up a bit. I'm happy to look
at this, but don't know when I'll be able to.

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

On Wed, 26 Nov 2008 23:06:32 Daniel Watkins wrote:
> On Wed, 2008-11-26 at 02:39 +0000, Tim Penhey wrote:
> > <snip>
>
> This is mthaddon's code, I just tidied it up a bit. I'm happy to
> look at this, but don't know when I'll be able to.

OK, I'll talk to mthaddon about this.

Revision history for this message
Robert Collins (lifeless) wrote :

This will do wrong things with multiline commit messages - double carriage returns, for instance.

review: Needs Fixing
Revision history for this message
Robert Collins (lifeless) wrote :

The defect with multiline commit messages, and the unnecessary work are
still there.

However, until merge-directives land the former isn't a concern, and the
latter is performance-not-functional.

-Rob
--

Updating diff...

An updated diff will be available in a few minutes. Reload to see the changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'pqm/__init__.py'
2--- pqm/__init__.py 2008-08-05 06:31:49 +0000
3+++ pqm/__init__.py 2009-03-05 06:50:16 +0000
4@@ -217,6 +217,9 @@
5 def make_local_dir(self, sender, branch, output_dir):
6 raise PQMTlaFailure(sender, 'Unsupported operation')
7
8+ def latest_revision_info(self, sender, branch):
9+ raise PQMTlaFailure(sender, 'Unsupported operation')
10+
11
12 class ArchHandler(VCSHandler):
13
14@@ -449,6 +452,11 @@
15 branch = Branch.open(branch_spec)
16 branch.create_checkout(output_dir, lightweight=True)
17
18+ def latest_revision_info(self, sender, branch_location):
19+ from bzrlib.branch import Branch
20+ branch = Branch.open(branch_location)
21+ return branch.revno(), branch.repository.get_revision(branch.last_revision()).message
22+
23
24 class BranchSpecOptionHandler:
25 """Configuration mechanism for a branch specifications.
26
27=== modified file 'pqm/script.py'
28--- pqm/script.py 2008-07-17 07:17:31 +0000
29+++ pqm/script.py 2009-03-05 06:50:16 +0000
30@@ -424,6 +424,20 @@
31 self.successful.append(line)
32 self.output += self._success_output(merge_name, start_time)
33 self.get_vcs().commit(sender, dir, self.commitmsg, to_repo_revision, config)
34+ # Now that we've committed to the branch, let's include the
35+ # commit details in the output
36+ try:
37+ revno, commit_msg = self.get_vcs().latest_revision_info(sender, to_repo_revision)
38+ self.successful[-1] = ("%s\n"
39+ "Revision: %s \n"
40+ "Commit Message: %s"
41+ % (line, revno, commit_msg))
42+ self.output += ["\n", "Revision Details:", "\n",
43+ "Revision: %s" % revno, "\n",
44+ "Commit Message: %s" % commit_msg, "\n"]
45+ except PQMTlaFailure:
46+ # If the latest_revision_info function isn't implemented
47+ pass
48
49 def get_arch_impl(self):
50 # TODO: Tim Penhey, 2008-05-28
51
52=== modified file 'pqm/tests/test_pqm.py'
53--- pqm/tests/test_pqm.py 2008-11-21 00:43:51 +0000
54+++ pqm/tests/test_pqm.py 2009-03-05 06:50:16 +0000
55@@ -202,11 +202,19 @@
56 self.assertEqual(script.getLines(),
57 [("star-merge http://www.example.com/foo/bar "
58 "http://www.example.com/bar/baz")])
59+<<<<<<< TREE
60 self.assertEqual([MergeCommand(None,
61 None,
62 None,
63 'http://www.example.com/foo/bar',
64 'http://www.example.com/bar/baz')],
65+=======
66+ self.assertEqual([MergeCommand(None,
67+ None,
68+ None,
69+ 'http://www.example.com/foo/bar',
70+ 'http://www.example.com/bar/baz')],
71+>>>>>>> MERGE-SOURCE
72 script.getCommands())
73
74 def testGPGFields(self):
75@@ -231,11 +239,19 @@
76 [("star-merge http://www.example.com/argh/blah "
77 "http://www.example.com/bing/bong")])
78 self.assertEqual(
79+<<<<<<< TREE
80 [MergeCommand(None,
81 None,
82 None,
83 'http://www.example.com/argh/blah',
84 'http://www.example.com/bing/bong')],
85+=======
86+ [MergeCommand(None,
87+ None,
88+ None,
89+ 'http://www.example.com/argh/blah',
90+ 'http://www.example.com/bing/bong')],
91+>>>>>>> MERGE-SOURCE
92 script.getCommands())
93
94 def testDate(self):
95@@ -575,6 +591,12 @@
96 return
97 self.fail("Merge conflict not raised.")
98
99+ def test_latest_revision_info(self):
100+ handler = pqm.Bazaar2Handler()
101+ revno, message = handler.latest_revision_info("me", "bzrbranch")
102+ self.assertEqual(1, revno)
103+ self.assertEqual('start branch.', message)
104+
105
106 class TestConfig(unittest.TestCase):
107

Subscribers

People subscribed via source and target branches