/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

[merge] jam-integration 1495

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
                            compact_date,
64
64
                            file_kind,
65
65
                            isdir,
 
66
                            getcwd,
 
67
                            pathjoin,
66
68
                            pumpfile,
67
69
                            splitpath,
68
70
                            rand_bytes,
 
71
                            abspath,
 
72
                            normpath,
69
73
                            realpath,
70
74
                            relpath,
71
75
                            rename)
193
197
        self.branch = branch
194
198
        self.basedir = realpath(basedir)
195
199
 
196
 
        self._set_inventory(self.read_working_inventory())
197
 
 
198
200
        # update the whole cache up front and write to disk if anything changed;
199
201
        # in the future we might want to do this more selectively
200
202
        # two possible ways offer themselves : in self._unlock, write the cache
209
211
            mutter("write hc")
210
212
            hc.write()
211
213
 
 
214
        self._set_inventory(self.read_working_inventory())
 
215
 
212
216
    def _set_inventory(self, inv):
213
217
        self._inventory = inv
214
218
        self.path2id = self._inventory.path2id
225
229
        If there is one, it is returned, along with the unused portion of path.
226
230
        """
227
231
        if path is None:
228
 
            path = os.getcwdu()
 
232
            path = getcwd()
229
233
        else:
230
234
            # sanity check.
231
235
            if path.find('://') != -1:
232
236
                raise NotBranchError(path=path)
233
 
        path = os.path.abspath(path)
 
237
        path = abspath(path)
234
238
        tail = u''
235
239
        while True:
236
240
            try:
238
242
            except NotBranchError:
239
243
                pass
240
244
            if tail:
241
 
                tail = os.path.join(os.path.basename(path), tail)
 
245
                tail = pathjoin(os.path.basename(path), tail)
242
246
            else:
243
247
                tail = os.path.basename(path)
 
248
            lastpath = path
244
249
            path = os.path.dirname(path)
245
 
            # FIXME: top in windows is indicated how ???
246
 
            if path == os.path.sep:
 
250
            if lastpath == path:
247
251
                # reached the root, whatever that may be
248
252
                raise NotBranchError(path=path)
249
253
 
263
267
                               getattr(self, 'basedir', None))
264
268
 
265
269
    def abspath(self, filename):
266
 
        return os.path.join(self.basedir, filename)
 
270
        return pathjoin(self.basedir, filename)
267
271
 
268
 
    def relpath(self, abspath):
 
272
    def relpath(self, abs):
269
273
        """Return the local path portion from a given absolute path."""
270
 
        return relpath(self.basedir, abspath)
 
274
        return relpath(self.basedir, abs)
271
275
 
272
276
    def has_filename(self, filename):
273
277
        return bzrlib.osutils.lexists(self.abspath(filename))
314
318
    def get_file_size(self, file_id):
315
319
        return os.path.getsize(self.id2abspath(file_id))
316
320
 
 
321
    @needs_read_lock
317
322
    def get_file_sha1(self, file_id):
318
323
        path = self._inventory.id2path(file_id)
319
324
        return self._hashcache.get_sha1(path)
372
377
            if len(fp) == 0:
373
378
                raise BzrError("cannot add top-level %r" % f)
374
379
 
375
 
            fullpath = os.path.normpath(self.abspath(f))
 
380
            fullpath = normpath(self.abspath(f))
376
381
 
377
382
            try:
378
383
                kind = file_kind(fullpath)
909
914
        between multiple working trees, i.e. via shared storage, then we 
910
915
        would probably want to lock both the local tree, and the branch.
911
916
        """
 
917
        if self._hashcache.needs_write:
 
918
            self._hashcache.write()
912
919
        return self.branch.unlock()
913
920
 
914
921
    @needs_write_lock