Plugins/VcsPlugins/vcsMercurial/FetchExtension/fetch.py

changeset 1066
a3dd41fd9ea8
child 1067
1a6dd77e6413
equal deleted inserted replaced
1064:10bdbb173c0f 1066:a3dd41fd9ea8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the fetch extension interface.
8 """
9
10 import os
11
12 from PyQt4.QtCore import QObject
13 from PyQt4.QtGui import QDialog
14
15 from ..HgDialog import HgDialog
16
17 from .HgFetchDialog import HgFetchDialog
18
19
20 class Fetch(QObject):
21 """
22 Class implementing the fetch extension interface.
23 """
24 def __init__(self, vcs):
25 """
26 Constructor
27
28 @param vcs reference to the Mercurial vcs object
29 """
30 QObject.__init__(self, vcs)
31
32 self.vcs = vcs
33
34 def shutdown(self):
35 """
36 Public method used to shutdown the fetch interface.
37 """
38 pass
39
40 def hgFetch(self, name):
41 """
42 Public method to fetch changes from a remote repository.
43
44 @param name file/directory name (string)
45 """
46 # find the root of the repo
47 repodir = self.vcs.splitPath(name)[0]
48 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
49 repodir = os.path.dirname(repodir)
50 if repodir == os.sep:
51 return
52
53 res = False
54 dlg = HgFetchDialog()
55 if dlg.exec_() == QDialog.Accepted:
56 message, switchParent = dlg.getData()
57
58 args = []
59 args.append("fetch")
60 if message != "":
61 args.append("--message")
62 args.append(message)
63 if switchParent:
64 args.append("--switch-parent")
65 args.append("-v")
66
67 dia = HgDialog(self.trUtf8('Fetching from a remote Mercurial repository'))
68 res = dia.startProcess(args, repodir)
69 if res:
70 dia.exec_()
71 res = dia.hasAddOrDelete()
72 self.vcs.checkVCSStatus()
73 return res

eric ide

mercurial