/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/workingtree.py

  • Committer: Vincent Ladeuil
  • Date: 2007-07-04 12:28:56 UTC
  • mfrom: (2584 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070704122856-7jn5e6ou08ukimof
merge bzr.dev @ 2584 resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
lazy_import(globals(), """
45
45
from bisect import bisect_left
46
46
import collections
47
 
from copy import deepcopy
48
47
import errno
49
48
import itertools
50
49
import operator
616
615
        # should probably put it back with the previous ID.
617
616
        # the read and write working inventory should not occur in this 
618
617
        # function - they should be part of lock_write and unlock.
619
 
        inv = self.read_working_inventory()
 
618
        inv = self.inventory
620
619
        for f, file_id, kind in zip(files, ids, kinds):
621
620
            assert kind is not None
622
621
            if file_id is None:
624
623
            else:
625
624
                file_id = osutils.safe_file_id(file_id)
626
625
                inv.add_path(f, kind=kind, file_id=file_id)
627
 
        self._write_inventory(inv)
 
626
            self._inventory_is_modified = True
628
627
 
629
628
    @needs_tree_write_lock
630
629
    def _gather_kinds(self, files, kinds):
1971
1970
        """
1972
1971
        raise NotImplementedError(self.unlock)
1973
1972
 
1974
 
    def update(self):
 
1973
    def update(self, change_reporter=None):
1975
1974
        """Update a working tree along its branch.
1976
1975
 
1977
1976
        This will update the branch if its bound too, which means we have
2007
2006
                old_tip = self.branch.update()
2008
2007
            else:
2009
2008
                old_tip = None
2010
 
            return self._update_tree(old_tip)
 
2009
            return self._update_tree(old_tip, change_reporter)
2011
2010
        finally:
2012
2011
            self.unlock()
2013
2012
 
2014
2013
    @needs_tree_write_lock
2015
 
    def _update_tree(self, old_tip=None):
 
2014
    def _update_tree(self, old_tip=None, change_reporter=None):
2016
2015
        """Update a tree to the master branch.
2017
2016
 
2018
2017
        :param old_tip: if supplied, the previous tip revision the branch,
2046
2045
                                      self.branch,
2047
2046
                                      to_tree,
2048
2047
                                      basis,
2049
 
                                      this_tree=self)
 
2048
                                      this_tree=self,
 
2049
                                      change_reporter=change_reporter)
2050
2050
            finally:
2051
2051
                basis.unlock()
2052
2052
            # TODO - dedup parents list with things merged by pull ?
2094
2094
                                  self.branch,
2095
2095
                                  other_tree,
2096
2096
                                  base_tree,
2097
 
                                  this_tree=self)
 
2097
                                  this_tree=self,
 
2098
                                  change_reporter=change_reporter)
2098
2099
        return result
2099
2100
 
2100
2101
    def _write_hashcache_if_dirty(self):
2772
2773
# and not independently creatable, so are not registered.
2773
2774
_legacy_formats = [WorkingTreeFormat2(),
2774
2775
                   ]
2775
 
 
2776
 
 
2777
 
class WorkingTreeTestProviderAdapter(object):
2778
 
    """A tool to generate a suite testing multiple workingtree formats at once.
2779
 
 
2780
 
    This is done by copying the test once for each transport and injecting
2781
 
    the transport_server, transport_readonly_server, and workingtree_format
2782
 
    classes into each copy. Each copy is also given a new id() to make it
2783
 
    easy to identify.
2784
 
    """
2785
 
 
2786
 
    def __init__(self, transport_server, transport_readonly_server, formats):
2787
 
        self._transport_server = transport_server
2788
 
        self._transport_readonly_server = transport_readonly_server
2789
 
        self._formats = formats
2790
 
    
2791
 
    def _clone_test(self, test, bzrdir_format, workingtree_format, variation):
2792
 
        """Clone test for adaption."""
2793
 
        new_test = deepcopy(test)
2794
 
        new_test.transport_server = self._transport_server
2795
 
        new_test.transport_readonly_server = self._transport_readonly_server
2796
 
        new_test.bzrdir_format = bzrdir_format
2797
 
        new_test.workingtree_format = workingtree_format
2798
 
        def make_new_test_id():
2799
 
            new_id = "%s(%s)" % (test.id(), variation)
2800
 
            return lambda: new_id
2801
 
        new_test.id = make_new_test_id()
2802
 
        return new_test
2803
 
    
2804
 
    def adapt(self, test):
2805
 
        from bzrlib.tests import TestSuite
2806
 
        result = TestSuite()
2807
 
        for workingtree_format, bzrdir_format in self._formats:
2808
 
            new_test = self._clone_test(
2809
 
                test,
2810
 
                bzrdir_format,
2811
 
                workingtree_format, workingtree_format.__class__.__name__)
2812
 
            result.addTest(new_test)
2813
 
        return result