eric6/Plugins/VcsPlugins/vcsMercurial/FetchExtension/fetch.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the fetch extension interface.
8 """
9
10 from __future__ import unicode_literals
11
12 import os
13
14 from PyQt5.QtWidgets import QDialog
15
16 from ..HgExtension import HgExtension
17 from ..HgDialog import HgDialog
18
19
20 class Fetch(HgExtension):
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 super(Fetch, self).__init__(vcs)
31
32 self.__vcs = vcs
33
34 def hgFetch(self, name, revisions=None):
35 """
36 Public method to fetch changes from a remote repository.
37
38 @param name directory name of the project to be fetched to
39 @type str
40 @param revisions list of revisions to be pulled
41 @type list of str
42 @return flag indicating, that the update contained an add
43 or delete
44 @rtype bool
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 os.path.splitdrive(repodir)[1] == os.sep:
51 return False
52
53 from .HgFetchDialog import HgFetchDialog
54 res = False
55 dlg = HgFetchDialog(self.__vcs)
56 if dlg.exec_() == QDialog.Accepted:
57 message, switchParent = dlg.getData()
58
59 args = self.vcs.initCommand("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 if revisions:
67 for rev in revisions:
68 args.append("--rev")
69 args.append(rev)
70
71 dia = HgDialog(
72 self.tr('Fetching from a remote Mercurial repository'),
73 self.vcs)
74 res = dia.startProcess(args, repodir)
75 if res:
76 dia.exec_()
77 res = dia.hasAddOrDelete()
78 self.vcs.checkVCSStatus()
79 return res

eric ide

mercurial