summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/container/directory.py2
-rw-r--r--ranger/ext/vcs/__init__.py2
-rw-r--r--ranger/ext/vcs/vcs.py34
3 files changed, 18 insertions, 20 deletions
diff --git a/ranger/container/directory.py b/ranger/container/directory.py
index 77c2e250..2c3c9f02 100644
--- a/ranger/container/directory.py
+++ b/ranger/container/directory.py
@@ -18,7 +18,7 @@ from ranger.ext.accumulator import Accumulator
 from ranger.ext.lazy_property import lazy_property
 from ranger.ext.human_readable import human_readable
 from ranger.container.settings import LocalSettings
-from ranger.ext.vcs.vcs import Vcs
+from ranger.ext.vcs import Vcs
 
 def sort_by_basename(path):
     """returns path.relative_path (for sorting)"""
diff --git a/ranger/ext/vcs/__init__.py b/ranger/ext/vcs/__init__.py
index b639b50f..8adc11c6 100644
--- a/ranger/ext/vcs/__init__.py
+++ b/ranger/ext/vcs/__init__.py
@@ -1 +1,3 @@
 """VCS Extension Package"""
+
+from .vcs import Vcs, VcsError
diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py
index 67493c34..94aada5d 100644
--- a/ranger/ext/vcs/vcs.py
+++ b/ranger/ext/vcs/vcs.py
@@ -39,7 +39,15 @@ class Vcs(object):
     HEAD = 'HEAD'
     NONE = 'NONE'
 
-    # Possible status responses in order of importance
+    REPOTYPES = {
+        'git': {'class': 'Git', 'setting': 'vcs_backend_git'},
+        'hg': {'class': 'Hg', 'setting': 'vcs_backend_hg'},
+        'bzr': {'class': 'Bzr', 'setting': 'vcs_backend_bzr'},
+        'svn': {'class': 'SVN', 'setting': 'vcs_backend_svn'},
+    }
+
+    # Possible status responses in order of importance with statuses that
+    # don't make sense disabled
     DIR_STATUS = (
         'conflict',
         'untracked',
@@ -61,24 +69,11 @@ class Vcs(object):
     )
 
     def __init__(self, directoryobject):
-        self.repotypes = {
-            'git': ranger.ext.vcs.git.Git,
-            'hg': ranger.ext.vcs.hg.Hg,
-            'bzr': ranger.ext.vcs.bzr.Bzr,
-            'svn': ranger.ext.vcs.svn.SVN,
-        }
-
         self.path = directoryobject.path
-        self.repotypes_settings = [
-            repotype for repotype, setting in \
-            (
-                ('git', directoryobject.settings.vcs_backend_git),
-                ('hg', directoryobject.settings.vcs_backend_hg),
-                ('bzr', directoryobject.settings.vcs_backend_bzr),
-                ('svn', directoryobject.settings.vcs_backend_svn),
-            )
-            if setting in ('enabled', 'local')
-        ]
+        self.repotypes_settings = set(
+            repotype for repotype, values in self.REPOTYPES.items()
+            if getattr(directoryobject.settings, values['setting']) in ('enabled', 'local')
+        )
 
         self.status_subpaths = {}
         self.head = None
@@ -90,7 +85,8 @@ class Vcs(object):
 
         if self.root:
             self.track = True
-            self.__class__ = self.repotypes[self.repotype]
+            self.__class__ = getattr(getattr(ranger.ext.vcs, self.repotype),
+                                     self.REPOTYPES[self.repotype]['class'])
 
             if not os.access(self.repodir, os.R_OK):
                 self.track = False