Plugins/VcsPlugins/vcsMercurial/FetchExtension/fetch.py

Sat, 28 May 2011 12:57:01 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 28 May 2011 12:57:01 +0200
changeset 1067
1a6dd77e6413
parent 1066
a3dd41fd9ea8
child 1087
fb8cd56819a9
permissions
-rw-r--r--

Corrected a wrong return value in fetch.py.

# -*- coding: utf-8 -*-

# Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing the fetch extension interface.
"""

import os

from PyQt4.QtCore import QObject
from PyQt4.QtGui import QDialog

from ..HgDialog import HgDialog

from .HgFetchDialog import HgFetchDialog


class Fetch(QObject):
    """
    Class implementing the fetch extension interface.
    """
    def __init__(self, vcs):
        """
        Constructor
        
        @param vcs reference to the Mercurial vcs object
        """
        QObject.__init__(self, vcs)
        
        self.vcs = vcs
    
    def shutdown(self):
        """
        Public method used to shutdown the fetch interface.
        """
        pass
    
    def hgFetch(self, name):
        """
        Public method to fetch changes from a remote repository.
        
        @param name file/directory name (string)
        @return flag indicating that the project should be reread (boolean)
        """
        # find the root of the repo
        repodir = self.vcs.splitPath(name)[0]
        while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
            repodir = os.path.dirname(repodir)
            if repodir == os.sep:
                return False
        
        res = False
        dlg = HgFetchDialog()
        if dlg.exec_() == QDialog.Accepted:
            message, switchParent = dlg.getData()
            
            args = []
            args.append("fetch")
            if message != "":
                args.append("--message")
                args.append(message)
            if switchParent:
                args.append("--switch-parent")
            args.append("-v")
            
            dia = HgDialog(self.trUtf8('Fetching from a remote Mercurial repository'))
            res = dia.startProcess(args, repodir)
            if res:
                dia.exec_()
                res = dia.hasAddOrDelete()
                self.vcs.checkVCSStatus()
        return res

eric ide

mercurial