26
26
from bzrlib.branch import Branch
27
27
from bzrlib import BZRDIR
28
28
from bzrlib.commands import Command
29
from bzrlib.revisionspec import RevisionSpec
29
30
from bzrlib.workingtree import WorkingTree
104
105
takes_options = ['revision']
106
107
def run(self, revision_id=None, revision=None):
107
from bzrlib.revisionspec import RevisionSpec
109
109
if revision_id is not None and revision is not None:
110
110
raise BzrCommandError('You can only supply one of revision_id or --revision')
136
136
takes_args = ['revision_info*']
137
137
takes_options = ['revision']
138
138
def run(self, revision=None, revision_info_list=[]):
139
from bzrlib.revisionspec import RevisionSpec
142
141
if revision is not None:
1482
class cmd_re_sign(Command):
1483
"""Create a digital signature for an existing revision."""
1484
# TODO be able to replace existing ones.
1486
hidden = True # is this right ?
1487
takes_args = ['revision_id?']
1488
takes_options = ['revision']
1490
def run(self, revision_id=None, revision=None):
1491
import bzrlib.config as config
1492
import bzrlib.gpg as gpg
1493
if revision_id is not None and revision is not None:
1494
raise BzrCommandError('You can only supply one of revision_id or --revision')
1495
if revision_id is None and revision is None:
1496
raise BzrCommandError('You must supply either --revision or a revision_id')
1497
b = Branch.open_containing('.')
1498
gpg_strategy = gpg.GPGStrategy(config.BranchConfig(b))
1499
if revision_id is not None:
1500
self.sign_one(gpg_strategy, b, revision_id)
1501
elif revision is not None:
1502
for rev in revision:
1504
raise BzrCommandError('You cannot specify a NULL revision.')
1505
revno, rev_id = rev.in_history(b)
1506
self.sign_one(gpg_strategy, b, rev_id)
1508
def sign_one(self, gpg_strategy, b, revision_id):
1509
import bzrlib.testament as testament
1510
from cStringIO import StringIO
1511
plaintext = testament.Testament.from_revision(b, revision_id).as_short_text()
1512
b.revision_store.add(StringIO(gpg_strategy.sign(plaintext)), revision_id, "sig")
1482
1516
# these get imported and then picked up by the scan for cmd_*
1483
1517
# TODO: Some more consistent way to split command definitions across files;
1484
1518
# we do need to load at least some information about them to know of