9 |
9 |
10 |
10 |
11 import os |
11 import os |
12 import shutil |
12 import shutil |
13 |
13 |
14 from PyQt5.QtCore import QProcess, pyqtSignal, QFileInfo, QFileSystemWatcher, \ |
14 from PyQt5.QtCore import ( |
15 QCoreApplication |
15 QProcess, pyqtSignal, QFileInfo, QFileSystemWatcher, QCoreApplication |
|
16 ) |
16 from PyQt5.QtWidgets import QApplication, QDialog, QInputDialog |
17 from PyQt5.QtWidgets import QApplication, QDialog, QInputDialog |
17 |
18 |
18 from E5Gui.E5Application import e5App |
19 from E5Gui.E5Application import e5App |
19 from E5Gui import E5MessageBox, E5FileDialog |
20 from E5Gui import E5MessageBox, E5FileDialog |
20 |
21 |
460 for nam in nameList: |
461 for nam in nameList: |
461 # check for commit of the project |
462 # check for commit of the project |
462 if os.path.isdir(nam): |
463 if os.path.isdir(nam): |
463 project = e5App().getObject("Project") |
464 project = e5App().getObject("Project") |
464 if nam == project.getProjectPath(): |
465 if nam == project.getProjectPath(): |
465 ok &= \ |
466 ok &= ( |
466 project.checkAllScriptsDirty( |
467 project.checkAllScriptsDirty( |
467 reportSyntaxErrors=True) and \ |
468 reportSyntaxErrors=True) and |
468 project.checkDirty() |
469 project.checkDirty() |
|
470 ) |
469 continue |
471 continue |
470 elif os.path.isfile(nam): |
472 elif os.path.isfile(nam): |
471 editor = \ |
473 editor = ( |
472 e5App().getObject("ViewManager").getOpenEditor(nam) |
474 e5App().getObject("ViewManager").getOpenEditor(nam) |
|
475 ) |
473 if editor: |
476 if editor: |
474 ok &= editor.checkDirty() |
477 ok &= editor.checkDirty() |
475 if not ok: |
478 if not ok: |
476 break |
479 break |
477 |
480 |
497 repodir = os.path.dirname(repodir) |
500 repodir = os.path.dirname(repodir) |
498 if os.path.splitdrive(repodir)[1] == os.sep: |
501 if os.path.splitdrive(repodir)[1] == os.sep: |
499 return |
502 return |
500 |
503 |
501 if self.__commitDialog is not None: |
504 if self.__commitDialog is not None: |
502 msg, amend, commitSubrepositories, author, dateTime = \ |
505 (msg, amend, commitSubrepositories, author, |
503 self.__commitDialog.getCommitData() |
506 dateTime) = self.__commitDialog.getCommitData() |
504 self.__commitDialog.deleteLater() |
507 self.__commitDialog.deleteLater() |
505 self.__commitDialog = None |
508 self.__commitDialog = None |
506 if amend and not msg: |
509 if amend and not msg: |
507 msg = self.__getMostRecentCommitMessage(repodir) |
510 msg = self.__getMostRecentCommitMessage(repodir) |
508 else: |
511 else: |
993 return False |
996 return False |
994 |
997 |
995 project = e5App().getObject("Project") |
998 project = e5App().getObject("Project") |
996 names = [project.getRelativePath(nam) for nam in names] |
999 names = [project.getRelativePath(nam) for nam in names] |
997 if names[0]: |
1000 if names[0]: |
998 from UI.DeleteFilesConfirmationDialog import \ |
1001 from UI.DeleteFilesConfirmationDialog import ( |
999 DeleteFilesConfirmationDialog |
1002 DeleteFilesConfirmationDialog |
|
1003 ) |
1000 dlg = DeleteFilesConfirmationDialog( |
1004 dlg = DeleteFilesConfirmationDialog( |
1001 self.parent(), |
1005 self.parent(), |
1002 self.tr("Revert changes"), |
1006 self.tr("Revert changes"), |
1003 self.tr( |
1007 self.tr( |
1004 "Do you really want to revert all changes to these files" |
1008 "Do you really want to revert all changes to these files" |
1096 return |
1100 return |
1097 |
1101 |
1098 project = e5App().getObject("Project") |
1102 project = e5App().getObject("Project") |
1099 names = [project.getRelativePath(nam) for nam in names] |
1103 names = [project.getRelativePath(nam) for nam in names] |
1100 if names[0]: |
1104 if names[0]: |
1101 from UI.DeleteFilesConfirmationDialog import \ |
1105 from UI.DeleteFilesConfirmationDialog import ( |
1102 DeleteFilesConfirmationDialog |
1106 DeleteFilesConfirmationDialog |
|
1107 ) |
1103 dlg = DeleteFilesConfirmationDialog( |
1108 dlg = DeleteFilesConfirmationDialog( |
1104 self.parent(), |
1109 self.parent(), |
1105 self.tr("Re-Merge"), |
1110 self.tr("Re-Merge"), |
1106 self.tr( |
1111 self.tr( |
1107 "Do you really want to re-merge these files" |
1112 "Do you really want to re-merge these files" |
1423 infoBlock = [] |
1428 infoBlock = [] |
1424 if output: |
1429 if output: |
1425 index = 0 |
1430 index = 0 |
1426 for line in output.splitlines(): |
1431 for line in output.splitlines(): |
1427 index += 1 |
1432 index += 1 |
1428 changeset, tags, author, date, branches, bookmarks = \ |
1433 (changeset, tags, author, date, branches, |
1429 line.split("@@@") |
1434 bookmarks) = line.split("@@@") |
1430 cdate, ctime = date.split()[:2] |
1435 cdate, ctime = date.split()[:2] |
1431 info = [] |
1436 info = [] |
1432 info.append(QCoreApplication.translate( |
1437 info.append(QCoreApplication.translate( |
1433 "mercurial", |
1438 "mercurial", |
1434 """<tr><td><b>Parent #{0}</b></td><td></td></tr>\n""" |
1439 """<tr><td><b>Parent #{0}</b></td><td></td></tr>\n""" |
1551 self.tr('Copying {0}').format(name), self) |
1556 self.tr('Copying {0}').format(name), self) |
1552 res = dia.startProcess(args, repodir) |
1557 res = dia.startProcess(args, repodir) |
1553 if res: |
1558 if res: |
1554 dia.exec_() |
1559 dia.exec_() |
1555 res = dia.normalExit() |
1560 res = dia.normalExit() |
1556 if res and \ |
1561 if ( |
1557 target.startswith(project.getProjectPath()): |
1562 res and |
|
1563 target.startswith(project.getProjectPath()) |
|
1564 ): |
1558 if os.path.isdir(name): |
1565 if os.path.isdir(name): |
1559 project.copyDirectory(name, target) |
1566 project.copyDirectory(name, target) |
1560 else: |
1567 else: |
1561 project.appendFile(target) |
1568 project.appendFile(target) |
1562 return res |
1569 return res |
1928 @type list of str |
1935 @type list of str |
1929 @return flag indicating, that the update contained an add |
1936 @return flag indicating, that the update contained an add |
1930 or delete |
1937 or delete |
1931 @rtype bool |
1938 @rtype bool |
1932 """ |
1939 """ |
1933 if self.getPlugin().getPreferences("PreferUnbundle") and \ |
1940 if ( |
1934 self.bundleFile and \ |
1941 self.getPlugin().getPreferences("PreferUnbundle") and |
1935 os.path.exists(self.bundleFile) and \ |
1942 self.bundleFile and |
1936 revisions is None: |
1943 os.path.exists(self.bundleFile) and |
|
1944 revisions is None |
|
1945 ): |
1937 command = "unbundle" |
1946 command = "unbundle" |
1938 title = self.tr('Apply changegroups') |
1947 title = self.tr('Apply changegroups') |
1939 else: |
1948 else: |
1940 command = "pull" |
1949 command = "pull" |
1941 title = self.tr('Pulling from a remote Mercurial repository') |
1950 title = self.tr('Pulling from a remote Mercurial repository') |
1961 dia = HgDialog(title, self) |
1970 dia = HgDialog(title, self) |
1962 res = dia.startProcess(args, repodir) |
1971 res = dia.startProcess(args, repodir) |
1963 if res: |
1972 if res: |
1964 dia.exec_() |
1973 dia.exec_() |
1965 res = dia.hasAddOrDelete() |
1974 res = dia.hasAddOrDelete() |
1966 if self.bundleFile and \ |
1975 if ( |
1967 os.path.exists(self.bundleFile): |
1976 self.bundleFile and |
|
1977 os.path.exists(self.bundleFile) |
|
1978 ): |
1968 os.remove(self.bundleFile) |
1979 os.remove(self.bundleFile) |
1969 self.bundleFile = None |
1980 self.bundleFile = None |
1970 self.checkVCSStatus() |
1981 self.checkVCSStatus() |
1971 return res |
1982 return res |
1972 |
1983 |
2044 |
2055 |
2045 if output: |
2056 if output: |
2046 index = 0 |
2057 index = 0 |
2047 for line in output.splitlines(): |
2058 for line in output.splitlines(): |
2048 index += 1 |
2059 index += 1 |
2049 changeset, tags, author, date, branches, parents, bookmarks = \ |
2060 (changeset, tags, author, date, branches, parents, |
2050 line.split("@@@") |
2061 bookmarks) = line.split("@@@") |
2051 cdate, ctime = date.split()[:2] |
2062 cdate, ctime = date.split()[:2] |
2052 info.append("""<p><table>""") |
2063 info.append("""<p><table>""") |
2053 if mode == "heads": |
2064 if mode == "heads": |
2054 info.append(QCoreApplication.translate( |
2065 info.append(QCoreApplication.translate( |
2055 "mercurial", |
2066 "mercurial", |
2318 if defaultUrl: |
2329 if defaultUrl: |
2319 cfg.write("default = {0}\n".format(defaultUrl)) |
2330 cfg.write("default = {0}\n".format(defaultUrl)) |
2320 if defaultPushUrl: |
2331 if defaultPushUrl: |
2321 cfg.write("default-push = {0}\n".format( |
2332 cfg.write("default-push = {0}\n".format( |
2322 defaultPushUrl)) |
2333 defaultPushUrl)) |
2323 if withLargefiles and \ |
2334 if ( |
2324 (lfMinSize, lfPattern) != (None, None): |
2335 withLargefiles and |
|
2336 (lfMinSize, lfPattern) != (None, None) |
|
2337 ): |
2325 cfg.write("\n[largefiles]\n") |
2338 cfg.write("\n[largefiles]\n") |
2326 if lfMinSize is not None: |
2339 if lfMinSize is not None: |
2327 cfg.write("minsize = {0}\n".format(lfMinSize)) |
2340 cfg.write("minsize = {0}\n".format(lfMinSize)) |
2328 if lfPattern is not None: |
2341 if lfPattern is not None: |
2329 cfg.write("patterns =\n") |
2342 cfg.write("patterns =\n") |
2618 if file: |
2631 if file: |
2619 self.__lastChangeGroupPath = os.path.dirname(file) |
2632 self.__lastChangeGroupPath = os.path.dirname(file) |
2620 |
2633 |
2621 if self.logBrowserIncoming is None: |
2634 if self.logBrowserIncoming is None: |
2622 from .HgLogBrowserDialog import HgLogBrowserDialog |
2635 from .HgLogBrowserDialog import HgLogBrowserDialog |
2623 self.logBrowserIncoming = \ |
2636 self.logBrowserIncoming = HgLogBrowserDialog( |
2624 HgLogBrowserDialog(self, mode="incoming") |
2637 self, mode="incoming") |
2625 self.logBrowserIncoming.show() |
2638 self.logBrowserIncoming.show() |
2626 self.logBrowserIncoming.raise_() |
2639 self.logBrowserIncoming.raise_() |
2627 self.logBrowserIncoming.start(name, bundle=file) |
2640 self.logBrowserIncoming.start(name, bundle=file) |
2628 |
2641 |
2629 def hgUnbundle(self, name, files=None): |
2642 def hgUnbundle(self, name, files=None): |
2873 return False |
2886 return False |
2874 |
2887 |
2875 from .HgImportDialog import HgImportDialog |
2888 from .HgImportDialog import HgImportDialog |
2876 dlg = HgImportDialog() |
2889 dlg = HgImportDialog() |
2877 if dlg.exec_() == QDialog.Accepted: |
2890 if dlg.exec_() == QDialog.Accepted: |
2878 patchFile, noCommit, message, date, user, stripCount, force = \ |
2891 (patchFile, noCommit, message, date, user, stripCount, |
2879 dlg.getParameters() |
2892 force) = dlg.getParameters() |
2880 |
2893 |
2881 args = self.initCommand("import") |
2894 args = self.initCommand("import") |
2882 args.append("--verbose") |
2895 args.append("--verbose") |
2883 if noCommit: |
2896 if noCommit: |
2884 args.append("--no-commit") |
2897 args.append("--no-commit") |
2927 |
2940 |
2928 from .HgExportDialog import HgExportDialog |
2941 from .HgExportDialog import HgExportDialog |
2929 dlg = HgExportDialog(self.hgGetBookmarksList(repodir), |
2942 dlg = HgExportDialog(self.hgGetBookmarksList(repodir), |
2930 self.version >= (4, 7, 0)) |
2943 self.version >= (4, 7, 0)) |
2931 if dlg.exec_() == QDialog.Accepted: |
2944 if dlg.exec_() == QDialog.Accepted: |
2932 filePattern, revisions, bookmark, switchParent, allText, noDates, \ |
2945 (filePattern, revisions, bookmark, switchParent, allText, |
2933 git = dlg.getParameters() |
2946 noDates, git) = dlg.getParameters() |
2934 |
2947 |
2935 args = self.initCommand("export") |
2948 args = self.initCommand("export") |
2936 args.append("--output") |
2949 args.append("--output") |
2937 args.append(filePattern) |
2950 args.append(filePattern) |
2938 args.append("--verbose") |
2951 args.append("--verbose") |
3026 |
3039 |
3027 from .HgGraftDialog import HgGraftDialog |
3040 from .HgGraftDialog import HgGraftDialog |
3028 res = False |
3041 res = False |
3029 dlg = HgGraftDialog(self, revs) |
3042 dlg = HgGraftDialog(self, revs) |
3030 if dlg.exec_() == QDialog.Accepted: |
3043 if dlg.exec_() == QDialog.Accepted: |
3031 revs, (userData, currentUser, userName), \ |
3044 (revs, |
3032 (dateData, currentDate, dateStr), log, dryrun, \ |
3045 (userData, currentUser, userName), |
3033 noCommit = dlg.getData() |
3046 (dateData, currentDate, dateStr), |
|
3047 log, dryrun, noCommit) = dlg.getData() |
3034 |
3048 |
3035 args = self.initCommand("graft") |
3049 args = self.initCommand("graft") |
3036 args.append("--verbose") |
3050 args.append("--verbose") |
3037 if userData: |
3051 if userData: |
3038 if currentUser: |
3052 if currentUser: |
3300 self.tr("""<p>The sub-repositories file .hgsub could not""" |
3314 self.tr("""<p>The sub-repositories file .hgsub could not""" |
3301 """ be read.</p><p>Reason: {0}</p>""") |
3315 """ be read.</p><p>Reason: {0}</p>""") |
3302 .format(str(err))) |
3316 .format(str(err))) |
3303 return |
3317 return |
3304 |
3318 |
3305 from .HgRemoveSubrepositoriesDialog import \ |
3319 from .HgRemoveSubrepositoriesDialog import ( |
3306 HgRemoveSubrepositoriesDialog |
3320 HgRemoveSubrepositoriesDialog |
|
3321 ) |
3307 dlg = HgRemoveSubrepositoriesDialog(subrepositories) |
3322 dlg = HgRemoveSubrepositoriesDialog(subrepositories) |
3308 if dlg.exec_() == QDialog.Accepted: |
3323 if dlg.exec_() == QDialog.Accepted: |
3309 subrepositories, removedSubrepos, deleteSubrepos = dlg.getData() |
3324 subrepositories, removedSubrepos, deleteSubrepos = dlg.getData() |
3310 contents = "\n".join(subrepositories) + "\n" |
3325 contents = "\n".join(subrepositories) + "\n" |
3311 try: |
3326 try: |
3357 |
3372 |
3358 self.__defaultConfigured = False |
3373 self.__defaultConfigured = False |
3359 self.__defaultPushConfigured = False |
3374 self.__defaultPushConfigured = False |
3360 if output: |
3375 if output: |
3361 for line in output.splitlines(): |
3376 for line in output.splitlines(): |
3362 if line.startswith("paths.default=") and \ |
3377 if ( |
3363 not line.strip().endswith("="): |
3378 line.startswith("paths.default=") and |
|
3379 not line.strip().endswith("=") |
|
3380 ): |
3364 self.__defaultConfigured = True |
3381 self.__defaultConfigured = True |
3365 if line.startswith("paths.default-push=") and \ |
3382 if ( |
3366 not line.strip().endswith("="): |
3383 line.startswith("paths.default-push=") and |
|
3384 not line.strip().endswith("=") |
|
3385 ): |
3367 self.__defaultPushConfigured = True |
3386 self.__defaultPushConfigured = True |
3368 |
3387 |
3369 def canCommitMerge(self, name): |
3388 def canCommitMerge(self, name): |
3370 """ |
3389 """ |
3371 Public method to check, if the working directory is an uncommitted |
3390 Public method to check, if the working directory is an uncommitted |
3493 else: |
3512 else: |
3494 output, error = self.__client.runcommand(args) |
3513 output, error = self.__client.runcommand(args) |
3495 |
3514 |
3496 if output: |
3515 if output: |
3497 for line in output.splitlines(): |
3516 for line in output.splitlines(): |
3498 extensionName = \ |
3517 extensionName = ( |
3499 line.split("=", 1)[0].strip().split(".")[-1].strip() |
3518 line.split("=", 1)[0].strip().split(".")[-1].strip() |
|
3519 ) |
3500 self.__activeExtensions.append(extensionName) |
3520 self.__activeExtensions.append(extensionName) |
3501 if self.version < (4, 8, 0) and "closehead" in self.__activeExtensions: |
3521 if self.version < (4, 8, 0) and "closehead" in self.__activeExtensions: |
3502 self.__activeExtensions.remove["closehead"] |
3522 self.__activeExtensions.remove["closehead"] |
3503 |
3523 |
3504 if activeExtensions != sorted(self.__activeExtensions): |
3524 if activeExtensions != sorted(self.__activeExtensions): |