Example #1
0
    def addRepo(self, group, root, row=-1):
        grp = group
        if grp == None:
            grp = self.allreposIndex()
        rgi = grp.internalPointer()
        if row < 0:
            row = rgi.childCount()

        # make sure all paths are properly normalized
        root = os.path.normpath(root)

        # Check whether the repo that we are adding is a subrepo
        # This check could be expensive, particularly for network repositories
        # Thus, only perform this check on network repos if the showNetworkSubrepos
        # flag is set
        itemIsSubrepo = False
        if self.showNetworkSubrepos \
                or not paths.netdrive_status(root):
            outerrepopath = paths.find_root(os.path.dirname(root))
            if outerrepopath:
                # Check whether repo we are adding is a subrepo of
                # its containing (outer) repo
                # This check is currently quite imperfect, since it
                # only checks the current repo revision
                outerrepo = hg.repository(ui.ui(), path=outerrepopath)
                relroot = util.normpath(root[len(outerrepopath) + 1:])
                if relroot in outerrepo['.'].substate:
                    itemIsSubrepo = True

        self.beginInsertRows(grp, row, row)
        if itemIsSubrepo:
            ri = SubrepoItem(root)
        else:
            ri = RepoItem(root)
        rgi.insertChild(row, ri)

        if not self.showSubrepos \
                or (not self.showNetworkSubrepos and paths.netdrive_status(root)):
            self.endInsertRows()
            return

        invalidRepoList = ri.appendSubrepos()

        self.endInsertRows()

        if invalidRepoList:
            if invalidRepoList[0] == root:
                qtlib.WarningMsgBox(
                    _('Could not get subrepository list'),
                    _('It was not possible to get the subrepository list for '
                      'the repository in:<br><br><i>%s</i>') % root)
            else:
                qtlib.WarningMsgBox(
                    _('Could not open some subrepositories'),
                    _('It was not possible to fully load the subrepository '
                      'list for the repository in:<br><br><i>%s</i><br><br>'
                      'The following subrepositories may be missing, broken or '
                      'on an inconsistent state and cannot be accessed:'
                      '<br><br><i>%s</i>') %
                    (root, "<br>".join(invalidRepoList)))
    def addRepo(self, group, root, row=-1):
        grp = group
        if grp == None:
            grp = self.allreposIndex()
        rgi = grp.internalPointer()
        if row < 0:
            row = rgi.childCount()

        # make sure all paths are properly normalized
        root = os.path.normpath(root)

        # Check whether the repo that we are adding is a subrepo
        # This check could be expensive, particularly for network repositories
        # Thus, only perform this check on network repos if the showNetworkSubrepos
        # flag is set
        itemIsSubrepo = False
        if self.showNetworkSubrepos \
                or not paths.netdrive_status(root):
            outerrepopath = paths.find_root(os.path.dirname(root))
            if outerrepopath:
                # Check whether repo we are adding is a subrepo of
                # its containing (outer) repo
                # This check is currently quite imperfect, since it
                # only checks the current repo revision
                outerrepo = hg.repository(ui.ui(), path=outerrepopath)
                relroot = util.normpath(root[len(outerrepopath)+1:])
                if relroot in outerrepo['.'].substate:
                    itemIsSubrepo = True

        self.beginInsertRows(grp, row, row)
        if itemIsSubrepo:
            ri = SubrepoItem(root)
        else:
            ri = RepoItem(root)
        rgi.insertChild(row, ri)

        if not self.showSubrepos \
                or (not self.showNetworkSubrepos and paths.netdrive_status(root)):
            self.endInsertRows()
            return

        invalidRepoList = ri.appendSubrepos()

        self.endInsertRows()

        if invalidRepoList:
            if invalidRepoList[0] == root:
                qtlib.WarningMsgBox(_('Could not get subrepository list'),
                    _('It was not possible to get the subrepository list for '
                    'the repository in:<br><br><i>%s</i>') % root)
            else:
                qtlib.WarningMsgBox(_('Could not open some subrepositories'),
                    _('It was not possible to fully load the subrepository '
                    'list for the repository in:<br><br><i>%s</i><br><br>'
                    'The following subrepositories may be missing, broken or '
                    'on an inconsistent state and cannot be accessed:'
                    '<br><br><i>%s</i>')  %
                    (root, "<br>".join(invalidRepoList)))
Example #3
0
 def loadSubrepos(self, root, filterFunc=(lambda r: True)):
     for c in getRepoItemList(root):
         if filterFunc(c.rootpath()):
             if self.showNetworkSubrepos \
                     or not paths.netdrive_status(c.rootpath()):
                 self.removeRows(0, c.childCount(),
                     self.createIndex(c.row(), 0, c))
                 c.appendSubrepos()
Example #4
0
 def startMonitoringIfEnabled(self):
     """Start filesystem monitoring on repository open by RepoManager or
     running command finished"""
     repo = self._repo
     monitorrepo = repo.ui.config('tortoisehg', 'monitorrepo', 'always')
     if monitorrepo == 'never':
         dbgoutput('watching of F/S events is disabled by configuration')
     elif isinstance(repo, bundlerepo.bundlerepository):
         dbgoutput('not watching F/S events for bundle repository')
     elif monitorrepo == 'localonly' and paths.netdrive_status(repo.path):
         dbgoutput('not watching F/S events for network drive')
     elif self.isBusy():
         dbgoutput('not watching F/S events while busy')
     else:
         self._watcher.startMonitoring()
Example #5
0
 def startMonitoringIfEnabled(self):
     """Start filesystem monitoring on repository open by RepoManager or
     running command finished"""
     repo = self._repo
     monitorrepo = repo.ui.config('tortoisehg', 'monitorrepo', 'always')
     if monitorrepo == 'never':
         dbgoutput('watching of F/S events is disabled by configuration')
     elif isinstance(repo, bundlerepo.bundlerepository):
         dbgoutput('not watching F/S events for bundle repository')
     elif monitorrepo == 'localonly' and paths.netdrive_status(repo.path):
         dbgoutput('not watching F/S events for network drive')
     elif self.isBusy():
         dbgoutput('not watching F/S events while busy')
     else:
         self._watcher.startMonitoring()
Example #6
0
    def _scanAllRepos(self):
        m = self.tview.model()
        indexes = m.indexesOfRepoItems(standalone=True)
        if not self._isSettingEnabled('showNetworkSubrepos'):
            indexes = [idx for idx in indexes
                       if not paths.netdrive_status(m.repoRoot(idx))]

        topic = _('Updating repository registry')
        for n, idx in enumerate(indexes):
            self.progressReceived.emit(
                topic, n, _('Loading repository %s') % m.repoRoot(idx), '',
                len(indexes))
            m.loadSubrepos(idx)
        self.progressReceived.emit(
            topic, None, _('Repository Registry updated'), '', None)
Example #7
0
    def _scanAllRepos(self):
        m = self.tview.model()
        indexes = m.indexesOfRepoItems(standalone=True)
        if not self._isSettingEnabled('showNetworkSubrepos'):
            indexes = [
                idx for idx in indexes
                if not paths.netdrive_status(m.repoRoot(idx))
            ]

        topic = _('Updating repository registry')
        for n, idx in enumerate(indexes):
            self.progressReceived.emit(
                topic, n,
                _('Loading repository %s') % m.repoRoot(idx), '', len(indexes))
            m.loadSubrepos(idx)
        self.progressReceived.emit(topic, None,
                                   _('Repository Registry updated'), '', None)
 def loadSubrepos(self, root, filterFunc=(lambda r: True)):
     repoList = getRepoItemList(root)
     for n, c in enumerate(repoList):
         QCoreApplication.processEvents()
         if filterFunc(c.rootpath()):
             if self.showNetworkSubrepos \
                     or not paths.netdrive_status(c.rootpath()):
                 self.updateProgress.emit(n, len(repoList),
                     _('Updating repository registry'),
                     _('Loading repository %s')
                     % hglib.tounicode(c.rootpath()))
                 QCoreApplication.processEvents()
                 self.removeRows(0, c.childCount(),
                     self.createIndex(c.row(), 0, c))
                 c.appendSubrepos()
     self.updateProgress.emit(len(repoList), len(repoList),
         _('Updating repository registry'),
         _('Repository Registry updated'))
Example #9
0
 def loadSubrepos(self, root, filterFunc=(lambda r: True)):
     repoList = getRepoItemList(root)
     for n, c in enumerate(repoList):
         QCoreApplication.processEvents()
         if filterFunc(c.rootpath()):
             if self.showNetworkSubrepos \
                     or not paths.netdrive_status(c.rootpath()):
                 self.updateProgress.emit(
                     n, len(repoList), _('Updating repository registry'),
                     _('Loading repository %s') %
                     hglib.tounicode(c.rootpath()))
                 QCoreApplication.processEvents()
                 self.removeRows(0, c.childCount(),
                                 self.createIndex(c.row(), 0, c))
                 c.appendSubrepos()
     self.updateProgress.emit(len(repoList), len(repoList),
                              _('Updating repository registry'),
                              _('Repository Registry updated'))
Example #10
0
    def addRepo(self, group, root, row=-1):
        grp = group
        if grp == None:
            grp = self.allreposIndex()
        rgi = grp.internalPointer()
        if row < 0:
            row = rgi.childCount()

        # Is the root of the repo that we want to add a subrepo contained
        # within a repo or subrepo? If so, assume it is an hg subrepo
        itemIsSubrepo = not paths.find_root(os.path.dirname(root)) is None
        self.beginInsertRows(grp, row, row)
        if itemIsSubrepo:
            ri = SubrepoItem(root)
        else:
            ri = RepoItem(root)
        rgi.insertChild(row, ri)

        if not self.showSubrepos \
                or (not self.showNetworkSubrepos and paths.netdrive_status(root)):
            self.endInsertRows()
            return

        invalidRepoList = ri.appendSubrepos()

        self.endInsertRows()

        if invalidRepoList:
            if invalidRepoList[0] == root:
                qtlib.WarningMsgBox(_('Could not get subrepository list'),
                    _('It was not possible to get the subrepository list for '
                    'the repository in:<br><br><i>%s</i>') % root)
            else:
                qtlib.WarningMsgBox(_('Could not open some subrepositories'),
                    _('It was not possible to fully load the subrepository '
                    'list for the repository in:<br><br><i>%s</i><br><br>'
                    'The following subrepositories may be missing, broken or '
                    'on an inconsistent state and cannot be accessed:'
                    '<br><br><i>%s</i>')  %
                    (root, "<br>".join(invalidRepoList)))
Example #11
0
    def __init__(self, repo):
        QObject.__init__(self)
        self.repo = repo
        self.busycount = 0
        repo.configChanged = self.configChanged
        repo.repositoryChanged = self.repositoryChanged
        repo.repositoryDestroyed = self.repositoryDestroyed
        repo.workingDirectoryChanged = self.workingDirectoryChanged
        repo.workingBranchChanged = self.workingBranchChanged
        self.recordState()

        monitorrepo = repo.ui.config('tortoisehg', 'monitorrepo', 'always')
        if isinstance(repo, bundlerepo.bundlerepository):
            dbgoutput('not watching F/S events for bundle repository')
        elif monitorrepo == 'localonly' and paths.netdrive_status(repo.path):
            dbgoutput('not watching F/S events for network drive')
        else:
            self.watcher = QFileSystemWatcher(self)
            self.watcher.addPath(hglib.tounicode(repo.path))
            self.watcher.directoryChanged.connect(self.onDirChange)
            self.watcher.fileChanged.connect(self.onFileChange)
            self.addMissingPaths()
Example #12
0
    def __init__(self, repo):
        QObject.__init__(self)
        self.repo = repo
        self.busycount = 0
        repo.configChanged = self.configChanged
        repo.repositoryChanged = self.repositoryChanged
        repo.repositoryDestroyed = self.repositoryDestroyed
        repo.workingDirectoryChanged = self.workingDirectoryChanged
        repo.workingBranchChanged = self.workingBranchChanged
        self.recordState()

        monitorrepo = repo.ui.config('tortoisehg', 'monitorrepo', 'always')
        if isinstance(repo, bundlerepo.bundlerepository):
            dbgoutput('not watching F/S events for bundle repository')
        elif monitorrepo == 'localonly' and paths.netdrive_status(repo.path):
            dbgoutput('not watching F/S events for network drive')
        else:
            self.watcher = QFileSystemWatcher(self)
            self.watcher.addPath(hglib.tounicode(repo.path))
            self.watcher.addPath(hglib.tounicode(repo.path + '/store'))
            self.watcher.directoryChanged.connect(self.onDirChange)
            self.watcher.fileChanged.connect(self.onFileChange)
            self.addMissingPaths()
Example #13
0
def get_states(upath, repo=None):
    """
    Get the states of a given path in source control.
    """
    global overlay_cache, cache_tick_count
    global cache_root, cache_pdir
    global enabled, localonly
    global includepaths, excludepaths

    #debugf("called: _get_state(%s)", path)
    tc = GetTickCount()

    try:
        # handle some Asian charsets
        path = upath.encode('mbcs')
    except:
        path = upath
    # check if path is cached
    pdir = os.path.dirname(path)
    status = overlay_cache.get(path, '')
    if overlay_cache and (cache_pdir == pdir or cache_pdir and status
                          not in ' r' and path.startswith(cache_pdir)):
        #use cached data when pdir has not changed or when the cached state is a repo state
        if tc - cache_tick_count < CACHE_TIMEOUT:
            if not status:
                if os.path.isdir(os.path.join(path, '.hg')):
                    add(path, ROOT)
                    status = ROOT
                else:
                    status = overlay_cache.get(pdir + '*', NOT_IN_REPO)
                    add(path, status)
                debugf("%s: %s (cached~)", (path, status))
            else:
                debugf("%s: %s (cached)", (path, status))
            return status
        else:
            debugf("Timed out!!")
            overlay_cache.clear()
            cache_tick_count = GetTickCount()
    # path is a drive
    if path.endswith(":\\"):
        add(path, NOT_IN_REPO)
        return NOT_IN_REPO
    # open repo
    if cache_pdir == pdir:
        root = cache_root
    else:
        debugf("find new root")
        root = paths.find_root(path)
        if root == path:
            if not overlay_cache:
                cache_root = pdir
            add(path, ROOT)
            debugf("%s: r", path)
            return ROOT
        cache_root = root
        cache_pdir = pdir

    if root is None:
        debugf("_get_state: not in repo")
        overlay_cache = {None: None}
        cache_tick_count = GetTickCount()
        return NOT_IN_REPO
    debugf("_get_state: root = " + root)
    hgdir = os.path.join(root, '.hg', '')
    if pdir == hgdir[:-1] or pdir.startswith(hgdir):
        add(pdir, NOT_IN_REPO)
        return NOT_IN_REPO
    try:
        if not enabled:
            overlay_cache = {None: None}
            cache_tick_count = GetTickCount()
            debugf("overlayicons disabled")
            return NOT_IN_REPO
        if localonly and paths.netdrive_status(path):
            debugf("%s: is a network drive", path)
            overlay_cache = {None: None}
            cache_tick_count = GetTickCount()
            return NOT_IN_REPO
        if includepaths:
            for p in includepaths:
                if path.startswith(p):
                    break
            else:
                debugf("%s: is not in an include path", path)
                overlay_cache = {None: None}
                cache_tick_count = GetTickCount()
                return NOT_IN_REPO
        for p in excludepaths:
            if path.startswith(p):
                debugf("%s: is in an exclude path", path)
                overlay_cache = {None: None}
                cache_tick_count = GetTickCount()
                return NOT_IN_REPO
        tc1 = GetTickCount()
        real = os.path.realpath  #only test if necessary (symlink in path)
        if not repo or (repo.root != root and repo.root != real(root)):
            repo = hg.repository(ui.ui(), path=root)
            debugf("hg.repository() took %g ticks", (GetTickCount() - tc1))
    except error.RepoError:
        # We aren't in a working tree
        debugf("%s: not in repo", pdir)
        add(pdir + '*', IGNORED)
        return IGNORED
    except Exception, e:
        debugf("error while handling %s:", pdir)
        debugf(e)
        add(pdir + '*', UNKNOWN)
        return UNKNOWN
Example #14
0
def get_states(upath, repo=None):
    """
    Get the states of a given path in source control.
    """
    global overlay_cache, cache_tick_count
    global cache_root, cache_pdir
    global enabled, localonly
    global includepaths, excludepaths

    # debugf("called: _get_state(%s)", path)
    tc = GetTickCount()

    try:
        # handle some Asian charsets
        path = upath.encode("mbcs")
    except:
        path = upath
    # check if path is cached
    pdir = os.path.dirname(path)
    status = overlay_cache.get(path, "")
    if overlay_cache and (cache_pdir == pdir or cache_pdir and status not in " r" and path.startswith(cache_pdir)):
        # use cached data when pdir has not changed or when the cached state is a repo state
        if tc - cache_tick_count < CACHE_TIMEOUT:
            if not status:
                if os.path.isdir(os.path.join(path, ".hg")):
                    add(path, ROOT)
                    status = ROOT
                else:
                    status = overlay_cache.get(pdir + "*", NOT_IN_REPO)
                    add(path, status)
                debugf("%s: %s (cached~)", (path, status))
            else:
                debugf("%s: %s (cached)", (path, status))
            return status
        else:
            debugf("Timed out!!")
            overlay_cache.clear()
            cache_tick_count = GetTickCount()
    # path is a drive
    if path.endswith(":\\"):
        add(path, NOT_IN_REPO)
        return NOT_IN_REPO
    # open repo
    if cache_pdir == pdir:
        root = cache_root
    else:
        debugf("find new root")
        root = paths.find_root(path)
        if root == path:
            if not overlay_cache:
                cache_root = pdir
            add(path, ROOT)
            debugf("%s: r", path)
            return ROOT
        cache_root = root
        cache_pdir = pdir

    if root is None:
        debugf("_get_state: not in repo")
        overlay_cache = {None: None}
        cache_tick_count = GetTickCount()
        return NOT_IN_REPO
    debugf("_get_state: root = " + root)
    hgdir = os.path.join(root, ".hg", "")
    if pdir == hgdir[:-1] or pdir.startswith(hgdir):
        add(pdir, NOT_IN_REPO)
        return NOT_IN_REPO
    try:
        if not enabled:
            overlay_cache = {None: None}
            cache_tick_count = GetTickCount()
            debugf("overlayicons disabled")
            return NOT_IN_REPO
        if localonly and paths.netdrive_status(path):
            debugf("%s: is a network drive", path)
            overlay_cache = {None: None}
            cache_tick_count = GetTickCount()
            return NOT_IN_REPO
        if includepaths:
            for p in includepaths:
                if path.startswith(p):
                    break
            else:
                debugf("%s: is not in an include path", path)
                overlay_cache = {None: None}
                cache_tick_count = GetTickCount()
                return NOT_IN_REPO
        for p in excludepaths:
            if path.startswith(p):
                debugf("%s: is in an exclude path", path)
                overlay_cache = {None: None}
                cache_tick_count = GetTickCount()
                return NOT_IN_REPO
        tc1 = GetTickCount()
        real = os.path.realpath  # only test if necessary (symlink in path)
        if not repo or (repo.root != root and repo.root != real(root)):
            repo = hg.repository(ui.ui(), path=root)
            debugf("hg.repository() took %g ticks", (GetTickCount() - tc1))
    except error.RepoError:
        # We aren't in a working tree
        debugf("%s: not in repo", pdir)
        add(pdir + "*", IGNORED)
        return IGNORED
    except Exception, e:
        debugf("error while handling %s:", pdir)
        debugf(e)
        add(pdir + "*", UNKNOWN)
        return UNKNOWN