169
186
takes_args = ['file*']
170
187
takes_options = ['show-ids', 'revision',
171
Option('short', help='Give short SVN-style status lines.'),
172
Option('versioned', help='Only show versioned files.')]
188
Option('short', help='Give short SVN-style status lines'),
189
Option('versioned', help='Only show versioned files')]
173
190
aliases = ['st', 'stat']
175
192
encoding_type = 'replace'
176
_see_also = ['diff', 'revert', 'status-flags']
193
_see_also = ['diff', 'revert']
179
196
def run(self, show_ids=False, file_list=None, revision=None, short=False,
676
676
takes_options = ['remember', 'overwrite', 'verbose',
677
677
Option('create-prefix',
678
678
help='Create the path leading up to the branch '
679
'if it does not already exist.'),
679
'if it does not already exist'),
680
680
Option('directory',
681
help='Branch to push from, '
682
'rather than the one containing the working directory.',
681
help='branch to push from, '
682
'rather than the one containing the working directory',
686
686
Option('use-existing-dir',
687
687
help='By default push will fail if the target'
688
688
' directory exists, but does not already'
689
' have a control directory. This flag will'
689
' have a control directory. This flag will'
690
690
' allow push to proceed.'),
692
692
takes_args = ['location?']
1025
1022
tree.lock_tree_write()
1027
1024
existing_pending_merges = tree.get_parent_ids()[1:]
1028
last_rev = _mod_revision.ensure_null(tree.last_revision())
1029
if last_rev == _mod_revision.ensure_null(
1030
tree.branch.last_revision()):
1025
last_rev = tree.last_revision()
1026
if last_rev == tree.branch.last_revision():
1031
1027
# may be up to date, check master too.
1032
1028
master = tree.branch.get_master_branch()
1033
if master is None or last_rev == _mod_revision.ensure_null(
1034
master.last_revision()):
1029
if master is None or last_rev == master.last_revision():
1035
1030
revno = tree.branch.revision_id_to_revno(last_rev)
1036
1031
note("Tree is up to date at revision %d." % (revno,))
1038
conflicts = tree.update(delta._ChangeReporter(
1039
unversioned_filter=tree.is_ignored))
1040
revno = tree.branch.revision_id_to_revno(
1041
_mod_revision.ensure_null(tree.last_revision()))
1033
conflicts = tree.update()
1034
revno = tree.branch.revision_id_to_revno(tree.last_revision())
1042
1035
note('Updated to revision %d.' % (revno,))
1043
1036
if tree.get_parent_ids()[1:] != existing_pending_merges:
1044
1037
note('Your local commits will now show as pending merges with '
1344
1336
takes_args = ["location"]
1345
1337
takes_options = [RegistryOption('format',
1346
1338
help='Specify a format for this repository. See'
1347
' "bzr help formats" for details.',
1339
' "bzr help formats" for details',
1348
1340
registry=bzrdir.format_registry,
1349
1341
converter=bzrdir.format_registry.make_bzrdir,
1350
1342
value_switches=True, title='Repository format'),
1351
1343
Option('no-trees',
1352
1344
help='Branches in the repository will default to'
1353
' not having a working tree.'),
1345
' not having a working tree'),
1355
1347
aliases = ["init-repo"]
1603
1592
# TODO: Make --revision support uuid: and hash: [future tag:] notation.
1605
1594
takes_args = ['location?']
1608
help='Show from oldest to newest.'),
1611
help='Display timezone as local, original, or utc.'),
1614
help='Show files changed in each revision.'),
1620
help='Show revisions whose message matches this '
1621
'regular expression.',
1624
help='Limit the output to the first N revisions.',
1595
takes_options = [Option('forward',
1596
help='show from oldest to newest'),
1600
help='show files changed in each revision'),
1601
'show-ids', 'revision',
1605
help='show revisions whose message matches this regexp',
1608
help='limit the output to the first N revisions',
1628
1611
encoding_type = 'replace'
1630
1613
@display_command
1682
1665
raise errors.BzrCommandError(
1683
1666
"Log doesn't accept two revisions in different"
1685
rev1 = revision[0].in_history(b)
1686
rev2 = revision[1].in_history(b)
1668
if revision[0].spec is None:
1669
# missing begin-range means first revision
1672
rev1 = revision[0].in_history(b).revno
1674
if revision[1].spec is None:
1675
# missing end-range means last known revision
1678
rev2 = revision[1].in_history(b).revno
1688
1680
raise errors.BzrCommandError(
1689
1681
'bzr log --revision takes one or two values.')
1683
# By this point, the revision numbers are converted to the +ve
1684
# form if they were supplied in the -ve form, so we can do
1685
# this comparison in relative safety
1687
(rev2, rev1) = (rev1, rev2)
1691
1689
if log_format is None:
1692
1690
log_format = log.log_formatter_registry.get_default(b)
1743
1741
_see_also = ['status', 'cat']
1744
1742
takes_args = ['path?']
1745
1743
# TODO: Take a revision or remote path and list that tree instead.
1749
Option('non-recursive',
1750
help='Don\'t recurse into subdirectories.'),
1752
help='Print paths relative to the root of the branch.'),
1753
Option('unknown', help='Print unknown files.'),
1754
Option('versioned', help='Print versioned files.'),
1755
Option('ignored', help='Print ignored files.'),
1757
help='Write an ascii NUL (\\0) separator '
1758
'between files rather than a newline.'),
1760
help='List entries of a particular kind: file, directory, symlink.',
1744
takes_options = ['verbose', 'revision',
1745
Option('non-recursive',
1746
help='don\'t recurse into sub-directories'),
1748
help='Print all paths from the root of the branch.'),
1749
Option('unknown', help='Print unknown files'),
1750
Option('versioned', help='Print versioned files'),
1751
Option('ignored', help='Print ignored files'),
1753
Option('null', help='Null separate the files'),
1764
1756
@display_command
1765
def run(self, revision=None, verbose=False,
1757
def run(self, revision=None, verbose=False,
1766
1758
non_recursive=False, from_root=False,
1767
1759
unknown=False, versioned=False, ignored=False,
1768
1760
null=False, kind=None, show_ids=False, path=None):
2140
2121
_see_also = ['bugs', 'uncommit']
2141
2122
takes_args = ['selected*']
2143
Option('message', type=unicode,
2145
help="Description of the new revision."),
2148
help='Commit even if nothing has changed.'),
2149
Option('file', type=str,
2152
help='Take commit message from this file.'),
2154
help="Refuse to commit if there are unknown "
2155
"files in the working tree."),
2156
ListOption('fixes', type=str,
2157
help="Mark a bug as being fixed by this revision."),
2159
help="Perform a local commit in a bound "
2160
"branch. Local commits are not pushed to "
2161
"the master branch until a normal commit "
2123
takes_options = ['message', 'verbose',
2125
help='commit even if nothing has changed'),
2126
Option('file', type=str,
2129
help='file containing commit message'),
2131
help="refuse to commit if there are unknown "
2132
"files in the working tree."),
2133
ListOption('fixes', type=str,
2134
help="mark a bug as being fixed by this "
2137
help="perform a local only commit in a bound "
2138
"branch. Such commits are not pushed to "
2139
"the master branch until a normal commit "
2165
2143
aliases = ['ci', 'checkin']
2167
2145
def _get_bug_fix_properties(self, fixes, branch):
2408
2386
modified by plugins will not be tested, and tests provided by plugins will
2411
Tests that need working space on disk use a common temporary directory,
2412
typically inside $TMPDIR or /tmp.
2415
2390
bzr selftest ignore
2416
2391
run only tests relating to 'ignore'
2417
2392
bzr --no-plugins selftest -v
2418
2393
disable plugins and list tests as they're run
2395
For each test, that needs actual disk access, bzr create their own
2396
subdirectory in the temporary testing directory (testXXXX.tmp).
2397
By default the name of such subdirectory is based on the name of the test.
2398
If option '--numbered-dirs' is given, bzr will use sequent numbers
2399
of running tests to create such subdirectories. This is default behavior
2400
on Windows because of path length limitation.
2420
2402
# NB: this is used from the class without creating an instance, which is
2421
2403
# why it does not have a self parameter.
2438
2420
takes_args = ['testspecs*']
2439
2421
takes_options = ['verbose',
2441
help='Stop when one test fails.',
2423
help='stop when one test fails',
2442
2424
short_name='1',
2426
Option('keep-output',
2427
help='keep output directories when tests fail'),
2444
2428
Option('transport',
2445
2429
help='Use a different transport by default '
2446
2430
'throughout the test suite.',
2447
2431
type=get_transport_type),
2449
help='Run the benchmarks rather than selftests.'),
2432
Option('benchmark', help='run the bzr benchmarks.'),
2450
2433
Option('lsprof-timed',
2451
help='Generate lsprof output for benchmarked'
2434
help='generate lsprof output for benchmarked'
2452
2435
' sections of code.'),
2453
2436
Option('cache-dir', type=str,
2454
help='Cache intermediate benchmark output in this '
2437
help='a directory to cache intermediate'
2438
' benchmark steps'),
2439
Option('clean-output',
2440
help='clean temporary tests directories'
2441
' without running tests'),
2456
2442
Option('first',
2457
help='Run all tests, but run specified tests first.',
2443
help='run all tests, but run specified tests first',
2458
2444
short_name='f',
2446
Option('numbered-dirs',
2447
help='use numbered dirs for TestCaseInTempDir'),
2460
2448
Option('list-only',
2461
help='List the tests instead of running them.'),
2449
help='list the tests instead of running them'),
2462
2450
Option('randomize', type=str, argname="SEED",
2463
help='Randomize the order of tests using the given'
2464
' seed or "now" for the current time.'),
2451
help='randomize the order of tests using the given'
2452
' seed or "now" for the current time'),
2465
2453
Option('exclude', type=str, argname="PATTERN",
2466
2454
short_name='x',
2467
help='Exclude tests that match this regular'
2455
help='exclude tests that match this regular'
2470
2458
encoding_type = 'replace'
2472
2460
def run(self, testspecs_list=None, verbose=None, one=False,
2473
transport=None, benchmark=None,
2474
lsprof_timed=None, cache_dir=None,
2475
first=False, list_only=False,
2461
keep_output=False, transport=None, benchmark=None,
2462
lsprof_timed=None, cache_dir=None, clean_output=False,
2463
first=False, numbered_dirs=None, list_only=False,
2476
2464
randomize=None, exclude=None):
2477
2465
import bzrlib.ui
2478
2466
from bzrlib.tests import selftest
2479
2467
import bzrlib.benchmarks as benchmarks
2480
2468
from bzrlib.benchmarks import tree_creator
2481
from bzrlib.version import show_version
2471
from bzrlib.tests import clean_selftest_output
2472
clean_selftest_output()
2475
warning("notice: selftest --keep-output "
2476
"is no longer supported; "
2477
"test output is always removed")
2479
if numbered_dirs is None and sys.platform == 'win32':
2480
numbered_dirs = True
2483
2482
if cache_dir is not None:
2484
2483
tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
2486
show_version(show_config=False, show_copyright=False)
2484
print '%10s: %s' % ('bzr', osutils.realpath(sys.argv[0]))
2485
print '%10s: %s' % ('bzrlib', bzrlib.__path__[0])
2488
2487
if testspecs_list is not None:
2489
2488
pattern = '|'.join(testspecs_list)
2609
2609
--force is given.
2612
_see_also = ['update', 'remerge', 'status-flags']
2612
_see_also = ['update', 'remerge']
2613
2613
takes_args = ['branch?']
2617
help='Merge even if the destination tree has uncommitted changes.'),
2614
takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
2621
2615
Option('show-base', help="Show base revision text in "
2623
2617
Option('uncommitted', help='Apply uncommitted changes'
2624
' from a working copy, instead of branch changes.'),
2618
' from a working copy, instead of branch changes'),
2625
2619
Option('pull', help='If the destination is already'
2626
2620
' completely merged into the source, pull from the'
2627
' source rather than merging. When this happens,'
2621
' source rather than merging. When this happens,'
2628
2622
' you do not need to commit the result.'),
2629
2623
Option('directory',
2630
help='Branch to merge into, '
2631
'rather than the one containing the working directory.',
2624
help='Branch to merge into, '
2625
'rather than the one containing the working directory',
2637
2631
def run(self, branch=None, revision=None, force=False, merge_type=None,
2655
2650
change_reporter = delta._ChangeReporter(
2656
2651
unversioned_filter=tree.is_ignored)
2658
other_transport = None
2659
other_revision_id = None
2660
base_revision_id = None
2661
possible_transports = []
2663
2653
if branch is not None:
2664
mergeable, other_transport = _get_bundle_helper(branch)
2655
mergeable = bundle.read_mergeable_from_url(
2657
except errors.NotABundle:
2658
pass # Continue on considering this url a Branch
2666
2660
if revision is not None:
2667
2661
raise errors.BzrCommandError(
2668
2662
'Cannot use -r with merge directives or bundles')
2669
mergeable.install_revisions(tree.branch.repository)
2670
base_revision_id, other_revision_id, verified =\
2671
mergeable.get_merge_request(tree.branch.repository)
2672
if base_revision_id in tree.branch.repository.get_ancestry(
2673
tree.branch.last_revision(), topo_sorted=False):
2674
base_revision_id = None
2679
possible_transports.append(other_transport)
2681
if other_revision_id is None:
2682
verified = 'inapplicable'
2683
if revision is None \
2684
or len(revision) < 1 or revision[0].needs_branch():
2685
branch = self._get_remembered_parent(tree, branch,
2688
if revision is None or len(revision) < 1:
2691
other = [branch, None]
2663
other_revision_id = mergeable.install_revisions(
2664
tree.branch.repository)
2665
revision = [RevisionSpec.from_string(
2666
'revid:' + other_revision_id)]
2668
if revision is None \
2669
or len(revision) < 1 or revision[0].needs_branch():
2670
branch = self._get_remembered_parent(tree, branch, 'Merging from')
2672
if revision is None or len(revision) < 1:
2675
other = [branch, None]
2678
other = [branch, -1]
2679
other_branch, path = Branch.open_containing(branch)
2682
raise errors.BzrCommandError('Cannot use --uncommitted and'
2683
' --revision at the same time.')
2684
branch = revision[0].get_branch() or branch
2685
if len(revision) == 1:
2687
if other_revision_id is not None:
2694
other = [branch, -1]
2695
other_branch, path = Branch.open_containing(branch,
2696
possible_transports)
2699
raise errors.BzrCommandError('Cannot use --uncommitted and'
2700
' --revision at the same time.')
2701
branch = revision[0].get_branch() or branch
2702
if len(revision) == 1:
2704
other_branch, path = Branch.open_containing(
2705
branch, possible_transports)
2692
other_branch, path = Branch.open_containing(branch)
2706
2693
revno = revision[0].in_history(other_branch).revno
2707
2694
other = [branch, revno]
2709
assert len(revision) == 2
2710
if None in revision:
2711
raise errors.BzrCommandError(
2712
"Merge doesn't permit empty revision specifier.")
2713
base_branch, path = Branch.open_containing(
2714
branch, possible_transports)
2715
branch1 = revision[1].get_branch() or branch
2716
other_branch, path1 = Branch.open_containing(
2717
branch1, possible_transports)
2718
if revision[0].get_branch() is not None:
2719
# then path was obtained from it, and is None.
2722
base = [branch, revision[0].in_history(base_branch).revno]
2724
revision[1].in_history(other_branch).revno]
2726
# Remember where we merge from
2696
assert len(revision) == 2
2697
if None in revision:
2698
raise errors.BzrCommandError(
2699
"Merge doesn't permit empty revision specifier.")
2700
base_branch, path = Branch.open_containing(branch)
2701
branch1 = revision[1].get_branch() or branch
2702
other_branch, path1 = Branch.open_containing(branch1)
2703
if revision[0].get_branch() is not None:
2704
# then path was obtained from it, and is None.
2707
base = [branch, revision[0].in_history(base_branch).revno]
2708
other = [branch1, revision[1].in_history(other_branch).revno]
2727
2710
if ((tree.branch.get_parent() is None or remember) and
2728
2711
other_branch is not None):
2729
2712
tree.branch.set_parent(other_branch.base)
2862
2838
restore(tree.abspath(filename))
2863
2839
except errors.NotConflicted:
2865
# Disable pending merges, because the file texts we are remerging
2866
# have not had those merges performed. If we use the wrong parents
2867
# list, we imply that the working tree text has seen and rejected
2868
# all the changes from the other tree, when in fact those changes
2869
# have not yet been seen.
2870
tree.set_parent_ids(parents[:1])
2872
conflicts = _mod_merge.merge_inner(
2873
tree.branch, other_tree, base_tree,
2875
interesting_ids=interesting_ids,
2876
other_rev_id=parents[1],
2877
merge_type=merge_type,
2878
show_base=show_base,
2879
reprocess=reprocess)
2881
tree.set_parent_ids(parents)
2841
conflicts = _mod_merge.merge_inner(
2842
tree.branch, other_tree, base_tree,
2844
interesting_ids=interesting_ids,
2845
other_rev_id=parents[1],
2846
merge_type=merge_type,
2847
show_base=show_base,
2848
reprocess=reprocess)
2884
2851
if conflicts > 0:
3007
2969
_see_also = ['merge', 'pull']
3008
2970
takes_args = ['other_branch?']
3010
Option('reverse', 'Reverse the order of revisions.'),
3012
'Display changes in the local branch only.'),
3013
Option('this' , 'Same as --mine-only.'),
3014
Option('theirs-only',
3015
'Display changes in the remote branch only.'),
3016
Option('other', 'Same as --theirs-only.'),
2971
takes_options = [Option('reverse', 'Reverse the order of revisions'),
2973
'Display changes in the local branch only'),
2974
Option('this' , 'same as --mine-only'),
2975
Option('theirs-only',
2976
'Display changes in the remote branch only'),
2977
Option('other', 'same as --theirs-only'),
3021
2982
encoding_type = 'replace'
3023
2984
@display_command
3100
3057
return status_code
3103
class cmd_pack(Command):
3104
"""Compress the data within a repository."""
3106
_see_also = ['repositories']
3107
takes_args = ['branch_or_repo?']
3109
def run(self, branch_or_repo='.'):
3110
dir = bzrdir.BzrDir.open_containing(branch_or_repo)[0]
3112
branch = dir.open_branch()
3113
repository = branch.repository
3114
except errors.NotBranchError:
3115
repository = dir.open_repository()
3119
3060
class cmd_plugins(Command):
3120
"""List the installed plugins.
3122
This command displays the list of installed plugins including the
3123
path where each one is located and a short description of each.
3125
A plugin is an external component for Bazaar that extends the
3126
revision control system, by adding or replacing code in Bazaar.
3127
Plugins can do a variety of things, including overriding commands,
3128
adding new commands, providing additional network transports and
3129
customizing log output.
3131
See the Bazaar web site, http://bazaar-vcs.org, for further
3132
information on plugins including where to find them and how to
3133
install them. Instructions are also provided there on how to
3134
write new plugins using the Python programming language.
3137
3063
@display_command
3139
3065
import bzrlib.plugin
3196
3121
# with new uncommitted lines marked
3197
3122
aliases = ['ann', 'blame', 'praise']
3198
3123
takes_args = ['filename']
3199
takes_options = [Option('all', help='Show annotations on all lines.'),
3200
Option('long', help='Show commit date in annotations.'),
3124
takes_options = [Option('all', help='show annotations on all lines'),
3125
Option('long', help='show date in annotations'),
3204
encoding_type = 'exact'
3206
3130
@display_command
3207
3131
def run(self, filename, all=False, long=False, revision=None,
3444
3366
takes_options = [
3446
help='Serve on stdin/out for use from inetd or sshd.'),
3368
help='serve on stdin/out for use from inetd or sshd'),
3448
help='Listen for connections on nominated port of the form '
3449
'[hostname:]portnumber. Passing 0 as the port number will '
3450
'result in a dynamically allocated port. The default port is '
3370
help='listen for connections on nominated port of the form '
3371
'[hostname:]portnumber. Passing 0 as the port number will '
3372
'result in a dynamically allocated port. Default port is '
3453
3375
Option('directory',
3454
help='Serve contents of this directory.',
3376
help='serve contents of directory',
3456
3378
Option('allow-writes',
3457
help='By default the server is a readonly server. Supplying '
3379
help='By default the server is a readonly server. Supplying '
3458
3380
'--allow-writes enables write access to the contents of '
3459
'the served directory and below.'
3381
'the served directory and below. '
3603
3523
takes_args = ['submit_branch?', 'public_branch?']
3607
_see_also = ['submit']
3609
3525
takes_options = [
3610
3526
RegistryOption.from_kwargs('patch-type',
3611
3527
'The type of patch to include in the directive',
3613
value_switches=True,
3615
bundle='Bazaar revision bundle (default).',
3616
diff='Normal unified diff.',
3617
plain='No patch, just directive.'),
3618
Option('sign', help='GPG-sign the directive.'), 'revision',
3528
title='Patch type', value_switches=True, enum_switch=False,
3529
bundle='Bazaar revision bundle (default)',
3530
diff='Normal unified diff',
3531
plain='No patch, just directive'),
3532
Option('sign', help='GPG-sign the directive'), 'revision',
3619
3533
Option('mail-to', type=str,
3620
help='Instead of printing the directive, email to this address.'),
3534
help='Instead of printing the directive, email to this address'),
3621
3535
Option('message', type=str, short_name='m',
3622
help='Message to use when committing this merge.')
3536
help='Message to use when committing this merge')
3625
3539
encoding_type = 'exact'
3649
3560
public_branch = stored_public_branch
3650
3561
elif stored_public_branch is None:
3651
3562
branch.set_public_branch(public_branch)
3652
if not include_bundle and public_branch is None:
3563
if patch_type != "bundle" and public_branch is None:
3653
3564
raise errors.BzrCommandError('No public branch specified or'
3655
base_revision_id = None
3656
3566
if revision is not None:
3657
if len(revision) > 2:
3567
if len(revision) != 1:
3658
3568
raise errors.BzrCommandError('bzr merge-directive takes '
3659
'at most two one revision identifiers')
3660
revision_id = revision[-1].in_history(branch).rev_id
3661
if len(revision) == 2:
3662
base_revision_id = revision[0].in_history(branch).rev_id
3663
base_revision_id = ensure_null(base_revision_id)
3569
'exactly one revision identifier')
3571
revision_id = revision[0].in_history(branch).rev_id
3665
3573
revision_id = branch.last_revision()
3666
3574
revision_id = ensure_null(revision_id)
3667
3575
if revision_id == NULL_REVISION:
3668
3576
raise errors.BzrCommandError('No revisions to bundle.')
3669
directive = merge_directive.MergeDirective2.from_objects(
3577
directive = merge_directive.MergeDirective.from_objects(
3670
3578
branch.repository, revision_id, time.time(),
3671
3579
osutils.local_time_offset(), submit_branch,
3672
public_branch=public_branch, include_patch=include_patch,
3673
include_bundle=include_bundle, message=message,
3674
base_revision_id=base_revision_id)
3580
public_branch=public_branch, patch_type=patch_type,
3675
3582
if mail_to is None:
3677
3584
self.outf.write(directive.to_signed(branch))
3683
3590
s.send_email(message)
3686
class cmd_submit(Command):
3687
"""Create a merge-directive for submiting changes.
3689
A merge directive provides many things needed for requesting merges:
3690
- A machine-readable description of the merge to perform
3691
- An optional patch that is a preview of the changes requested
3692
- An optional bundle of revision data, so that the changes can be applied
3693
directly from the merge directive, without retrieving data from a
3696
If --no-bundle is specified, then public_branch is needed (and must be
3697
up-to-date), so that the receiver can perform the merge using the
3698
public_branch. The public_branch is always included if known, so that
3699
people can check it later.
3701
The submit branch defaults to the parent, but can be overridden. Both
3702
submit branch and public branch will be remembered if supplied.
3704
If a public_branch is known for the submit_branch, that public submit
3705
branch is used in the merge instructions. This means that a local mirror
3706
can be used as your actual submit branch, once you have set public_branch
3710
encoding_type = 'exact'
3712
aliases = ['bundle', 'bundle-revisions']
3714
_see_also = ['merge']
3716
takes_args = ['submit_branch?', 'public_branch?']
3719
help='Do not include a bundle in the merge directive.'),
3720
Option('no-patch', help='Do not include a preview patch in the merge'
3723
help='Remember submit and public branch.'),
3725
help='Branch to generate the submission from, '
3726
'rather than the one containing the working directory.',
3729
Option('output', short_name='o', help='Write directive to this file.',
3734
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
3735
no_patch=False, revision=None, remember=False, output=None,
3737
from bzrlib.revision import ensure_null, NULL_REVISION
3741
outfile = open(output, 'wb')
3743
from_ = kwargs.get('from', '.')
3744
branch = Branch.open_containing(from_)[0]
3745
if remember and submit_branch is None:
3746
raise errors.BzrCommandError(
3747
'--remember requires a branch to be specified.')
3748
stored_submit_branch = branch.get_submit_branch()
3749
remembered_submit_branch = False
3750
if submit_branch is None:
3751
submit_branch = stored_submit_branch
3752
remembered_submit_branch = True
3754
if stored_submit_branch is None or remember:
3755
branch.set_submit_branch(submit_branch)
3756
if submit_branch is None:
3757
submit_branch = branch.get_parent()
3758
remembered_submit_branch = True
3759
if submit_branch is None:
3760
raise errors.BzrCommandError('No submit branch known or'
3762
if remembered_submit_branch:
3763
note('Using saved location: %s', submit_branch)
3765
stored_public_branch = branch.get_public_branch()
3766
if public_branch is None:
3767
public_branch = stored_public_branch
3768
elif stored_public_branch is None or remember:
3769
branch.set_public_branch(public_branch)
3770
if no_bundle and public_branch is None:
3771
raise errors.BzrCommandError('No public branch specified or'
3773
base_revision_id = None
3774
if revision is not None:
3775
if len(revision) > 2:
3776
raise errors.BzrCommandError('bzr submit takes '
3777
'at most two one revision identifiers')
3778
revision_id = revision[-1].in_history(branch).rev_id
3779
if len(revision) == 2:
3780
base_revision_id = revision[0].in_history(branch).rev_id
3781
base_revision_id = ensure_null(base_revision_id)
3783
revision_id = branch.last_revision()
3784
revision_id = ensure_null(revision_id)
3785
if revision_id == NULL_REVISION:
3786
raise errors.BzrCommandError('No revisions to submit.')
3787
directive = merge_directive.MergeDirective2.from_objects(
3788
branch.repository, revision_id, time.time(),
3789
osutils.local_time_offset(), submit_branch,
3790
public_branch=public_branch, include_patch=not no_patch,
3791
include_bundle=not no_bundle, message=None,
3792
base_revision_id=base_revision_id)
3793
outfile.writelines(directive.to_lines())
3795
if output is not None:
3798
3593
class cmd_tag(Command):
3799
3594
"""Create a tag naming a revision.
3998
3787
cur_transport = new_transport
4001
3791
# Now we only need to create child directories
4003
3793
cur_transport = needed.pop()
4004
3794
cur_transport.ensure_base()
4007
def _get_bundle_helper(location):
4008
"""Get a bundle if 'location' points to one.
4010
Try try to identify a bundle and returns its mergeable form. If it's not,
4011
we return the tried transport anyway so that it can reused to access the
4014
:param location: can point to a bundle or a branch.
4016
:return: mergeable, transport
4019
url = urlutils.normalize_url(location)
4020
url, filename = urlutils.split(url, exclude_trailing_slash=False)
4021
location_transport = transport.get_transport(url)
4024
# There may be redirections but we ignore the intermediate
4025
# and final transports used
4026
read = bundle.read_mergeable_from_transport
4027
mergeable, t = read(location_transport, filename)
4028
except errors.NotABundle:
4029
# Continue on considering this url a Branch but adjust the
4030
# location_transport
4031
location_transport = location_transport.clone(filename)
4032
return mergeable, location_transport
4035
3796
# Compatibility
4036
3797
merge = _merge_helper