26
__version__ = '0.19.0'
29
version_info = tuple(int(n) for n in __version__.split('.'))
32
def check_bzrlib_version(desired):
33
"""Check that bzrlib is compatible.
35
If version is < bzrtools version, assume incompatible.
36
If version == bzrtools version, assume completely compatible
37
If version == bzrtools version + 1, assume compatible, with deprecations
38
Otherwise, assume incompatible.
40
desired_plus = (desired[0], desired[1]+1)
41
bzrlib_version = bzrlib.version_info[:2]
42
if bzrlib_version == desired or (bzrlib_version == desired_plus and
43
bzrlib.version_info[3] == 'dev'):
46
from bzrlib.trace import warning
48
# get the message out any way we can
49
from warnings import warn as warning
50
if bzrlib_version < desired:
51
warning('Installed Bazaar version %s is too old to be used with'
53
'"Bzrtools" %s.' % (bzrlib.__version__, __version__))
54
# Not using BzrNewError, because it may not exist.
55
raise Exception, ('Version mismatch', version_info)
57
warning('Plugin "Bzrtools" is not up to date with installed Bazaar'
59
' There should be a newer version of Bzrtools available, e.g.'
61
% (bzrlib.__version__, bzrlib_version[0], bzrlib_version[1]))
62
if bzrlib_version != desired_plus:
63
raise Exception, 'Version mismatch'
66
check_bzrlib_version(version_info[:2])
25
68
from bzrlib.lazy_import import lazy_import
26
69
lazy_import(globals(), """
27
from bzrlib import help, urlutils
70
from bzrlib import help
31
from version import version_info, __version__
32
from command import BzrToolsCommand
33
74
from errors import CommandError, NoPyBaz
34
75
from patchsource import BzrPatchSource
38
79
import bzrlib.builtins
39
80
import bzrlib.commands
40
from bzrlib.branch import Branch
41
from bzrlib.bzrdir import BzrDir
42
81
from bzrlib.commands import get_cmd_object
43
82
from bzrlib.errors import BzrCommandError
44
83
import bzrlib.ignores
45
from bzrlib.trace import note
46
84
from bzrlib.option import Option
47
85
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__),
51
from command import BzrToolsCommand
53
90
bzrlib.ignores.add_runtime_ignores(['./.shelf'])
56
class cmd_clean_tree(BzrToolsCommand):
93
class cmd_clean_tree(bzrlib.commands.Command):
57
94
"""Remove unwanted files from working tree.
59
96
By default, only unknown files, not ignored files, are deleted. Versioned
148
185
max_distance=max_distance)
151
class cmd_fetch_ghosts(BzrToolsCommand):
188
class cmd_fetch_ghosts(bzrlib.commands.Command):
152
189
"""Attempt to retrieve ghosts from another branch.
153
190
If the other branch is not supplied, the last-pulled branch is used.
163
200
each file name found in the patch file."""
166
class cmd_patch(BzrToolsCommand):
203
class cmd_patch(bzrlib.commands.Command):
167
204
"""Apply a named patch to the current tree.
169
206
takes_args = ['filename?']
178
215
return patch(wt, filename, strip, silent)
181
class cmd_shelve(BzrToolsCommand):
218
class cmd_shelve(bzrlib.commands.Command):
182
219
"""Temporarily set aside some changes from the current tree.
184
221
Shelve allows you to temporarily put changes you've made "on the shelf",
363
class cmd_shell(BzrToolsCommand):
400
class cmd_shell(bzrlib.commands.Command):
364
401
"""Begin an interactive shell tailored for bzr.
365
402
Bzr commands can be used without typing bzr first, and will be run natively
366
403
when possible. Tab completion is tailored for bzr. The shell prompt shows
409
446
the branch has no new commits (relative to its parent).
411
448
takes_options = [Option("branch", help="Remove associated branch from"
413
Option('force', help='Delete tree even if contents are'
415
450
takes_args = ["checkout"]
416
def run(self, checkout, branch=False, force=False):
451
def run(self, checkout, branch=False):
417
452
from zap import zap
418
return zap(checkout, remove_branch=branch, allow_modified=force)
421
class cmd_cbranch(BzrToolsCommand):
453
return zap(checkout, remove_branch=branch)
456
class cmd_cbranch(bzrlib.commands.Command):
423
458
Create a new checkout, associated with a new repository branch.
446
481
revision=revision)
449
class cmd_branches(BzrToolsCommand):
484
class cmd_branches(bzrlib.commands.Command):
450
485
"""Scan a location for branches"""
451
486
takes_args = ["location?"]
452
487
def run(self, location=None):
454
489
return branches(location)
457
class cmd_multi_pull(BzrToolsCommand):
492
class cmd_multi_pull(bzrlib.commands.Command):
458
493
"""Pull all the branches under a location, e.g. a repository.
460
495
Both branches present in the directory and the branches of checkouts are
463
498
takes_args = ["location?"]
464
499
def run(self, location=None):
500
from bzrlib.branch import Branch
465
501
from bzrlib.transport import get_transport
466
502
from bzrtools import iter_branch_tree
467
503
if location is None:
469
505
t = get_transport(location)
470
possible_transports = []
471
506
if not t.listable():
472
507
print "Can't list this type of location."
490
525
print "Pulling %s from %s" % (relpath, parent)
492
branch_t = get_transport(parent, possible_transports)
493
pullable.pull(Branch.open_from_transport(branch_t))
527
pullable.pull(Branch.open(parent))
494
528
except Exception, e:
498
class cmd_import(BzrToolsCommand):
532
class cmd_branch_mark(bzrlib.commands.Command):
534
Add, view or list branch markers <EXPERIMENTAL>
536
To add a mark, do 'bzr branch-mark MARK'.
537
To list marks, do 'bzr branch-mark' (this lists all marks for the branch's
539
To delete a mark, do 'bzr branch-mark --delete MARK'
541
These marks can be used to track a branch's status.
543
takes_args = ['mark?', 'branch?']
544
takes_options = [Option('delete', help='Delete this mark.')]
545
def run(self, mark=None, branch=None, delete=False):
546
from branch_mark import branch_mark
547
branch_mark(mark, branch, delete)
550
class cmd_import(bzrlib.commands.Command):
499
551
"""Import sources from a directory, tarball or zip file
501
553
This command will import a directory, tarball or zip file into a bzr
515
567
do_import(source, tree)
518
class cmd_cdiff(BzrToolsCommand):
570
class cmd_cdiff(bzrlib.commands.Command):
519
571
"""A color version of bzr's diff"""
520
572
takes_args = property(lambda x: get_cmd_object('diff').takes_args)
521
573
takes_options = list(get_cmd_object('diff').takes_options) + [
528
580
colordiff(check_style, *args, **kwargs)
531
class cmd_baz_import(BzrToolsCommand):
583
class cmd_baz_import(bzrlib.commands.Command):
532
584
"""Import an Arch or Baz archive into a bzr repository.
534
586
This command should be used on local archives (or mirrors) only. It is
570
622
print "This command is disabled. Please install PyBaz."
573
class cmd_baz_import_branch(BzrToolsCommand):
625
class cmd_baz_import_branch(bzrlib.commands.Command):
574
626
"""Import an Arch or Baz branch into a bzr branch.
576
628
WARNING: Encoding should not be specified unless necessary, because if you
600
652
print "This command is disabled. Please install PyBaz."
603
class cmd_rspush(BzrToolsCommand):
655
class cmd_rspush(bzrlib.commands.Command):
604
656
"""Upload this branch to another location using rsync.
606
658
If no location is specified, the last-used location will be used. To
622
674
working_tree=not no_tree)
677
class cmd_switch(bzrlib.commands.Command):
678
"""Set the branch of a lightweight checkout and update."""
680
takes_args = ['to_location']
682
def run(self, to_location):
683
from switch import cmd_switch
684
cmd_switch().run(to_location)
627
689
cmd_baz_import_branch,
629
691
cmd_branch_history,