src/eric7/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/largefiles.py

branch
eric7
changeset 11006
a671918232f3
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
equal deleted inserted replaced
11005:b918c6c2736b 11006:a671918232f3
23 class Largefiles(HgExtension): 23 class Largefiles(HgExtension):
24 """ 24 """
25 Class implementing the largefiles extension interface. 25 Class implementing the largefiles extension interface.
26 """ 26 """
27 27
28 def __init__(self, vcs): 28 def __init__(self, vcs, ui=None):
29 """ 29 """
30 Constructor 30 Constructor
31 31
32 @param vcs reference to the Mercurial vcs object 32 @param vcs reference to the Mercurial vcs object
33 @type Hg 33 @type Hg
34 """ 34 @param ui reference to a UI widget (defaults to None)
35 super().__init__(vcs) 35 @type QWidget
36 """
37 super().__init__(vcs, ui=ui)
36 38
37 def hgLfconvert(self, direction, projectFile): 39 def hgLfconvert(self, direction, projectFile):
38 """ 40 """
39 Public slot to convert the repository format of the current project. 41 Public slot to convert the repository format of the current project.
40 42
50 if direction not in ["largefiles", "normal"]: 52 if direction not in ["largefiles", "normal"]:
51 raise ValueError("Bad value for 'direction' parameter.") 53 raise ValueError("Bad value for 'direction' parameter.")
52 54
53 projectDir = os.path.dirname(projectFile) 55 projectDir = os.path.dirname(projectFile)
54 56
55 dlg = LfConvertDataDialog(projectDir, direction) 57 dlg = LfConvertDataDialog(projectDir, direction, parent=self.ui)
56 if dlg.exec() == QDialog.DialogCode.Accepted: 58 if dlg.exec() == QDialog.DialogCode.Accepted:
57 newName, minSize, patterns = dlg.getData() 59 newName, minSize, patterns = dlg.getData()
58 newProjectFile = os.path.join(newName, os.path.basename(projectFile)) 60 newProjectFile = os.path.join(newName, os.path.basename(projectFile))
59 61
60 # step 1: convert the current project to new project 62 # step 1: convert the current project to new project
67 args.append(projectDir) 69 args.append(projectDir)
68 args.append(newName) 70 args.append(newName)
69 if direction == "largefiles" and patterns: 71 if direction == "largefiles" and patterns:
70 args.extend(patterns) 72 args.extend(patterns)
71 73
72 dia = HgDialog(self.tr("Convert Project - Converting"), self.vcs) 74 dia = HgDialog(
75 self.tr("Convert Project - Converting"), hg=self.vcs, parent=self.ui
76 )
73 res = dia.startProcess(args) 77 res = dia.startProcess(args)
74 if res: 78 if res:
75 dia.exec() 79 dia.exec()
76 res = dia.normalExit() and os.path.isdir( 80 res = dia.normalExit() and os.path.isdir(
77 os.path.join(newName, self.vcs.adminDir) 81 os.path.join(newName, self.vcs.adminDir)
95 99
96 # step 2.2: create working directory contents 100 # step 2.2: create working directory contents
97 args = self.vcs.initCommand("update") 101 args = self.vcs.initCommand("update")
98 args.append("--verbose") 102 args.append("--verbose")
99 dia = HgDialog( 103 dia = HgDialog(
100 self.tr("Convert Project - Extracting"), self.vcs, client=client 104 self.tr("Convert Project - Extracting"), hg=self.vcs, parent=self.ui
101 ) 105 )
102 res = dia.startProcess(args) 106 res = dia.startProcess(args)
103 if res: 107 if res:
104 dia.exec() 108 dia.exec()
105 res = dia.normalExit() and os.path.isfile(newProjectFile) 109 res = dia.normalExit() and os.path.isfile(newProjectFile)
140 if isinstance(names, list): 144 if isinstance(names, list):
141 self.vcs.addArguments(args, names) 145 self.vcs.addArguments(args, names)
142 else: 146 else:
143 args.append(names) 147 args.append(names)
144 148
145 dia = HgDialog(self.tr("Adding files to the Mercurial repository"), self.vcs) 149 dia = HgDialog(
150 self.tr("Adding files to the Mercurial repository"),
151 hg=self.vcs,
152 parent=self.ui,
153 )
146 res = dia.startProcess(args) 154 res = dia.startProcess(args)
147 if res: 155 if res:
148 dia.exec() 156 dia.exec()
149 157
150 def hgLfPull(self, revisions=None): 158 def hgLfPull(self, revisions=None):
158 166
159 revs = [] 167 revs = []
160 if revisions: 168 if revisions:
161 revs = revisions 169 revs = revisions
162 else: 170 else:
163 dlg = LfRevisionsInputDialog() 171 dlg = LfRevisionsInputDialog(parent=self.ui)
164 if dlg.exec() == QDialog.DialogCode.Accepted: 172 if dlg.exec() == QDialog.DialogCode.Accepted:
165 revs = dlg.getRevisions() 173 revs = dlg.getRevisions()
166 174
167 if revs: 175 if revs:
168 args = self.vcs.initCommand("lfpull") 176 args = self.vcs.initCommand("lfpull")
169 args.append("-v") 177 args.append("-v")
170 for rev in revs: 178 for rev in revs:
171 args.append("--rev") 179 args.append("--rev")
172 args.append(rev) 180 args.append(rev)
173 181
174 dia = HgDialog(self.tr("Pulling large files"), self.vcs) 182 dia = HgDialog(self.tr("Pulling large files"), hg=self.vcs, parent=self.ui)
175 res = dia.startProcess(args) 183 res = dia.startProcess(args)
176 if res: 184 if res:
177 dia.exec() 185 dia.exec()
178 186
179 def hgLfVerify(self, mode): 187 def hgLfVerify(self, mode):
191 elif mode == "lfc": 199 elif mode == "lfc":
192 args.append("--lfc") 200 args.append("--lfc")
193 else: 201 else:
194 return 202 return
195 203
196 dia = HgDialog(self.tr("Verifying the integrity of large files"), self.vcs) 204 dia = HgDialog(
205 self.tr("Verifying the integrity of large files"),
206 hg=self.vcs,
207 parent=self.ui,
208 )
197 res = dia.startProcess(args) 209 res = dia.startProcess(args)
198 if res: 210 if res:
199 dia.exec() 211 dia.exec()

eric ide

mercurial