Plugins/VcsPlugins/vcsMercurial/hg.py

changeset 5319
a512d3951a13
parent 5292
ac8b476ba122
child 5322
c2cabdca0734
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py	Sat Nov 12 17:28:22 2016 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/hg.py	Sun Nov 13 19:40:14 2016 +0100
@@ -2274,6 +2274,33 @@
         if res:
             dia.exec_()
     
+    def hgGetCurrentBranch(self, repodir):
+        """
+        Public method to get the current branch of the working directory.
+        
+        @param repodir directory name of the repository
+        @type str
+        @return name of the current branch
+        @rtype str
+        """
+        args = self.initCommand("branch")
+        
+        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.strip()
+    
     def hgEditUserConfig(self):
         """
         Public method used to edit the user configuration file.

eric ide

mercurial