Merge lp:~knittl/bzr/cat-signature into lp:bzr

Proposed by Daniel Knittl-Frank
Status: Work in progress
Proposed branch: lp:~knittl/bzr/cat-signature
Merge into: lp:bzr
Diff against target: 110 lines (+84/-0)
3 files modified
bzrlib/builtins.py (+25/-0)
bzrlib/tests/blackbox/__init__.py (+1/-0)
bzrlib/tests/blackbox/test_cat_signature.py (+58/-0)
To merge this branch: bzr merge lp:~knittl/bzr/cat-signature
Reviewer Review Type Date Requested Status
Daniel Knittl-Frank (community) Needs Resubmitting
John A Meinel Needs Fixing
Review via email: mp+36467@code.launchpad.net

Description of the change

new hidden command `cat-signature` to print the signature for a commit

To post a comment you must log in.
lp:~knittl/bzr/cat-signature updated
5438. By Daniel Knittl-Frank <email address hidden>

Fix whitespace (4, not 2 per level)

Revision history for this message
John A Meinel (jameinel) wrote :

cmd_cat_signature should be indented to 4 spaces, not 2 as per our guidelines, and there should be some more spacing between options.

We probably also want the output encoding to be exact. The content should be 7-bit safe, but just in case.

I'm not sure that @display_command actually makes sense. It means that we'll ignore stuff like EPIPE, I'd probably take it off, but it isn't a big deal.

Something like:

+class cmd_cat_signature(Command):
+ __doc__ = """Show signature of a revision's testament"""
+
+ hidden = True
+ takes_options = ['revision']
+ takes_args = ['branch?']
+ encoding = 'exact'
+
+ def run(self, branch=u'.', revision=None):

46
47 === added file 'bzrlib/tests/blackbox/test_cat_signature.py'
48 --- bzrlib/tests/blackbox/test_cat_signature.py 1970-01-01 00:00:00 +0000
49 +++ bzrlib/tests/blackbox/test_cat_signature.py 2010-09-23 16:27:46 +0000
50 @@ -0,0 +1,58 @@
51 +# Copyright (C) 2007-2010 Canonical Ltd

Copyright for this file should be only 2010

But the tests themselves seem fine to me. And the actual functional code seems good.

review: Needs Fixing
lp:~knittl/bzr/cat-signature updated
5439. By Daniel Knittl-Frank <email address hidden>

Use exact encoding

5440. By Daniel Knittl-Frank <email address hidden>

Copyright 2010

Revision history for this message
Martin Pool (mbp) wrote :

Also, could you please execute the contributor agreement at
http://canonical.com/contributors/

Revision history for this message
Vincent Ladeuil (vila) wrote :

Will mark as wip until the contributor agreement is sorted out.

Revision history for this message
Daniel Knittl-Frank (knittl) wrote :

> Will mark as wip until the contributor agreement is sorted out.

Does bzr still require contributors to sign a (canonical) CLA? Couldn't find anything in the Bazaar documentation.

review: Needs Resubmitting

Unmerged revisions

5440. By Daniel Knittl-Frank <email address hidden>

Copyright 2010

5439. By Daniel Knittl-Frank <email address hidden>

Use exact encoding

5438. By Daniel Knittl-Frank <email address hidden>

Fix whitespace (4, not 2 per level)

5437. By Daniel Knittl-Frank <email address hidden>

Add blackbox tests for cat-signature

5436. By Daniel Knittl-Frank <email address hidden>

Return non-zero exit code when there is no signature

5435. By Daniel Knittl-Frank <email address hidden>

Make command hidden

5434. By Daniel Knittl-Frank <email address hidden>

add cleanup line (used in cmd_testament)

5433. By Daniel Knittl-Frank <email address hidden>

rename to cat-signature to be consistent with cat-revision, etc.

5432. By Daniel Knittl-Frank <email address hidden>

new command: show-signature [-r revision] [branch]

prints the signature for the testament of a given revision

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2010-09-20 04:56:26 +0000
+++ bzrlib/builtins.py 2010-09-23 18:25:59 +0000
@@ -4504,6 +4504,31 @@
4504 self.outf.write(" %s\n" % path)4504 self.outf.write(" %s\n" % path)
4505 self.outf.write("\n")4505 self.outf.write("\n")
45064506
4507class cmd_cat_signature(Command):
4508 __doc__ = """Show signature of a revision's testament"""
4509
4510 hidden = True
4511 takes_options = ['revision']
4512 takes_args = ['branch?']
4513 encoding = 'exact'
4514
4515 def run(self, branch=u'.', revision=None):
4516 if branch == u'.':
4517 b = Branch.open_containing(branch)[0]
4518 else:
4519 b = Branch.open(branch)
4520 self.add_cleanup(b.lock_read().unlock)
4521
4522 if revision is None:
4523 rev_id = b.last_revision()
4524 else:
4525 rev_id = revision[0].as_revision_id(b)
4526
4527 try:
4528 self.outf.write(b.repository.get_signature_text(rev_id))
4529 except errors.NoSuchRevision:
4530 return 1
4531
45074532
4508class cmd_testament(Command):4533class cmd_testament(Command):
4509 __doc__ = """Show testament (signing-form) of a revision."""4534 __doc__ = """Show testament (signing-form) of a revision."""
45104535
=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- bzrlib/tests/blackbox/__init__.py 2010-07-28 07:05:19 +0000
+++ bzrlib/tests/blackbox/__init__.py 2010-09-23 18:25:59 +0000
@@ -49,6 +49,7 @@
49 'bzrlib.tests.blackbox.test_bundle_info',49 'bzrlib.tests.blackbox.test_bundle_info',
50 'bzrlib.tests.blackbox.test_cat',50 'bzrlib.tests.blackbox.test_cat',
51 'bzrlib.tests.blackbox.test_cat_revision',51 'bzrlib.tests.blackbox.test_cat_revision',
52 'bzrlib.tests.blackbox.test_cat_signature',
52 'bzrlib.tests.blackbox.test_check',53 'bzrlib.tests.blackbox.test_check',
53 'bzrlib.tests.blackbox.test_checkout',54 'bzrlib.tests.blackbox.test_checkout',
54 'bzrlib.tests.blackbox.test_clean_tree',55 'bzrlib.tests.blackbox.test_clean_tree',
5556
=== added file 'bzrlib/tests/blackbox/test_cat_signature.py'
--- bzrlib/tests/blackbox/test_cat_signature.py 1970-01-01 00:00:00 +0000
+++ bzrlib/tests/blackbox/test_cat_signature.py 2010-09-23 18:25:59 +0000
@@ -0,0 +1,58 @@
1# Copyright (C) 2010 Canonical Ltd
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17"""Black-box tests for bzr cat-revision.
18"""
19
20from bzrlib.bzrdir import BzrDir
21from bzrlib.tests import TestCaseWithTransport
22
23
24class TestCatSignature(TestCaseWithTransport):
25
26 def setup_tree(self):
27 wt = BzrDir.create_standalone_workingtree('.')
28 b = wt.branch
29 # commit without signature
30 wt.commit("base A", allow_pointless=True, rev_id='A')
31 # next commit has a dummy signature attached
32 wt.commit("base B", allow_pointless=True, rev_id='B')
33 b.repository.lock_write()
34 b.repository.start_write_group()
35 try:
36 wt.branch.repository.add_signature_text('B', 'dummy signature')
37 except:
38 b.repository.abort_write_group()
39 raise
40 else:
41 b.repository.commit_write_group()
42 finally:
43 b.repository.unlock()
44
45 return wt
46
47 def test_cat_signature(self):
48 """Print out the signature for a revision"""
49 wt = self.setup_tree()
50 out, err = self.run_bzr('cat-signature -r revid:B')
51 self.assertEquals(out, 'dummy signature')
52
53 def test_cat_signature_unsigned(self):
54 """Do not output anything when there is no signature,
55 but exit with code 1"""
56 self.setup_tree()
57 out, err = self.run_bzr('cat-signature -r revid:A', retcode=1)
58 self.assertEquals(out, '')