/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: John Arbash Meinel
  • Date: 2006-08-08 23:48:44 UTC
  • mfrom: (1910 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1912.
  • Revision ID: john@arbash-meinel.com-20060808234844-602f87fbb7bbd2fe
[merge] bzr.dev 1910

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
 
 
 
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
459
459
    def get_file(self, file_id):
460
460
        return self.get_file_byname(self.id2path(file_id))
461
461
 
 
462
    def get_file_text(self, file_id):
 
463
        return self.get_file(file_id).read()
 
464
 
462
465
    def get_file_byname(self, filename):
463
466
        return file(self.abspath(filename), 'rb')
464
467
 
854
857
        if to_dir_id == None and to_name != '':
855
858
            raise BzrError("destination %r is not a versioned directory" % to_name)
856
859
        to_dir_ie = inv[to_dir_id]
857
 
        if to_dir_ie.kind not in ('directory', 'root_directory'):
 
860
        if to_dir_ie.kind != 'directory':
858
861
            raise BzrError("destination %r is not a directory" % to_abs)
859
862
 
860
863
        to_idpath = inv.get_idpath(to_dir_id)
1015
1018
        """
1016
1019
        ## TODO: Work from given directory downwards
1017
1020
        for path, dir_entry in self.inventory.directories():
1018
 
            mutter("search for unknowns in %r", path)
 
1021
            # mutter("search for unknowns in %r", path)
1019
1022
            dirabs = self.abspath(path)
1020
1023
            if not isdir(dirabs):
1021
1024
                # e.g. directory deleted
1221
1224
        if new_revision is None:
1222
1225
            self.branch.set_revision_history([])
1223
1226
            return False
1224
 
        # current format is locked in with the branch
1225
 
        revision_history = self.branch.revision_history()
1226
1227
        try:
1227
 
            position = revision_history.index(new_revision)
1228
 
        except ValueError:
1229
 
            raise errors.NoSuchRevision(self.branch, new_revision)
1230
 
        self.branch.set_revision_history(revision_history[:position + 1])
 
1228
            self.branch.generate_revision_history(new_revision)
 
1229
        except errors.NoSuchRevision:
 
1230
            # not present in the repo - dont try to set it deeper than the tip
 
1231
            self.branch.set_revision_history([new_revision])
1231
1232
        return True
1232
1233
 
1233
1234
    def _cache_basis_inventory(self, new_revision):
1256
1257
            path = self._basis_inventory_name()
1257
1258
            sio = StringIO(xml)
1258
1259
            self._control_files.put(path, sio)
1259
 
        except WeaveRevisionNotPresent:
 
1260
        except (errors.NoSuchRevision, errors.RevisionNotPresent):
1260
1261
            pass
1261
1262
 
1262
1263
    def read_basis_inventory(self):
1524
1525
                pass
1525
1526
            return False
1526
1527
        else:
1527
 
            try:
1528
 
                self.branch.revision_history().index(revision_id)
1529
 
            except ValueError:
1530
 
                raise errors.NoSuchRevision(self.branch, revision_id)
1531
1528
            self._control_files.put_utf8('last-revision', revision_id)
1532
1529
            return True
1533
1530
 
1858
1855
        self._transport_readonly_server = transport_readonly_server
1859
1856
        self._formats = formats
1860
1857
    
 
1858
    def _clone_test(self, test, bzrdir_format, workingtree_format, variation):
 
1859
        """Clone test for adaption."""
 
1860
        new_test = deepcopy(test)
 
1861
        new_test.transport_server = self._transport_server
 
1862
        new_test.transport_readonly_server = self._transport_readonly_server
 
1863
        new_test.bzrdir_format = bzrdir_format
 
1864
        new_test.workingtree_format = workingtree_format
 
1865
        def make_new_test_id():
 
1866
            new_id = "%s(%s)" % (test.id(), variation)
 
1867
            return lambda: new_id
 
1868
        new_test.id = make_new_test_id()
 
1869
        return new_test
 
1870
    
1861
1871
    def adapt(self, test):
1862
1872
        from bzrlib.tests import TestSuite
1863
1873
        result = TestSuite()
1864
1874
        for workingtree_format, bzrdir_format in self._formats:
1865
 
            new_test = deepcopy(test)
1866
 
            new_test.transport_server = self._transport_server
1867
 
            new_test.transport_readonly_server = self._transport_readonly_server
1868
 
            new_test.bzrdir_format = bzrdir_format
1869
 
            new_test.workingtree_format = workingtree_format
1870
 
            def make_new_test_id():
1871
 
                new_id = "%s(%s)" % (new_test.id(), workingtree_format.__class__.__name__)
1872
 
                return lambda: new_id
1873
 
            new_test.id = make_new_test_id()
 
1875
            new_test = self._clone_test(
 
1876
                test,
 
1877
                bzrdir_format,
 
1878
                workingtree_format, workingtree_format.__class__.__name__)
1874
1879
            result.addTest(new_test)
1875
1880
        return result