~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
                            pumpfile,
66
66
                            splitpath,
67
67
                            rand_bytes,
 
68
                            realpath,
68
69
                            relpath,
69
70
                            rename)
70
71
import bzrlib.tree
171
172
    not listed in the Inventory and vice versa.
172
173
    """
173
174
 
174
 
    def __init__(self, basedir, branch=None):
 
175
    def __init__(self, basedir='.', branch=None):
175
176
        """Construct a WorkingTree for basedir.
176
177
 
177
178
        If the branch is not supplied, it is opened automatically.
188
189
        assert isinstance(branch, Branch), \
189
190
            "branch %r is not a Branch" % branch
190
191
        self.branch = branch
191
 
        self.basedir = basedir
192
 
        self._inventory = self.read_working_inventory()
193
 
        self.path2id = self._inventory.path2id
 
192
        self.basedir = realpath(basedir)
 
193
 
 
194
        self._set_inventory(self.read_working_inventory())
194
195
 
195
196
        # update the whole cache up front and write to disk if anything changed;
196
197
        # in the future we might want to do this more selectively
206
207
            mutter("write hc")
207
208
            hc.write()
208
209
 
 
210
    def _set_inventory(self, inv):
 
211
        self._inventory = inv
 
212
        self.path2id = self._inventory.path2id
 
213
 
209
214
    @staticmethod
210
215
    def open_containing(path=None):
211
216
        """Open an existing working tree which has its root about path.
284
289
    def commit(self, *args, **kw):
285
290
        from bzrlib.commit import Commit
286
291
        Commit().commit(self.branch, *args, **kw)
287
 
        self._inventory = self.read_working_inventory()
 
292
        self._set_inventory(self.read_working_inventory())
288
293
 
289
294
    def id2abspath(self, file_id):
290
295
        return self.abspath(self.id2path(file_id))
564
569
                            ["rename rolled back"])
565
570
        except:
566
571
            # restore the inventory on error
567
 
            self._inventory = orig_inv
 
572
            self._set_inventory(orig_inv)
568
573
            raise
569
574
        self._write_inventory(inv)
570
575
        return result
894
899
            f.commit()
895
900
        finally:
896
901
            f.close()
 
902
        self._set_inventory(inv)
897
903
        mutter('wrote working inventory')
898
904
            
899
905