Source

thg-qt-mq / workbench-empty-serve.diff

Full commit
# HG changeset patch
# Parent 8789f0b87ae35b7bf0906fa24eced733960e9fca
workbench: start empty serve dialog if no repowidget open

diff --git a/tortoisehg/hgqt/serve.py b/tortoisehg/hgqt/serve.py
--- a/tortoisehg/hgqt/serve.py
+++ b/tortoisehg/hgqt/serve.py
@@ -242,7 +242,11 @@ def _setupwrapper():
         _setupwrapper_done = True
 
 def run(ui, *pats, **opts):
-    repopath = opts.get('root') or paths.find_root()
+    """Open webserve dialog and start it
+
+    To open empty webserve dialog, specify root=None.
+    """
+    repopath = opts.get('root', paths.find_root())
     webconfpath = opts.get('web_conf') or opts.get('webdir_conf')
     dlg = ServeDialog(webconf=_newwebconf(repopath, webconfpath))
     if repopath or webconfpath:
diff --git a/tortoisehg/hgqt/workbench.py b/tortoisehg/hgqt/workbench.py
--- a/tortoisehg/hgqt/workbench.py
+++ b/tortoisehg/hgqt/workbench.py
@@ -471,7 +471,6 @@ class Workbench(QMainWindow):
 
         self.actionClose_repository.setEnabled(someRepoOpen)
         self.actionImport.setEnabled(someRepoOpen)
-        self.actionServe.setEnabled(someRepoOpen)
         self.actionVerify.setEnabled(someRepoOpen)
         self.actionRecover.setEnabled(someRepoOpen)
         self.actionRollback.setEnabled(someRepoOpen)
@@ -589,10 +588,9 @@ class Workbench(QMainWindow):
                 w.repoview.resizeColumns()
 
     def serve(self):
+        from tortoisehg.hgqt import run
         w = self.repoTabsWidget.currentWidget()
-        if w:
-            from tortoisehg.hgqt import run
-            run.serve(self.ui, root=w.repo.root)
+        run.serve(self.ui, root=w and w.repo.root or None)
 
     def thgimport(self):
         w = self.repoTabsWidget.currentWidget()