Plugins/VcsPlugins/vcsMercurial/hg.py

changeset 1240
4d5fc346bd3b
parent 1237
a6b7e93f649c
child 1243
d68d8b2a37b3
equal deleted inserted replaced
1239:697757468865 1240:4d5fc346bd3b
43 from .HgCommandDialog import HgCommandDialog 43 from .HgCommandDialog import HgCommandDialog
44 from .HgBundleDialog import HgBundleDialog 44 from .HgBundleDialog import HgBundleDialog
45 from .HgBackoutDialog import HgBackoutDialog 45 from .HgBackoutDialog import HgBackoutDialog
46 from .HgServeDialog import HgServeDialog 46 from .HgServeDialog import HgServeDialog
47 from .HgUtilities import getConfigPath 47 from .HgUtilities import getConfigPath
48 from .HgClient import HgClient
48 49
49 from .BookmarksExtension.bookmarks import Bookmarks 50 from .BookmarksExtension.bookmarks import Bookmarks
50 from .QueuesExtension.queues import Queues 51 from .QueuesExtension.queues import Queues
51 from .FetchExtension.fetch import Fetch 52 from .FetchExtension.fetch import Fetch
52 from .PurgeExtension.purge import Purge 53 from .PurgeExtension.purge import Purge
140 141
141 self.__iniWatcher = QFileSystemWatcher(self) 142 self.__iniWatcher = QFileSystemWatcher(self)
142 self.__iniWatcher.fileChanged.connect(self.__iniFileChanged) 143 self.__iniWatcher.fileChanged.connect(self.__iniFileChanged)
143 self.__iniWatcher.addPath(getConfigPath()) 144 self.__iniWatcher.addPath(getConfigPath())
144 145
146 self.__client = None
147
145 # instantiate the extensions 148 # instantiate the extensions
146 self.__extensions = { 149 self.__extensions = {
147 "bookmarks": Bookmarks(self), 150 "bookmarks": Bookmarks(self),
148 "mq": Queues(self), 151 "mq": Queues(self),
149 "fetch": Fetch(self), 152 "fetch": Fetch(self),
187 self.__projectHelper.shutdown() 190 self.__projectHelper.shutdown()
188 191
189 # shut down the extensions 192 # shut down the extensions
190 for extension in self.__extensions.values(): 193 for extension in self.__extensions.values():
191 extension.shutdown() 194 extension.shutdown()
195
196 # shut down the client
197 self.__client and self.__client.stopServer()
198
199 def getClient(self):
200 """
201 Public method to get a reference to the command server interface.
202
203 @return reference to the client (HgClient)
204 """
205 return self.__client
192 206
193 def vcsExists(self): 207 def vcsExists(self):
194 """ 208 """
195 Public method used to test for the presence of the hg executable. 209 Public method used to test for the presence of the hg executable.
196 210
270 msg = '***' 284 msg = '***'
271 285
272 args = [] 286 args = []
273 args.append('init') 287 args.append('init')
274 args.append(projectDir) 288 args.append(projectDir)
289 # init is not possible with the command server
275 dia = HgDialog(self.trUtf8('Creating Mercurial repository')) 290 dia = HgDialog(self.trUtf8('Creating Mercurial repository'))
276 res = dia.startProcess(args) 291 res = dia.startProcess(args)
277 if res: 292 if res:
278 dia.exec_() 293 dia.exec_()
279 status = dia.normalExit() 294 status = dia.normalExit()
285 args = [] 300 args = []
286 args.append('commit') 301 args.append('commit')
287 args.append('--addremove') 302 args.append('--addremove')
288 args.append('--message') 303 args.append('--message')
289 args.append(msg) 304 args.append(msg)
290 dia = HgDialog(self.trUtf8('Initial commit to Mercurial repository')) 305 dia = HgDialog(self.trUtf8('Initial commit to Mercurial repository'),
306 self)
291 res = dia.startProcess(args, projectDir) 307 res = dia.startProcess(args, projectDir)
292 if res: 308 if res:
293 dia.exec_() 309 dia.exec_()
294 status = dia.normalExit() 310 status = dia.normalExit()
295 311
324 args.append(rev) 340 args.append(rev)
325 args.append(self.__hgURL(vcsUrl)) 341 args.append(self.__hgURL(vcsUrl))
326 args.append(projectDir) 342 args.append(projectDir)
327 343
328 if noDialog: 344 if noDialog:
329 return self.startSynchronizedProcess(QProcess(), 'hg', args) 345 if self.__client is None:
330 else: 346 return self.startSynchronizedProcess(QProcess(), 'hg', args)
331 dia = HgDialog(self.trUtf8('Cloning project from a Mercurial repository')) 347 else:
348 out, err = self.__client.runcommand(args)
349 return err == ""
350 else:
351 dia = HgDialog(self.trUtf8('Cloning project from a Mercurial repository'),
352 self)
332 res = dia.startProcess(args) 353 res = dia.startProcess(args)
333 if res: 354 if res:
334 dia.exec_() 355 dia.exec_()
335 return dia.normalExit() 356 return dia.normalExit()
336 357
422 args.append(fname) 443 args.append(fname)
423 444
424 if noDialog: 445 if noDialog:
425 self.startSynchronizedProcess(QProcess(), "hg", args, dname) 446 self.startSynchronizedProcess(QProcess(), "hg", args, dname)
426 else: 447 else:
427 dia = HgDialog(self.trUtf8('Commiting changes to Mercurial repository')) 448 dia = HgDialog(self.trUtf8('Committing changes to Mercurial repository'),
449 self)
428 res = dia.startProcess(args, dname) 450 res = dia.startProcess(args, dname)
429 if res: 451 if res:
430 dia.exec_() 452 dia.exec_()
431 self.committed.emit() 453 self.committed.emit()
432 if self.__forgotNames: 454 if self.__forgotNames:
467 repodir = os.path.dirname(repodir) 489 repodir = os.path.dirname(repodir)
468 if repodir == os.sep: 490 if repodir == os.sep:
469 return False 491 return False
470 492
471 if noDialog: 493 if noDialog:
472 self.startSynchronizedProcess(QProcess(), "hg", args, repodir) 494 if self.__client is None:
495 self.startSynchronizedProcess(QProcess(), 'hg', args, repodir)
496 else:
497 out, err = self.__client.runcommand(args)
473 res = False 498 res = False
474 else: 499 else:
475 dia = HgDialog(self.trUtf8('Synchronizing with the Mercurial repository')) 500 dia = HgDialog(self.trUtf8('Synchronizing with the Mercurial repository'),
501 self)
476 res = dia.startProcess(args, repodir) 502 res = dia.startProcess(args, repodir)
477 if res: 503 if res:
478 dia.exec_() 504 dia.exec_()
479 res = dia.hasAddOrDelete() 505 res = dia.hasAddOrDelete()
480 self.checkVCSStatus() 506 self.checkVCSStatus()
516 self.addArguments(args, name) 542 self.addArguments(args, name)
517 else: 543 else:
518 args.append(name) 544 args.append(name)
519 545
520 if noDialog: 546 if noDialog:
521 self.startSynchronizedProcess(QProcess(), "hg", args, repodir) 547 if self.__client is None:
548 self.startSynchronizedProcess(QProcess(), 'hg', args, repodir)
549 else:
550 out, err = self.__client.runcommand(args)
522 else: 551 else:
523 dia = HgDialog( 552 dia = HgDialog(
524 self.trUtf8('Adding files/directories to the Mercurial repository')) 553 self.trUtf8('Adding files/directories to the Mercurial repository'), self)
525 res = dia.startProcess(args, repodir) 554 res = dia.startProcess(args, repodir)
526 if res: 555 if res:
527 dia.exec_() 556 dia.exec_()
528 557
529 def vcsAddBinary(self, name, isDir=False): 558 def vcsAddBinary(self, name, isDir=False):
576 repodir = os.path.dirname(repodir) 605 repodir = os.path.dirname(repodir)
577 if repodir == os.sep: 606 if repodir == os.sep:
578 return False 607 return False
579 608
580 if noDialog: 609 if noDialog:
581 res = self.startSynchronizedProcess(QProcess(), "hg", args, repodir) 610 if self.__client is None:
611 res = self.startSynchronizedProcess(QProcess(), 'hg', args, repodir)
612 else:
613 out, err = self.__client.runcommand(args)
614 res = err == ""
582 else: 615 else:
583 dia = HgDialog( 616 dia = HgDialog(
584 self.trUtf8('Removing files/directories from the Mercurial repository')) 617 self.trUtf8('Removing files/directories from the Mercurial repository'),
618 self)
585 res = dia.startProcess(args, repodir) 619 res = dia.startProcess(args, repodir)
586 if res: 620 if res:
587 dia.exec_() 621 dia.exec_()
588 res = dia.normalExitWithoutErrors() 622 res = dia.normalExitWithoutErrors()
589 623
635 if repodir == os.sep: 669 if repodir == os.sep:
636 return False 670 return False
637 671
638 if noDialog: 672 if noDialog:
639 res = self.startSynchronizedProcess(QProcess(), "hg", args, repodir) 673 res = self.startSynchronizedProcess(QProcess(), "hg", args, repodir)
674 if self.__client is None:
675 res = self.startSynchronizedProcess(QProcess(), 'hg', args, repodir)
676 else:
677 out, err = self.__client.runcommand(args)
678 res = err == ""
640 else: 679 else:
641 dia = HgDialog(self.trUtf8('Renaming {0}').format(name)) 680 dia = HgDialog(self.trUtf8('Renaming {0}').format(name), self)
642 res = dia.startProcess(args, repodir) 681 res = dia.startProcess(args, repodir)
643 if res: 682 if res:
644 dia.exec_() 683 dia.exec_()
645 res = dia.normalExit() 684 res = dia.normalExit()
646 if res: 685 if res:
741 args.append("Created tag <{0}>.".format(tag)) 780 args.append("Created tag <{0}>.".format(tag))
742 else: 781 else:
743 args.append("Removed tag <{0}>.".format(tag)) 782 args.append("Removed tag <{0}>.".format(tag))
744 args.append(tag) 783 args.append(tag)
745 784
746 dia = HgDialog(self.trUtf8('Taging in the Mercurial repository')) 785 dia = HgDialog(self.trUtf8('Taging in the Mercurial repository'), self)
747 res = dia.startProcess(args, repodir) 786 res = dia.startProcess(args, repodir)
748 if res: 787 if res:
749 dia.exec_() 788 dia.exec_()
750 789
751 def vcsRevert(self, name): 790 def vcsRevert(self, name):
771 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 810 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
772 repodir = os.path.dirname(repodir) 811 repodir = os.path.dirname(repodir)
773 if repodir == os.sep: 812 if repodir == os.sep:
774 return 813 return
775 814
776 dia = HgDialog(self.trUtf8('Reverting changes')) 815 dia = HgDialog(self.trUtf8('Reverting changes'), self)
777 res = dia.startProcess(args, repodir) 816 res = dia.startProcess(args, repodir)
778 if res: 817 if res:
779 dia.exec_() 818 dia.exec_()
780 self.checkVCSStatus() 819 self.checkVCSStatus()
781 820
819 args.append("--force") 858 args.append("--force")
820 if rev: 859 if rev:
821 args.append("--rev") 860 args.append("--rev")
822 args.append(rev) 861 args.append(rev)
823 862
824 dia = HgDialog(self.trUtf8('Merging').format(name)) 863 dia = HgDialog(self.trUtf8('Merging').format(name), self)
825 res = dia.startProcess(args, repodir) 864 res = dia.startProcess(args, repodir)
826 if res: 865 if res:
827 dia.exec_() 866 dia.exec_()
828 self.checkVCSStatus() 867 self.checkVCSStatus()
829 868
881 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 920 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
882 repodir = os.path.dirname(repodir) 921 repodir = os.path.dirname(repodir)
883 if repodir == os.sep: 922 if repodir == os.sep:
884 return 0 923 return 0
885 924
886 ioEncoding = Preferences.getSystem("IOEncoding")
887 process = QProcess()
888 args = [] 925 args = []
889 args.append('status') 926 args.append('status')
890 args.append('--all') 927 args.append('--all')
891 args.append('--noninteractive') 928 args.append('--noninteractive')
892 process.setWorkingDirectory(repodir) 929
893 process.start('hg', args) 930 output = ""
894 procStarted = process.waitForStarted() 931 if self.__client is None:
895 if procStarted: 932 process = QProcess()
896 finished = process.waitForFinished(30000) 933 process.setWorkingDirectory(repodir)
897 if finished and process.exitCode() == 0: 934 process.start('hg', args)
898 output = \ 935 procStarted = process.waitForStarted()
899 str(process.readAllStandardOutput(), ioEncoding, 'replace') 936 if procStarted:
900 for line in output.splitlines(): 937 finished = process.waitForFinished(30000)
901 flag, path = line.split(" ", 1) 938 if finished and process.exitCode() == 0:
902 absname = os.path.join(repodir, os.path.normcase(path)) 939 output = \
903 if flag not in "?I": 940 str(process.readAllStandardOutput(),
904 if fname == '.': 941 Preferences.getSystem("IOEncoding"),
905 if absname.startswith(dname + os.path.sep): 942 'replace')
906 return self.canBeCommitted 943 else:
907 if absname == dname: 944 output, error = self.__client.runcommand(args)
908 return self.canBeCommitted 945
909 else: 946 if output:
910 if absname == name: 947 for line in output.splitlines():
911 return self.canBeCommitted 948 flag, path = line.split(" ", 1)
949 absname = os.path.join(repodir, os.path.normcase(path))
950 if flag not in "?I":
951 if fname == '.':
952 if absname.startswith(dname + os.path.sep):
953 return self.canBeCommitted
954 if absname == dname:
955 return self.canBeCommitted
956 else:
957 if absname == name:
958 return self.canBeCommitted
912 959
913 return self.canBeAdded 960 return self.canBeAdded
914 961
915 def vcsAllRegisteredStates(self, names, dname, shortcut=True): 962 def vcsAllRegisteredStates(self, names, dname, shortcut=True):
916 """ 963 """
942 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 989 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
943 repodir = os.path.dirname(repodir) 990 repodir = os.path.dirname(repodir)
944 if repodir == os.sep: 991 if repodir == os.sep:
945 return names 992 return names
946 993
947 ioEncoding = Preferences.getSystem("IOEncoding")
948 process = QProcess()
949 args = [] 994 args = []
950 args.append('status') 995 args.append('status')
951 args.append('--all') 996 args.append('--all')
952 args.append('--noninteractive') 997 args.append('--noninteractive')
953 process.setWorkingDirectory(dname) 998
954 process.start('hg', args) 999 output = ""
955 procStarted = process.waitForStarted() 1000 if self.__client is None:
956 if procStarted: 1001 process = QProcess()
957 finished = process.waitForFinished(30000) 1002 process.setWorkingDirectory(dname)
958 if finished and process.exitCode() == 0: 1003 process.start('hg', args)
959 dirs = [x for x in names.keys() if os.path.isdir(x)] 1004 procStarted = process.waitForStarted()
960 output = \ 1005 if procStarted:
961 str(process.readAllStandardOutput(), ioEncoding, 'replace') 1006 finished = process.waitForFinished(30000)
962 for line in output.splitlines(): 1007 if finished and process.exitCode() == 0:
963 flag, path = line.split(" ", 1) 1008 output = \
964 name = os.path.normcase(os.path.join(repodir, path)) 1009 str(process.readAllStandardOutput(),
965 dirName = os.path.dirname(name) 1010 Preferences.getSystem("IOEncoding"),
966 if name.startswith(dname): 1011 'replace')
967 if flag not in "?I": 1012 else:
968 if name in names: 1013 output, error = self.__client.runcommand(args)
969 names[name] = self.canBeCommitted 1014
970 if dirName in names: 1015 if output:
971 names[dirName] = self.canBeCommitted 1016 dirs = [x for x in names.keys() if os.path.isdir(x)]
972 if dirs: 1017 for line in output.splitlines():
973 for d in dirs: 1018 flag, path = line.split(" ", 1)
974 if name.startswith(d): 1019 name = os.path.normcase(os.path.join(repodir, path))
975 names[d] = self.canBeCommitted 1020 dirName = os.path.dirname(name)
976 dirs.remove(d) 1021 if name.startswith(dname):
977 break
978 if flag not in "?I": 1022 if flag not in "?I":
979 self.statusCache[name] = self.canBeCommitted 1023 if name in names:
980 self.statusCache[dirName] = self.canBeCommitted 1024 names[name] = self.canBeCommitted
981 else: 1025 if dirName in names:
982 self.statusCache[name] = self.canBeAdded 1026 names[dirName] = self.canBeCommitted
983 if dirName not in self.statusCache: 1027 if dirs:
984 self.statusCache[dirName] = self.canBeAdded 1028 for d in dirs:
1029 if name.startswith(d):
1030 names[d] = self.canBeCommitted
1031 dirs.remove(d)
1032 break
1033 if flag not in "?I":
1034 self.statusCache[name] = self.canBeCommitted
1035 self.statusCache[dirName] = self.canBeCommitted
1036 else:
1037 self.statusCache[name] = self.canBeAdded
1038 if dirName not in self.statusCache:
1039 self.statusCache[dirName] = self.canBeAdded
985 1040
986 return names 1041 return names
987 1042
988 def clearStatusCache(self): 1043 def clearStatusCache(self):
989 """ 1044 """
1042 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1097 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1043 repodir = os.path.dirname(repodir) 1098 repodir = os.path.dirname(repodir)
1044 if repodir == os.sep: 1099 if repodir == os.sep:
1045 return 1100 return
1046 1101
1047 dia = HgDialog(self.trUtf8('Mercurial command')) 1102 dia = HgDialog(self.trUtf8('Mercurial command'), self)
1048 res = dia.startProcess(args, repodir) 1103 res = dia.startProcess(args, repodir)
1049 if res: 1104 if res:
1050 dia.exec_() 1105 dia.exec_()
1051 1106
1052 def vcsOptionsDialog(self, project, archive, editable=False, parent=None): 1107 def vcsOptionsDialog(self, project, archive, editable=False, parent=None):
1075 @param ppath local path to get the repository infos (string) 1130 @param ppath local path to get the repository infos (string)
1076 @return string with ready formated info for display (string) 1131 @return string with ready formated info for display (string)
1077 """ 1132 """
1078 info = [] 1133 info = []
1079 1134
1080 process = QProcess()
1081 args = [] 1135 args = []
1082 args.append('parents') 1136 args.append('parents')
1083 args.append('--template') 1137 args.append('--template')
1084 args.append('{rev}:{node|short}@@@{tags}@@@{author|xmlescape}@@@' 1138 args.append('{rev}:{node|short}@@@{tags}@@@{author|xmlescape}@@@'
1085 '{date|isodate}@@@{branches}@@@{bookmarks}\n') 1139 '{date|isodate}@@@{branches}@@@{bookmarks}\n')
1086 process.setWorkingDirectory(ppath) 1140
1087 process.start('hg', args) 1141 output = ""
1088 procStarted = process.waitForStarted() 1142 if self.__client is None:
1089 if procStarted: 1143 process = QProcess()
1090 finished = process.waitForFinished(30000) 1144 process.setWorkingDirectory(ppath)
1091 if finished and process.exitCode() == 0: 1145 process.start('hg', args)
1092 output = str(process.readAllStandardOutput(), 1146 procStarted = process.waitForStarted()
1093 Preferences.getSystem("IOEncoding"), 'replace') 1147 if procStarted:
1094 index = 0 1148 finished = process.waitForFinished(30000)
1095 for line in output.splitlines(): 1149 if finished and process.exitCode() == 0:
1096 index += 1 1150 output = str(process.readAllStandardOutput(),
1097 changeset, tags, author, date, branches, bookmarks = line.split("@@@") 1151 Preferences.getSystem("IOEncoding"), 'replace')
1098 cdate, ctime = date.split()[:2] 1152 else:
1099 info.append("""<p><table>""") 1153 output, error = self.__client.runcommand(args)
1154
1155 if output:
1156 index = 0
1157 for line in output.splitlines():
1158 index += 1
1159 changeset, tags, author, date, branches, bookmarks = line.split("@@@")
1160 cdate, ctime = date.split()[:2]
1161 info.append("""<p><table>""")
1162 info.append(QApplication.translate("mercurial",
1163 """<tr><td><b>Parent #{0}</b></td><td></td></tr>\n"""
1164 """<tr><td><b>Changeset</b></td><td>{1}</td></tr>""")\
1165 .format(index, changeset))
1166 if tags:
1100 info.append(QApplication.translate("mercurial", 1167 info.append(QApplication.translate("mercurial",
1101 """<tr><td><b>Parent #{0}</b></td><td></td></tr>\n""" 1168 """<tr><td><b>Tags</b></td><td>{0}</td></tr>""")\
1102 """<tr><td><b>Changeset</b></td><td>{1}</td></tr>""")\ 1169 .format('<br/>'.join(tags.split())))
1103 .format(index, changeset)) 1170 if bookmarks:
1104 if tags:
1105 info.append(QApplication.translate("mercurial",
1106 """<tr><td><b>Tags</b></td><td>{0}</td></tr>""")\
1107 .format('<br/>'.join(tags.split())))
1108 if bookmarks:
1109 info.append(QApplication.translate("mercurial",
1110 """<tr><td><b>Bookmarks</b></td><td>{0}</td></tr>""")\
1111 .format('<br/>'.join(bookmarks.split())))
1112 if branches:
1113 info.append(QApplication.translate("mercurial",
1114 """<tr><td><b>Branches</b></td><td>{0}</td></tr>""")\
1115 .format('<br/>'.join(branches.split())))
1116 info.append(QApplication.translate("mercurial", 1171 info.append(QApplication.translate("mercurial",
1117 """<tr><td><b>Last author</b></td><td>{0}</td></tr>\n""" 1172 """<tr><td><b>Bookmarks</b></td><td>{0}</td></tr>""")\
1118 """<tr><td><b>Committed date</b></td><td>{1}</td></tr>\n""" 1173 .format('<br/>'.join(bookmarks.split())))
1119 """<tr><td><b>Committed time</b></td><td>{2}</td></tr>""")\ 1174 if branches:
1120 .format(author, cdate, ctime)) 1175 info.append(QApplication.translate("mercurial",
1121 info.append("""</table></p>""") 1176 """<tr><td><b>Branches</b></td><td>{0}</td></tr>""")\
1177 .format('<br/>'.join(branches.split())))
1178 info.append(QApplication.translate("mercurial",
1179 """<tr><td><b>Last author</b></td><td>{0}</td></tr>\n"""
1180 """<tr><td><b>Committed date</b></td><td>{1}</td></tr>\n"""
1181 """<tr><td><b>Committed time</b></td><td>{2}</td></tr>""")\
1182 .format(author, cdate, ctime))
1183 info.append("""</table></p>""")
1122 1184
1123 url = "" 1185 url = ""
1124 args = [] 1186 args = []
1125 args.append('showconfig') 1187 args.append('showconfig')
1126 args.append('paths.default') 1188 args.append('paths.default')
1127 process.setWorkingDirectory(ppath) 1189
1128 process.start('hg', args) 1190 output = ""
1129 procStarted = process.waitForStarted() 1191 if self.__client is None:
1130 if procStarted: 1192 process.setWorkingDirectory(ppath)
1131 finished = process.waitForFinished(30000) 1193 process.start('hg', args)
1132 if finished and process.exitCode() == 0: 1194 procStarted = process.waitForStarted()
1133 output = str(process.readAllStandardOutput(), 1195 if procStarted:
1134 Preferences.getSystem("IOEncoding"), 'replace') 1196 finished = process.waitForFinished(30000)
1135 if output: 1197 if finished and process.exitCode() == 0:
1136 url = output.splitlines()[0].strip() 1198 output = str(process.readAllStandardOutput(),
1137 else: 1199 Preferences.getSystem("IOEncoding"), 'replace')
1138 url = "" 1200 else:
1201 output, error = self.__client.runcommand(args)
1202
1203 if output:
1204 url = output.splitlines()[0].strip()
1205 else:
1206 url = ""
1139 1207
1140 return QApplication.translate('mercurial', 1208 return QApplication.translate('mercurial',
1141 """<h3>Repository information</h3>\n""" 1209 """<h3>Repository information</h3>\n"""
1142 """<p><table>\n""" 1210 """<p><table>\n"""
1143 """<tr><td><b>Mercurial V.</b></td><td>{0}</td></tr>\n""" 1211 """<tr><td><b>Mercurial V.</b></td><td>{0}</td></tr>\n"""
1220 repodir = os.path.dirname(repodir) 1288 repodir = os.path.dirname(repodir)
1221 if repodir == os.sep: 1289 if repodir == os.sep:
1222 return False 1290 return False
1223 1291
1224 dia = HgDialog(self.trUtf8('Copying {0}') 1292 dia = HgDialog(self.trUtf8('Copying {0}')
1225 .format(name)) 1293 .format(name), self)
1226 res = dia.startProcess(args, repodir) 1294 res = dia.startProcess(args, repodir)
1227 if res: 1295 if res:
1228 dia.exec_() 1296 dia.exec_()
1229 res = dia.normalExit() 1297 res = dia.normalExit()
1230 if res and \ 1298 if res and \
1240 Public method to get the list of tags. 1308 Public method to get the list of tags.
1241 1309
1242 @param repodir directory name of the repository (string) 1310 @param repodir directory name of the repository (string)
1243 @return list of tags (list of string) 1311 @return list of tags (list of string)
1244 """ 1312 """
1245 ioEncoding = Preferences.getSystem("IOEncoding")
1246 process = QProcess()
1247 args = [] 1313 args = []
1248 args.append('tags') 1314 args.append('tags')
1249 args.append('--verbose') 1315 args.append('--verbose')
1250 process.setWorkingDirectory(repodir) 1316
1251 process.start('hg', args) 1317 output = ""
1252 procStarted = process.waitForStarted() 1318 if self.__client is None:
1253 if procStarted: 1319 process = QProcess()
1254 finished = process.waitForFinished(30000) 1320 process.setWorkingDirectory(repodir)
1255 if finished and process.exitCode() == 0: 1321 process.start('hg', args)
1256 self.tagsList = [] 1322 procStarted = process.waitForStarted()
1257 output = \ 1323 if procStarted:
1258 str(process.readAllStandardOutput(), ioEncoding, 'replace') 1324 finished = process.waitForFinished(30000)
1259 for line in output.splitlines(): 1325 if finished and process.exitCode() == 0:
1260 l = line.strip().split() 1326 output = \
1261 if l[-1][0] in "1234567890": 1327 str(process.readAllStandardOutput(),
1262 # last element is a rev:changeset 1328 Preferences.getSystem("IOEncoding"),
1263 del l[-1] 1329 'replace')
1264 else: 1330 else:
1265 del l[-2:] 1331 output, error = self.__client.runcommand(args)
1266 name = " ".join(l) 1332
1267 if name not in ["tip", "default"]: 1333 if output:
1268 self.tagsList.append(name) 1334 self.tagsList = []
1335 for line in output.splitlines():
1336 l = line.strip().split()
1337 if l[-1][0] in "1234567890":
1338 # last element is a rev:changeset
1339 del l[-1]
1340 else:
1341 del l[-2:]
1342 name = " ".join(l)
1343 if name not in ["tip", "default"]:
1344 self.tagsList.append(name)
1269 1345
1270 return self.tagsList[:] 1346 return self.tagsList[:]
1271 1347
1272 def hgGetBranchesList(self, repodir): 1348 def hgGetBranchesList(self, repodir):
1273 """ 1349 """
1274 Public method to get the list of branches. 1350 Public method to get the list of branches.
1275 1351
1276 @param repodir directory name of the repository (string) 1352 @param repodir directory name of the repository (string)
1277 @return list of branches (list of string) 1353 @return list of branches (list of string)
1278 """ 1354 """
1279 ioEncoding = Preferences.getSystem("IOEncoding")
1280 process = QProcess()
1281 args = [] 1355 args = []
1282 args.append('branches') 1356 args.append('branches')
1283 args.append('--closed') 1357 args.append('--closed')
1284 process.setWorkingDirectory(repodir) 1358
1285 process.start('hg', args) 1359 output = ""
1286 procStarted = process.waitForStarted() 1360 if self.__client is None:
1287 if procStarted: 1361 process = QProcess()
1288 finished = process.waitForFinished(30000) 1362 process.setWorkingDirectory(repodir)
1289 if finished and process.exitCode() == 0: 1363 process.start('hg', args)
1290 self.branchesList = [] 1364 procStarted = process.waitForStarted()
1291 output = \ 1365 if procStarted:
1292 str(process.readAllStandardOutput(), ioEncoding, 'replace') 1366 finished = process.waitForFinished(30000)
1293 for line in output.splitlines(): 1367 if finished and process.exitCode() == 0:
1294 l = line.strip().split() 1368 output = \
1295 if l[-1][0] in "1234567890": 1369 str(process.readAllStandardOutput(),
1296 # last element is a rev:changeset 1370 Preferences.getSystem("IOEncoding"),
1297 del l[-1] 1371 'replace')
1298 else: 1372 else:
1299 del l[-2:] 1373 output, error = self.__client.runcommand(args)
1300 name = " ".join(l) 1374
1301 if name not in ["tip", "default"]: 1375 if output:
1302 self.branchesList.append(name) 1376 self.branchesList = []
1377 for line in output.splitlines():
1378 l = line.strip().split()
1379 if l[-1][0] in "1234567890":
1380 # last element is a rev:changeset
1381 del l[-1]
1382 else:
1383 del l[-2:]
1384 name = " ".join(l)
1385 if name not in ["tip", "default"]:
1386 self.branchesList.append(name)
1303 1387
1304 return self.branchesList[:] 1388 return self.branchesList[:]
1305 1389
1306 def hgListTagBranch(self, path, tags=True): 1390 def hgListTagBranch(self, path, tags=True):
1307 """ 1391 """
1472 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1556 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1473 repodir = os.path.dirname(repodir) 1557 repodir = os.path.dirname(repodir)
1474 if repodir == os.sep: 1558 if repodir == os.sep:
1475 return 1559 return
1476 1560
1477 dia = HgDialog(self.trUtf8('Pulling from a remote Mercurial repository')) 1561 dia = HgDialog(self.trUtf8('Pulling from a remote Mercurial repository'), self)
1478 res = dia.startProcess(args, repodir) 1562 res = dia.startProcess(args, repodir)
1479 if res: 1563 if res:
1480 dia.exec_() 1564 dia.exec_()
1481 res = dia.hasAddOrDelete() 1565 res = dia.hasAddOrDelete()
1482 self.checkVCSStatus() 1566 self.checkVCSStatus()
1504 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1588 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1505 repodir = os.path.dirname(repodir) 1589 repodir = os.path.dirname(repodir)
1506 if repodir == os.sep: 1590 if repodir == os.sep:
1507 return 1591 return
1508 1592
1509 dia = HgDialog(self.trUtf8('Pushing to a remote Mercurial repository')) 1593 dia = HgDialog(self.trUtf8('Pushing to a remote Mercurial repository'), self)
1510 res = dia.startProcess(args, repodir) 1594 res = dia.startProcess(args, repodir)
1511 if res: 1595 if res:
1512 dia.exec_() 1596 dia.exec_()
1513 res = dia.hasAddOrDelete() 1597 res = dia.hasAddOrDelete()
1514 self.checkVCSStatus() 1598 self.checkVCSStatus()
1523 if mode not in ("heads", "parents", "tip"): 1607 if mode not in ("heads", "parents", "tip"):
1524 mode = "heads" 1608 mode = "heads"
1525 1609
1526 info = [] 1610 info = []
1527 1611
1528 # find the root of the repo
1529 repodir = self.splitPath(ppath)[0]
1530 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1531 repodir = os.path.dirname(repodir)
1532 if repodir == os.sep:
1533 return
1534
1535 process = QProcess()
1536 args = [] 1612 args = []
1537 args.append(mode) 1613 args.append(mode)
1538 args.append('--template') 1614 args.append('--template')
1539 args.append('{rev}:{node|short}@@@{tags}@@@{author|xmlescape}@@@' 1615 args.append('{rev}:{node|short}@@@{tags}@@@{author|xmlescape}@@@'
1540 '{date|isodate}@@@{branches}@@@{parents}@@@{bookmarks}\n') 1616 '{date|isodate}@@@{branches}@@@{parents}@@@{bookmarks}\n')
1541 1617
1542 process.setWorkingDirectory(repodir) 1618 output = ""
1543 process.start('hg', args) 1619 if self.__client is None:
1544 procStarted = process.waitForStarted() 1620 # find the root of the repo
1545 if procStarted: 1621 repodir = self.splitPath(ppath)[0]
1546 finished = process.waitForFinished(30000) 1622 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1547 if finished and process.exitCode() == 0: 1623 repodir = os.path.dirname(repodir)
1548 output = str(process.readAllStandardOutput(), 1624 if repodir == os.sep:
1549 Preferences.getSystem("IOEncoding"), 'replace') 1625 return
1550 index = 0 1626
1551 for line in output.splitlines(): 1627 process = QProcess()
1552 index += 1 1628 process.setWorkingDirectory(repodir)
1553 changeset, tags, author, date, branches, parents, bookmarks = \ 1629 process.start('hg', args)
1554 line.split("@@@") 1630 procStarted = process.waitForStarted()
1555 cdate, ctime = date.split()[:2] 1631 if procStarted:
1556 info.append("""<p><table>""") 1632 finished = process.waitForFinished(30000)
1557 if mode == "heads": 1633 if finished and process.exitCode() == 0:
1558 info.append(QApplication.translate("mercurial", 1634 output = str(process.readAllStandardOutput(),
1559 """<tr><td><b>Head #{0}</b></td><td></td></tr>\n""" 1635 Preferences.getSystem("IOEncoding"), 'replace')
1560 .format(index, changeset))) 1636 else:
1561 elif mode == "parents": 1637 output, error = self.__client.runcommand(args)
1562 info.append(QApplication.translate("mercurial", 1638
1563 """<tr><td><b>Parent #{0}</b></td><td></td></tr>\n""" 1639 if output:
1564 .format(index, changeset))) 1640 index = 0
1565 elif mode == "tip": 1641 for line in output.splitlines():
1566 info.append(QApplication.translate("mercurial", 1642 index += 1
1567 """<tr><td><b>Tip</b></td><td></td></tr>\n""")) 1643 changeset, tags, author, date, branches, parents, bookmarks = \
1644 line.split("@@@")
1645 cdate, ctime = date.split()[:2]
1646 info.append("""<p><table>""")
1647 if mode == "heads":
1568 info.append(QApplication.translate("mercurial", 1648 info.append(QApplication.translate("mercurial",
1569 """<tr><td><b>Changeset</b></td><td>{0}</td></tr>""")\ 1649 """<tr><td><b>Head #{0}</b></td><td></td></tr>\n"""
1570 .format(changeset)) 1650 .format(index, changeset)))
1571 if tags: 1651 elif mode == "parents":
1572 info.append(QApplication.translate("mercurial",
1573 """<tr><td><b>Tags</b></td><td>{0}</td></tr>""")\
1574 .format('<br/>'.join(tags.split())))
1575 if bookmarks:
1576 info.append(QApplication.translate("mercurial",
1577 """<tr><td><b>Bookmarks</b></td><td>{0}</td></tr>""")\
1578 .format('<br/>'.join(bookmarks.split())))
1579 if branches:
1580 info.append(QApplication.translate("mercurial",
1581 """<tr><td><b>Branches</b></td><td>{0}</td></tr>""")\
1582 .format('<br/>'.join(branches.split())))
1583 if parents:
1584 info.append(QApplication.translate("mercurial",
1585 """<tr><td><b>Parents</b></td><td>{0}</td></tr>""")\
1586 .format('<br/>'.join(parents.split())))
1587 info.append(QApplication.translate("mercurial", 1652 info.append(QApplication.translate("mercurial",
1588 """<tr><td><b>Last author</b></td><td>{0}</td></tr>\n""" 1653 """<tr><td><b>Parent #{0}</b></td><td></td></tr>\n"""
1589 """<tr><td><b>Committed date</b></td><td>{1}</td></tr>\n""" 1654 .format(index, changeset)))
1590 """<tr><td><b>Committed time</b></td><td>{2}</td></tr>\n""" 1655 elif mode == "tip":
1591 """</table></p>""")\ 1656 info.append(QApplication.translate("mercurial",
1592 .format(author, cdate, ctime)) 1657 """<tr><td><b>Tip</b></td><td></td></tr>\n"""))
1593 1658 info.append(QApplication.translate("mercurial",
1594 dlg = VcsRepositoryInfoDialog(None, "\n".join(info)) 1659 """<tr><td><b>Changeset</b></td><td>{0}</td></tr>""")\
1595 dlg.exec_() 1660 .format(changeset))
1596 1661 if tags:
1662 info.append(QApplication.translate("mercurial",
1663 """<tr><td><b>Tags</b></td><td>{0}</td></tr>""")\
1664 .format('<br/>'.join(tags.split())))
1665 if bookmarks:
1666 info.append(QApplication.translate("mercurial",
1667 """<tr><td><b>Bookmarks</b></td><td>{0}</td></tr>""")\
1668 .format('<br/>'.join(bookmarks.split())))
1669 if branches:
1670 info.append(QApplication.translate("mercurial",
1671 """<tr><td><b>Branches</b></td><td>{0}</td></tr>""")\
1672 .format('<br/>'.join(branches.split())))
1673 if parents:
1674 info.append(QApplication.translate("mercurial",
1675 """<tr><td><b>Parents</b></td><td>{0}</td></tr>""")\
1676 .format('<br/>'.join(parents.split())))
1677 info.append(QApplication.translate("mercurial",
1678 """<tr><td><b>Last author</b></td><td>{0}</td></tr>\n"""
1679 """<tr><td><b>Committed date</b></td><td>{1}</td></tr>\n"""
1680 """<tr><td><b>Committed time</b></td><td>{2}</td></tr>\n"""
1681 """</table></p>""")\
1682 .format(author, cdate, ctime))
1683
1684 dlg = VcsRepositoryInfoDialog(None, "\n".join(info))
1685 dlg.exec_()
1597 1686
1598 def hgResolve(self, name): 1687 def hgResolve(self, name):
1599 """ 1688 """
1600 Public method used to resolve conflicts of a file/directory. 1689 Public method used to resolve conflicts of a file/directory.
1601 1690
1618 while not os.path.isdir(os.path.join(repodir, self.adminDir)): 1707 while not os.path.isdir(os.path.join(repodir, self.adminDir)):
1619 repodir = os.path.dirname(repodir) 1708 repodir = os.path.dirname(repodir)
1620 if repodir == os.sep: 1709 if repodir == os.sep:
1621 return False 1710 return False
1622 1711
1623 dia = HgDialog( 1712 dia = HgDialog(self.trUtf8('Resolving files/directories'), self)
1624 self.trUtf8('Resolving files/directories'))
1625 res = dia.startProcess(args, repodir) 1713 res = dia.startProcess(args, repodir)
1626 if res: 1714 if res:
1627 dia.exec_() 1715 dia.exec_()
1628 self.checkVCSStatus() 1716 self.checkVCSStatus()
1629 1717
1651 if ok and name: 1739 if ok and name:
1652 args = [] 1740 args = []
1653 args.append('branch') 1741 args.append('branch')
1654 args.append(name.strip().replace(" ", "_")) 1742 args.append(name.strip().replace(" ", "_"))
1655 1743
1656 dia = HgDialog(self.trUtf8('Creating branch in the Mercurial repository')) 1744 dia = HgDialog(self.trUtf8('Creating branch in the Mercurial repository'),
1745 self)
1657 res = dia.startProcess(args, repodir) 1746 res = dia.startProcess(args, repodir)
1658 if res: 1747 if res:
1659 dia.exec_() 1748 dia.exec_()
1660 1749
1661 def hgShowBranch(self, name): 1750 def hgShowBranch(self, name):
1674 return 1763 return
1675 1764
1676 args = [] 1765 args = []
1677 args.append("branch") 1766 args.append("branch")
1678 1767
1679 dia = HgDialog(self.trUtf8('Showing current branch')) 1768 dia = HgDialog(self.trUtf8('Showing current branch'), self)
1680 res = dia.startProcess(args, repodir, False) 1769 res = dia.startProcess(args, repodir, False)
1681 if res: 1770 if res:
1682 dia.exec_() 1771 dia.exec_()
1683 1772
1684 def hgEditUserConfig(self): 1773 def hgEditUserConfig(self):
1731 return 1820 return
1732 1821
1733 args = [] 1822 args = []
1734 args.append('verify') 1823 args.append('verify')
1735 1824
1736 dia = HgDialog(self.trUtf8('Verifying the integrity of the Mercurial repository')) 1825 dia = HgDialog(self.trUtf8('Verifying the integrity of the Mercurial repository'),
1826 self)
1737 res = dia.startProcess(args, repodir) 1827 res = dia.startProcess(args, repodir)
1738 if res: 1828 if res:
1739 dia.exec_() 1829 dia.exec_()
1740 1830
1741 def hgShowConfig(self, name): 1831 def hgShowConfig(self, name):
1755 1845
1756 args = [] 1846 args = []
1757 args.append('showconfig') 1847 args.append('showconfig')
1758 args.append("--untrusted") 1848 args.append("--untrusted")
1759 1849
1760 dia = HgDialog(self.trUtf8('Showing the combined configuration settings')) 1850 dia = HgDialog(self.trUtf8('Showing the combined configuration settings'), self)
1761 res = dia.startProcess(args, repodir, False) 1851 res = dia.startProcess(args, repodir, False)
1762 if res: 1852 if res:
1763 dia.exec_() 1853 dia.exec_()
1764 1854
1765 def hgShowPaths(self, name): 1855 def hgShowPaths(self, name):
1778 return 1868 return
1779 1869
1780 args = [] 1870 args = []
1781 args.append('paths') 1871 args.append('paths')
1782 1872
1783 dia = HgDialog(self.trUtf8('Showing aliases for remote repositories')) 1873 dia = HgDialog(self.trUtf8('Showing aliases for remote repositories'), self)
1784 res = dia.startProcess(args, repodir, False) 1874 res = dia.startProcess(args, repodir, False)
1785 if res: 1875 if res:
1786 dia.exec_() 1876 dia.exec_()
1787 1877
1788 def hgRecover(self, name): 1878 def hgRecover(self, name):
1801 return 1891 return
1802 1892
1803 args = [] 1893 args = []
1804 args.append('recover') 1894 args.append('recover')
1805 1895
1806 dia = HgDialog(self.trUtf8('Recovering from interrupted transaction')) 1896 dia = HgDialog(self.trUtf8('Recovering from interrupted transaction'), self)
1807 res = dia.startProcess(args, repodir, False) 1897 res = dia.startProcess(args, repodir, False)
1808 if res: 1898 if res:
1809 dia.exec_() 1899 dia.exec_()
1810 1900
1811 def hgIdentify(self, name): 1901 def hgIdentify(self, name):
1824 return 1914 return
1825 1915
1826 args = [] 1916 args = []
1827 args.append('identify') 1917 args.append('identify')
1828 1918
1829 dia = HgDialog(self.trUtf8('Identifying project directory')) 1919 dia = HgDialog(self.trUtf8('Identifying project directory'), self)
1830 res = dia.startProcess(args, repodir, False) 1920 res = dia.startProcess(args, repodir, False)
1831 if res: 1921 if res:
1832 dia.exec_() 1922 dia.exec_()
1833 1923
1834 def hgCreateIgnoreFile(self, name, autoAdd=False): 1924 def hgCreateIgnoreFile(self, name, autoAdd=False):
1945 if compression: 2035 if compression:
1946 args.append("--type") 2036 args.append("--type")
1947 args.append(compression) 2037 args.append(compression)
1948 args.append(fname) 2038 args.append(fname)
1949 2039
1950 dia = HgDialog(self.trUtf8('Create changegroup')) 2040 dia = HgDialog(self.trUtf8('Create changegroup'), self)
1951 res = dia.startProcess(args, repodir) 2041 res = dia.startProcess(args, repodir)
1952 if res: 2042 if res:
1953 dia.exec_() 2043 dia.exec_()
1954 2044
1955 def hgPreviewBundle(self, name): 2045 def hgPreviewBundle(self, name):
2007 if file: 2097 if file:
2008 args = [] 2098 args = []
2009 args.append('identify') 2099 args.append('identify')
2010 args.append(file) 2100 args.append(file)
2011 2101
2012 dia = HgDialog(self.trUtf8('Identifying changegroup file')) 2102 dia = HgDialog(self.trUtf8('Identifying changegroup file'), self)
2013 res = dia.startProcess(args, repodir, False) 2103 res = dia.startProcess(args, repodir, False)
2014 if res: 2104 if res:
2015 dia.exec_() 2105 dia.exec_()
2016 2106
2017 def hgUnbundle(self, name): 2107 def hgUnbundle(self, name):
2044 args.append('unbundle') 2134 args.append('unbundle')
2045 if update: 2135 if update:
2046 args.append("--update") 2136 args.append("--update")
2047 args.extend(files) 2137 args.extend(files)
2048 2138
2049 dia = HgDialog(self.trUtf8('Apply changegroups')) 2139 dia = HgDialog(self.trUtf8('Apply changegroups'), self)
2050 res = dia.startProcess(args, repodir) 2140 res = dia.startProcess(args, repodir)
2051 if res: 2141 if res:
2052 dia.exec_() 2142 dia.exec_()
2053 2143
2054 def hgBisect(self, name, subcommand): 2144 def hgBisect(self, name, subcommand):
2092 args.append("bisect") 2182 args.append("bisect")
2093 args.append("--{0}".format(subcommand)) 2183 args.append("--{0}".format(subcommand))
2094 if rev: 2184 if rev:
2095 args.append(rev) 2185 args.append(rev)
2096 2186
2097 dia = HgDialog(self.trUtf8('Mercurial Bisect ({0})').format(subcommand)) 2187 dia = HgDialog(self.trUtf8('Mercurial Bisect ({0})').format(subcommand), self)
2098 res = dia.startProcess(args, repodir) 2188 res = dia.startProcess(args, repodir)
2099 if res: 2189 if res:
2100 dia.exec_() 2190 dia.exec_()
2101 2191
2102 def hgForget(self, name): 2192 def hgForget(self, name):
2125 repodir = os.path.dirname(repodir) 2215 repodir = os.path.dirname(repodir)
2126 if repodir == os.sep: 2216 if repodir == os.sep:
2127 return 2217 return
2128 2218
2129 dia = HgDialog( 2219 dia = HgDialog(
2130 self.trUtf8('Removing files from the Mercurial repository only')) 2220 self.trUtf8('Removing files from the Mercurial repository only'), self)
2131 res = dia.startProcess(args, repodir) 2221 res = dia.startProcess(args, repodir)
2132 if res: 2222 if res:
2133 dia.exec_() 2223 dia.exec_()
2134 if isinstance(name, list): 2224 if isinstance(name, list):
2135 self.__forgotNames.extend(name) 2225 self.__forgotNames.extend(name)
2180 args.append(user) 2270 args.append(user)
2181 args.append('--message') 2271 args.append('--message')
2182 args.append(message) 2272 args.append(message)
2183 args.append(rev) 2273 args.append(rev)
2184 2274
2185 dia = HgDialog(self.trUtf8('Backing out changeset')) 2275 dia = HgDialog(self.trUtf8('Backing out changeset'), self)
2186 res = dia.startProcess(args, repodir) 2276 res = dia.startProcess(args, repodir)
2187 if res: 2277 if res:
2188 dia.exec_() 2278 dia.exec_()
2189 2279
2190 def hgRollback(self, name): 2280 def hgRollback(self, name):
2205 res = E5MessageBox.yesNo(None, 2295 res = E5MessageBox.yesNo(None,
2206 self.trUtf8("Rollback last transaction"), 2296 self.trUtf8("Rollback last transaction"),
2207 self.trUtf8("""Are you sure you want to rollback the last transaction?"""), 2297 self.trUtf8("""Are you sure you want to rollback the last transaction?"""),
2208 icon=E5MessageBox.Warning) 2298 icon=E5MessageBox.Warning)
2209 if res: 2299 if res:
2210 dia = HgDialog(self.trUtf8('Rollback last transaction')) 2300 dia = HgDialog(self.trUtf8('Rollback last transaction'), self)
2211 res = dia.startProcess(["rollback"], repodir) 2301 res = dia.startProcess(["rollback"], repodir)
2212 if res: 2302 if res:
2213 dia.exec_() 2303 dia.exec_()
2214 2304
2215 def hgServe(self, name): 2305 def hgServe(self, name):
2239 Private slot to handle a change of the Mercurial configuration file. 2329 Private slot to handle a change of the Mercurial configuration file.
2240 2330
2241 @param path name of the changed file (string) 2331 @param path name of the changed file (string)
2242 """ 2332 """
2243 self.__getExtensionsInfo() 2333 self.__getExtensionsInfo()
2334
2335 if self.__client:
2336 ok, err = self.__client.restartServer()
2337 if not ok:
2338 E5MessageBox.warning(None,
2339 self.trUtf8("Mercurial Command Server"),
2340 self.trUtf8("""<p>The Mercurial Command Server could not be"""
2341 """ restarted.</p><p>Reason: {0}</p>""").format(err))
2342 self.__client = None
2244 2343
2245 def __monitorRepoIniFile(self, name): 2344 def __monitorRepoIniFile(self, name):
2246 """ 2345 """
2247 Private slot to add a repository configuration file to the list of monitored 2346 Private slot to add a repository configuration file to the list of monitored
2248 files. 2347 files.
2267 Private method to get the active extensions from Mercurial. 2366 Private method to get the active extensions from Mercurial.
2268 """ 2367 """
2269 activeExtensions = sorted(self.__activeExtensions) 2368 activeExtensions = sorted(self.__activeExtensions)
2270 self.__activeExtensions = [] 2369 self.__activeExtensions = []
2271 2370
2272 process = QProcess()
2273 args = [] 2371 args = []
2274 args.append('showconfig') 2372 args.append('showconfig')
2275 args.append('extensions') 2373 args.append('extensions')
2276 process.start('hg', args) 2374
2277 procStarted = process.waitForStarted() 2375 if self.__client is None:
2278 if procStarted: 2376 process = QProcess()
2279 finished = process.waitForFinished(30000) 2377 process.start('hg', args)
2280 if finished and process.exitCode() == 0: 2378 procStarted = process.waitForStarted()
2281 output = str(process.readAllStandardOutput(), 2379 if procStarted:
2282 Preferences.getSystem("IOEncoding"), 'replace') 2380 finished = process.waitForFinished(30000)
2283 for line in output.splitlines(): 2381 if finished and process.exitCode() == 0:
2284 extensionName = line.split("=", 1)[0].strip().split(".")[-1].strip() 2382 output = str(process.readAllStandardOutput(),
2285 self.__activeExtensions.append(extensionName) 2383 Preferences.getSystem("IOEncoding"), 'replace')
2384 else:
2385 output, error = self.__client.runcommand(args)
2386
2387 if output:
2388 for line in output.splitlines():
2389 extensionName = line.split("=", 1)[0].strip().split(".")[-1].strip()
2390 self.__activeExtensions.append(extensionName)
2286 2391
2287 if self.versionStr >= "1.8": 2392 if self.versionStr >= "1.8":
2288 if "bookmarks" not in self.__activeExtensions: 2393 if "bookmarks" not in self.__activeExtensions:
2289 self.__activeExtensions.append("bookmarks") 2394 self.__activeExtensions.append("bookmarks")
2290 2395
2332 @param project reference to the project object 2437 @param project reference to the project object
2333 @return the project helper object 2438 @return the project helper object
2334 """ 2439 """
2335 self.__projectHelper = self.__plugin.getProjectHelper() 2440 self.__projectHelper = self.__plugin.getProjectHelper()
2336 self.__projectHelper.setObjects(self, project) 2441 self.__projectHelper.setObjects(self, project)
2337 self.__monitorRepoIniFile(project.ppath) 2442 self.__monitorRepoIniFile(project.getProjectPath())
2443
2444 if self.versionStr >= "1.9":
2445 client = HgClient(project.getProjectPath(), "utf-8", self)
2446 ok, err = client.startServer()
2447 if ok:
2448 self.__client = client
2449 else:
2450 E5MessageBox.warning(None,
2451 self.trUtf8("Mercurial Command Server"),
2452 self.trUtf8("""<p>The Mercurial Command Server could not be"""
2453 """ started.</p><p>Reason: {0}</p>""").format(err))
2454
2338 return self.__projectHelper 2455 return self.__projectHelper
2339 2456
2340 ############################################################################ 2457 ############################################################################
2341 ## Status Monitor Thread methods 2458 ## Status Monitor Thread methods
2342 ############################################################################ 2459 ############################################################################

eric ide

mercurial