~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Robert Collins
  • Date: 2005-10-10 01:32:08 UTC
  • Revision ID: robertc@robertcollins.net-20051010013208-163c23746972763a
branch: namespace

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# (C) 2005 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
16
16
 
17
 
# FIXME: This refactoring of the workingtree code doesn't seem to keep 
18
 
# the WorkingTree's copy of the inventory in sync with the branch.  The
19
 
# branch modifies its working inventory when it does a commit to make
20
 
# missing files permanently removed.
21
17
 
22
18
# TODO: Maybe also keep the full path of the entry, and the children?
23
19
# But those depend on its position within a particular inventory, and
35
31
import types
36
32
 
37
33
import bzrlib
 
34
from bzrlib.errors import BzrError, BzrCheckError
 
35
 
38
36
from bzrlib.osutils import (pumpfile, quotefn, splitpath, joinpath,
39
37
                            appendpath, sha_strings)
40
38
from bzrlib.trace import mutter
41
 
from bzrlib.errors import (NotVersionedError, InvalidEntryName,
42
 
                           BzrError, BzrCheckError)
 
39
from bzrlib.errors import NotVersionedError
43
40
 
44
41
 
45
42
class InventoryEntry(object):
232
229
        '123'
233
230
        >>> e = InventoryFile('123', 'src/hello.c', ROOT_ID)
234
231
        Traceback (most recent call last):
235
 
        InvalidEntryName: Invalid entry name: src/hello.c
 
232
        BzrCheckError: InventoryEntry name 'src/hello.c' is invalid
236
233
        """
237
234
        assert isinstance(name, basestring), name
238
235
        if '/' in name or '\\' in name:
239
 
            raise InvalidEntryName(name=name)
 
236
            raise BzrCheckError('InventoryEntry name %r is invalid' % name)
 
237
        
240
238
        self.executable = False
241
239
        self.revision = None
242
240
        self.text_sha1 = None
400
398
        Note that this should be modified to be a noop on virtual trees
401
399
        as all entries created there are prepopulated.
402
400
        """
403
 
        # TODO: Rather than running this manually, we should check the 
404
 
        # working sha1 and other expensive properties when they're
405
 
        # first requested, or preload them if they're already known
406
 
        pass            # nothing to do by default
407
401
 
408
402
 
409
403
class RootEntry(InventoryEntry):
887
881
        parent_path = parts[:-1]
888
882
        parent_id = self.path2id(parent_path)
889
883
        if parent_id == None:
890
 
            raise NotVersionedError(path=parent_path)
 
884
            raise NotVersionedError(parent_path)
 
885
 
891
886
        if kind == 'directory':
892
887
            ie = InventoryDirectory(file_id, parts[-1], parent_id)
893
888
        elif kind == 'file':