Commits

Yuya Nishihara committed 5df95c0

workbench: apply selected url before running sync operation from toolbar

Comments (0)

Files changed (2)

tortoisehg/hgqt/repowidget.py

         self.repoview.saveSettings(s)
         return True
 
+    def setSyncUrl(self, url):
+        """Change the current peer-repo url of the sync widget; url may be
+        a symbolic name defined in [paths] section"""
+        self.syncDemand.get().setUrl(url)
+
     def incoming(self):
         self.syncDemand.get().incoming()
 

tortoisehg/hgqt/workbench.py

             else:
                 self.urlCombo.addItem(a, (a, a))
 
+    def _syncUrlFor(self, op):
+        """Current URL alias for the given sync operation"""
+        urlindex = self.urlCombo.currentIndex()
+        if urlindex < 0:
+            return
+        opindex = {'incoming': 0, 'pull': 0, 'outgoing': 1, 'push': 1}[op]
+        return self.urlCombo.itemData(urlindex).toPyObject()[opindex]
+
     def _setupCustomTools(self, ui):
         tools, toollist = hglib.tortoisehgtools(ui,
             selectedlocation='workbench.custom-toolbar')
         w = self.repoTabsWidget.currentWidget()
         if w:
             op = str(action.data().toString())
+            w.setSyncUrl(self._syncUrlFor(op) or '')
             getattr(w, op)()
 
     def serve(self):