Commit 8c33be86 authored by Kai Willadsen's avatar Kai Willadsen

Add and use sorting criteria for VC systems (closes bgo#663055)

This fixes the problem of not knowing which VC the user wants to see
when a directory is under revision control by multiple different

The sort order is in rough order of popularity, with distributed
version control systems coming first. The reasoning for this is that
if we find e.g., SVN and Git in a single directory, the likelihood is
that there is an organisation SVN repository and the Git copy is the
user's local working repository. Therefore, we show the Git copy.
parent 846c36b0
......@@ -45,6 +45,22 @@ def get_plugins_metadata():
return ret
vc_sort_order = (
"Subversion 1.7",
def get_vcs(location):
"""Pick only the Vcs with the longest repo root
......@@ -73,6 +89,15 @@ def get_vcs(location):
if not vcs:
# No plugin recognized that location, fallback to _null
return [_null.Vc(location)]
vc_comp = lambda a, b: cmp(vc_sort_order.index(a), vc_sort_order.index(b))
vc_name = lambda x: x.NAME
vcs.sort(cmp=vc_comp, key=vc_name)
# Simplistic hack so that we don't offer both 1.7 and <1.6 SVN
vc_names = [plugin.NAME for plugin in vcs]
if "Subversion" in vc_names and "Subversion 1.7" in vc_names:
vcs = [plugin for plugin in vcs if plugin.NAME != "Subversion 1.7"]
return vcs
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment