~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-19 06:14:38 UTC
  • mfrom: (1704.2.23 bzr.mbp.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060519061438-6300caf3926c3cff
(mbp) small fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import bzrlib.branch
26
26
from bzrlib.branch import Branch
27
27
import bzrlib.bzrdir as bzrdir
28
 
from bzrlib.bundle.read_bundle import BundleReader
29
 
from bzrlib.bundle.apply_bundle import merge_bundle
30
28
from bzrlib.commands import Command, display_command
31
29
import bzrlib.errors as errors
32
30
from bzrlib.errors import (BzrError, BzrCheckError, BzrCommandError, 
33
31
                           NotBranchError, DivergedBranches, NotConflicted,
34
32
                           NoSuchFile, NoWorkingTree, FileInWrongBranch,
35
 
                           NotVersionedError, BadBundle)
 
33
                           NotVersionedError)
36
34
from bzrlib.log import show_one_log
37
35
from bzrlib.merge import Merge3Merger
38
36
from bzrlib.option import Option
519
517
                        if new_transport.base == transport.base:
520
518
                            raise BzrCommandError("Could not create "
521
519
                                                  "path prefix.")
522
 
            dir_to = br_from.bzrdir.clone(location,
523
 
                revision_id=br_from.last_revision())
 
520
            dir_to = br_from.bzrdir.clone(location)
524
521
            br_to = dir_to.open_branch()
525
522
            count = len(br_to.revision_history())
526
523
        else:
795
792
 
796
793
    This makes bzr stop tracking changes to a versioned file.  It does
797
794
    not delete the working copy.
798
 
 
799
 
    You can specify one or more files, and/or --new.  If you specify --new,
800
 
    only 'added' files will be removed.  If you specify both, then new files
801
 
    in the specified directories will be removed.  If the directories are
802
 
    also new, they will also be removed.
803
795
    """
804
 
    takes_args = ['file*']
805
 
    takes_options = ['verbose', Option('new', help='remove newly-added files')]
 
796
    takes_args = ['file+']
 
797
    takes_options = ['verbose']
806
798
    aliases = ['rm']
807
799
    
808
 
    def run(self, file_list, verbose=False, new=False):
 
800
    def run(self, file_list, verbose=False):
809
801
        tree, file_list = tree_files(file_list)
810
 
        if new is False:
811
 
            if file_list is None:
812
 
                raise BzrCommandError('Specify one or more files to remove, or'
813
 
                                      ' use --new.')
814
 
        else:
815
 
            from bzrlib.delta import compare_trees
816
 
            added = [compare_trees(tree.basis_tree(), tree,
817
 
                                   specific_files=file_list).added]
818
 
            file_list = sorted([f[0] for f in added[0]], reverse=True)
819
 
            if len(file_list) == 0:
820
 
                raise BzrCommandError('No matching files.')
821
802
        tree.remove(file_list, verbose=verbose)
822
803
 
823
804
 
1802
1783
                                 'throughout the test suite.',
1803
1784
                            type=get_transport_type),
1804
1785
                     Option('benchmark', help='run the bzr bencharks.'),
1805
 
                     Option('lsprof-timed',
1806
 
                            help='generate lsprof output for benchmarked'
1807
 
                                 ' sections of code.'),
1808
 
                     ]
 
1786
                    ]
1809
1787
 
1810
 
    def run(self, testspecs_list=None, verbose=None, one=False,
1811
 
            keep_output=False, transport=None, benchmark=None,
1812
 
            lsprof_timed=None):
 
1788
    def run(self, testspecs_list=None, verbose=False, one=False,
 
1789
            keep_output=False, transport=None, benchmark=None):
1813
1790
        import bzrlib.ui
1814
1791
        from bzrlib.tests import selftest
1815
1792
        import bzrlib.benchmarks as benchmarks
1829
1806
                pattern = ".*"
1830
1807
            if benchmark:
1831
1808
                test_suite_factory = benchmarks.test_suite
1832
 
                if verbose is None:
1833
 
                    verbose = True
1834
1809
            else:
1835
1810
                test_suite_factory = None
1836
 
                if verbose is None:
1837
 
                    verbose = False
1838
1811
            result = selftest(verbose=verbose, 
1839
1812
                              pattern=pattern,
1840
1813
                              stop_on_failure=one, 
1841
1814
                              keep_output=keep_output,
1842
1815
                              transport=transport,
1843
 
                              test_suite_factory=test_suite_factory,
1844
 
                              lsprof_timed=lsprof_timed)
 
1816
                              test_suite_factory=test_suite_factory)
1845
1817
            if result:
1846
1818
                bzrlib.trace.info('tests passed')
1847
1819
            else:
1876
1848
        print "  nick: %s" % (branch.nick,)
1877
1849
        if rh:
1878
1850
            print "  revid: %s" % (rh[-1],)
1879
 
    print "Using python interpreter:", sys.executable
1880
 
    import site
1881
 
    print "Using python standard library:", os.path.dirname(site.__file__)
1882
 
    print "Using bzrlib:",
1883
 
    if len(bzrlib.__path__) > 1:
1884
 
        # print repr, which is a good enough way of making it clear it's
1885
 
        # more than one element (eg ['/foo/bar', '/foo/bzr'])
1886
 
        print repr(bzrlib.__path__)
1887
 
    else:
1888
 
        print bzrlib.__path__[0]
1889
 
 
1890
 
    print
1891
1851
    print bzrlib.__copyright__
1892
1852
    print "http://bazaar-vcs.org/"
1893
1853
    print
1988
1948
    
1989
1949
    merge refuses to run if there are any uncommitted changes, unless
1990
1950
    --force is given.
1991
 
 
1992
 
    The following merge types are available:
1993
1951
    """
1994
1952
    takes_args = ['branch?']
1995
1953
    takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
1996
1954
                     Option('show-base', help="Show base revision text in "
1997
1955
                            "conflicts")]
1998
1956
 
1999
 
    def help(self):
2000
 
        from merge import merge_type_help
2001
 
        from inspect import getdoc
2002
 
        return getdoc(self) + '\n' + merge_type_help() 
2003
 
 
2004
1957
    def run(self, branch=None, revision=None, force=False, merge_type=None,
2005
1958
            show_base=False, reprocess=False, remember=False):
2006
1959
        if merge_type is None:
2007
1960
            merge_type = Merge3Merger
2008
1961
 
2009
 
 
2010
1962
        tree = WorkingTree.open_containing(u'.')[0]
2011
 
        try:
2012
 
            if branch is not None:
2013
 
                reader = BundleReader(file(branch, 'rb'))
2014
 
            else:
2015
 
                reader = None
2016
 
        except IOError, e:
2017
 
            if e.errno not in (errno.ENOENT, errno.EISDIR):
2018
 
                raise
2019
 
            reader = None
2020
 
        except BadBundle:
2021
 
            reader = None
2022
 
        if reader is not None:
2023
 
            conflicts = merge_bundle(reader, tree, not force, merge_type,
2024
 
                                        reprocess, show_base)
2025
 
            if conflicts == 0:
2026
 
                return 0
2027
 
            else:
2028
 
                return 1
2029
 
 
2030
1963
        stored_loc = tree.branch.get_parent()
2031
1964
        if branch is None:
2032
1965
            if stored_loc is None:
2087
2020
 
2088
2021
class cmd_remerge(Command):
2089
2022
    """Redo a merge.
2090
 
 
2091
 
    Use this if you want to try a different merge technique while resolving
2092
 
    conflicts.  Some merge techniques are better than others, and remerge 
2093
 
    lets you try different ones on different files.
2094
 
 
2095
 
    The options for remerge have the same meaning and defaults as the ones for
2096
 
    merge.  The difference is that remerge can (only) be run when there is a
2097
 
    pending merge, and it lets you specify particular files.
2098
 
 
2099
 
    Examples:
2100
 
    $ bzr remerge --show-base
2101
 
        Re-do the merge of all conflicted files, and show the base text in
2102
 
        conflict regions, in addition to the usual THIS and OTHER texts.
2103
 
 
2104
 
    $ bzr remerge --merge-type weave --reprocess foobar
2105
 
        Re-do the merge of "foobar", using the weave merge algorithm, with
2106
 
        additional processing to reduce the size of conflict regions.
2107
 
    
2108
 
    The following merge types are available:"""
 
2023
    """
2109
2024
    takes_args = ['file*']
2110
2025
    takes_options = ['merge-type', 'reprocess',
2111
2026
                     Option('show-base', help="Show base revision text in "
2112
2027
                            "conflicts")]
2113
2028
 
2114
 
    def help(self):
2115
 
        from merge import merge_type_help
2116
 
        from inspect import getdoc
2117
 
        return getdoc(self) + '\n' + merge_type_help() 
2118
 
 
2119
2029
    def run(self, file_list=None, merge_type=None, show_base=False,
2120
2030
            reprocess=False):
2121
2031
        from bzrlib.merge import merge_inner, transform_tree
2507
2417
    --dry-run will go through all the motions, but not actually
2508
2418
    remove anything.
2509
2419
    
2510
 
    In the future, uncommit will create a revision bundle, which can then
 
2420
    In the future, uncommit will create a changeset, which can then
2511
2421
    be re-applied.
2512
2422
    """
2513
2423
 
2667
2577
# aliases.  ideally we would avoid loading the implementation until the
2668
2578
# details were needed.
2669
2579
from bzrlib.conflicts import cmd_resolve, cmd_conflicts, restore
2670
 
from bzrlib.bundle.commands import cmd_bundle_revisions
2671
2580
from bzrlib.sign_my_commits import cmd_sign_my_commits
2672
2581
from bzrlib.weave_commands import cmd_weave_list, cmd_weave_join, \
2673
2582
        cmd_weave_plan_merge, cmd_weave_merge_text