~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Robert Collins
  • Date: 2006-07-24 04:40:06 UTC
  • mto: (1852.7.2 split-tree-source)
  • mto: This revision was merged to the branch mainline in revision 1890.
  • Revision ID: robertc@robertcollins.net-20060724044006-faa99aee0dff9ae9
Finish updating iter_entries change to make all tests pass.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
    InventoryDirectory('123', 'src', parent_id='TREE_ROOT', revision=None)
82
82
    >>> i.add(InventoryFile('2323', 'hello.c', parent_id='123'))
83
83
    InventoryFile('2323', 'hello.c', parent_id='123', sha1=None, len=None)
84
 
    >>> shouldbe = {0: 'src', 1: pathjoin('src','hello.c')}
 
84
    >>> shouldbe = {0: '', 1: 'src', 2: pathjoin('src','hello.c')}
85
85
    >>> for ix, j in enumerate(i.iter_entries()):
86
86
    ...   print (j[0] == shouldbe[ix], j[1])
87
87
    ... 
 
88
    (True, RootEntry('TREE_ROOT', u'', parent_id=None, revision=None))
88
89
    (True, InventoryDirectory('123', 'src', parent_id='TREE_ROOT', revision=None))
89
90
    (True, InventoryFile('2323', 'hello.c', parent_id='123', sha1=None, len=None))
90
91
    >>> i.add(InventoryFile('2323', 'bye.c', '123'))
107
108
    ...     print path
108
109
    ...     assert i.path2id(path)
109
110
    ... 
 
111
    <BLANKLINE>
110
112
    src
111
113
    src/bye.c
112
114
    src/hello.c
840
842
    May also look up by name:
841
843
 
842
844
    >>> [x[0] for x in inv.iter_entries()]
843
 
    [u'hello.c']
 
845
    ['', u'hello.c']
844
846
    >>> inv = Inventory('TREE_ROOT-12345678-12345678')
845
847
    >>> inv.add(InventoryFile('123-123', 'hello.c', ROOT_ID))
846
848
    InventoryFile('123-123', 'hello.c', parent_id='TREE_ROOT-12345678-12345678', sha1=None, len=None)
940
942
        if from_dir is None:
941
943
            assert self.root
942
944
            from_dir = self.root
 
945
            yield '', self.root
943
946
        elif isinstance(from_dir, basestring):
944
947
            from_dir = self._byid[from_dir]
945
948