Plugins/VcsPlugins/vcsSubversion/subversion.py

changeset 425
ca5e65413fc5
parent 418
a13fe26c57a4
child 442
f233430b5613
equal deleted inserted replaced
424:d0915392cbd7 425:ca5e65413fc5
210 else: 210 else:
211 cwdIsPpath = False 211 cwdIsPpath = False
212 if os.getcwd() == project.ppath: 212 if os.getcwd() == project.ppath:
213 os.chdir(os.path.dirname(project.ppath)) 213 os.chdir(os.path.dirname(project.ppath))
214 cwdIsPpath = True 214 cwdIsPpath = True
215 tmpProjectDir = "%s_tmp" % project.ppath 215 tmpProjectDir = "{0}_tmp".format(project.ppath)
216 shutil.rmtree(tmpProjectDir, True) 216 shutil.rmtree(tmpProjectDir, True)
217 os.rename(project.ppath, tmpProjectDir) 217 os.rename(project.ppath, tmpProjectDir)
218 os.makedirs(project.ppath) 218 os.makedirs(project.ppath)
219 self.vcsCheckout(vcsDataDict, project.ppath) 219 self.vcsCheckout(vcsDataDict, project.ppath)
220 if cwdIsPpath: 220 if cwdIsPpath:
261 if not msg: 261 if not msg:
262 msg = '***' 262 msg = '***'
263 263
264 vcsDir = self.svnNormalizeURL(vcsDataDict["url"]) 264 vcsDir = self.svnNormalizeURL(vcsDataDict["url"])
265 if vcsDir.startswith('/'): 265 if vcsDir.startswith('/'):
266 vcsDir = 'file://%s' % vcsDir 266 vcsDir = 'file://{0}'.format(vcsDir)
267 elif vcsDir[1] in ['|', ':']: 267 elif vcsDir[1] in ['|', ':']:
268 vcsDir = 'file:///%s' % vcsDir 268 vcsDir = 'file:///{0}'.format(vcsDir)
269 269
270 project = vcsDir[vcsDir.rfind('/')+1:] 270 project = vcsDir[vcsDir.rfind('/')+1:]
271 271
272 # create the dir structure to be imported into the repository 272 # create the dir structure to be imported into the repository
273 tmpDir = '%s_tmp' % projectDir 273 tmpDir = '{0}_tmp'.format(projectDir)
274 try: 274 try:
275 os.makedirs(tmpDir) 275 os.makedirs(tmpDir)
276 if self.otherData["standardLayout"]: 276 if self.otherData["standardLayout"]:
277 os.mkdir(os.path.join(tmpDir, project)) 277 os.mkdir(os.path.join(tmpDir, project))
278 os.mkdir(os.path.join(tmpDir, project, 'branches')) 278 os.mkdir(os.path.join(tmpDir, project, 'branches'))
319 tag = vcsDataDict["tag"] 319 tag = vcsDataDict["tag"]
320 except KeyError: 320 except KeyError:
321 tag = None 321 tag = None
322 vcsDir = self.svnNormalizeURL(vcsDataDict["url"]) 322 vcsDir = self.svnNormalizeURL(vcsDataDict["url"])
323 if vcsDir.startswith('/'): 323 if vcsDir.startswith('/'):
324 vcsDir = 'file://%s' % vcsDir 324 vcsDir = 'file://{0}'.format(vcsDir)
325 elif vcsDir[1] in ['|', ':']: 325 elif vcsDir[1] in ['|', ':']:
326 vcsDir = 'file:///%s' % vcsDir 326 vcsDir = 'file:///{0}'.format(vcsDir)
327 327
328 if self.otherData["standardLayout"]: 328 if self.otherData["standardLayout"]:
329 if tag is None or tag == '': 329 if tag is None or tag == '':
330 svnUrl = '%s/trunk' % vcsDir 330 svnUrl = '{0}/trunk'.format(vcsDir)
331 else: 331 else:
332 if not tag.startswith('tags') and not tag.startswith('branches'): 332 if not tag.startswith('tags') and not tag.startswith('branches'):
333 type, ok = QInputDialog.getItem(\ 333 type, ok = QInputDialog.getItem(\
334 None, 334 None,
335 self.trUtf8("Subversion Checkout"), 335 self.trUtf8("Subversion Checkout"),
338 " Please select from the list."), 338 " Please select from the list."),
339 self.tagTypeList, 339 self.tagTypeList,
340 0, False) 340 0, False)
341 if not ok: 341 if not ok:
342 return False 342 return False
343 tag = '%s/%s' % (type, tag) 343 tag = '{0}/{1}'.format(type, tag)
344 svnUrl = '%s/%s' % (vcsDir, tag) 344 svnUrl = '{0}/{1}'.format(vcsDir, tag)
345 else: 345 else:
346 svnUrl = vcsDir 346 svnUrl = vcsDir
347 347
348 args = [] 348 args = []
349 args.append('checkout') 349 args.append('checkout')
373 tag = vcsDataDict["tag"] 373 tag = vcsDataDict["tag"]
374 except KeyError: 374 except KeyError:
375 tag = None 375 tag = None
376 vcsDir = self.svnNormalizeURL(vcsDataDict["url"]) 376 vcsDir = self.svnNormalizeURL(vcsDataDict["url"])
377 if vcsDir.startswith('/') or vcsDir[1] == '|': 377 if vcsDir.startswith('/') or vcsDir[1] == '|':
378 vcsDir = 'file://%s' % vcsDir 378 vcsDir = 'file://{0}'.format(vcsDir)
379 379
380 if self.otherData["standardLayout"]: 380 if self.otherData["standardLayout"]:
381 if tag is None or tag == '': 381 if tag is None or tag == '':
382 svnUrl = '%s/trunk' % vcsDir 382 svnUrl = '{0}/trunk'.format(vcsDir)
383 else: 383 else:
384 if not tag.startswith('tags') and not tag.startswith('branches'): 384 if not tag.startswith('tags') and not tag.startswith('branches'):
385 type, ok = QInputDialog.getItem(\ 385 type, ok = QInputDialog.getItem(\
386 None, 386 None,
387 self.trUtf8("Subversion Export"), 387 self.trUtf8("Subversion Export"),
390 " Please select from the list."), 390 " Please select from the list."),
391 self.tagTypeList, 391 self.tagTypeList,
392 0, False) 392 0, False)
393 if not ok: 393 if not ok:
394 return False 394 return False
395 tag = '%s/%s' % (type, tag) 395 tag = '{0}/{1}'.format(type, tag)
396 svnUrl = '%s/%s' % (vcsDir, tag) 396 svnUrl = '{0}/{1}'.format(vcsDir, tag)
397 else: 397 else:
398 svnUrl = vcsDir 398 svnUrl = vcsDir
399 399
400 args = [] 400 args = []
401 args.append('export') 401 args.append('export')
839 """ be aborted""")) 839 """ be aborted"""))
840 return 840 return
841 841
842 reposRoot = rx_base.cap(1) 842 reposRoot = rx_base.cap(1)
843 if tagOp in [1, 4]: 843 if tagOp in [1, 4]:
844 url = '%s/tags/%s' % (reposRoot, urllib.parse.quote(tag)) 844 url = '{0}/tags/{1}'.format(reposRoot, urllib.parse.quote(tag))
845 elif tagOp in [2, 8]: 845 elif tagOp in [2, 8]:
846 url = '%s/branches/%s' % (reposRoot, urllib.parse.quote(tag)) 846 url = '{0}/branches/{1}'.format(reposRoot, urllib.parse.quote(tag))
847 else: 847 else:
848 url = self.__svnURL(tag) 848 url = self.__svnURL(tag)
849 849
850 args = [] 850 args = []
851 if tagOp in [1, 2]: 851 if tagOp in [1, 2]:
852 args.append('copy') 852 args.append('copy')
853 self.addArguments(args, self.options['global']) 853 self.addArguments(args, self.options['global'])
854 self.addArguments(args, self.options['tag']) 854 self.addArguments(args, self.options['tag'])
855 args.append('--message') 855 args.append('--message')
856 args.append('Created tag <%s>' % tag) 856 args.append('Created tag <{0}>'.format(tag))
857 args.append(reposURL) 857 args.append(reposURL)
858 args.append(url) 858 args.append(url)
859 else: 859 else:
860 args.append('delete') 860 args.append('delete')
861 self.addArguments(args, self.options['global']) 861 self.addArguments(args, self.options['global'])
862 self.addArguments(args, self.options['tag']) 862 self.addArguments(args, self.options['tag'])
863 args.append('--message') 863 args.append('--message')
864 args.append('Deleted tag <%s>' % tag) 864 args.append('Deleted tag <{0}>'.format(tag))
865 args.append(url) 865 args.append(url)
866 866
867 dia = SvnDialog(self.trUtf8('Tagging {0} in the Subversion repository') 867 dia = SvnDialog(self.trUtf8('Tagging {0} in the Subversion repository')
868 .format(name)) 868 .format(name))
869 res = dia.startProcess(args) 869 res = dia.startProcess(args)
934 return 934 return
935 935
936 reposRoot = rx_base.cap(1) 936 reposRoot = rx_base.cap(1)
937 tn = tag 937 tn = tag
938 if tagType == 1: 938 if tagType == 1:
939 url = '%s/tags/%s' % (reposRoot, urllib.parse.quote(tag)) 939 url = '{0}/tags/{1}'.format(reposRoot, urllib.parse.quote(tag))
940 elif tagType == 2: 940 elif tagType == 2:
941 url = '%s/branches/%s' % (reposRoot, urllib.parse.quote(tag)) 941 url = '{0}/branches/{1}'.format(reposRoot, urllib.parse.quote(tag))
942 elif tagType == 4: 942 elif tagType == 4:
943 url = '%s/trunk' % (reposRoot) 943 url = '{0}/trunk'.format(reposRoot)
944 tn = 'HEAD' 944 tn = 'HEAD'
945 else: 945 else:
946 url = self.__svnURL(tag) 946 url = self.__svnURL(tag)
947 tn = url 947 tn = url
948 948
1238 line.replace('<author>', '').replace('</author>', '') 1238 line.replace('<author>', '').replace('</author>', '')
1239 elif line.startswith('<date>'): 1239 elif line.startswith('<date>'):
1240 value = line.replace('<date>', '').replace('</date>', '') 1240 value = line.replace('<date>', '').replace('</date>', '')
1241 date, time = value.split('T') 1241 date, time = value.split('T')
1242 info['committed-date'] = date 1242 info['committed-date'] = date
1243 info['committed-time'] = "%s%s" % (time.split('.')[0], time[-1]) 1243 info['committed-time'] = "{0}{1}".format(
1244 time.split('.')[0], time[-1])
1244 1245
1245 return QApplication.translate('subversion', 1246 return QApplication.translate('subversion',
1246 """<h3>Repository information</h3>""" 1247 """<h3>Repository information</h3>"""
1247 """<table>""" 1248 """<table>"""
1248 """<tr><td><b>Subversion V.</b></td><td>{0}</td></tr>""" 1249 """<tr><td><b>Subversion V.</b></td><td>{0}</td></tr>"""
1758 url = url.split(':', 2) 1759 url = url.split(':', 2)
1759 if len(url) == 3: 1760 if len(url) == 3:
1760 scheme = url[0] 1761 scheme = url[0]
1761 host = url[1] 1762 host = url[1]
1762 port, path = url[2].split("/",1) 1763 port, path = url[2].split("/",1)
1763 return "%s:%s:%s/%s" % (scheme, host, port, urllib.parse.quote(path)) 1764 return "{0}:{1}:{2}/{3}".format(scheme, host, port, urllib.parse.quote(path))
1764 else: 1765 else:
1765 scheme = url[0] 1766 scheme = url[0]
1766 if scheme == "file": 1767 if scheme == "file":
1767 return "%s:%s" % (scheme, urllib.parse.quote(url[1])) 1768 return "{0}:{1}".format(scheme, urllib.parse.quote(url[1]))
1768 else: 1769 else:
1769 host, path = url[1][2:].split("/",1) 1770 host, path = url[1][2:].split("/",1)
1770 return "%s://%s/%s" % (scheme, host, urllib.parse.quote(path)) 1771 return "{0}://{1}/{2}".format(scheme, host, urllib.parse.quote(path))
1771 1772
1772 def svnNormalizeURL(self, url): 1773 def svnNormalizeURL(self, url):
1773 """ 1774 """
1774 Public method to normalize a url for subversion. 1775 Public method to normalize a url for subversion.
1775 1776
1778 """ 1779 """
1779 url = url.replace('\\', '/') 1780 url = url.replace('\\', '/')
1780 if url.endswith('/'): 1781 if url.endswith('/'):
1781 url = url[:-1] 1782 url = url[:-1]
1782 urll = url.split('//') 1783 urll = url.split('//')
1783 return "%s//%s" % (urll[0], '/'.join(urll[1:])) 1784 return "{0}//{1}".format(urll[0], '/'.join(urll[1:]))
1784 1785
1785 ############################################################################ 1786 ############################################################################
1786 ## Methods to get the helper objects are below. 1787 ## Methods to get the helper objects are below.
1787 ############################################################################ 1788 ############################################################################
1788 1789

eric ide

mercurial