~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Aaron Bentley
  • Date: 2006-11-21 23:26:35 UTC
  • Revision ID: abentley@panoramicfeedback.com-20061121232635-z2b0g5rv73im3cdc
Add encoding parameter everywhere

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
"""
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
559
574
    takes_options = ['verbose', Option('prefixes', type=str,
560
575
                     help="Prefixes of branches to import, colon-separated")]
561
576
 
562
 
    def run(self, to_root_dir, from_archive, verbose=False,
 
577
    def run(self, to_root_dir, from_archive, encoding=None, verbose=False,
563
578
            reuse_history_list=[], prefixes=None):
564
579
        from errors import NoPyBaz
565
580
        try:
566
581
            import baz_import
567
 
            baz_import.baz_import(to_root_dir, from_archive,
 
582
            baz_import.baz_import(to_root_dir, from_archive, encoding,
568
583
                                  verbose, reuse_history_list, prefixes)
569
584
        except NoPyBaz:
570
585
            print "This command is disabled.  Please install PyBaz."
576
591
    takes_options = ['verbose', Option('max-count', type=int)]
577
592
 
578
593
    def run(self, to_location, from_branch=None, fast=False, max_count=None,
579
 
            verbose=False, dry_run=False, reuse_history_list=[]):
 
594
            encoding=None, verbose=False, dry_run=False,
 
595
            reuse_history_list=[]):
580
596
        from errors import NoPyBaz
581
597
        try:
582
598
            import baz_import
583
599
            baz_import.baz_import_branch(to_location, from_branch, fast, 
584
 
                                         max_count, verbose, dry_run,
 
600
                                         max_count, verbose, encoding, dry_run,
585
601
                                         reuse_history_list)
586
602
        except NoPyBaz:
587
603
            print "This command is disabled.  Please install PyBaz."
588
604
 
589
605
 
 
606
class cmd_rspush(bzrlib.commands.Command):
 
607
    """Upload this branch to another location using rsync.
 
608
 
 
609
    If no location is specified, the last-used location will be used.  To 
 
610
    prevent dirty trees from being uploaded, rspush will error out if there are 
 
611
    unknown files or local changes.  It will also error out if the upstream 
 
612
    directory is non-empty and not an earlier version of the branch. 
 
613
    """
 
614
    takes_args = ['location?']
 
615
    takes_options = [Option('overwrite', help='Ignore differences between'
 
616
                            ' branches and overwrite unconditionally'),
 
617
                     Option('no-tree', help='Do not push the working tree,'
 
618
                            ' just the .bzr.')]
 
619
 
 
620
    def run(self, location=None, overwrite=False, no_tree=False):
 
621
        from bzrlib import workingtree
 
622
        import bzrtools
 
623
        cur_branch = workingtree.WorkingTree.open_containing(".")[0]
 
624
        bzrtools.rspush(cur_branch, location, overwrite=overwrite, 
 
625
                      working_tree=not no_tree)
 
626
 
 
627
 
 
628
class cmd_switch(bzrlib.commands.Command):
 
629
    """Set the branch of a lightweight checkout and update."""
 
630
 
 
631
    takes_args = ['to_location']
 
632
 
 
633
    def run(self, to_location):
 
634
        from switch import cmd_switch
 
635
        cmd_switch().run(to_location)
 
636
 
 
637
 
590
638
commands = [
591
639
            cmd_baz_import,
592
640
            cmd_baz_import_branch,
601
649
            cmd_import,
602
650
            cmd_multi_pull,
603
651
            cmd_patch,
 
652
            cmd_rspush,
604
653
            cmd_shelf, 
605
654
            cmd_shell,
606
655
            cmd_shelve, 
609
658
            cmd_zap,            
610
659
            ]
611
660
 
612
 
commands.append(rspush.cmd_rspush)
613
661
 
614
662
if hasattr(bzrlib.commands, 'register_command'):
615
663
    for command in commands:
621
669
    import tests
622
670
    from doctest import DocTestSuite, ELLIPSIS
623
671
    from unittest import TestSuite
 
672
    import bzrtools
624
673
    import tests.clean_tree
625
674
    import upstream_import
626
675
    import zap