842
_see_also = ['push', 'update', 'status-flags']
843
_see_also = ['push', 'update', 'status-flags', 'send']
843
844
takes_options = ['remember', 'overwrite', 'revision',
844
845
custom_help('verbose',
845
846
help='Show logs of pulled revisions.'),
2440
2441
if len(matches) > 0:
2441
2442
print "Warning: the following files are version controlled and" \
2442
" match your ignore pattern:\n%s" % ("\n".join(matches),)
2443
" match your ignore pattern:\n%s" \
2444
"\nThese files will continue to be version controlled" \
2445
" unless you 'bzr remove' them." % ("\n".join(matches),)
2445
2448
class cmd_ignored(Command):
2589
2592
tree = b.basis_tree()
2590
2593
rev_tree = _get_one_revision_tree('cat', revision, branch=b)
2592
cur_file_id = tree.path2id(relpath)
2593
2595
old_file_id = rev_tree.path2id(relpath)
2595
2597
if name_from_revision:
2598
# Try in revision if requested
2596
2599
if old_file_id is None:
2597
2600
raise errors.BzrCommandError(
2598
2601
"%r is not present in revision %s" % (
2599
2602
filename, rev_tree.get_revision_id()))
2601
2604
content = rev_tree.get_file_text(old_file_id)
2602
elif cur_file_id is not None:
2603
content = rev_tree.get_file_text(cur_file_id)
2604
elif old_file_id is not None:
2605
content = rev_tree.get_file_text(old_file_id)
2607
raise errors.BzrCommandError(
2608
"%r is not present in revision %s" % (
2609
filename, rev_tree.get_revision_id()))
2606
cur_file_id = tree.path2id(relpath)
2608
if cur_file_id is not None:
2609
# Then try with the actual file id
2611
content = rev_tree.get_file_text(cur_file_id)
2613
except errors.NoSuchId:
2614
# The actual file id didn't exist at that time
2616
if not found and old_file_id is not None:
2617
# Finally try with the old file id
2618
content = rev_tree.get_file_text(old_file_id)
2621
# Can't be found anywhere
2622
raise errors.BzrCommandError(
2623
"%r is not present in revision %s" % (
2624
filename, rev_tree.get_revision_id()))
2611
2626
from bzrlib.filters import (
2612
2627
ContentFilterContext,
2698
2713
help="Refuse to commit if there are unknown "
2699
2714
"files in the working tree."),
2700
2715
ListOption('fixes', type=str,
2701
help="Mark a bug as being fixed by this revision."),
2716
help="Mark a bug as being fixed by this revision "
2717
"(see \"bzr help bugs\")."),
2702
2718
ListOption('author', type=unicode,
2703
2719
help="Set the author's name, if it's different "
2704
2720
"from the committer."),
2715
2731
aliases = ['ci', 'checkin']
2717
def _get_bug_fix_properties(self, fixes, branch):
2733
def _iter_bug_fix_urls(self, fixes, branch):
2719
2734
# Configure the properties for bug fixing attributes.
2720
2735
for fixed_bug in fixes:
2721
2736
tokens = fixed_bug.split(':')
2722
2737
if len(tokens) != 2:
2723
2738
raise errors.BzrCommandError(
2724
"Invalid bug %s. Must be in the form of 'tag:id'. "
2725
"Commit refused." % fixed_bug)
2739
"Invalid bug %s. Must be in the form of 'tracker:id'. "
2740
"See \"bzr help bugs\" for more information on this "
2741
"feature.\nCommit refused." % fixed_bug)
2726
2742
tag, bug_id = tokens
2728
bug_url = bugtracker.get_bug_url(tag, branch, bug_id)
2744
yield bugtracker.get_bug_url(tag, branch, bug_id)
2729
2745
except errors.UnknownBugTrackerAbbreviation:
2730
2746
raise errors.BzrCommandError(
2731
2747
'Unrecognized bug %s. Commit refused.' % fixed_bug)
2732
except errors.MalformedBugIdentifier:
2748
except errors.MalformedBugIdentifier, e:
2733
2749
raise errors.BzrCommandError(
2734
"Invalid bug identifier for %s. Commit refused."
2736
properties.append('%s fixed' % bug_url)
2737
return '\n'.join(properties)
2750
"%s\nCommit refused." % (str(e),))
2739
2752
def run(self, message=None, file=None, verbose=False, selected_list=None,
2740
2753
unchanged=False, strict=False, local=False, fixes=None,
2768
2781
if fixes is None:
2770
bug_property = self._get_bug_fix_properties(fixes, tree.branch)
2783
bug_property = bugtracker.encode_fixes_bug_urls(
2784
self._iter_bug_fix_urls(fixes, tree.branch))
2771
2785
if bug_property:
2772
2786
properties['bugs'] = bug_property
3344
3358
encoding_type = 'exact'
3345
_see_also = ['update', 'remerge', 'status-flags']
3359
_see_also = ['update', 'remerge', 'status-flags', 'send']
3346
3360
takes_args = ['location?']
3347
3361
takes_options = [
3390
3404
basis_tree = tree.revision_tree(tree.last_revision())
3391
3405
except errors.NoSuchRevision:
3392
3406
basis_tree = tree.basis_tree()
3393
changes = tree.changes_from(basis_tree)
3394
if changes.has_changed():
3395
raise errors.UncommittedChanges(tree)
3408
changes = tree.changes_from(basis_tree)
3409
if changes.has_changed():
3410
raise errors.UncommittedChanges(tree)
3397
3412
view_info = _get_view_info_for_change_reporter(tree)
3398
3413
change_reporter = delta._ChangeReporter(
3812
3827
OTHER_BRANCH may be local or remote.
3814
To filter on a range of revirions, you can use the command -r begin..end
3829
To filter on a range of revisions, you can use the command -r begin..end
3815
3830
-r revision requests a specific revision, -r ..end or -r begin.. are
4729
4744
default. "0.9" uses revision bundle format 0.9 and merge directive
4730
4745
format 1. It is compatible with Bazaar 0.12 - 0.18.
4732
Merge directives are applied using the merge command or the pull command.
4747
The merge directives created by bzr send may be applied using bzr merge or
4748
bzr pull by specifying a file containing a merge directive as the location.
4735
4751
encoding_type = 'exact'
4777
Option('body', help='Body for the email.', type=unicode),
4761
4778
RegistryOption.from_kwargs('format',
4762
4779
'Use the specified output format.',
4763
4780
**{'4': 'Bundle format 4, Merge Directive 2 (default)',
4767
4784
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
4768
4785
no_patch=False, revision=None, remember=False, output=None,
4769
format='4', mail_to=None, message=None, **kwargs):
4786
format='4', mail_to=None, message=None, body=None, **kwargs):
4770
4787
return self._run(submit_branch, revision, public_branch, remember,
4771
4788
format, no_bundle, no_patch, output,
4772
kwargs.get('from', '.'), mail_to, message)
4789
kwargs.get('from', '.'), mail_to, message, body)
4774
4791
def _run(self, submit_branch, revision, public_branch, remember, format,
4775
no_bundle, no_patch, output, from_, mail_to, message):
4792
no_bundle, no_patch, output, from_, mail_to, message, body):
4776
4793
from bzrlib.revision import NULL_REVISION
4777
4794
branch = Branch.open_containing(from_)[0]
4778
4795
if output is None:
4790
4807
if mail_to is None:
4791
4808
mail_to = config.get_user_option('submit_to')
4792
4809
mail_client = config.get_mail_client()
4810
if (not getattr(mail_client, 'supports_body', False)
4811
and body is not None):
4812
raise errors.BzrCommandError(
4813
'Mail client "%s" does not support specifying body' %
4814
mail_client.__class__.__name__)
4793
4815
if remember and submit_branch is None:
4794
4816
raise errors.BzrCommandError(
4795
4817
'--remember requires a branch to be specified.')
4872
4894
subject += revision.get_summary()
4873
4895
basename = directive.get_disk_name(branch)
4874
4896
mail_client.compose_merge_request(mail_to, subject,
4875
outfile.getvalue(), basename)
4877
4900
if output != '-':
4878
4901
outfile.close()
4947
4970
return self._run(submit_branch, revision, public_branch, remember,
4948
4971
format, no_bundle, no_patch, output,
4949
kwargs.get('from', '.'), None, None)
4972
kwargs.get('from', '.'), None, None, None)
4952
4975
class cmd_tag(Command):
5357
5380
class cmd_hooks(Command):
5358
"""Show a branch's currently registered hooks.
5362
takes_args = ['path?']
5364
def run(self, path=None):
5367
branch_hooks = Branch.open(path).hooks
5368
for hook_type in branch_hooks:
5369
hooks = branch_hooks[hook_type]
5370
self.outf.write("%s:\n" % (hook_type,))
5373
self.outf.write(" %s\n" %
5374
(branch_hooks.get_hook_name(hook),))
5376
self.outf.write(" <no hooks installed>\n")
5386
for hook_key in sorted(hooks.known_hooks.keys()):
5387
some_hooks = hooks.known_hooks_key_to_object(hook_key)
5388
self.outf.write("%s:\n" % type(some_hooks).__name__)
5389
for hook_name, hook_point in sorted(some_hooks.items()):
5390
self.outf.write(" %s:\n" % (hook_name,))
5391
found_hooks = list(hook_point)
5393
for hook in found_hooks:
5394
self.outf.write(" %s\n" %
5395
(some_hooks.get_hook_name(hook),))
5397
self.outf.write(" <no hooks installed>\n")
5379
5400
class cmd_shelve(Command):
5412
5433
value_switches=True, enum_switch=False),
5414
5435
Option('list', help='List shelved changes.'),
5437
help='Destroy removed changes instead of shelving them.'),
5416
5439
_see_also = ['unshelve']
5418
5441
def run(self, revision=None, all=False, file_list=None, message=None,
5419
writer=None, list=False):
5442
writer=None, list=False, destroy=False):
5421
5444
return self.run_for_list()
5422
5445
from bzrlib.shelf_ui import Shelver
5424
5447
writer = bzrlib.option.diff_writer_registry.get()
5426
5449
Shelver.from_args(writer(sys.stdout), revision, all, file_list,
5450
message, destroy=destroy).run()
5428
5451
except errors.UserAbort:
5472
5495
Unshelver.from_args(shelf_id, action).run()
5498
class cmd_clean_tree(Command):
5499
"""Remove unwanted files from working tree.
5501
By default, only unknown files, not ignored files, are deleted. Versioned
5502
files are never deleted.
5504
Another class is 'detritus', which includes files emitted by bzr during
5505
normal operations and selftests. (The value of these files decreases with
5508
If no options are specified, unknown files are deleted. Otherwise, option
5509
flags are respected, and may be combined.
5511
To check what clean-tree will do, use --dry-run.
5513
takes_options = [Option('ignored', help='Delete all ignored files.'),
5514
Option('detritus', help='Delete conflict files, merge'
5515
' backups, and failed selftest dirs.'),
5517
help='Delete files unknown to bzr (default).'),
5518
Option('dry-run', help='Show files to delete instead of'
5520
Option('force', help='Do not prompt before deleting.')]
5521
def run(self, unknown=False, ignored=False, detritus=False, dry_run=False,
5523
from bzrlib.clean_tree import clean_tree
5524
if not (unknown or ignored or detritus):
5528
clean_tree('.', unknown=unknown, ignored=ignored, detritus=detritus,
5529
dry_run=dry_run, no_prompt=force)
5475
5532
def _create_prefix(cur_transport):
5476
5533
needed = [cur_transport]
5477
5534
# Recurse upwards until we can create a directory successfully