~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Aaron Bentley
  • Date: 2006-11-30 03:18:39 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20061130031839-q2s2ixzkebyrc9qq
Change recommendation to pybaz 1.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Aaron Bentley <aaron.bentley@utoronto.ca>
 
1
# Copyright (C) 2005, 2006 Aaron Bentley <aaron.bentley@utoronto.ca>
2
2
# Copyright (C) 2005, 2006 Canonical Limited.
3
3
# Copyright (C) 2006 Michael Ellerman.
4
4
#
23
23
import bzrlib
24
24
 
25
25
 
26
 
__version__ = '0.15.0'
 
26
__version__ = '0.14.0'
27
27
 
28
28
 
29
29
version_info = tuple(int(n) for n in __version__.split('.'))
47
47
        # get the message out any way we can
48
48
        from warnings import warn as warning
49
49
    if bzrlib_version < desired:
50
 
        warning('Installed Bazzar version %s is too old to be used with'
51
 
                ' plugin \n'
52
 
                '"Bzrtools" %s.' % (bzrlib.__version__, __version__))
 
50
        warning('Installed bzr version %s is too old to be used with bzrtools'
 
51
                ' %s.' % (bzrlib.__version__, __version__))
53
52
        # Not using BzrNewError, because it may not exist.
54
53
        raise Exception, ('Version mismatch', version_info)
55
54
    else:
56
 
        warning('Plugin "Bzrtools" is not up to date with installed Bazaar'
57
 
                ' version %s.\n'
58
 
                ' There should be a newer version of Bzrtools available, e.g.'
59
 
                ' %i.%i.'
 
55
        warning('Bzrtools is not up to date with installed bzr version %s.'
 
56
                ' \nThere should be a newer version available, e.g. %i.%i.' 
60
57
                % (bzrlib.__version__, bzrlib_version[0], bzrlib_version[1]))
61
58
        if bzrlib_version != desired_plus:
62
59
            raise Exception, 'Version mismatch'
157
154
                     help="Do not use rsvg to produce antialiased output"), 
158
155
                     Option('merge-branch', type=str, 
159
156
                     help="Use this branch to calcuate a merge base"), 
160
 
                     Option('cluster', help="Use clustered output."),
161
 
                     Option('max-distance', help="Show no nodes farther than this",
162
 
                            type=int)]
 
157
                     Option('cluster', help="Use clustered output.")]
163
158
    def run(self, branch, file, no_collapse=False, no_antialias=False,
164
 
        merge_branch=None, cluster=False, max_distance=None):
 
159
        merge_branch=None, cluster=False):
165
160
        import graph
166
161
        if cluster:
167
162
            ranking = "cluster"
168
163
        else:
169
164
            ranking = "forced"
170
165
        graph.write_ancestry_file(branch, file, not no_collapse, 
171
 
                                  not no_antialias, merge_branch, ranking, 
172
 
                                  max_distance=max_distance)
 
166
                                  not no_antialias, merge_branch, ranking)
173
167
 
174
168
 
175
169
class cmd_fetch_ghosts(bzrlib.commands.Command):
185
179
 
186
180
strip_help="""Strip the smallest prefix containing num leading slashes  from \
187
181
each file name found in the patch file."""
 
182
Option.OPTIONS['bzrdiff'] = Option('bzrdiff',type=None,
 
183
                                help="""Handle extra bzr tags""")
188
184
 
189
185
 
190
186
class cmd_patch(bzrlib.commands.Command):
191
187
    """Apply a named patch to the current tree.
192
188
    """
193
189
    takes_args = ['filename?']
194
 
    takes_options = [Option('strip', type=int, help=strip_help),
195
 
                     Option('silent', help='Suppress chatter')]
196
 
    def run(self, filename=None, strip=None, silent=False):
 
190
    takes_options = [Option('strip', type=int, help=strip_help)]
 
191
    def run(self, filename=None, strip=-1, bzrdiff=0):
197
192
        from patch import patch
198
193
        from bzrlib.workingtree import WorkingTree
199
194
        wt = WorkingTree.open_containing('.')[0]
200
 
        if strip is None:
201
 
            strip = 0
202
 
        return patch(wt, filename, strip, silent)
 
195
        if strip == -1:
 
196
            if bzrdiff: strip = 0
 
197
            else:       strip = 0
 
198
 
 
199
        return patch(wt, filename, strip, legacy= not bzrdiff)
203
200
 
204
201
 
205
202
class cmd_shelve(bzrlib.commands.Command):
438
435
    """
439
436
    Create a new checkout, associated with a new repository branch.
440
437
    
441
 
    When you cbranch, bzr looks up a target location in locations.conf, and
442
 
    creates the branch there.
443
 
 
444
 
    In your locations.conf, add the following lines:
445
 
    [/working_directory_root]
446
 
    cbranch_target = /branch_root
447
 
    cbranch_target:policy = appendpath
448
 
 
449
 
    This will mean that if you run "bzr cbranch foo/bar foo/baz" in the
450
 
    working directory root, the branch will be created in 
451
 
    "/branch_root/foo/baz"
452
 
 
453
 
    NOTE: cbranch also supports "cbranch_root", but that behaviour is
454
 
    deprecated.
 
438
    When you cbranch, bzr looks up the repository associated with your current
 
439
    directory in locations.conf.  It creates a new branch in that repository
 
440
    with the same name and relative path as the checkout you request.
 
441
 
 
442
    The locations.conf parameter is "cbranch_root".  So if you want 
 
443
    cbranch operations in /home/jrandom/bigproject to produce branches in 
 
444
    /home/jrandom/bigproject/repository, you'd add this:
 
445
 
 
446
    [/home/jrandom/bigproject]
 
447
    cbranch_root = /home/jrandom/bigproject/repository
 
448
 
 
449
    Note that if "/home/jrandom/bigproject/repository" isn't a repository,
 
450
    standalone branches will be produced.  Standalone branches will also
 
451
    be produced if the source branch is in 0.7 format (or earlier).
455
452
    """
456
453
    takes_options = [Option("lightweight", 
457
454
                            help="Create a lightweight checkout"), 'revision']
529
526
 
530
527
 
531
528
class cmd_import(bzrlib.commands.Command):
532
 
    """Import sources from a directory, tarball or zip file
 
529
    """Import sources from a tarball
533
530
    
534
 
    This command will import a directory, tarball or zip file into a bzr
535
 
    tree, replacing any versioned files already present.  If a directory is
536
 
    specified, it is used as the target.  If the directory does not exist, or
537
 
    is not versioned, it is created.
 
531
    This command will import a tarball into a bzr tree, replacing any versioned
 
532
    files already present.  If a directory is specified, it is used as the
 
533
    target.  If the directory does not exist, or is not versioned, it is
 
534
    created.
538
535
 
539
536
    Tarballs may be gzip or bzip2 compressed.  This is autodetected.
540
537
 
541
 
    If the tarball or zip has a single root directory, that directory is
542
 
    stripped when extracting the tarball.  This is not done for directories.
 
538
    If the tarball has a single root directory, that directory is stripped
 
539
    when extracting the tarball.
543
540
    """
544
541
    
545
542
    takes_args = ['source', 'tree?']
551
548
class cmd_cdiff(bzrlib.commands.Command):
552
549
    """A color version of bzr's diff"""
553
550
    takes_args = property(lambda x: get_cmd_object('diff').takes_args)
554
 
 
555
 
    def _takes_options(self):
556
 
        options = list(get_cmd_object('diff').takes_options)
557
 
        options.append(Option('check-style',
558
 
            help='Warn if trailing whitespace or spurious changes have been'
559
 
                 ' added.'))
560
 
        return options
561
 
 
562
 
    takes_options = property(_takes_options)
563
 
 
564
 
    def run(self, check_style=False, *args, **kwargs):
 
551
    takes_options = property(lambda x: get_cmd_object('diff').takes_options)
 
552
    def run(*args, **kwargs):
565
553
        from colordiff import colordiff
566
 
        colordiff(check_style, *args, **kwargs)
 
554
        colordiff(*args, **kwargs)
567
555
 
568
556
 
569
557
class cmd_baz_import(bzrlib.commands.Command):
704
692
    from unittest import TestSuite
705
693
    import bzrtools
706
694
    import tests.clean_tree
707
 
    import tests.upstream_import
 
695
    import upstream_import
708
696
    import zap
709
697
    import tests.blackbox
710
698
    import tests.shelf_tests
719
707
    result.addTest(tests.test_suite())
720
708
    result.addTest(TestLoader().loadTestsFromModule(tests.shelf_tests))
721
709
    result.addTest(tests.blackbox.test_suite())
722
 
    result.addTest(tests.upstream_import.test_suite())
 
710
    result.addTest(upstream_import.test_suite())
723
711
    result.addTest(zap.test_suite())
724
712
    return result