Steve Borho avatar Steve Borho committed e533936

workbench: add an URL combo (incomplete)

The toolbar buttons do not use the combo URLs, and it isn't remembering the
URL you had selected when you switch to another repo and back.

Comments (0)

Files changed (1)

tortoisehg/hgqt/workbench.py

         newaction(_('Pull'), self._repofwd('pull'), icon='hg-pull',
                   tooltip=_('Pull incoming changes from selected URL'),
                   enabled='repoopen', toolbar='sync')
+        self.urlCombo = QComboBox(self)
+        self.synctbar.addWidget(self.urlCombo)
         newaction(_('Outgoing'), self._repofwd('outgoing'), icon='hg-outgoing',
                   tooltip=_('Detect outgoing changes to selected URL'),
                   enabled='repoopen', toolbar='sync')
 
         self.updateMenu()
 
+    def _setupUrlCombo(self, repo):
+        'repository has been switched, fill urlCombo with URLs'
+        aliases = [alias for alias, path in repo.ui.configitems('paths')]
+        if 'default' in aliases:
+            aliases.remove('default')
+            aliases.insert(0, 'default')
+        for a in aliases[:]:
+            if a + '-push' in aliases:
+                # add foo,foo-push entry to top of menu
+                aliases.insert(0, u'\u2193 %s | %s-push \u2191' % (a,a))
+                # move foo,foo-push individual entries to bottom
+                aliases.remove(a)
+                aliases.remove(a + '-push')
+                aliases.append(a)
+                aliases.append(a + '-push')
+        self.urlCombo.clear()
+        self.urlCombo.addItems(aliases)
+
     def _setupCustomTools(self, ui):
         tools, toollist = hglib.tortoisehgtools(ui,
             selectedlocation='workbench.custom-toolbar')
                 root = w.repo.root
                 self.activeRepoChanged.emit(hglib.tounicode(root))
                 self._setupCustomTools(w.repo.ui)
+                self._setupUrlCombo(w.repo)
         else:
             self.activeRepoChanged.emit("")
         repo = w and w.repo or None
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.