/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

Update with new parent-ids patch.

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
 
1944
1952
                     Option('lsprof-timed',
1945
1953
                            help='generate lsprof output for benchmarked'
1946
1954
                                 ' sections of code.'),
 
1955
                     Option('cache-dir', type=str,
 
1956
                            help='a directory to cache intermediate'
 
1957
                                 ' benchmark steps'),
1947
1958
                     ]
1948
1959
 
1949
1960
    def run(self, testspecs_list=None, verbose=None, one=False,
1950
1961
            keep_output=False, transport=None, benchmark=None,
1951
 
            lsprof_timed=None):
 
1962
            lsprof_timed=None, cache_dir=None):
1952
1963
        import bzrlib.ui
1953
1964
        from bzrlib.tests import selftest
1954
1965
        import bzrlib.benchmarks as benchmarks
 
1966
        from bzrlib.benchmarks import tree_creator
 
1967
 
 
1968
        if cache_dir is not None:
 
1969
            tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
1955
1970
        # we don't want progress meters from the tests to go to the
1956
1971
        # real output; and we don't want log messages cluttering up
1957
1972
        # the real logs.
2123
2138
    takes_args = ['branch?']
2124
2139
    takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
2125
2140
                     Option('show-base', help="Show base revision text in "
2126
 
                            "conflicts")]
 
2141
                            "conflicts"), 
 
2142
                     Option('uncommitted', help='Apply uncommitted changes'
 
2143
                            ' from a working copy, instead of branch changes')]
2127
2144
 
2128
2145
    def help(self):
2129
2146
        from merge import merge_type_help
2131
2148
        return getdoc(self) + '\n' + merge_type_help() 
2132
2149
 
2133
2150
    def run(self, branch=None, revision=None, force=False, merge_type=None,
2134
 
            show_base=False, reprocess=False, remember=False):
 
2151
            show_base=False, reprocess=False, remember=False, 
 
2152
            uncommitted=False):
2135
2153
        if merge_type is None:
2136
2154
            merge_type = Merge3Merger
2137
2155
 
2153
2171
        branch = self._get_remembered_parent(tree, branch, 'Merging from')
2154
2172
 
2155
2173
        if revision is None or len(revision) < 1:
2156
 
            base = [None, None]
2157
 
            other = [branch, -1]
 
2174
            if uncommitted:
 
2175
                base = [branch, -1]
 
2176
                other = [branch, None]
 
2177
            else:
 
2178
                base = [None, None]
 
2179
                other = [branch, -1]
2158
2180
            other_branch, path = Branch.open_containing(branch)
2159
2181
        else:
 
2182
            if uncommitted:
 
2183
                raise BzrCommandError('Cannot use --uncommitted and --revision'
 
2184
                                      ' at the same time.')
2160
2185
            if len(revision) == 1:
2161
2186
                base = [None, None]
2162
2187
                other_branch, path = Branch.open_containing(branch)