~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Martin Pool
  • Date: 2008-05-08 04:33:38 UTC
  • mfrom: (3414 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080508043338-ru3vflx8z641a76k
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
    return tree, new_list
97
97
 
98
98
 
99
 
@symbol_versioning.deprecated_function(symbol_versioning.zero_fifteen)
100
 
def get_format_type(typestring):
101
 
    """Parse and return a format specifier."""
102
 
    # Have to use BzrDirMetaFormat1 directly, so that
103
 
    # RepositoryFormat.set_default_format works
104
 
    if typestring == "default":
105
 
        return bzrdir.BzrDirMetaFormat1()
106
 
    try:
107
 
        return bzrdir.format_registry.make_bzrdir(typestring)
108
 
    except KeyError:
109
 
        msg = 'Unknown bzr format "%s". See "bzr help formats".' % typestring
110
 
        raise errors.BzrCommandError(msg)
111
 
 
112
 
 
113
99
# TODO: Make sure no commands unconditionally use the working directory as a
114
100
# branch.  If a filename argument is used, the first of them should be used to
115
101
# specify the branch.  (Perhaps this can be factored out into some kind of
669
655
                raise errors.BzrCommandError(
670
656
                    'bzr pull --revision takes one value.')
671
657
 
672
 
        if verbose:
673
 
            old_rh = branch_to.revision_history()
674
 
        if tree_to is not None:
675
 
            change_reporter = delta._ChangeReporter(
676
 
                unversioned_filter=tree_to.is_ignored)
677
 
            result = tree_to.pull(branch_from, overwrite, revision_id,
678
 
                                  change_reporter,
679
 
                                  possible_transports=possible_transports)
680
 
        else:
681
 
            result = branch_to.pull(branch_from, overwrite, revision_id)
 
658
        branch_to.lock_write()
 
659
        try:
 
660
            if tree_to is not None:
 
661
                change_reporter = delta._ChangeReporter(
 
662
                    unversioned_filter=tree_to.is_ignored)
 
663
                result = tree_to.pull(branch_from, overwrite, revision_id,
 
664
                                      change_reporter,
 
665
                                      possible_transports=possible_transports)
 
666
            else:
 
667
                result = branch_to.pull(branch_from, overwrite, revision_id)
682
668
 
683
 
        result.report(self.outf)
684
 
        if verbose:
685
 
            new_rh = branch_to.revision_history()
686
 
            log.show_changed_revisions(branch_to, old_rh, new_rh,
687
 
                                       to_file=self.outf)
 
669
            result.report(self.outf)
 
670
            if verbose and result.old_revid != result.new_revid:
 
671
                old_rh = list(
 
672
                    branch_to.repository.iter_reverse_revision_history(
 
673
                    result.old_revid))
 
674
                old_rh.reverse()
 
675
                new_rh = branch_to.revision_history()
 
676
                log.show_changed_revisions(branch_to, old_rh, new_rh,
 
677
                                           to_file=self.outf)
 
678
        finally:
 
679
            branch_to.unlock()
688
680
 
689
681
 
690
682
class cmd_push(Command):
933
925
                revision_id = br_from.last_revision()
934
926
            if to_location is None:
935
927
                to_location = urlutils.derive_to_location(from_location)
936
 
                name = None
937
 
            else:
938
 
                name = os.path.basename(to_location) + '\n'
939
 
 
940
928
            to_transport = transport.get_transport(to_location)
941
929
            try:
942
930
                to_transport.mkdir('.')
957
945
                to_transport.delete_tree('.')
958
946
                msg = "The branch %s has no revision %s." % (from_location, revision[0])
959
947
                raise errors.BzrCommandError(msg)
960
 
            if name:
961
 
                branch.control_files.put_utf8('branch-name', name)
962
948
            _merge_tags_if_possible(br_from, branch)
963
949
            note('Branched %d revision(s).' % branch.revno())
964
950
        finally:
2650
2636
                            'known failures.'),
2651
2637
                     Option('load-list', type=str, argname='TESTLISTFILE',
2652
2638
                            help='Load a test id list from a text file.'),
 
2639
                     ListOption('debugflag', type=str, short_name='E',
 
2640
                                help='Turn on a selftest debug flag.'),
2653
2641
                     ]
2654
2642
    encoding_type = 'replace'
2655
2643
 
2658
2646
            lsprof_timed=None, cache_dir=None,
2659
2647
            first=False, list_only=False,
2660
2648
            randomize=None, exclude=None, strict=False,
2661
 
            load_list=None):
 
2649
            load_list=None, debugflag=None):
2662
2650
        import bzrlib.ui
2663
2651
        from bzrlib.tests import selftest
2664
2652
        import bzrlib.benchmarks as benchmarks
2701
2689
                              exclude_pattern=exclude,
2702
2690
                              strict=strict,
2703
2691
                              load_list=load_list,
 
2692
                              debug_flags=debugflag,
2704
2693
                              )
2705
2694
        finally:
2706
2695
            if benchfile is not None:
2716
2705
    """Show version of bzr."""
2717
2706
 
2718
2707
    encoding_type = 'replace'
 
2708
    takes_options = [
 
2709
        Option("short", help="Print just the version number."),
 
2710
        ]
2719
2711
 
2720
2712
    @display_command
2721
 
    def run(self):
 
2713
    def run(self, short=False):
2722
2714
        from bzrlib.version import show_version
2723
 
        show_version(to_file=self.outf)
 
2715
        if short:
 
2716
            self.outf.write(bzrlib.version_string + '\n')
 
2717
        else:
 
2718
            show_version(to_file=self.outf)
2724
2719
 
2725
2720
 
2726
2721
class cmd_rocks(Command):
3655
3650
    specified revision.  For example, "bzr uncommit -r 15" will leave the
3656
3651
    branch at revision 15.
3657
3652
 
3658
 
    In the future, uncommit will create a revision bundle, which can then
3659
 
    be re-applied.
 
3653
    Uncommit leaves the working tree ready for a new commit.  The only change
 
3654
    it may make is to restore any pending merges that were present before
 
3655
    the commit.
3660
3656
    """
3661
3657
 
3662
3658
    # TODO: jam 20060108 Add an option to allow uncommit to remove
4103
4099
               'rather than the one containing the working directory.',
4104
4100
               short_name='f',
4105
4101
               type=unicode),
4106
 
        Option('output', short_name='o', help='Write directive to this file.',
 
4102
        Option('output', short_name='o',
 
4103
               help='Write merge directive to this file; '
 
4104
                    'use - for stdout.',
4107
4105
               type=unicode),
4108
4106
        Option('mail-to', help='Mail the request to this address.',
4109
4107
               type=unicode),