Plugins/VcsPlugins/vcsSubversion/subversion.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1083
dc680a0ce221
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
7 Module implementing the version control systems interface to Subversion. 7 Module implementing the version control systems interface to Subversion.
8 """ 8 """
9 9
10 import os 10 import os
11 import shutil 11 import shutil
12 import urllib.request, urllib.parse, urllib.error 12 import urllib.request
13 import urllib.parse
14 import urllib.error
13 15
14 from PyQt4.QtCore import * 16 from PyQt4.QtCore import *
15 from PyQt4.QtGui import * 17 from PyQt4.QtGui import *
16 18
17 from E5Gui.E5Application import e5App 19 from E5Gui.E5Application import e5App
45 from .ProjectBrowserHelper import SvnProjectBrowserHelper 47 from .ProjectBrowserHelper import SvnProjectBrowserHelper
46 48
47 import Preferences 49 import Preferences
48 import Utilities 50 import Utilities
49 51
52
50 class Subversion(VersionControl): 53 class Subversion(VersionControl):
51 """ 54 """
52 Class implementing the version control systems interface to Subversion. 55 Class implementing the version control systems interface to Subversion.
53 56
54 @signal committed() emitted after the commit action has completed 57 @signal committed() emitted after the commit action has completed
63 @param parent parent widget (QWidget) 66 @param parent parent widget (QWidget)
64 @param name name of this object (string) 67 @param name name of this object (string)
65 """ 68 """
66 VersionControl.__init__(self, parent, name) 69 VersionControl.__init__(self, parent, name)
67 self.defaultOptions = { 70 self.defaultOptions = {
68 'global' : [''], 71 'global': [''],
69 'commit' : [''], 72 'commit': [''],
70 'checkout' : [''], 73 'checkout': [''],
71 'update' : [''], 74 'update': [''],
72 'add' : [''], 75 'add': [''],
73 'remove' : [''], 76 'remove': [''],
74 'diff' : [''], 77 'diff': [''],
75 'log' : [''], 78 'log': [''],
76 'history' : [''], 79 'history': [''],
77 'status' : [''], 80 'status': [''],
78 'tag' : [''], 81 'tag': [''],
79 'export' : [''] 82 'export': ['']
80 } 83 }
81 self.interestingDataKeys = [ 84 self.interestingDataKeys = [
82 "standardLayout", 85 "standardLayout",
83 ] 86 ]
84 87
93 self.mergeList = [[], [], []] 96 self.mergeList = [[], [], []]
94 self.showedTags = False 97 self.showedTags = False
95 self.showedBranches = False 98 self.showedBranches = False
96 99
97 self.tagTypeList = [ 100 self.tagTypeList = [
98 'tags', 101 'tags',
99 'branches', 102 'branches',
100 ] 103 ]
101 104
102 self.commandHistory = [] 105 self.commandHistory = []
103 self.wdHistory = [] 106 self.wdHistory = []
104 107
180 else: 183 else:
181 errMsg = self.trUtf8("Could not start the svn executable.") 184 errMsg = self.trUtf8("Could not start the svn executable.")
182 185
183 return False, errMsg 186 return False, errMsg
184 187
185 def vcsInit(self, vcsDir, noDialog = False): 188 def vcsInit(self, vcsDir, noDialog=False):
186 """ 189 """
187 Public method used to initialize the subversion repository. 190 Public method used to initialize the subversion repository.
188 191
189 The subversion repository has to be initialized from outside eric5 192 The subversion repository has to be initialized from outside eric5
190 because the respective command always works locally. Therefore we 193 because the respective command always works locally. Therefore we
244 project.setDirty(True) 247 project.setDirty(True)
245 project.saveProject() 248 project.saveProject()
246 project.closeProject() 249 project.closeProject()
247 return 250 return
248 shutil.rmtree(tmpProjectDir, True) 251 shutil.rmtree(tmpProjectDir, True)
249 project.closeProject(noSave = True) 252 project.closeProject(noSave=True)
250 project.openProject(pfn) 253 project.openProject(pfn)
251 254
252 def vcsImport(self, vcsDataDict, projectDir, noDialog = False): 255 def vcsImport(self, vcsDataDict, projectDir, noDialog=False):
253 """ 256 """
254 Public method used to import the project into the Subversion repository. 257 Public method used to import the project into the Subversion repository.
255 258
256 @param vcsDataDict dictionary of data required for the import 259 @param vcsDataDict dictionary of data required for the import
257 @param projectDir project directory (string) 260 @param projectDir project directory (string)
268 if vcsDir.startswith('/'): 271 if vcsDir.startswith('/'):
269 vcsDir = 'file://{0}'.format(vcsDir) 272 vcsDir = 'file://{0}'.format(vcsDir)
270 elif vcsDir[1] in ['|', ':']: 273 elif vcsDir[1] in ['|', ':']:
271 vcsDir = 'file:///{0}'.format(vcsDir) 274 vcsDir = 'file:///{0}'.format(vcsDir)
272 275
273 project = vcsDir[vcsDir.rfind('/')+1:] 276 project = vcsDir[vcsDir.rfind('/') + 1:]
274 277
275 # create the dir structure to be imported into the repository 278 # create the dir structure to be imported into the repository
276 tmpDir = '{0}_tmp'.format(projectDir) 279 tmpDir = '{0}_tmp'.format(projectDir)
277 try: 280 try:
278 os.makedirs(tmpDir) 281 os.makedirs(tmpDir)
283 shutil.copytree(projectDir, os.path.join(tmpDir, project, 'trunk')) 286 shutil.copytree(projectDir, os.path.join(tmpDir, project, 'trunk'))
284 else: 287 else:
285 shutil.copytree(projectDir, os.path.join(tmpDir, project)) 288 shutil.copytree(projectDir, os.path.join(tmpDir, project))
286 except OSError: 289 except OSError:
287 if os.path.isdir(tmpDir): 290 if os.path.isdir(tmpDir):
288 shutil.rmtree(tmpDir, True) 291 shutil.rmtree(tmpDir, True)
289 return False, False 292 return False, False
290 293
291 args = [] 294 args = []
292 args.append('import') 295 args.append('import')
293 self.addArguments(args, self.options['global']) 296 self.addArguments(args, self.options['global'])
306 status = dia.normalExit() 309 status = dia.normalExit()
307 310
308 shutil.rmtree(tmpDir, True) 311 shutil.rmtree(tmpDir, True)
309 return status, False 312 return status, False
310 313
311 def vcsCheckout(self, vcsDataDict, projectDir, noDialog = False): 314 def vcsCheckout(self, vcsDataDict, projectDir, noDialog=False):
312 """ 315 """
313 Public method used to check the project out of the Subversion repository. 316 Public method used to check the project out of the Subversion repository.
314 317
315 @param vcsDataDict dictionary of data required for the checkout 318 @param vcsDataDict dictionary of data required for the checkout
316 @param projectDir project directory to create (string) 319 @param projectDir project directory to create (string)
411 res = dia.startProcess(args) 414 res = dia.startProcess(args)
412 if res: 415 if res:
413 dia.exec_() 416 dia.exec_()
414 return dia.normalExit() 417 return dia.normalExit()
415 418
416 def vcsCommit(self, name, message, noDialog = False): 419 def vcsCommit(self, name, message, noDialog=False):
417 """ 420 """
418 Public method used to make the change of a file/directory permanent in the 421 Public method used to make the change of a file/directory permanent in the
419 Subversion repository. 422 Subversion repository.
420 423
421 @param name file/directory name to be committed (string or list of strings) 424 @param name file/directory name to be committed (string or list of strings)
492 if res: 495 if res:
493 dia.exec_() 496 dia.exec_()
494 self.committed.emit() 497 self.committed.emit()
495 self.checkVCSStatus() 498 self.checkVCSStatus()
496 499
497 def vcsUpdate(self, name, noDialog = False): 500 def vcsUpdate(self, name, noDialog=False):
498 """ 501 """
499 Public method used to update a file/directory with the Subversion repository. 502 Public method used to update a file/directory with the Subversion repository.
500 503
501 @param name file/directory name to be updated (string or list of strings) 504 @param name file/directory name to be updated (string or list of strings)
502 @param noDialog flag indicating quiet operations (boolean) 505 @param noDialog flag indicating quiet operations (boolean)
527 dia.exec_() 530 dia.exec_()
528 res = dia.hasAddOrDelete() 531 res = dia.hasAddOrDelete()
529 self.checkVCSStatus() 532 self.checkVCSStatus()
530 return res 533 return res
531 534
532 def vcsAdd(self, name, isDir = False, noDialog = False): 535 def vcsAdd(self, name, isDir=False, noDialog=False):
533 """ 536 """
534 Public method used to add a file/directory to the Subversion repository. 537 Public method used to add a file/directory to the Subversion repository.
535 538
536 @param name file/directory name to be added (string) 539 @param name file/directory name to be added (string)
537 @param isDir flag indicating name is a directory (boolean) 540 @param isDir flag indicating name is a directory (boolean)
586 self.trUtf8('Adding files/directories to the Subversion repository')) 589 self.trUtf8('Adding files/directories to the Subversion repository'))
587 res = dia.startProcess(args, wdir) 590 res = dia.startProcess(args, wdir)
588 if res: 591 if res:
589 dia.exec_() 592 dia.exec_()
590 593
591 def vcsAddBinary(self, name, isDir = False): 594 def vcsAddBinary(self, name, isDir=False):
592 """ 595 """
593 Public method used to add a file/directory in binary mode to the 596 Public method used to add a file/directory in binary mode to the
594 Subversion repository. 597 Subversion repository.
595 598
596 @param name file/directory name to be added (string) 599 @param name file/directory name to be added (string)
613 if isinstance(path, list): 616 if isinstance(path, list):
614 dname, fnames = self.splitPathList(path) 617 dname, fnames = self.splitPathList(path)
615 for n in path: 618 for n in path:
616 d = os.path.split(n)[0] 619 d = os.path.split(n)[0]
617 while not os.path.exists(os.path.join(d, self.adminDir)): 620 while not os.path.exists(os.path.join(d, self.adminDir)):
618 # add directories recursively, 621 # add directories recursively,
619 # if they aren't in the repository already 622 # if they aren't in the repository already
620 if d in tree: 623 if d in tree:
621 break 624 break
622 tree.append(d) 625 tree.append(d)
623 d = os.path.split(d)[0] 626 d = os.path.split(d)[0]
641 self.trUtf8('Adding directory trees to the Subversion repository')) 644 self.trUtf8('Adding directory trees to the Subversion repository'))
642 res = dia.startProcess(args, dname) 645 res = dia.startProcess(args, dname)
643 if res: 646 if res:
644 dia.exec_() 647 dia.exec_()
645 648
646 def vcsRemove(self, name, project = False, noDialog = False): 649 def vcsRemove(self, name, project=False, noDialog=False):
647 """ 650 """
648 Public method used to remove a file/directory from the Subversion repository. 651 Public method used to remove a file/directory from the Subversion repository.
649 652
650 The default operation is to remove the local copy as well. 653 The default operation is to remove the local copy as well.
651 654
676 dia.exec_() 679 dia.exec_()
677 res = dia.normalExit() 680 res = dia.normalExit()
678 681
679 return res 682 return res
680 683
681 def vcsMove(self, name, project, target = None, noDialog = False): 684 def vcsMove(self, name, project, target=None, noDialog=False):
682 """ 685 """
683 Public method used to move a file/directory. 686 Public method used to move a file/directory.
684 687
685 @param name file/directory name to be moved (string) 688 @param name file/directory name to be moved (string)
686 @param project reference to the project object 689 @param project reference to the project object
746 project.removeFile(name) 749 project.removeFile(name)
747 return res 750 return res
748 751
749 def vcsLog(self, name): 752 def vcsLog(self, name):
750 """ 753 """
751 Public method used to view the log of a file/directory from the 754 Public method used to view the log of a file/directory from the
752 Subversion repository. 755 Subversion repository.
753 756
754 @param name file/directory name to show the log of (string) 757 @param name file/directory name to show the log of (string)
755 """ 758 """
756 self.log = SvnLogDialog(self) 759 self.log = SvnLogDialog(self)
757 self.log.show() 760 self.log.show()
758 self.log.start(name) 761 self.log.start(name)
759 762
760 def vcsDiff(self, name): 763 def vcsDiff(self, name):
761 """ 764 """
762 Public method used to view the difference of a file/directory to the 765 Public method used to view the difference of a file/directory to the
763 Subversion repository. 766 Subversion repository.
764 767
765 If name is a directory and is the project directory, all project files 768 If name is a directory and is the project directory, all project files
766 are saved first. If name is a file (or list of files), which is/are being edited 769 are saved first. If name is a file (or list of files), which is/are being edited
767 and has unsaved modification, they can be saved or the operation may be aborted. 770 and has unsaved modification, they can be saved or the operation may be aborted.
768 771
769 @param name file/directory name to be diffed (string) 772 @param name file/directory name to be diffed (string)
770 """ 773 """
771 if isinstance(name, list): 774 if isinstance(name, list):
773 else: 776 else:
774 names = [name] 777 names = [name]
775 for nam in names: 778 for nam in names:
776 if os.path.isfile(nam): 779 if os.path.isfile(nam):
777 editor = e5App().getObject("ViewManager").getOpenEditor(nam) 780 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
778 if editor and not editor.checkDirty() : 781 if editor and not editor.checkDirty():
779 return 782 return
780 else: 783 else:
781 project = e5App().getObject("Project") 784 project = e5App().getObject("Project")
782 if nam == project.ppath and not project.saveAllScripts(): 785 if nam == project.ppath and not project.saveAllScripts():
783 return 786 return
786 QApplication.processEvents() 789 QApplication.processEvents()
787 self.diff.start(name) 790 self.diff.start(name)
788 791
789 def vcsStatus(self, name): 792 def vcsStatus(self, name):
790 """ 793 """
791 Public method used to view the status of files/directories in the 794 Public method used to view the status of files/directories in the
792 Subversion repository. 795 Subversion repository.
793 796
794 @param name file/directory name(s) to show the status of 797 @param name file/directory name(s) to show the status of
795 (string or list of strings) 798 (string or list of strings)
796 """ 799 """
798 self.status.show() 801 self.status.show()
799 self.status.start(name) 802 self.status.start(name)
800 803
801 def vcsTag(self, name): 804 def vcsTag(self, name):
802 """ 805 """
803 Public method used to set the tag of a file/directory in the 806 Public method used to set the tag of a file/directory in the
804 Subversion repository. 807 Subversion repository.
805 808
806 @param name file/directory name to be tagged (string) 809 @param name file/directory name to be tagged (string)
807 """ 810 """
808 dname, fname = self.splitPath(name) 811 dname, fname = self.splitPath(name)
818 821
819 if self.otherData["standardLayout"]: 822 if self.otherData["standardLayout"]:
820 url = None 823 url = None
821 else: 824 else:
822 url = self.svnNormalizeURL(reposURL) 825 url = self.svnNormalizeURL(reposURL)
823 dlg = SvnTagDialog(self.allTagsBranchesList, url, 826 dlg = SvnTagDialog(self.allTagsBranchesList, url,
824 self.otherData["standardLayout"]) 827 self.otherData["standardLayout"])
825 if dlg.exec_() == QDialog.Accepted: 828 if dlg.exec_() == QDialog.Accepted:
826 tag, tagOp = dlg.getParameters() 829 tag, tagOp = dlg.getParameters()
827 if tag in self.allTagsBranchesList: 830 if tag in self.allTagsBranchesList:
828 self.allTagsBranchesList.remove(tag) 831 self.allTagsBranchesList.remove(tag)
912 915
913 if self.otherData["standardLayout"]: 916 if self.otherData["standardLayout"]:
914 url = None 917 url = None
915 else: 918 else:
916 url = self.svnNormalizeURL(reposURL) 919 url = self.svnNormalizeURL(reposURL)
917 dlg = SvnSwitchDialog(self.allTagsBranchesList, url, 920 dlg = SvnSwitchDialog(self.allTagsBranchesList, url,
918 self.otherData["standardLayout"]) 921 self.otherData["standardLayout"])
919 if dlg.exec_() == QDialog.Accepted: 922 if dlg.exec_() == QDialog.Accepted:
920 tag, tagType = dlg.getParameters() 923 tag, tagType = dlg.getParameters()
921 if tag in self.allTagsBranchesList: 924 if tag in self.allTagsBranchesList:
922 self.allTagsBranchesList.remove(tag) 925 self.allTagsBranchesList.remove(tag)
972 opts = self.options['global'][:] 975 opts = self.options['global'][:]
973 force = '--force' in opts 976 force = '--force' in opts
974 if force: 977 if force:
975 del opts[opts.index('--force')] 978 del opts[opts.index('--force')]
976 979
977 dlg = SvnMergeDialog(self.mergeList[0], self.mergeList[1], self.mergeList[2], 980 dlg = SvnMergeDialog(self.mergeList[0], self.mergeList[1], self.mergeList[2],
978 force) 981 force)
979 if dlg.exec_() == QDialog.Accepted: 982 if dlg.exec_() == QDialog.Accepted:
980 urlrev1, urlrev2, target, force = dlg.getParameters() 983 urlrev1, urlrev2, target, force = dlg.getParameters()
981 else: 984 else:
982 return 985 return
1035 return self.canBeCommitted 1038 return self.canBeCommitted
1036 else: 1039 else:
1037 return self.canBeAdded 1040 return self.canBeAdded
1038 1041
1039 name = os.path.normcase(name) 1042 name = os.path.normcase(name)
1040 states = { name : 0 } 1043 states = {name: 0}
1041 states = self.vcsAllRegisteredStates(states, dname, False) 1044 states = self.vcsAllRegisteredStates(states, dname, False)
1042 if states[name] == self.canBeCommitted: 1045 if states[name] == self.canBeCommitted:
1043 return self.canBeCommitted 1046 return self.canBeCommitted
1044 else: 1047 else:
1045 return self.canBeAdded 1048 return self.canBeAdded
1046 1049
1047 def vcsAllRegisteredStates(self, names, dname, shortcut = True): 1050 def vcsAllRegisteredStates(self, names, dname, shortcut=True):
1048 """ 1051 """
1049 Public method used to get the registered states of a number of files in the vcs. 1052 Public method used to get the registered states of a number of files in the vcs.
1050 1053
1051 <b>Note:</b> If a shortcut is to be taken, the code will only check, if the named 1054 <b>Note:</b> If a shortcut is to be taken, the code will only check, if the named
1052 directory has been scanned already. If so, it is assumed, that the states for 1055 directory has been scanned already. If so, it is assumed, that the states for
1053 all files have been populated by the previous run. 1056 all files have been populated by the previous run.
1054 1057
1055 @param names dictionary with all filenames to be checked as keys 1058 @param names dictionary with all filenames to be checked as keys
1056 @param dname directory to check in (string) 1059 @param dname directory to check in (string)
1057 @param shortcut flag indicating a shortcut should be taken (boolean) 1060 @param shortcut flag indicating a shortcut should be taken (boolean)
1058 @return the received dictionary completed with a combination of 1061 @return the received dictionary completed with a combination of
1059 canBeCommited and canBeAdded or None in order to signal an error 1062 canBeCommited and canBeAdded or None in order to signal an error
1060 """ 1063 """
1061 if not os.path.isdir(os.path.join(dname, self.adminDir)): 1064 if not os.path.isdir(os.path.join(dname, self.adminDir)):
1062 # not under version control -> do nothing 1065 # not under version control -> do nothing
1063 return names 1066 return names
1163 dia = SvnDialog(self.trUtf8('Subversion command')) 1166 dia = SvnDialog(self.trUtf8('Subversion command'))
1164 res = dia.startProcess(args, wd) 1167 res = dia.startProcess(args, wd)
1165 if res: 1168 if res:
1166 dia.exec_() 1169 dia.exec_()
1167 1170
1168 def vcsOptionsDialog(self, project, archive, editable = False, parent = None): 1171 def vcsOptionsDialog(self, project, archive, editable=False, parent=None):
1169 """ 1172 """
1170 Public method to get a dialog to enter repository info. 1173 Public method to get a dialog to enter repository info.
1171 1174
1172 @param project reference to the project object 1175 @param project reference to the project object
1173 @param archive name of the project in the repository (string) 1176 @param archive name of the project in the repository (string)
1174 @param editable flag indicating that the project name is editable (boolean) 1177 @param editable flag indicating that the project name is editable (boolean)
1175 @param parent parent widget (QWidget) 1178 @param parent parent widget (QWidget)
1176 """ 1179 """
1177 return SvnOptionsDialog(self, project, parent) 1180 return SvnOptionsDialog(self, project, parent)
1178 1181
1179 def vcsNewProjectOptionsDialog(self, parent = None): 1182 def vcsNewProjectOptionsDialog(self, parent=None):
1180 """ 1183 """
1181 Public method to get a dialog to enter repository info for getting a new project. 1184 Public method to get a dialog to enter repository info for getting a new project.
1182 1185
1183 @param parent parent widget (QWidget) 1186 @param parent parent widget (QWidget)
1184 """ 1187 """
1190 1193
1191 @param ppath local path to get the repository infos (string) 1194 @param ppath local path to get the repository infos (string)
1192 @return string with ready formated info for display (string) 1195 @return string with ready formated info for display (string)
1193 """ 1196 """
1194 info = {\ 1197 info = {\
1195 'committed-rev' : '', 1198 'committed-rev': '',
1196 'committed-date' : '', 1199 'committed-date': '',
1197 'committed-time' : '', 1200 'committed-time': '',
1198 'url' : '', 1201 'url': '',
1199 'last-author' : '', 1202 'last-author': '',
1200 'revision' : '' 1203 'revision': ''
1201 } 1204 }
1202 1205
1203 ioEncoding = Preferences.getSystem("IOEncoding") 1206 ioEncoding = Preferences.getSystem("IOEncoding")
1204 1207
1205 process = QProcess() 1208 process = QProcess()
1223 elif line.startswith('<commit'): 1226 elif line.startswith('<commit'):
1224 commitFound = True 1227 commitFound = True
1225 elif line.startswith('</commit>'): 1228 elif line.startswith('</commit>'):
1226 commitFound = False 1229 commitFound = False
1227 elif line.startswith("revision="): 1230 elif line.startswith("revision="):
1228 rev = line[line.find('"')+1:line.rfind('"')] 1231 rev = line[line.find('"') + 1:line.rfind('"')]
1229 if entryFound: 1232 if entryFound:
1230 info['revision'] = rev 1233 info['revision'] = rev
1231 entryFound = False 1234 entryFound = False
1232 elif commitFound: 1235 elif commitFound:
1233 info['committed-rev'] = rev 1236 info['committed-rev'] = rev
1254 """<tr><td><b>Committed date</b></td><td>{4}</td></tr>""" 1257 """<tr><td><b>Committed date</b></td><td>{4}</td></tr>"""
1255 """<tr><td><b>Comitted time</b></td><td>{5}</td></tr>""" 1258 """<tr><td><b>Comitted time</b></td><td>{5}</td></tr>"""
1256 """<tr><td><b>Last author</b></td><td>{6}</td></tr>""" 1259 """<tr><td><b>Last author</b></td><td>{6}</td></tr>"""
1257 """</table>""" 1260 """</table>"""
1258 )\ 1261 )\
1259 .format(self.versionStr, 1262 .format(self.versionStr,
1260 info['url'], 1263 info['url'],
1261 info['revision'], 1264 info['revision'],
1262 info['committed-rev'], 1265 info['committed-rev'],
1263 info['committed-date'], 1266 info['committed-date'],
1264 info['committed-time'], 1267 info['committed-time'],
1265 info['last-author']) 1268 info['last-author'])
1266 1269
1267 ############################################################################ 1270 ############################################################################
1268 ## Public Subversion specific methods are below. 1271 ## Public Subversion specific methods are below.
1269 ############################################################################ 1272 ############################################################################
1361 project.copyDirectory(name, target) 1364 project.copyDirectory(name, target)
1362 else: 1365 else:
1363 project.appendFile(target) 1366 project.appendFile(target)
1364 return res 1367 return res
1365 1368
1366 def svnListProps(self, name, recursive = False): 1369 def svnListProps(self, name, recursive=False):
1367 """ 1370 """
1368 Public method used to list the properties of a file/directory. 1371 Public method used to list the properties of a file/directory.
1369 1372
1370 @param name file/directory name (string or list of strings) 1373 @param name file/directory name (string or list of strings)
1371 @param recursive flag indicating a recursive list is requested 1374 @param recursive flag indicating a recursive list is requested
1372 """ 1375 """
1373 self.propList = SvnPropListDialog(self) 1376 self.propList = SvnPropListDialog(self)
1374 self.propList.show() 1377 self.propList.show()
1375 self.propList.start(name, recursive) 1378 self.propList.start(name, recursive)
1376 1379
1377 def svnSetProp(self, name, recursive = False): 1380 def svnSetProp(self, name, recursive=False):
1378 """ 1381 """
1379 Public method used to add a property to a file/directory. 1382 Public method used to add a property to a file/directory.
1380 1383
1381 @param name file/directory name (string or list of strings) 1384 @param name file/directory name (string or list of strings)
1382 @param recursive flag indicating a recursive list is requested 1385 @param recursive flag indicating a recursive list is requested
1409 dia = SvnDialog(self.trUtf8('Subversion Set Property')) 1412 dia = SvnDialog(self.trUtf8('Subversion Set Property'))
1410 res = dia.startProcess(args, dname) 1413 res = dia.startProcess(args, dname)
1411 if res: 1414 if res:
1412 dia.exec_() 1415 dia.exec_()
1413 1416
1414 def svnDelProp(self, name, recursive = False): 1417 def svnDelProp(self, name, recursive=False):
1415 """ 1418 """
1416 Public method used to delete a property of a file/directory. 1419 Public method used to delete a property of a file/directory.
1417 1420
1418 @param name file/directory name (string or list of strings) 1421 @param name file/directory name (string or list of strings)
1419 @param recursive flag indicating a recursive list is requested 1422 @param recursive flag indicating a recursive list is requested
1449 dia = SvnDialog(self.trUtf8('Subversion Delete Property')) 1452 dia = SvnDialog(self.trUtf8('Subversion Delete Property'))
1450 res = dia.startProcess(args, dname) 1453 res = dia.startProcess(args, dname)
1451 if res: 1454 if res:
1452 dia.exec_() 1455 dia.exec_()
1453 1456
1454 def svnListTagBranch(self, path, tags = True): 1457 def svnListTagBranch(self, path, tags=True):
1455 """ 1458 """
1456 Public method used to list the available tags or branches. 1459 Public method used to list the available tags or branches.
1457 1460
1458 @param path directory name of the project (string) 1461 @param path directory name of the project (string)
1459 @param tags flag indicating listing of branches or tags 1462 @param tags flag indicating listing of branches or tags
1466 self.showedTags = True 1469 self.showedTags = True
1467 allTagsBranchesList = self.allTagsBranchesList 1470 allTagsBranchesList = self.allTagsBranchesList
1468 else: 1471 else:
1469 self.tagsList = [] 1472 self.tagsList = []
1470 allTagsBranchesList = None 1473 allTagsBranchesList = None
1471 self.tagbranchList.start(path, tags, 1474 self.tagbranchList.start(path, tags,
1472 self.tagsList, allTagsBranchesList) 1475 self.tagsList, allTagsBranchesList)
1473 elif not tags: 1476 elif not tags:
1474 if not self.showedBranches: 1477 if not self.showedBranches:
1475 self.showedBranches = True 1478 self.showedBranches = True
1476 allTagsBranchesList = self.allTagsBranchesList 1479 allTagsBranchesList = self.allTagsBranchesList
1477 else: 1480 else:
1478 self.branchesList = [] 1481 self.branchesList = []
1479 allTagsBranchesList = None 1482 allTagsBranchesList = None
1480 self.tagbranchList.start(path, tags, 1483 self.tagbranchList.start(path, tags,
1481 self.branchesList, self.allTagsBranchesList) 1484 self.branchesList, self.allTagsBranchesList)
1482 1485
1483 def svnBlame(self, name): 1486 def svnBlame(self, name):
1484 """ 1487 """
1485 Public method to show the output of the svn blame command. 1488 Public method to show the output of the svn blame command.
1490 self.blame.show() 1493 self.blame.show()
1491 self.blame.start(name) 1494 self.blame.start(name)
1492 1495
1493 def svnExtendedDiff(self, name): 1496 def svnExtendedDiff(self, name):
1494 """ 1497 """
1495 Public method used to view the difference of a file/directory to the 1498 Public method used to view the difference of a file/directory to the
1496 Subversion repository. 1499 Subversion repository.
1497 1500
1498 If name is a directory and is the project directory, all project files 1501 If name is a directory and is the project directory, all project files
1499 are saved first. If name is a file (or list of files), which is/are being edited 1502 are saved first. If name is a file (or list of files), which is/are being edited
1500 and has unsaved modification, they can be saved or the operation may be aborted. 1503 and has unsaved modification, they can be saved or the operation may be aborted.
1501 1504
1502 This method gives the chance to enter the revisions to be compared. 1505 This method gives the chance to enter the revisions to be compared.
1503 1506
1504 @param name file/directory name to be diffed (string) 1507 @param name file/directory name to be diffed (string)
1508 else: 1511 else:
1509 names = [name] 1512 names = [name]
1510 for nam in names: 1513 for nam in names:
1511 if os.path.isfile(nam): 1514 if os.path.isfile(nam):
1512 editor = e5App().getObject("ViewManager").getOpenEditor(nam) 1515 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
1513 if editor and not editor.checkDirty() : 1516 if editor and not editor.checkDirty():
1514 return 1517 return
1515 else: 1518 else:
1516 project = e5App().getObject("Project") 1519 project = e5App().getObject("Project")
1517 if nam == project.ppath and not project.saveAllScripts(): 1520 if nam == project.ppath and not project.saveAllScripts():
1518 return 1521 return
1527 """ 1530 """
1528 Public method used to view the difference of a file/directory of two 1531 Public method used to view the difference of a file/directory of two
1529 repository URLs. 1532 repository URLs.
1530 1533
1531 If name is a directory and is the project directory, all project files 1534 If name is a directory and is the project directory, all project files
1532 are saved first. If name is a file (or list of files), which is/are being edited 1535 are saved first. If name is a file (or list of files), which is/are being edited
1533 and has unsaved modification, they can be saved or the operation may be aborted. 1536 and has unsaved modification, they can be saved or the operation may be aborted.
1534 1537
1535 This method gives the chance to enter the revisions to be compared. 1538 This method gives the chance to enter the revisions to be compared.
1536 1539
1537 @param name file/directory name to be diffed (string) 1540 @param name file/directory name to be diffed (string)
1541 else: 1544 else:
1542 names = [name] 1545 names = [name]
1543 for nam in names: 1546 for nam in names:
1544 if os.path.isfile(nam): 1547 if os.path.isfile(nam):
1545 editor = e5App().getObject("ViewManager").getOpenEditor(nam) 1548 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
1546 if editor and not editor.checkDirty() : 1549 if editor and not editor.checkDirty():
1547 return 1550 return
1548 else: 1551 else:
1549 project = e5App().getObject("Project") 1552 project = e5App().getObject("Project")
1550 if nam == project.ppath and not project.saveAllScripts(): 1553 if nam == project.ppath and not project.saveAllScripts():
1551 return 1554 return
1556 if dlg.exec_() == QDialog.Accepted: 1559 if dlg.exec_() == QDialog.Accepted:
1557 urls, summary = dlg.getURLs() 1560 urls, summary = dlg.getURLs()
1558 self.diff = SvnDiffDialog(self) 1561 self.diff = SvnDiffDialog(self)
1559 self.diff.show() 1562 self.diff.show()
1560 QApplication.processEvents() 1563 QApplication.processEvents()
1561 self.diff.start(name, urls = urls, summary = summary) 1564 self.diff.start(name, urls=urls, summary=summary)
1562 1565
1563 def svnLogLimited(self, name): 1566 def svnLogLimited(self, name):
1564 """ 1567 """
1565 Public method used to view the (limited) log of a file/directory from the 1568 Public method used to view the (limited) log of a file/directory from the
1566 Subversion repository. 1569 Subversion repository.
1567 1570
1568 @param name file/directory name to show the log of (string) 1571 @param name file/directory name to show the log of (string)
1569 """ 1572 """
1570 noEntries, ok = QInputDialog.getInteger( 1573 noEntries, ok = QInputDialog.getInteger(
1577 self.log.show() 1580 self.log.show()
1578 self.log.start(name, noEntries) 1581 self.log.start(name, noEntries)
1579 1582
1580 def svnLogBrowser(self, path): 1583 def svnLogBrowser(self, path):
1581 """ 1584 """
1582 Public method used to browse the log of a file/directory from the 1585 Public method used to browse the log of a file/directory from the
1583 Subversion repository. 1586 Subversion repository.
1584 1587
1585 @param path file/directory name to show the log of (string) 1588 @param path file/directory name to show the log of (string)
1586 """ 1589 """
1587 self.logBrowser = SvnLogBrowserDialog(self) 1590 self.logBrowser = SvnLogBrowserDialog(self)
1659 dia = SvnDialog(self.trUtf8('Relocating')) 1662 dia = SvnDialog(self.trUtf8('Relocating'))
1660 res = dia.startProcess(args) 1663 res = dia.startProcess(args)
1661 if res: 1664 if res:
1662 dia.exec_() 1665 dia.exec_()
1663 1666
1664 def svnRepoBrowser(self, projectPath = None): 1667 def svnRepoBrowser(self, projectPath=None):
1665 """ 1668 """
1666 Public method to open the repository browser. 1669 Public method to open the repository browser.
1667 1670
1668 @param projectPath path name of the project (string) 1671 @param projectPath path name of the project (string)
1669 """ 1672 """
1759 url = self.svnNormalizeURL(url) 1762 url = self.svnNormalizeURL(url)
1760 url = url.split(':', 2) 1763 url = url.split(':', 2)
1761 if len(url) == 3: 1764 if len(url) == 3:
1762 scheme = url[0] 1765 scheme = url[0]
1763 host = url[1] 1766 host = url[1]
1764 port, path = url[2].split("/",1) 1767 port, path = url[2].split("/", 1)
1765 return "{0}:{1}:{2}/{3}".format(scheme, host, port, urllib.parse.quote(path)) 1768 return "{0}:{1}:{2}/{3}".format(scheme, host, port, urllib.parse.quote(path))
1766 else: 1769 else:
1767 scheme = url[0] 1770 scheme = url[0]
1768 if scheme == "file": 1771 if scheme == "file":
1769 return "{0}:{1}".format(scheme, urllib.parse.quote(url[1])) 1772 return "{0}:{1}".format(scheme, urllib.parse.quote(url[1]))
1790 1793
1791 ############################################################################ 1794 ############################################################################
1792 ## Methods to get the helper objects are below. 1795 ## Methods to get the helper objects are below.
1793 ############################################################################ 1796 ############################################################################
1794 1797
1795 def vcsGetProjectBrowserHelper(self, browser, project, isTranslationsBrowser = False): 1798 def vcsGetProjectBrowserHelper(self, browser, project, isTranslationsBrowser=False):
1796 """ 1799 """
1797 Public method to instanciate a helper object for the different project browsers. 1800 Public method to instanciate a helper object for the different project browsers.
1798 1801
1799 @param browser reference to the project browser object 1802 @param browser reference to the project browser object
1800 @param project reference to the project object 1803 @param project reference to the project object

eric ide

mercurial