/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-16 18:38:57 UTC
  • mfrom: (1934 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1937.
  • Revision ID: john@arbash-meinel.com-20060816183857-7307edffa7098bd2
[merge] bzr.dev 1934

Show diffs side-by-side

added added

removed removed

Lines of Context:
274
274
 
275
275
    --dry-run will show which files would be added, but not actually 
276
276
    add them.
 
277
 
 
278
    --file-ids-from will try to use the file ids from the supplied path.
 
279
    It looks up ids trying to find a matching parent directory with the
 
280
    same filename, and then by pure path.
277
281
    """
278
282
    takes_args = ['file*']
279
 
    takes_options = ['no-recurse', 'dry-run', 'verbose']
 
283
    takes_options = ['no-recurse', 'dry-run', 'verbose',
 
284
                     Option('file-ids-from', type=unicode,
 
285
                            help='Lookup file ids from here')]
280
286
    encoding_type = 'replace'
281
287
 
282
 
    def run(self, file_list, no_recurse=False, dry_run=False, verbose=False):
 
288
    def run(self, file_list, no_recurse=False, dry_run=False, verbose=False,
 
289
            file_ids_from=None):
283
290
        import bzrlib.add
284
291
 
285
 
        action = bzrlib.add.AddAction(to_file=self.outf,
286
 
            should_print=(not is_quiet()))
287
 
 
288
 
        added, ignored = bzrlib.add.smart_add(file_list, not no_recurse, 
 
292
        if file_ids_from is not None:
 
293
            try:
 
294
                base_tree, base_path = WorkingTree.open_containing(
 
295
                                            file_ids_from)
 
296
            except errors.NoWorkingTree:
 
297
                base_branch, base_path = branch.Branch.open_containing(
 
298
                                            file_ids_from)
 
299
                base_tree = base_branch.basis_tree()
 
300
 
 
301
            action = bzrlib.add.AddFromBaseAction(base_tree, base_path,
 
302
                          to_file=self.outf, should_print=(not is_quiet()))
 
303
        else:
 
304
            action = bzrlib.add.AddAction(to_file=self.outf,
 
305
                should_print=(not is_quiet()))
 
306
 
 
307
        added, ignored = bzrlib.add.smart_add(file_list, not no_recurse,
289
308
                                              action=action, save=not dry_run)
290
309
        if len(ignored) > 0:
291
310
            if verbose:
762
781
        old_format = bzrdir.BzrDirFormat.get_default_format()
763
782
        bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
764
783
        try:
765
 
            if lightweight:
766
 
                checkout = bzrdir.BzrDirMetaFormat1().initialize(to_location)
767
 
                branch.BranchReferenceFormat().initialize(checkout, source)
768
 
            else:
769
 
                checkout_branch =  bzrdir.BzrDir.create_branch_convenience(
770
 
                    to_location, force_new_tree=False)
771
 
                checkout = checkout_branch.bzrdir
772
 
                checkout_branch.bind(source)
773
 
                if revision_id is not None:
774
 
                    rh = checkout_branch.revision_history()
775
 
                    checkout_branch.set_revision_history(rh[:rh.index(revision_id) + 1])
776
 
            checkout.create_workingtree(revision_id)
 
784
            source.create_checkout(to_location, revision_id, lightweight)
777
785
        finally:
778
786
            bzrdir.BzrDirFormat.set_default_format(old_format)
779
787
 
1955
1963
        import bzrlib.ui
1956
1964
        from bzrlib.tests import selftest
1957
1965
        import bzrlib.benchmarks as benchmarks
 
1966
        from bzrlib.benchmarks import tree_creator
1958
1967
 
1959
1968
        if cache_dir is not None:
1960
 
            benchmarks.Benchmark.CACHE_ROOT = osutils.abspath(cache_dir)
 
1969
            tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
1961
1970
        # we don't want progress meters from the tests to go to the
1962
1971
        # real output; and we don't want log messages cluttering up
1963
1972
        # the real logs.
1976
1985
                test_suite_factory = benchmarks.test_suite
1977
1986
                if verbose is None:
1978
1987
                    verbose = True
 
1988
                benchfile = open(".perf_history", "at")
1979
1989
            else:
1980
1990
                test_suite_factory = None
1981
1991
                if verbose is None:
1982
1992
                    verbose = False
1983
 
            result = selftest(verbose=verbose, 
1984
 
                              pattern=pattern,
1985
 
                              stop_on_failure=one, 
1986
 
                              keep_output=keep_output,
1987
 
                              transport=transport,
1988
 
                              test_suite_factory=test_suite_factory,
1989
 
                              lsprof_timed=lsprof_timed)
 
1993
                benchfile = None
 
1994
            try:
 
1995
                result = selftest(verbose=verbose, 
 
1996
                                  pattern=pattern,
 
1997
                                  stop_on_failure=one, 
 
1998
                                  keep_output=keep_output,
 
1999
                                  transport=transport,
 
2000
                                  test_suite_factory=test_suite_factory,
 
2001
                                  lsprof_timed=lsprof_timed,
 
2002
                                  bench_history=benchfile)
 
2003
            finally:
 
2004
                if benchfile is not None:
 
2005
                    benchfile.close()
1990
2006
            if result:
1991
2007
                info('tests passed')
1992
2008
            else:
1996
2012
            ui.ui_factory = save_ui
1997
2013
 
1998
2014
 
1999
 
def _get_bzr_branch():
2000
 
    """If bzr is run from a branch, return Branch or None"""
2001
 
    from os.path import dirname
2002
 
    
2003
 
    try:
2004
 
        branch = Branch.open(dirname(osutils.abspath(dirname(__file__))))
2005
 
        return branch
2006
 
    except errors.BzrError:
2007
 
        return None
2008
 
    
2009
 
 
2010
 
def show_version():
2011
 
    import bzrlib
2012
 
    print "Bazaar (bzr) %s" % bzrlib.__version__
2013
 
    # is bzrlib itself in a branch?
2014
 
    branch = _get_bzr_branch()
2015
 
    if branch:
2016
 
        rh = branch.revision_history()
2017
 
        revno = len(rh)
2018
 
        print "  bzr checkout, revision %d" % (revno,)
2019
 
        print "  nick: %s" % (branch.nick,)
2020
 
        if rh:
2021
 
            print "  revid: %s" % (rh[-1],)
2022
 
    print "Using python interpreter:", sys.executable
2023
 
    import site
2024
 
    print "Using python standard library:", os.path.dirname(site.__file__)
2025
 
    print "Using bzrlib:",
2026
 
    if len(bzrlib.__path__) > 1:
2027
 
        # print repr, which is a good enough way of making it clear it's
2028
 
        # more than one element (eg ['/foo/bar', '/foo/bzr'])
2029
 
        print repr(bzrlib.__path__)
2030
 
    else:
2031
 
        print bzrlib.__path__[0]
2032
 
 
2033
 
    print
2034
 
    print bzrlib.__copyright__
2035
 
    print "http://bazaar-vcs.org/"
2036
 
    print
2037
 
    print "bzr comes with ABSOLUTELY NO WARRANTY.  bzr is free software, and"
2038
 
    print "you may use, modify and redistribute it under the terms of the GNU"
2039
 
    print "General Public License version 2 or later."
2040
 
 
2041
 
 
2042
2015
class cmd_version(Command):
2043
2016
    """Show version of bzr."""
2044
2017
 
2045
2018
    @display_command
2046
2019
    def run(self):
 
2020
        from bzrlib.version import show_version
2047
2021
        show_version()
2048
2022
 
2049
2023
 
2129
2103
    takes_args = ['branch?']
2130
2104
    takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
2131
2105
                     Option('show-base', help="Show base revision text in "
2132
 
                            "conflicts")]
 
2106
                            "conflicts"), 
 
2107
                     Option('uncommitted', help='Apply uncommitted changes'
 
2108
                            ' from a working copy, instead of branch changes')]
2133
2109
 
2134
2110
    def help(self):
2135
2111
        from merge import merge_type_help
2137
2113
        return getdoc(self) + '\n' + merge_type_help() 
2138
2114
 
2139
2115
    def run(self, branch=None, revision=None, force=False, merge_type=None,
2140
 
            show_base=False, reprocess=False, remember=False):
 
2116
            show_base=False, reprocess=False, remember=False, 
 
2117
            uncommitted=False):
2141
2118
        if merge_type is None:
2142
2119
            merge_type = Merge3Merger
2143
2120
 
2159
2136
        branch = self._get_remembered_parent(tree, branch, 'Merging from')
2160
2137
 
2161
2138
        if revision is None or len(revision) < 1:
2162
 
            base = [None, None]
2163
 
            other = [branch, -1]
 
2139
            if uncommitted:
 
2140
                base = [branch, -1]
 
2141
                other = [branch, None]
 
2142
            else:
 
2143
                base = [None, None]
 
2144
                other = [branch, -1]
2164
2145
            other_branch, path = Branch.open_containing(branch)
2165
2146
        else:
 
2147
            if uncommitted:
 
2148
                raise BzrCommandError('Cannot use --uncommitted and --revision'
 
2149
                                      ' at the same time.')
2166
2150
            if len(revision) == 1:
2167
2151
                base = [None, None]
2168
2152
                other_branch, path = Branch.open_containing(branch)
2509
2493
 
2510
2494
class cmd_testament(Command):
2511
2495
    """Show testament (signing-form) of a revision."""
2512
 
    takes_options = ['revision', 'long', 
 
2496
    takes_options = ['revision', 
 
2497
                     Option('long', help='Produce long-format testament'), 
2513
2498
                     Option('strict', help='Produce a strict-format'
2514
2499
                            ' testament')]
2515
2500
    takes_args = ['branch?']