~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: John Arbash Meinel
  • Date: 2005-12-01 17:11:25 UTC
  • mto: (1185.50.19 bzr-jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1532.
  • Revision ID: john@arbash-meinel.com-20051201171125-5e1f0970246c4925
Updated the bzr sourcecode to use bzrlib.osutils.pathjoin rather than os.path.join to enforce internal use of / instead of \

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
import bzrlib
38
38
from bzrlib.osutils import (pumpfile, quotefn, splitpath, joinpath,
39
 
                            appendpath, sha_strings)
 
39
                            pathjoin, sha_strings)
40
40
from bzrlib.trace import mutter
41
41
from bzrlib.errors import (NotVersionedError, InvalidEntryName,
42
42
                           BzrError, BzrCheckError)
79
79
    InventoryDirectory('123', 'src', parent_id='TREE_ROOT')
80
80
    >>> i.add(InventoryFile('2323', 'hello.c', parent_id='123'))
81
81
    InventoryFile('2323', 'hello.c', parent_id='123')
82
 
    >>> shouldbe = {0: 'src', 1: os.path.join('src','hello.c')}
 
82
    >>> shouldbe = {0: 'src', 1: pathjoin('src','hello.c')}
83
83
    >>> for ix, j in enumerate(i.iter_entries()):
84
84
    ...   print (j[0] == shouldbe[ix], j[1])
85
85
    ... 
102
102
    >>> i['2326']
103
103
    InventoryFile('2326', 'wibble.c', parent_id='2325')
104
104
    >>> for path, entry in i.iter_entries():
105
 
    ...     print path.replace('\\\\', '/')     # for win32 os.sep
 
105
    ...     print path
106
106
    ...     assert i.path2id(path)
107
107
    ... 
108
108
    src
110
110
    src/hello.c
111
111
    src/wibble
112
112
    src/wibble/wibble.c
113
 
    >>> i.id2path('2326').replace('\\\\', '/')
 
113
    >>> i.id2path('2326')
114
114
    'src/wibble/wibble.c'
115
115
    """
116
116
    
202
202
 
203
203
    def get_tar_item(self, root, dp, now, tree):
204
204
        """Get a tarfile item and a file stream for its content."""
205
 
        item = tarfile.TarInfo(os.path.join(root, dp))
 
205
        item = tarfile.TarInfo(pathjoin(root, dp))
206
206
        # TODO: would be cool to actually set it to the timestamp of the
207
207
        # revision it was last changed
208
208
        item.mtime = now
267
267
        
268
268
        This is a template method - implement _put_on_disk in subclasses.
269
269
        """
270
 
        fullpath = appendpath(dest, dp)
 
270
        fullpath = pathjoin(dest, dp)
271
271
        self._put_on_disk(fullpath, tree)
272
272
        mutter("  export {%s} kind %s to %s", self.file_id,
273
273
                self.kind, fullpath)
764
764
            yield name, ie
765
765
            if ie.kind == 'directory':
766
766
                for cn, cie in self.iter_entries(from_dir=ie.file_id):
767
 
                    yield os.path.join(name, cn), cie
 
767
                    yield pathjoin(name, cn), cie
768
768
 
769
769
 
770
770
    def entries(self):
777
777
            kids = dir_ie.children.items()
778
778
            kids.sort()
779
779
            for name, ie in kids:
780
 
                child_path = os.path.join(dir_path, name)
 
780
                child_path = pathjoin(dir_path, name)
781
781
                accum.append((child_path, ie))
782
782
                if ie.kind == 'directory':
783
783
                    descend(ie, child_path)
797
797
            kids.sort()
798
798
 
799
799
            for name, child_ie in kids:
800
 
                child_path = os.path.join(parent_path, name)
 
800
                child_path = pathjoin(parent_path, name)
801
801
                descend(child_ie, child_path)
802
802
        descend(self.root, u'')
803
803
        return accum
864
864
 
865
865
        if parent.children.has_key(entry.name):
866
866
            raise BzrError("%s is already versioned" %
867
 
                    appendpath(self.id2path(parent.file_id), entry.name))
 
867
                    pathjoin(self.id2path(parent.file_id), entry.name))
868
868
 
869
869
        self._byid[entry.file_id] = entry
870
870
        parent.children[entry.name] = entry