1210
1210
possible_transports = []
1211
1211
if location is not None:
1213
mergeable = bundle.read_mergeable_from_url(location,
1214
possible_transports=possible_transports)
1213
mergeable = _mod_mergeable.read_mergeable_from_url(
1214
location, possible_transports=possible_transports)
1215
1215
except errors.NotABundle:
1216
1216
mergeable = None
4438
4438
self.add_cleanup(tree.lock_write().unlock)
4439
4439
if location is not None:
4441
mergeable = bundle.read_mergeable_from_url(location,
4442
possible_transports=possible_transports)
4441
mergeable = _mod_mergeable.read_mergeable_from_url(
4442
location, possible_transports=possible_transports)
4443
4443
except errors.NotABundle:
4444
4444
mergeable = None
5260
5260
return self._run(b, revision_id_list, revision)
5262
5262
def _run(self, b, revision_id_list, revision):
5263
from .repository import WriteGroup
5263
5264
gpg_strategy = gpg.GPGStrategy(b.get_config_stack())
5264
5265
if revision_id_list is not None:
5265
b.repository.start_write_group()
5266
with WriteGroup(b.repository):
5267
5267
for revision_id in revision_id_list:
5268
5268
revision_id = cache_utf8.encode(revision_id)
5269
5269
b.repository.sign_revision(revision_id, gpg_strategy)
5270
except BaseException:
5271
b.repository.abort_write_group()
5274
b.repository.commit_write_group()
5275
5270
elif revision is not None:
5276
5271
if len(revision) == 1:
5277
5272
revno, rev_id = revision[0].in_history(b)
5278
b.repository.start_write_group()
5273
with WriteGroup(b.repository):
5280
5274
b.repository.sign_revision(rev_id, gpg_strategy)
5281
except BaseException:
5282
b.repository.abort_write_group()
5285
b.repository.commit_write_group()
5286
5275
elif len(revision) == 2:
5287
5276
# are they both on rh- if so we can walk between them
5288
5277
# might be nice to have a range helper for arbitrary
5294
5283
if from_revno is None or to_revno is None:
5295
5284
raise errors.BzrCommandError(
5296
5285
gettext('Cannot sign a range of non-revision-history revisions'))
5297
b.repository.start_write_group()
5286
with WriteGroup(b.repository):
5299
5287
for revno in range(from_revno, to_revno + 1):
5300
5288
b.repository.sign_revision(b.get_rev_id(revno),
5302
except BaseException:
5303
b.repository.abort_write_group()
5306
b.repository.commit_write_group()
5308
5291
raise errors.BzrCommandError(
5309
5292
gettext('Please supply either one revision, or a range.'))
7018
7001
grep.versioned_grep(opts)
7004
class cmd_patch(Command):
7005
"""Apply a named patch to the current tree.
7009
takes_args = ['filename?']
7010
takes_options = [Option('strip', type=int, short_name='p',
7011
help=("Strip the smallest prefix containing num "
7012
"leading slashes from filenames.")),
7013
Option('silent', help='Suppress chatter.')]
7015
def run(self, filename=None, strip=None, silent=False):
7016
from .patch import patch_tree
7017
wt = WorkingTree.open_containing('.')[0]
7021
if filename is None:
7022
my_file = getattr(sys.stdin, 'buffer', sys.stdin)
7024
my_file = open(filename, 'rb')
7025
patches = [my_file.read()]
7026
return patch_tree(wt, patches, strip, quiet=is_quiet(), out=self.outf)
7029
class cmd_resolve_location(Command):
7030
__doc__ = """Expand a location to a full URL.
7033
Look up a Launchpad URL.
7035
brz resolve-location lp:brz
7037
takes_args = ['location']
7040
def run(self, location):
7041
from .location import location_to_url
7042
url = location_to_url(location)
7043
display_url = urlutils.unescape_for_display(url, self.outf.encoding)
7044
self.outf.write('%s\n' % display_url)
7021
7047
def _register_lazy_builtins():
7022
7048
# register lazy builtins from other modules; called at startup and should
7023
7049
# be only called once.