/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_4.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-05 14:47:26 UTC
  • mfrom: (5752.2.11 2.4-windows-lfstat)
  • Revision ID: pqm@pqm.ubuntu.com-20110405144726-zi3lj2kwvjml4kx5
(jameinel) Add osutils.lstat/fstat so that even on Windows lstat(fname) ==
 fstat(open(fname).fileno()) (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007-2011 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
31
31
import errno
32
32
import stat
33
33
 
34
 
import bzrlib
35
34
from bzrlib import (
36
35
    bzrdir,
37
36
    cache_utf8,
46
45
    transform,
47
46
    views,
48
47
    )
49
 
import bzrlib.branch
50
 
import bzrlib.ui
51
48
""")
52
49
 
53
50
from bzrlib.decorators import needs_read_lock, needs_write_lock
62
59
    realpath,
63
60
    safe_unicode,
64
61
    )
65
 
from bzrlib.trace import mutter
66
62
from bzrlib.transport.local import LocalTransport
67
63
from bzrlib.tree import InterTree
68
64
from bzrlib.tree import Tree
85
81
        self._format = _format
86
82
        self.bzrdir = _bzrdir
87
83
        basedir = safe_unicode(basedir)
88
 
        mutter("opening working tree %r", basedir)
 
84
        trace.mutter("opening working tree %r", basedir)
89
85
        self._branch = branch
90
86
        self.basedir = realpath(basedir)
91
87
        # if branch is at our basedir and is a format 6 or less
369
365
        state = self.current_dirstate()
370
366
        if stat_value is None:
371
367
            try:
372
 
                stat_value = os.lstat(file_abspath)
 
368
                stat_value = osutils.lstat(file_abspath)
373
369
            except OSError, e:
374
370
                if e.errno == errno.ENOENT:
375
371
                    return None
478
474
            self._must_be_locked()
479
475
            if not path:
480
476
                path = self.id2path(file_id)
481
 
            mode = os.lstat(self.abspath(path)).st_mode
 
477
            mode = osutils.lstat(self.abspath(path)).st_mode
482
478
            return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
483
479
 
484
480
    def all_file_ids(self):
1247
1243
        # have to change the legacy inventory too.
1248
1244
        if self._inventory is not None:
1249
1245
            for file_id in file_ids:
1250
 
                self._inventory.remove_recursive_id(file_id)
 
1246
                if self._inventory.has_id(file_id):
 
1247
                    self._inventory.remove_recursive_id(file_id)
1251
1248
 
1252
1249
    @needs_tree_write_lock
1253
1250
    def rename_one(self, from_rel, to_rel, after=False):
1292
1289
            self._inventory = inv
1293
1290
        self.flush()
1294
1291
 
 
1292
    @needs_tree_write_lock
 
1293
    def reset_state(self, revision_ids=None):
 
1294
        """Reset the state of the working tree.
 
1295
 
 
1296
        This does a hard-reset to a last-known-good state. This is a way to
 
1297
        fix if something got corrupted (like the .bzr/checkout/dirstate file)
 
1298
        """
 
1299
        if revision_ids is None:
 
1300
            revision_ids = self.get_parent_ids()
 
1301
        if not revision_ids:
 
1302
            base_tree = self.branch.repository.revision_tree(
 
1303
                _mod_revision.NULL_REVISION)
 
1304
            trees = []
 
1305
        else:
 
1306
            trees = zip(revision_ids,
 
1307
                        self.branch.repository.revision_trees(revision_ids))
 
1308
            base_tree = trees[0][1]
 
1309
        state = self.current_dirstate()
 
1310
        # We don't support ghosts yet
 
1311
        state.set_state_from_scratch(base_tree.inventory, trees, [])
 
1312
 
1295
1313
 
1296
1314
class ContentFilterAwareSHA1Provider(dirstate.SHA1Provider):
1297
1315
 
1329
1347
    def _file_content_summary(self, path, stat_result):
1330
1348
        # This is to support the somewhat obsolete path_content_summary method
1331
1349
        # with content filtering: see
1332
 
        # <https://bugs.edge.launchpad.net/bzr/+bug/415508>.
 
1350
        # <https://bugs.launchpad.net/bzr/+bug/415508>.
1333
1351
        #
1334
1352
        # If the dirstate cache is up to date and knows the hash and size,
1335
1353
        # return that.
1384
1402
 
1385
1403
class DirStateWorkingTreeFormat(WorkingTreeFormat3):
1386
1404
 
 
1405
    missing_parent_conflicts = True
 
1406
 
1387
1407
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
1388
1408
                   accelerator_tree=None, hardlink=False):
1389
1409
        """See WorkingTreeFormat.initialize().
1737
1757
                elif kind == 'directory':
1738
1758
                    parent_ies[(dirname + '/' + name).strip('/')] = inv_entry
1739
1759
                elif kind == 'symlink':
1740
 
                    inv_entry.executable = False
1741
 
                    inv_entry.text_size = None
1742
1760
                    inv_entry.symlink_target = utf8_decode(fingerprint)[0]
1743
1761
                elif kind == 'tree-reference':
1744
1762
                    inv_entry.reference_revision = fingerprint or None
1868
1886
    def is_executable(self, file_id, path=None):
1869
1887
        ie = self.inventory[file_id]
1870
1888
        if ie.kind != "file":
1871
 
            return None
 
1889
            return False
1872
1890
        return ie.executable
1873
1891
 
1874
1892
    def is_locked(self):