예제 #1
0
 def invalidateDirectory(self, path):
     path = str(path)
     try:
         parts = osutils.splitpath(path)
         entry = self.cache
         for part in parts[:-1]:
             entry = entry.children[part]
         print("Removing", path, "from the cache")
         del entry.children[parts[-1]]
     except KeyError:
         pass
     else:
         self.autoRefreshPath = path
         self.autoRefreshTimer.start(1000)
예제 #2
0
    def _cacheDirectoryStatus(self, path):
        p = '/'.join(path)
        if sys.platform != 'win32':
            p = '/' + p
        # print "caching", p
        try:
            # to stop bzr-svn from trying to give status on svn checkouts
            # if not QtCore.QDir(p).exists('.bzr'):
            #    raise errors.NotBranchError(p)
            wt, relpath = workingtree.WorkingTree.open_containing(p)
        except errors.BzrError:
            self.fileSystemWatcher.addPath(p)
            return self._cacheStatus(path, 'non-versioned')
        self.fileSystemWatcher.addPath(wt.basedir)
        bt = wt.basis_tree()
        root = self._cacheStatus(osutils.splitpath(wt.basedir), 'branch')
        # delta will be a TreeDelta: commit 7389 makes TreeDelta HOLD TreeChange objects in
        # list member variables called added, removed, renamed, copied, kind_changes, modified
        # unchanged, unversioned and missing
        delta = wt.changes_from(bt, want_unchanged=True, want_unversioned=True)
        # ... and thus entry will be a TreeChange object, with the path in,
        # perhaps unsurprisingly, 'path' rather than entry[0]. Path is a tuple of
        # old and new path, so get whatever works
        for entry in delta.added:
            self._cacheStatus(osutils.splitpath(entry.path[0]
                                                or entry.path[1]),
                              'added',
                              root=root)
        for entry in delta.removed:
            # FIXME
            self._cacheStatus(osutils.splitpath(entry.path[0]
                                                or entry.path[1]),
                              'modified',
                              root=root)
#            self._cacheStatus(osutils.splitpath(entry[0]), 'removed', root=root)
        for entry in delta.modified:
            self._cacheStatus(osutils.splitpath(entry.path[0]
                                                or entry.path[1]),
                              'modified',
                              root=root)
        for entry in delta.unchanged:
            self._cacheStatus(osutils.splitpath(entry.path[0]
                                                or entry.path[1]),
                              'unchanged',
                              root=root)
            # self._cacheStatus(osutils.splitpath(entry[0]), 'unchanged', root=root)
        for entry in delta.unversioned:
            self._cacheStatus(osutils.splitpath(entry.path[0]
                                                or entry.path[1]),
                              'non-versioned',
                              root=root)
        try:
            return self._getCacheEntry(path)
        except KeyError:
            self.fileSystemWatcher.addPath(p)
            return self._cacheStatus(path, 'non-versioned')
예제 #3
0
 def setDirectory(self, path):
     self.currentDirectory = path
     self.setWindowTitle("QBrz - %s" % path)
     QtWidgets.QApplication.setOverrideCursor(
         QtGui.QCursor(QtCore.Qt.WaitCursor))
     try:
         pathParts = osutils.splitpath(path)
         self.fileListView.invisibleRootItem().takeChildren()
         item = QtWidgets.QTreeWidgetItem(self.fileListView)
         item.setText(0, '..')
         item.setIcon(0, self.icons['folder'])
         item.setData(0, QtCore.Qt.UserRole, os.path.dirname(path))
         fileInfoList = QtCore.QDir(path).entryInfoList(
             QtCore.QDir.AllEntries | QtCore.QDir.NoDotAndDotDot,
             QtCore.QDir.DirsFirst)
         for fileInfo in fileInfoList:
             item = QtWidgets.QTreeWidgetItem(self.fileListView)
             item.setText(0, fileInfo.fileName())
             if fileInfo.isDir():
                 status = self.cache.getDirectoryStatus(
                     pathParts, str(fileInfo.fileName()))
                 if status == 'non-versioned':
                     icon = 'folder'
                 else:
                     icon = 'folder-' + status
                 item.setData(0, QtCore.Qt.UserRole, fileInfo.filePath())
                 item.setIcon(0, self.icons[icon])
             else:
                 status = self.cache.getFileStatus(pathParts,
                                                   str(fileInfo.fileName()))
                 if status == 'non-versioned':
                     icon = 'file'
                 else:
                     icon = 'file-' + status
                 item.setIcon(0, self.icons[icon])
                 item.setText(1, formatFileSize(fileInfo.size()))
                 item.setTextAlignment(1, QtCore.Qt.AlignRight)
             item.setText(2, status)
     finally:
         QtWidgets.QApplication.restoreOverrideCursor()
예제 #4
0
 def path_key(change):
     if change.path[0] is not None:
         path = change.path[0]
     else:
         path = change.path[1]
     return osutils.splitpath(path)