~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Aaron Bentley
  • Date: 2006-11-23 18:06:43 UTC
  • Revision ID: abentley@panoramicfeedback.com-20061123180643-6ry3xqozdbn4cfhy
Update docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005, 2006 Aaron Bentley <aaron.bentley@utoronto.ca>
 
2
# Copyright (C) 2005, 2006 Canonical Limited.
 
3
# Copyright (C) 2006 Michael Ellerman.
 
4
#
 
5
#    This program is free software; you can redistribute it and/or modify
 
6
#    it under the terms of the GNU General Public License as published by
 
7
#    the Free Software Foundation; either version 2 of the License, or
 
8
#    (at your option) any later version.
 
9
#
 
10
#    This program is distributed in the hope that it will be useful,
 
11
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
#    GNU General Public License for more details.
 
14
#
 
15
#    You should have received a copy of the GNU General Public License
 
16
#    along with this program; if not, write to the Free Software
 
17
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 
1
19
"""\
2
20
Various useful plugins for working with bzr.
3
21
"""
5
23
import bzrlib
6
24
 
7
25
 
8
 
__version__ = '0.11.0'
 
26
__version__ = '0.13.0'
9
27
 
10
28
 
11
29
version_info = tuple(int(n) for n in __version__.split('.'))
44
62
check_bzrlib_version(version_info[:2])
45
63
 
46
64
 
47
 
import rspush
48
65
from errors import CommandError, NoPyBaz
49
66
from patchsource import BzrPatchSource
50
67
from shelf import Shelf
51
 
from switch import cmd_switch
52
68
import sys
53
69
import os.path
54
70
 
55
71
import bzrlib.builtins
56
 
import bzrlib.branch
57
72
import bzrlib.commands
58
73
from bzrlib.commands import get_cmd_object
59
74
from bzrlib.errors import BzrCommandError
63
78
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), 
64
79
                                                 "external")))
65
80
 
 
81
import show_paths
 
82
 
66
83
bzrlib.ignores.add_runtime_ignores(['./.shelf'])
67
84
 
68
85
 
284
301
    def run(self, subcommand, args_list):
285
302
        import sys
286
303
 
 
304
        if args_list is None:
 
305
            args_list = []
287
306
        cmd = self._get_cmd_object(subcommand)
288
307
        source = BzrPatchSource()
289
308
        s = Shelf(source.base)
552
571
    branches you missed by accident.  Here's an example of doing a partial
553
572
    import from thelove@canonical.com:
554
573
    bzr baz-import thelove thelove@canonical.com --prefixes dists:talloc-except
 
574
 
 
575
    WARNING: Encoding should not be specified unless necessary, because if you
 
576
    specify an encoding, your converted branch will not interoperate with
 
577
    independently-converted branches, unless the other branches were converted
 
578
    with exactly the same encoding.  Any encoding recognized by Python may
 
579
    be specified.  Aliases are not detected, so 'utf_8', 'U8', 'UTF' and 'utf8'
 
580
    are incompatible.
555
581
    """
556
582
    takes_args = ['to_root_dir', 'from_archive', 'reuse_history*']
557
583
    takes_options = ['verbose', Option('prefixes', type=str,
558
 
                     help="Prefixes of branches to import, colon-separated")]
 
584
                     help="Prefixes of branches to import, colon-separated"),
 
585
                     Option('encoding', type=str, 
 
586
                     help='Force encoding to specified value.  See WARNING.')]
559
587
 
560
 
    def run(self, to_root_dir, from_archive, verbose=False,
 
588
    def run(self, to_root_dir, from_archive, encoding=None, verbose=False,
561
589
            reuse_history_list=[], prefixes=None):
562
590
        from errors import NoPyBaz
563
591
        try:
564
592
            import baz_import
565
 
            baz_import.baz_import(to_root_dir, from_archive,
 
593
            baz_import.baz_import(to_root_dir, from_archive, encoding,
566
594
                                  verbose, reuse_history_list, prefixes)
567
595
        except NoPyBaz:
568
596
            print "This command is disabled.  Please install PyBaz."
569
597
 
570
598
 
571
599
class cmd_baz_import_branch(bzrlib.commands.Command):
572
 
    """Import an Arch or Baz branch into a bzr branch."""
 
600
    """Import an Arch or Baz branch into a bzr branch.
 
601
 
 
602
    WARNING: Encoding should not be specified unless necessary, because if you
 
603
    specify an encoding, your converted branch will not interoperate with
 
604
    independently-converted branches, unless the other branches were converted
 
605
    with exactly the same encoding.  Any encoding recognized by Python may
 
606
    be specified.  Aliases are not detected, so 'utf_8', 'U8', 'UTF' and 'utf8'
 
607
    are incompatible.
 
608
    """
573
609
    takes_args = ['to_location', 'from_branch?', 'reuse_history*']
574
 
    takes_options = ['verbose', Option('max-count', type=int)]
 
610
    takes_options = ['verbose', Option('max-count', type=int),
 
611
                     Option('encoding', type=str, 
 
612
                     help='Force encoding to specified value.  See WARNING.')]
575
613
 
576
614
    def run(self, to_location, from_branch=None, fast=False, max_count=None,
577
 
            verbose=False, dry_run=False, reuse_history_list=[]):
 
615
            encoding=None, verbose=False, dry_run=False,
 
616
            reuse_history_list=[]):
578
617
        from errors import NoPyBaz
579
618
        try:
580
619
            import baz_import
581
620
            baz_import.baz_import_branch(to_location, from_branch, fast, 
582
 
                                         max_count, verbose, dry_run,
 
621
                                         max_count, verbose, encoding, dry_run,
583
622
                                         reuse_history_list)
584
623
        except NoPyBaz:
585
624
            print "This command is disabled.  Please install PyBaz."
586
625
 
587
626
 
 
627
class cmd_rspush(bzrlib.commands.Command):
 
628
    """Upload this branch to another location using rsync.
 
629
 
 
630
    If no location is specified, the last-used location will be used.  To 
 
631
    prevent dirty trees from being uploaded, rspush will error out if there are 
 
632
    unknown files or local changes.  It will also error out if the upstream 
 
633
    directory is non-empty and not an earlier version of the branch. 
 
634
    """
 
635
    takes_args = ['location?']
 
636
    takes_options = [Option('overwrite', help='Ignore differences between'
 
637
                            ' branches and overwrite unconditionally'),
 
638
                     Option('no-tree', help='Do not push the working tree,'
 
639
                            ' just the .bzr.')]
 
640
 
 
641
    def run(self, location=None, overwrite=False, no_tree=False):
 
642
        from bzrlib import workingtree
 
643
        import bzrtools
 
644
        cur_branch = workingtree.WorkingTree.open_containing(".")[0]
 
645
        bzrtools.rspush(cur_branch, location, overwrite=overwrite, 
 
646
                      working_tree=not no_tree)
 
647
 
 
648
 
 
649
class cmd_switch(bzrlib.commands.Command):
 
650
    """Set the branch of a lightweight checkout and update."""
 
651
 
 
652
    takes_args = ['to_location']
 
653
 
 
654
    def run(self, to_location):
 
655
        from switch import cmd_switch
 
656
        cmd_switch().run(to_location)
 
657
 
 
658
 
588
659
commands = [
589
660
            cmd_baz_import,
590
661
            cmd_baz_import_branch,
599
670
            cmd_import,
600
671
            cmd_multi_pull,
601
672
            cmd_patch,
 
673
            cmd_rspush,
602
674
            cmd_shelf, 
603
675
            cmd_shell,
604
676
            cmd_shelve, 
607
679
            cmd_zap,            
608
680
            ]
609
681
 
610
 
commands.append(rspush.cmd_rspush)
611
682
 
612
683
if hasattr(bzrlib.commands, 'register_command'):
613
684
    for command in commands:
619
690
    import tests
620
691
    from doctest import DocTestSuite, ELLIPSIS
621
692
    from unittest import TestSuite
 
693
    import bzrtools
622
694
    import tests.clean_tree
623
695
    import upstream_import
624
696
    import zap