Plugins/VcsPlugins/vcsMercurial/hg.py

branch
Py2 comp.
changeset 3058
0a02c433f52d
parent 3057
10516539f238
parent 3023
34ce20603bf7
child 3060
5883ce99ee12
equal deleted inserted replaced
3057:10516539f238 3058:0a02c433f52d
264 @param vcsDataDict dictionary of data required for the conversion 264 @param vcsDataDict dictionary of data required for the conversion
265 @param project reference to the project object 265 @param project reference to the project object
266 """ 266 """
267 success = self.vcsImport(vcsDataDict, project.ppath)[0] 267 success = self.vcsImport(vcsDataDict, project.ppath)[0]
268 if not success: 268 if not success:
269 E5MessageBox.critical(self.__ui, 269 E5MessageBox.critical(
270 self.__ui,
270 self.trUtf8("Create project repository"), 271 self.trUtf8("Create project repository"),
271 self.trUtf8( 272 self.trUtf8(
272 """The project repository could not be created.""")) 273 """The project repository could not be created."""))
273 else: 274 else:
274 pfn = project.pfile 275 pfn = project.pfile
454 ok &= editor.checkDirty() 455 ok &= editor.checkDirty()
455 if not ok: 456 if not ok:
456 break 457 break
457 458
458 if not ok: 459 if not ok:
459 res = E5MessageBox.yesNo(self.__ui, 460 res = E5MessageBox.yesNo(
461 self.__ui,
460 self.trUtf8("Commit Changes"), 462 self.trUtf8("Commit Changes"),
461 self.trUtf8( 463 self.trUtf8(
462 """The commit affects files, that have unsaved""" 464 """The commit affects files, that have unsaved"""
463 """ changes. Shall the commit be continued?"""), 465 """ changes. Shall the commit be continued?"""),
464 icon=E5MessageBox.Warning) 466 icon=E5MessageBox.Warning)
959 project = e5App().getObject("Project") 961 project = e5App().getObject("Project")
960 names = [project.getRelativePath(nam) for nam in names] 962 names = [project.getRelativePath(nam) for nam in names]
961 if names[0]: 963 if names[0]:
962 from UI.DeleteFilesConfirmationDialog import \ 964 from UI.DeleteFilesConfirmationDialog import \
963 DeleteFilesConfirmationDialog 965 DeleteFilesConfirmationDialog
964 dlg = DeleteFilesConfirmationDialog(self.parent(), 966 dlg = DeleteFilesConfirmationDialog(
967 self.parent(),
965 self.trUtf8("Revert changes"), 968 self.trUtf8("Revert changes"),
966 self.trUtf8( 969 self.trUtf8(
967 "Do you really want to revert all changes to these files" 970 "Do you really want to revert all changes to these files"
968 " or directories?"), 971 " or directories?"),
969 names) 972 names)
970 yes = dlg.exec_() == QDialog.Accepted 973 yes = dlg.exec_() == QDialog.Accepted
971 else: 974 else:
972 yes = E5MessageBox.yesNo(None, 975 yes = E5MessageBox.yesNo(
976 None,
973 self.trUtf8("Revert changes"), 977 self.trUtf8("Revert changes"),
974 self.trUtf8("""Do you really want to revert all changes of""" 978 self.trUtf8("""Do you really want to revert all changes of"""
975 """ the project?""")) 979 """ the project?"""))
976 if yes: 980 if yes:
977 dia = HgDialog(self.trUtf8('Reverting changes'), self) 981 dia = HgDialog(self.trUtf8('Reverting changes'), self)
1176 process.start('hg', args) 1180 process.start('hg', args)
1177 procStarted = process.waitForStarted(5000) 1181 procStarted = process.waitForStarted(5000)
1178 if procStarted: 1182 if procStarted:
1179 finished = process.waitForFinished(30000) 1183 finished = process.waitForFinished(30000)
1180 if finished and process.exitCode() == 0: 1184 if finished and process.exitCode() == 0:
1181 output = \ 1185 output = str(
1182 str(process.readAllStandardOutput(), 1186 process.readAllStandardOutput(),
1183 Preferences.getSystem("IOEncoding"), 1187 Preferences.getSystem("IOEncoding"),
1184 'replace') 1188 'replace')
1185 else: 1189 else:
1186 output, error = self.__client.runcommand(args) 1190 output, error = self.__client.runcommand(args)
1187 1191
1338 process.start('hg', args) 1342 process.start('hg', args)
1339 procStarted = process.waitForStarted(5000) 1343 procStarted = process.waitForStarted(5000)
1340 if procStarted: 1344 if procStarted:
1341 finished = process.waitForFinished(30000) 1345 finished = process.waitForFinished(30000)
1342 if finished and process.exitCode() == 0: 1346 if finished and process.exitCode() == 0:
1343 output = str(process.readAllStandardOutput(), 1347 output = str(
1348 process.readAllStandardOutput(),
1344 Preferences.getSystem("IOEncoding"), 'replace') 1349 Preferences.getSystem("IOEncoding"), 'replace')
1345 else: 1350 else:
1346 output, error = self.__client.runcommand(args) 1351 output, error = self.__client.runcommand(args)
1347 1352
1348 infoBlock = [] 1353 infoBlock = []
1352 index += 1 1357 index += 1
1353 changeset, tags, author, date, branches, bookmarks = \ 1358 changeset, tags, author, date, branches, bookmarks = \
1354 line.split("@@@") 1359 line.split("@@@")
1355 cdate, ctime = date.split()[:2] 1360 cdate, ctime = date.split()[:2]
1356 info = [] 1361 info = []
1357 info.append(QApplication.translate("mercurial", 1362 info.append(QApplication.translate(
1363 "mercurial",
1358 """<tr><td><b>Parent #{0}</b></td><td></td></tr>\n""" 1364 """<tr><td><b>Parent #{0}</b></td><td></td></tr>\n"""
1359 """<tr><td><b>Changeset</b></td><td>{1}</td></tr>""")\ 1365 """<tr><td><b>Changeset</b></td><td>{1}</td></tr>""")\
1360 .format(index, changeset)) 1366 .format(index, changeset))
1361 if tags: 1367 if tags:
1362 info.append(QApplication.translate("mercurial", 1368 info.append(QApplication.translate(
1369 "mercurial",
1363 """<tr><td><b>Tags</b></td><td>{0}</td></tr>""")\ 1370 """<tr><td><b>Tags</b></td><td>{0}</td></tr>""")\
1364 .format('<br/>'.join(tags.split()))) 1371 .format('<br/>'.join(tags.split())))
1365 if bookmarks: 1372 if bookmarks:
1366 info.append(QApplication.translate("mercurial", 1373 info.append(QApplication.translate(
1374 "mercurial",
1367 """<tr><td><b>Bookmarks</b></td><td>{0}</td></tr>""")\ 1375 """<tr><td><b>Bookmarks</b></td><td>{0}</td></tr>""")\
1368 .format('<br/>'.join(bookmarks.split()))) 1376 .format('<br/>'.join(bookmarks.split())))
1369 if branches: 1377 if branches:
1370 info.append(QApplication.translate("mercurial", 1378 info.append(QApplication.translate(
1379 "mercurial",
1371 """<tr><td><b>Branches</b></td><td>{0}</td></tr>""")\ 1380 """<tr><td><b>Branches</b></td><td>{0}</td></tr>""")\
1372 .format('<br/>'.join(branches.split()))) 1381 .format('<br/>'.join(branches.split())))
1373 info.append(QApplication.translate("mercurial", 1382 info.append(QApplication.translate(
1383 "mercurial",
1374 """<tr><td><b>Last author</b></td><td>{0}</td></tr>\n""" 1384 """<tr><td><b>Last author</b></td><td>{0}</td></tr>\n"""
1375 """<tr><td><b>Committed date</b></td><td>{1}</td></tr>\n""" 1385 """<tr><td><b>Committed date</b></td><td>{1}</td></tr>\n"""
1376 """<tr><td><b>Committed time</b></td><td>{2}</td></tr>""")\ 1386 """<tr><td><b>Committed time</b></td><td>{2}</td></tr>""")\
1377 .format(author, cdate, ctime)) 1387 .format(author, cdate, ctime))
1378 infoBlock.append("\n".join(info)) 1388 infoBlock.append("\n".join(info))
1392 process.start('hg', args) 1402 process.start('hg', args)
1393 procStarted = process.waitForStarted(5000) 1403 procStarted = process.waitForStarted(5000)
1394 if procStarted: 1404 if procStarted:
1395 finished = process.waitForFinished(30000) 1405 finished = process.waitForFinished(30000)
1396 if finished and process.exitCode() == 0: 1406 if finished and process.exitCode() == 0:
1397 output = str(process.readAllStandardOutput(), 1407 output = str(
1408 process.readAllStandardOutput(),
1398 Preferences.getSystem("IOEncoding"), 'replace') 1409 Preferences.getSystem("IOEncoding"), 'replace')
1399 else: 1410 else:
1400 output, error = self.__client.runcommand(args) 1411 output, error = self.__client.runcommand(args)
1401 1412
1402 if output: 1413 if output:
1403 url = output.splitlines()[0].strip() 1414 url = output.splitlines()[0].strip()
1404 else: 1415 else:
1405 url = "" 1416 url = ""
1406 1417
1407 return QApplication.translate('mercurial', 1418 return QApplication.translate(
1419 'mercurial',
1408 """<h3>Repository information</h3>\n""" 1420 """<h3>Repository information</h3>\n"""
1409 """<p><table>\n""" 1421 """<p><table>\n"""
1410 """<tr><td><b>Mercurial V.</b></td><td>{0}</td></tr>\n""" 1422 """<tr><td><b>Mercurial V.</b></td><td>{0}</td></tr>\n"""
1411 """<tr></tr>\n""" 1423 """<tr></tr>\n"""
1412 """<tr><td><b>URL</b></td><td>{1}</td></tr>\n""" 1424 """<tr><td><b>URL</b></td><td>{1}</td></tr>\n"""
1489 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1501 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1490 repodir = os.path.dirname(repodir) 1502 repodir = os.path.dirname(repodir)
1491 if os.path.splitdrive(repodir)[1] == os.sep: 1503 if os.path.splitdrive(repodir)[1] == os.sep:
1492 return False 1504 return False
1493 1505
1494 dia = HgDialog(self.trUtf8('Copying {0}') 1506 dia = HgDialog(
1495 .format(name), self) 1507 self.trUtf8('Copying {0}').format(name), self)
1496 res = dia.startProcess(args, repodir) 1508 res = dia.startProcess(args, repodir)
1497 if res: 1509 if res:
1498 dia.exec_() 1510 dia.exec_()
1499 res = dia.normalExit() 1511 res = dia.normalExit()
1500 if res and \ 1512 if res and \
1718 procStarted = process.waitForStarted(5000) 1730 procStarted = process.waitForStarted(5000)
1719 if procStarted: 1731 if procStarted:
1720 finished = process.waitForFinished(30000) 1732 finished = process.waitForFinished(30000)
1721 if finished: 1733 if finished:
1722 if process.exitCode() == 0: 1734 if process.exitCode() == 0:
1723 output = str(process.readAllStandardOutput(), 1735 output = str(
1736 process.readAllStandardOutput(),
1724 Preferences.getSystem("IOEncoding"), 'replace') 1737 Preferences.getSystem("IOEncoding"), 'replace')
1725 else: 1738 else:
1726 error = str(process.readAllStandardError(), 1739 error = str(
1740 process.readAllStandardError(),
1727 Preferences.getSystem("IOEncoding"), 'replace') 1741 Preferences.getSystem("IOEncoding"), 'replace')
1728 else: 1742 else:
1729 error = self.trUtf8( 1743 error = self.trUtf8(
1730 "The hg process did not finish within 30s.") 1744 "The hg process did not finish within 30s.")
1731 else: 1745 else:
1732 error = self.trUtf8('The process {0} could not be started. ' 1746 error = self.trUtf8(
1747 'The process {0} could not be started. '
1733 'Ensure, that it is in the search path.').format('hg') 1748 'Ensure, that it is in the search path.').format('hg')
1734 else: 1749 else:
1735 output, error = self.__client.runcommand(args) 1750 output, error = self.__client.runcommand(args)
1736 1751
1737 return output, error 1752 return output, error
1775 else: 1790 else:
1776 rev1, rev2 = "", "" 1791 rev1, rev2 = "", ""
1777 1792
1778 output1, error = self.__hgGetFileForRevision(name, rev=rev1) 1793 output1, error = self.__hgGetFileForRevision(name, rev=rev1)
1779 if error: 1794 if error:
1780 E5MessageBox.critical(self.__ui, 1795 E5MessageBox.critical(
1796 self.__ui,
1781 self.trUtf8("Mercurial Side-by-Side Difference"), 1797 self.trUtf8("Mercurial Side-by-Side Difference"),
1782 error) 1798 error)
1783 return 1799 return
1784 name1 = "{0} (rev. {1})".format(name, rev1 and rev1 or ".") 1800 name1 = "{0} (rev. {1})".format(name, rev1 and rev1 or ".")
1785 1801
1786 if rev2: 1802 if rev2:
1787 output2, error = self.__hgGetFileForRevision(name, rev=rev2) 1803 output2, error = self.__hgGetFileForRevision(name, rev=rev2)
1788 if error: 1804 if error:
1789 E5MessageBox.critical(self.__ui, 1805 E5MessageBox.critical(
1806 self.__ui,
1790 self.trUtf8("Mercurial Side-by-Side Difference"), 1807 self.trUtf8("Mercurial Side-by-Side Difference"),
1791 error) 1808 error)
1792 return 1809 return
1793 name2 = "{0} (rev. {1})".format(name, rev2) 1810 name2 = "{0} (rev. {1})".format(name, rev2)
1794 else: 1811 else:
1796 f1 = open(name, "r", encoding="utf-8") 1813 f1 = open(name, "r", encoding="utf-8")
1797 output2 = f1.read() 1814 output2 = f1.read()
1798 f1.close() 1815 f1.close()
1799 name2 = name 1816 name2 = name
1800 except IOError: 1817 except IOError:
1801 E5MessageBox.critical(self.__ui, 1818 E5MessageBox.critical(
1819 self.__ui,
1802 self.trUtf8("Mercurial Side-by-Side Difference"), 1820 self.trUtf8("Mercurial Side-by-Side Difference"),
1803 self.trUtf8( 1821 self.trUtf8(
1804 """<p>The file <b>{0}</b> could not be read.</p>""") 1822 """<p>The file <b>{0}</b> could not be read.</p>""")
1805 .format(name)) 1823 .format(name))
1806 return 1824 return
1970 process.start('hg', args) 1988 process.start('hg', args)
1971 procStarted = process.waitForStarted(5000) 1989 procStarted = process.waitForStarted(5000)
1972 if procStarted: 1990 if procStarted:
1973 finished = process.waitForFinished(30000) 1991 finished = process.waitForFinished(30000)
1974 if finished and process.exitCode() == 0: 1992 if finished and process.exitCode() == 0:
1975 output = str(process.readAllStandardOutput(), 1993 output = str(
1994 process.readAllStandardOutput(),
1976 Preferences.getSystem("IOEncoding"), 'replace') 1995 Preferences.getSystem("IOEncoding"), 'replace')
1977 else: 1996 else:
1978 output, error = self.__client.runcommand(args) 1997 output, error = self.__client.runcommand(args)
1979 1998
1980 if output: 1999 if output:
1984 changeset, tags, author, date, branches, parents, bookmarks = \ 2003 changeset, tags, author, date, branches, parents, bookmarks = \
1985 line.split("@@@") 2004 line.split("@@@")
1986 cdate, ctime = date.split()[:2] 2005 cdate, ctime = date.split()[:2]
1987 info.append("""<p><table>""") 2006 info.append("""<p><table>""")
1988 if mode == "heads": 2007 if mode == "heads":
1989 info.append(QApplication.translate("mercurial", 2008 info.append(QApplication.translate(
2009 "mercurial",
1990 """<tr><td><b>Head #{0}</b></td><td></td></tr>\n""" 2010 """<tr><td><b>Head #{0}</b></td><td></td></tr>\n"""
1991 .format(index, changeset))) 2011 .format(index, changeset)))
1992 elif mode == "parents": 2012 elif mode == "parents":
1993 info.append(QApplication.translate("mercurial", 2013 info.append(QApplication.translate(
2014 "mercurial",
1994 """<tr><td><b>Parent #{0}</b></td><td></td></tr>\n""" 2015 """<tr><td><b>Parent #{0}</b></td><td></td></tr>\n"""
1995 .format(index, changeset))) 2016 .format(index, changeset)))
1996 elif mode == "tip": 2017 elif mode == "tip":
1997 info.append(QApplication.translate("mercurial", 2018 info.append(QApplication.translate(
2019 "mercurial",
1998 """<tr><td><b>Tip</b></td><td></td></tr>\n""")) 2020 """<tr><td><b>Tip</b></td><td></td></tr>\n"""))
1999 info.append(QApplication.translate("mercurial", 2021 info.append(QApplication.translate(
2022 "mercurial",
2000 """<tr><td><b>Changeset</b></td><td>{0}</td></tr>""")\ 2023 """<tr><td><b>Changeset</b></td><td>{0}</td></tr>""")\
2001 .format(changeset)) 2024 .format(changeset))
2002 if tags: 2025 if tags:
2003 info.append(QApplication.translate("mercurial", 2026 info.append(QApplication.translate(
2027 "mercurial",
2004 """<tr><td><b>Tags</b></td><td>{0}</td></tr>""")\ 2028 """<tr><td><b>Tags</b></td><td>{0}</td></tr>""")\
2005 .format('<br/>'.join(tags.split()))) 2029 .format('<br/>'.join(tags.split())))
2006 if bookmarks: 2030 if bookmarks:
2007 info.append(QApplication.translate("mercurial", 2031 info.append(QApplication.translate(
2032 "mercurial",
2008 """<tr><td><b>Bookmarks</b></td><td>{0}</td></tr>""")\ 2033 """<tr><td><b>Bookmarks</b></td><td>{0}</td></tr>""")\
2009 .format('<br/>'.join(bookmarks.split()))) 2034 .format('<br/>'.join(bookmarks.split())))
2010 if branches: 2035 if branches:
2011 info.append(QApplication.translate("mercurial", 2036 info.append(QApplication.translate(
2037 "mercurial",
2012 """<tr><td><b>Branches</b></td><td>{0}</td></tr>""")\ 2038 """<tr><td><b>Branches</b></td><td>{0}</td></tr>""")\
2013 .format('<br/>'.join(branches.split()))) 2039 .format('<br/>'.join(branches.split())))
2014 if parents: 2040 if parents:
2015 info.append(QApplication.translate("mercurial", 2041 info.append(QApplication.translate(
2042 "mercurial",
2016 """<tr><td><b>Parents</b></td><td>{0}</td></tr>""")\ 2043 """<tr><td><b>Parents</b></td><td>{0}</td></tr>""")\
2017 .format('<br/>'.join(parents.split()))) 2044 .format('<br/>'.join(parents.split())))
2018 info.append(QApplication.translate("mercurial", 2045 info.append(QApplication.translate(
2046 "mercurial",
2019 """<tr><td><b>Last author</b></td><td>{0}</td></tr>\n""" 2047 """<tr><td><b>Last author</b></td><td>{0}</td></tr>\n"""
2020 """<tr><td><b>Committed date</b></td><td>{1}</td></tr>\n""" 2048 """<tr><td><b>Committed date</b></td><td>{1}</td></tr>\n"""
2021 """<tr><td><b>Committed time</b></td><td>{2}</td></tr>\n""" 2049 """<tr><td><b>Committed time</b></td><td>{2}</td></tr>\n"""
2022 """</table></p>""")\ 2050 """</table></p>""")\
2023 .format(author, cdate, ctime)) 2051 .format(author, cdate, ctime))
2309 "glob:**.DS_Store", 2337 "glob:**.DS_Store",
2310 ] 2338 ]
2311 2339
2312 ignoreName = os.path.join(name, Hg.IgnoreFileName) 2340 ignoreName = os.path.join(name, Hg.IgnoreFileName)
2313 if os.path.exists(ignoreName): 2341 if os.path.exists(ignoreName):
2314 res = E5MessageBox.yesNo(self.__ui, 2342 res = E5MessageBox.yesNo(
2343 self.__ui,
2315 self.trUtf8("Create .hgignore file"), 2344 self.trUtf8("Create .hgignore file"),
2316 self.trUtf8("""<p>The file <b>{0}</b> exists already.""" 2345 self.trUtf8("""<p>The file <b>{0}</b> exists already."""
2317 """ Overwrite it?</p>""").format(ignoreName), 2346 """ Overwrite it?</p>""").format(ignoreName),
2318 icon=E5MessageBox.Warning) 2347 icon=E5MessageBox.Warning)
2319 else: 2348 else:
2379 if not ext: 2408 if not ext:
2380 ex = selectedFilter.split("(*")[1].split(")")[0] 2409 ex = selectedFilter.split("(*")[1].split(")")[0]
2381 if ex: 2410 if ex:
2382 fname += ex 2411 fname += ex
2383 if QFileInfo(fname).exists(): 2412 if QFileInfo(fname).exists():
2384 res = E5MessageBox.yesNo(self.__ui, 2413 res = E5MessageBox.yesNo(
2414 self.__ui,
2385 self.trUtf8("Create changegroup"), 2415 self.trUtf8("Create changegroup"),
2386 self.trUtf8("<p>The Mercurial changegroup file <b>{0}</b> " 2416 self.trUtf8("<p>The Mercurial changegroup file <b>{0}</b> "
2387 "already exists. Overwrite it?</p>") 2417 "already exists. Overwrite it?</p>")
2388 .format(fname), 2418 .format(fname),
2389 icon=E5MessageBox.Warning) 2419 icon=E5MessageBox.Warning)
2504 self.__lastChangeGroupPath or repodir, 2534 self.__lastChangeGroupPath or repodir,
2505 self.trUtf8("Mercurial Changegroup Files (*.hg);;All Files (*)")) 2535 self.trUtf8("Mercurial Changegroup Files (*.hg);;All Files (*)"))
2506 if files: 2536 if files:
2507 self.__lastChangeGroupPath = os.path.dirname(files[0]) 2537 self.__lastChangeGroupPath = os.path.dirname(files[0])
2508 2538
2509 update = E5MessageBox.yesNo(self.__ui, 2539 update = E5MessageBox.yesNo(
2540 self.__ui,
2510 self.trUtf8("Apply changegroups"), 2541 self.trUtf8("Apply changegroups"),
2511 self.trUtf8("""Shall the working directory be updated?"""), 2542 self.trUtf8("""Shall the working directory be updated?"""),
2512 yesDefault=True) 2543 yesDefault=True)
2513 2544
2514 args = [] 2545 args = []
2645 self.hgGetBranchesList(repodir), 2676 self.hgGetBranchesList(repodir),
2646 bookmarksList) 2677 bookmarksList)
2647 if dlg.exec_() == QDialog.Accepted: 2678 if dlg.exec_() == QDialog.Accepted:
2648 rev, merge, date, user, message = dlg.getParameters() 2679 rev, merge, date, user, message = dlg.getParameters()
2649 if not rev: 2680 if not rev:
2650 E5MessageBox.warning(self.__ui, 2681 E5MessageBox.warning(
2682 self.__ui,
2651 self.trUtf8("Backing out changeset"), 2683 self.trUtf8("Backing out changeset"),
2652 self.trUtf8("""No revision given. Aborting...""")) 2684 self.trUtf8("""No revision given. Aborting..."""))
2653 return 2685 return
2654 2686
2655 args = [] 2687 args = []
3027 try: 3059 try:
3028 f = open(hgsub, "r") 3060 f = open(hgsub, "r")
3029 contents = f.readlines() 3061 contents = f.readlines()
3030 f.close() 3062 f.close()
3031 except IOError as err: 3063 except IOError as err:
3032 E5MessageBox.critical(self.__ui, 3064 E5MessageBox.critical(
3065 self.__ui,
3033 self.trUtf8("Add Sub-repository"), 3066 self.trUtf8("Add Sub-repository"),
3034 self.trUtf8( 3067 self.trUtf8(
3035 """<p>The sub-repositories file .hgsub could not""" 3068 """<p>The sub-repositories file .hgsub could not"""
3036 """ be read.</p><p>Reason: {0}</p>""") 3069 """ be read.</p><p>Reason: {0}</p>""")
3037 .format(str(err))) 3070 .format(str(err)))
3038 return 3071 return
3039 3072
3040 if entry in contents: 3073 if entry in contents:
3041 E5MessageBox.critical(self.__ui, 3074 E5MessageBox.critical(
3075 self.__ui,
3042 self.trUtf8("Add Sub-repository"), 3076 self.trUtf8("Add Sub-repository"),
3043 self.trUtf8( 3077 self.trUtf8(
3044 """<p>The sub-repositories file .hgsub already""" 3078 """<p>The sub-repositories file .hgsub already"""
3045 """ contains an entry <b>{0}</b>.""" 3079 """ contains an entry <b>{0}</b>."""
3046 """ Aborting...</p>""").format(entry)) 3080 """ Aborting...</p>""").format(entry))
3054 try: 3088 try:
3055 f = open(hgsub, "w") 3089 f = open(hgsub, "w")
3056 f.writelines(contents) 3090 f.writelines(contents)
3057 f.close() 3091 f.close()
3058 except IOError as err: 3092 except IOError as err:
3059 E5MessageBox.critical(self.__ui, 3093 E5MessageBox.critical(
3094 self.__ui,
3060 self.trUtf8("Add Sub-repository"), 3095 self.trUtf8("Add Sub-repository"),
3061 self.trUtf8( 3096 self.trUtf8(
3062 """<p>The sub-repositories file .hgsub could not""" 3097 """<p>The sub-repositories file .hgsub could not"""
3063 """ be written to.</p><p>Reason: {0}</p>""") 3098 """ be written to.</p><p>Reason: {0}</p>""")
3064 .format(str(err))) 3099 .format(str(err)))
3074 """ 3109 """
3075 hgsub = self.getHgSubPath() 3110 hgsub = self.getHgSubPath()
3076 3111
3077 subrepositories = [] 3112 subrepositories = []
3078 if not os.path.isfile(hgsub): 3113 if not os.path.isfile(hgsub):
3079 E5MessageBox.critical(self.__ui, 3114 E5MessageBox.critical(
3115 self.__ui,
3080 self.trUtf8("Remove Sub-repositories"), 3116 self.trUtf8("Remove Sub-repositories"),
3081 self.trUtf8("""<p>The sub-repositories file .hgsub does not""" 3117 self.trUtf8("""<p>The sub-repositories file .hgsub does not"""
3082 """ exist. Aborting...</p>""")) 3118 """ exist. Aborting...</p>"""))
3083 return 3119 return
3084 3120
3085 try: 3121 try:
3086 f = open(hgsub, "r") 3122 f = open(hgsub, "r")
3087 subrepositories = [line.strip() for line in f.readlines()] 3123 subrepositories = [line.strip() for line in f.readlines()]
3088 f.close() 3124 f.close()
3089 except IOError as err: 3125 except IOError as err:
3090 E5MessageBox.critical(self.__ui, 3126 E5MessageBox.critical(
3127 self.__ui,
3091 self.trUtf8("Remove Sub-repositories"), 3128 self.trUtf8("Remove Sub-repositories"),
3092 self.trUtf8("""<p>The sub-repositories file .hgsub could not""" 3129 self.trUtf8("""<p>The sub-repositories file .hgsub could not"""
3093 """ be read.</p><p>Reason: {0}</p>""") 3130 """ be read.</p><p>Reason: {0}</p>""")
3094 .format(str(err))) 3131 .format(str(err)))
3095 return 3132 return
3103 try: 3140 try:
3104 f = open(hgsub, "w") 3141 f = open(hgsub, "w")
3105 f.write(contents) 3142 f.write(contents)
3106 f.close() 3143 f.close()
3107 except IOError as err: 3144 except IOError as err:
3108 E5MessageBox.critical(self.__ui, 3145 E5MessageBox.critical(
3146 self.__ui,
3109 self.trUtf8("Remove Sub-repositories"), 3147 self.trUtf8("Remove Sub-repositories"),
3110 self.trUtf8( 3148 self.trUtf8(
3111 """<p>The sub-repositories file .hgsub could not""" 3149 """<p>The sub-repositories file .hgsub could not"""
3112 """ be written to.</p><p>Reason: {0}</p>""") 3150 """ be written to.</p><p>Reason: {0}</p>""")
3113 .format(str(err))) 3151 .format(str(err)))
3133 self.__getExtensionsInfo() 3171 self.__getExtensionsInfo()
3134 3172
3135 if self.__client: 3173 if self.__client:
3136 ok, err = self.__client.restartServer() 3174 ok, err = self.__client.restartServer()
3137 if not ok: 3175 if not ok:
3138 E5MessageBox.warning(None, 3176 E5MessageBox.warning(
3177 None,
3139 self.trUtf8("Mercurial Command Server"), 3178 self.trUtf8("Mercurial Command Server"),
3140 self.trUtf8( 3179 self.trUtf8(
3141 """<p>The Mercurial Command Server could not be""" 3180 """<p>The Mercurial Command Server could not be"""
3142 """ restarted.</p><p>Reason: {0}</p>""").format(err)) 3181 """ restarted.</p><p>Reason: {0}</p>""").format(err))
3143 self.__client = None 3182 self.__client = None
3179 process.start('hg', args) 3218 process.start('hg', args)
3180 procStarted = process.waitForStarted(5000) 3219 procStarted = process.waitForStarted(5000)
3181 if procStarted: 3220 if procStarted:
3182 finished = process.waitForFinished(30000) 3221 finished = process.waitForFinished(30000)
3183 if finished and process.exitCode() == 0: 3222 if finished and process.exitCode() == 0:
3184 output = str(process.readAllStandardOutput(), 3223 output = str(
3224 process.readAllStandardOutput(),
3185 Preferences.getSystem("IOEncoding"), 'replace') 3225 Preferences.getSystem("IOEncoding"), 'replace')
3186 else: 3226 else:
3187 output, error = self.__client.runcommand(args) 3227 output, error = self.__client.runcommand(args)
3188 3228
3189 if output: 3229 if output:
3269 client = HgClient(repodir, "utf-8", self) 3309 client = HgClient(repodir, "utf-8", self)
3270 ok, err = client.startServer() 3310 ok, err = client.startServer()
3271 if ok: 3311 if ok:
3272 self.__client = client 3312 self.__client = client
3273 else: 3313 else:
3274 E5MessageBox.warning(None, 3314 E5MessageBox.warning(
3315 None,
3275 self.trUtf8("Mercurial Command Server"), 3316 self.trUtf8("Mercurial Command Server"),
3276 self.trUtf8( 3317 self.trUtf8(
3277 """<p>The Mercurial Command Server could not be""" 3318 """<p>The Mercurial Command Server could not be"""
3278 """ started.</p><p>Reason: {0}</p>""").format(err)) 3319 """ started.</p><p>Reason: {0}</p>""").format(err))
3279 3320

eric ide

mercurial