Angel Ezquerra committed b6e2c75

workbench: improve urlCombo sorting

The existing urlCombo sorting placed combined push|pull paths first. The
rationale was that if there is a combined path, the individual, non combined
paths are less important. However this made the default path not always be the
first (and default!) item on the combobox. This change fixes that.

To summarize, the sorting algorithm places the paths in the following order:

- "default" path if there is no "default-push" path.
- Combined "default | default-push" path is there is one.
- The rest of combined paths, sorted alphabetically.
- The "default" path is there is a "default-push" path.
- The rest of the non combined paths, sorted alphabetically.

This is a bit complex, but I think it does the right thing. Also, in the most
common case in which when there are no combined paths it becomes a straight
forward alphabetical order except for the default path which always goes first.

Comments (0)

Files changed (1)


         combinedaliases = [(a, a + '-push') for a in haspushaliases]
         # 6. Put the combined aliases first, followed by the regular aliases
         aliases = combinedaliases + regularaliases
+        # 7. Ensure the first path is a default path (either a
+        # combined "default | default-push" path or a regular default path)
+        if not 'default-push' in aliases and 'default' in aliases:
+            aliases.remove('default')
+            aliases.insert(0, 'default')
         for n, a in enumerate(aliases):