Commits

Elson Wei committed 69f52a4

mqutil: add getQQueues() to get repo's qqueue list

Comments (0)

Files changed (1)

tortoisehg/hgqt/mqutil.py

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
+from mercurial import util
+from hgext import mq as mqmod
+
 from tortoisehg.util import hglib
 from tortoisehg.hgqt.i18n import _
 from tortoisehg.hgqt import qtlib, rejects
 
+def getQQueues(repo):
+    ui = repo.ui.copy()
+    ui.quiet = True  # don't append "(active)"
+    ui.pushbuffer()
+    try:
+        opts = {'list': True}
+        mqmod.qqueue(ui, repo, None, **opts)
+        qqueues = ui.popbuffer().rstrip('\n').split('\n')
+    except (util.Abort, EnvironmentError):
+        qqueues = []
+    return qqueues
+
 def defaultNewPatchName(repo):
     t = time.strftime('%Y-%m-%d_%H-%M-%S')
     return t + '_r%d+.diff' % repo['.'].rev()