Sat, 10 Oct 2015 12:06:10 +0200
Fixed an issue with the Mercurial commit command when amending a commit but not given a commit message.
--- a/Documentation/Help/source.qhp Fri Oct 09 19:44:43 2015 +0200 +++ b/Documentation/Help/source.qhp Sat Oct 10 12:06:10 2015 +0200 @@ -5882,6 +5882,7 @@ <keyword name="Hg.__checkDefaults" id="Hg.__checkDefaults" ref="eric6.Plugins.VcsPlugins.vcsMercurial.hg.html#Hg.__checkDefaults" /> <keyword name="Hg.__getExtensionsInfo" id="Hg.__getExtensionsInfo" ref="eric6.Plugins.VcsPlugins.vcsMercurial.hg.html#Hg.__getExtensionsInfo" /> <keyword name="Hg.__getInOutBookmarks" id="Hg.__getInOutBookmarks" ref="eric6.Plugins.VcsPlugins.vcsMercurial.hg.html#Hg.__getInOutBookmarks" /> + <keyword name="Hg.__getMostRecentCommitMessage" id="Hg.__getMostRecentCommitMessage" ref="eric6.Plugins.VcsPlugins.vcsMercurial.hg.html#Hg.__getMostRecentCommitMessage" /> <keyword name="Hg.__hgGetFileForRevision" id="Hg.__hgGetFileForRevision" ref="eric6.Plugins.VcsPlugins.vcsMercurial.hg.html#Hg.__hgGetFileForRevision" /> <keyword name="Hg.__hgURL" id="Hg.__hgURL" ref="eric6.Plugins.VcsPlugins.vcsMercurial.hg.html#Hg.__hgURL" /> <keyword name="Hg.__iniFileChanged" id="Hg.__iniFileChanged" ref="eric6.Plugins.VcsPlugins.vcsMercurial.hg.html#Hg.__iniFileChanged" />
--- a/Documentation/Source/eric6.Plugins.VcsPlugins.vcsMercurial.hg.html Fri Oct 09 19:44:43 2015 +0200 +++ b/Documentation/Source/eric6.Plugins.VcsPlugins.vcsMercurial.hg.html Sat Oct 10 12:06:10 2015 +0200 @@ -83,6 +83,9 @@ <td><a href="#Hg.__getInOutBookmarks">__getInOutBookmarks</a></td> <td>Private method to get the list of incoming or outgoing bookmarks.</td> </tr><tr> +<td><a href="#Hg.__getMostRecentCommitMessage">__getMostRecentCommitMessage</a></td> +<td>Private method to get the most recent commit message.</td> +</tr><tr> <td><a href="#Hg.__hgGetFileForRevision">__hgGetFileForRevision</a></td> <td>Private method to get a file for a specific revision from the repository.</td> </tr><tr> @@ -448,6 +451,29 @@ <dd> list of bookmarks (list of string) </dd> +</dl><a NAME="Hg.__getMostRecentCommitMessage" ID="Hg.__getMostRecentCommitMessage"></a> +<h4>Hg.__getMostRecentCommitMessage</h4> +<b>__getMostRecentCommitMessage</b>(<i>repodir</i>) +<p> + Private method to get the most recent commit message. +</p><p> + Note: This message is extracted from the parent commit of the + working directory. +</p><dl> +<dt><i>repodir</i> (str)</dt> +<dd> +path containing the repository +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +most recent commit message +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +str +</dd> </dl><a NAME="Hg.__hgGetFileForRevision" ID="Hg.__hgGetFileForRevision"></a> <h4>Hg.__hgGetFileForRevision</h4> <b>__hgGetFileForRevision</b>(<i>name, rev=""</i>)
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py Fri Oct 09 19:44:43 2015 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/hg.py Sat Oct 10 12:06:10 2015 +0200 @@ -510,12 +510,26 @@ if not res: return + if isinstance(name, list): + dname, fnames = self.splitPathList(name) + else: + 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 + if self.__commitDialog is not None: msg = self.__commitDialog.logMessage() amend = self.__commitDialog.amend() commitSubrepositories = self.__commitDialog.commitSubrepositories() self.__commitDialog.deleteLater() self.__commitDialog = None + if amend and not msg: + msg = self.__getMostRecentCommitMessage(repodir) else: amend = False commitSubrepositories = False @@ -537,18 +551,6 @@ if msg: args.append("--message") args.append(msg) - if isinstance(name, list): - dname, fnames = self.splitPathList(name) - else: - 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 - if self.__client: if isinstance(name, list): self.addArguments(args, name) @@ -579,6 +581,40 @@ self.__forgotNames = [] self.checkVCSStatus() + def __getMostRecentCommitMessage(self, repodir): + """ + Private method to get the most recent commit message. + + Note: This message is extracted from the parent commit of the + working directory. + + @param repodir path containing the repository + @type str + @return most recent commit message + @rtype str + """ + args = self.initCommand("log") + args.append("--rev") + args.append(".") + args.append('--template') + args.append('{desc}') + + 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) + + return output + def vcsUpdate(self, name, noDialog=False, revision=None): """ Public method used to update a file/directory with the Mercurial