diff -r cfe71cde2eec -r ca02892fde13 eric6/Plugins/VcsPlugins/vcsMercurial/hg.py --- a/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py Thu Aug 22 15:47:14 2019 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsMercurial/hg.py Fri Aug 23 12:41:00 2019 +0200 @@ -394,7 +394,7 @@ return status def vcsCommit(self, name, message, noDialog=False, closeBranch=False, - mq=False): + mq=False, merge=False): """ Public method used to make the change of a file/directory permanent in the Mercurial repository. @@ -405,10 +405,11 @@ @param noDialog flag indicating quiet operations @keyparam closeBranch flag indicating a close branch commit (boolean) @keyparam mq flag indicating a queue commit (boolean) + @keyparam merge flag indicating a merge commit (boolean) """ msg = message - if mq: + if mq or merge: # ensure dialog is shown for a queue commit noDialog = False @@ -416,7 +417,8 @@ # call CommitDialog and get message from there if self.__commitDialog is None: from .HgCommitDialog import HgCommitDialog - self.__commitDialog = HgCommitDialog(self, msg, mq, self.__ui) + self.__commitDialog = HgCommitDialog(self, msg, mq, merge, + self.__ui) self.__commitDialog.accepted.connect(self.__vcsCommit_Step2) self.__commitDialog.show() self.__commitDialog.raise_() @@ -427,6 +429,7 @@ self.__commitData["noDialog"] = noDialog self.__commitData["closeBranch"] = closeBranch self.__commitData["mq"] = mq + self.__commitData["merge"] = merge if noDialog: self.__vcsCommit_Step2() @@ -440,6 +443,7 @@ noDialog = self.__commitData["noDialog"] closeBranch = self.__commitData["closeBranch"] mq = self.__commitData["mq"] + merge = self.__commitData["merge"] if not noDialog: # check, if there are unsaved changes, that should be committed @@ -509,6 +513,13 @@ args.append("-v") if mq: args.append("--mq") + elif merge: + if author: + args.append("--user") + args.append(author) + if dateTime: + args.append("--date") + args.append(dateTime) else: if closeBranch: args.append("--close-branch") @@ -2134,12 +2145,12 @@ dia.exec_() self.checkVCSStatus() - def hgCancelMerge(self, name): + def hgAbortMerge(self, name): """ - Public method to cancel an uncommitted merge. + Public method to abort an uncommitted merge. @param name file/directory name (string) - @return flag indicating, that the cancellation contained an add + @return flag indicating, that the abortion contained an add or delete (boolean) """ dname, fname = self.splitPath(name) @@ -2159,7 +2170,7 @@ args.append("--clean") dia = HgDialog( - self.tr('Canceling uncommitted merge'), + self.tr('Aborting uncommitted merge'), self) res = dia.startProcess(args, repodir, False) if res: @@ -3350,6 +3361,44 @@ not line.strip().endswith("="): self.__defaultPushConfigured = True + def canCommitMerge(self, name): + """ + Public method to check if the working directory is uncommitted merge. + + @param name file/directory name (string) + + @return flag indicating commit merge capability (boolean) + """ + dname, fname = self.splitPath(name) + + # find the root of the repo + repodir = dname + while not os.path.isdir(os.path.join(repodir, self.adminDir)): + repodir = os.path.dirname(repodir) + if os.path.splitdrive(repodir)[1] == os.sep: + return + + args = self.initCommand("identify") + + output = "" + if self.__client is None: + process = QProcess() + process.setWorkingDirectory(repodir) + process.start('hg', args) + procStarted = process.waitForStarted(5000) + if procStarted: + finished = process.waitForFinished(30000) + if finished and process.exitCode() == 0: + output = str(process.readAllStandardOutput(), + self.getEncoding(), 'replace') + else: + output, error = self.__client.runcommand(args) + + if output.count('+') == 2: + return True + else: + return False + def canPull(self): """ Public method to check, if pull is possible.