Yuya Nishihara avatar Yuya Nishihara committed 8d15a5b

workbench: send files specified by command-line to open instance (fixes #3402)

Comments (0)

Files changed (2)

tortoisehg/hgqt/qtapp.py

         except ImportError:
             pass
 
-def connectToExistingWorkbench(root):
+def connectToExistingWorkbench(root, revset=None):
     """
     Connect and send data to an existing workbench server
 
     also send "echo" to check that the connection works (i.e. that there is a
     server)
     """
-    data = root
+    if revset:
+        data = '\0'.join([root, revset])
+    else:
+        data = root
     servername = QApplication.applicationName() + '-' + util.getuser()
     socket = QLocalSocket()
     socket.connectToServer(servername, QIODevice.ReadWrite)
             socket.waitForReadyRead(10000)
             data = str(socket.readAll())
             if data and data != '[echo]':
-                uroot = hglib.tounicode(data)
+                args = data.split('\0', 1)
+                if len(args) > 1:
+                    uroot, urevset = map(hglib.tounicode, args)
+                else:
+                    uroot = hglib.tounicode(args[0])
+                    urevset = None
                 self.showRepoInWorkbench(uroot)
 
+                wb = self._workbench
+                if urevset:
+                    wb.setRevsetFilter(uroot, urevset)
+
                 # Bring the workbench window to the front
                 # This assumes that the client process has
                 # called allowSetForegroundWindow(-1) right before
                 # sending the request
-                wb = self._workbench
                 wb.setWindowState(wb.windowState() & ~Qt.WindowMinimized
                                   | Qt.WindowActive)
                 wb.show()

tortoisehg/hgqt/run.py

     if singleworkbenchmode:
         newworkbench = opts.get('newworkbench')
         if root and not newworkbench:
-            if qtapp.connectToExistingWorkbench(root):
+            if qtapp.connectToExistingWorkbench(root, _formatfilerevset(pats)):
                 # The were able to connect to an existing workbench server, and
                 # it confirmed that it has opened the selected repo for us
                 sys.exit(0)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.