~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2010-12-20 11:57:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5577.
  • Revision ID: jelmer@samba.org-20101220115714-2ru3hfappjweeg7q
Don't use no-plugins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
353
353
        return control.open_workingtree(), relpath
354
354
 
355
355
    @staticmethod
356
 
    def open_containing_paths(file_list, default_directory='.',
357
 
        canonicalize=True, apply_view=True):
 
356
    def open_containing_paths(file_list, default_directory=None,
 
357
                              canonicalize=True, apply_view=True):
358
358
        """Open the WorkingTree that contains a set of paths.
359
359
 
360
360
        Fail if the paths given are not all in a single tree.
362
362
        This is used for the many command-line interfaces that take a list of
363
363
        any number of files and that require they all be in the same tree.
364
364
        """
 
365
        if default_directory is None:
 
366
            default_directory = u'.'
365
367
        # recommended replacement for builtins.internal_tree_files
366
368
        if file_list is None or len(file_list) == 0:
367
369
            tree = WorkingTree.open_containing(default_directory)[0]
375
377
                    view_str = views.view_display_str(view_files)
376
378
                    note("Ignoring files outside view. View is %s" % view_str)
377
379
            return tree, file_list
378
 
        tree = WorkingTree.open_containing(file_list[0])[0]
 
380
        if default_directory == u'.':
 
381
            seed = file_list[0]
 
382
        else:
 
383
            seed = default_directory
 
384
            file_list = [osutils.pathjoin(default_directory, f)
 
385
                         for f in file_list]
 
386
        tree = WorkingTree.open_containing(seed)[0]
379
387
        return tree, tree.safe_relpath_files(file_list, canonicalize,
380
 
            apply_view=apply_view)
 
388
                                             apply_view=apply_view)
381
389
 
382
390
    def safe_relpath_files(self, file_list, canonicalize=True, apply_view=True):
383
391
        """Convert file_list into a list of relpaths in tree.
1663
1671
 
1664
1672
    @needs_write_lock
1665
1673
    def pull(self, source, overwrite=False, stop_revision=None,
1666
 
             change_reporter=None, possible_transports=None, local=False):
 
1674
             change_reporter=None, possible_transports=None, local=False,
 
1675
             show_base=False):
1667
1676
        source.lock_read()
1668
1677
        try:
1669
1678
            old_revision_info = self.branch.last_revision_info()
1683
1692
                                basis_tree,
1684
1693
                                this_tree=self,
1685
1694
                                pb=None,
1686
 
                                change_reporter=change_reporter)
 
1695
                                change_reporter=change_reporter,
 
1696
                                show_base=show_base)
1687
1697
                    basis_root_id = basis_tree.get_root_id()
1688
1698
                    new_root_id = new_basis_tree.get_root_id()
1689
1699
                    if basis_root_id != new_root_id:
2078
2088
                    files_to_backup.append(path[1])
2079
2089
 
2080
2090
        def backup(file_to_backup):
2081
 
            backup_name = self.bzrdir.generate_backup_name(file_to_backup)
 
2091
            backup_name = self.bzrdir._available_backup_name(file_to_backup)
2082
2092
            osutils.rename(abs_path, self.abspath(backup_name))
2083
 
            return "removed %s (but kept a copy: %s)" % (file_to_backup, backup_name)
 
2093
            return "removed %s (but kept a copy: %s)" % (file_to_backup,
 
2094
                                                         backup_name)
2084
2095
 
2085
2096
        # Build inv_delta and delete files where applicable,
2086
2097
        # do this before any modifications to inventory.
2261
2272
    _marker = object()
2262
2273
 
2263
2274
    def update(self, change_reporter=None, possible_transports=None,
2264
 
               revision=None, old_tip=_marker):
 
2275
               revision=None, old_tip=_marker, show_base=False):
2265
2276
        """Update a working tree along its branch.
2266
2277
 
2267
2278
        This will update the branch if its bound too, which means we have
2304
2315
            else:
2305
2316
                if old_tip is self._marker:
2306
2317
                    old_tip = None
2307
 
            return self._update_tree(old_tip, change_reporter, revision)
 
2318
            return self._update_tree(old_tip, change_reporter, revision, show_base)
2308
2319
        finally:
2309
2320
            self.unlock()
2310
2321
 
2311
2322
    @needs_tree_write_lock
2312
 
    def _update_tree(self, old_tip=None, change_reporter=None, revision=None):
 
2323
    def _update_tree(self, old_tip=None, change_reporter=None, revision=None,
 
2324
                     show_base=False):
2313
2325
        """Update a tree to the master branch.
2314
2326
 
2315
2327
        :param old_tip: if supplied, the previous tip revision the branch,
2342
2354
            other_tree = self.branch.repository.revision_tree(old_tip)
2343
2355
            nb_conflicts = merge.merge_inner(self.branch, other_tree,
2344
2356
                                             base_tree, this_tree=self,
2345
 
                                             change_reporter=change_reporter)
 
2357
                                             change_reporter=change_reporter,
 
2358
                                             show_base=show_base)
2346
2359
            if nb_conflicts:
2347
2360
                self.add_parent_tree((old_tip, other_tree))
2348
2361
                trace.note('Rerun update after fixing the conflicts.')
2372
2385
 
2373
2386
            nb_conflicts = merge.merge_inner(self.branch, to_tree, base_tree,
2374
2387
                                             this_tree=self,
2375
 
                                             change_reporter=change_reporter)
 
2388
                                             change_reporter=change_reporter,
 
2389
                                             show_base=show_base)
2376
2390
            self.set_last_revision(revision)
2377
2391
            # TODO - dedup parents list with things merged by pull ?
2378
2392
            # reuse the tree we've updated to to set the basis: