summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2015-10-09 02:29:13 +0200
committernfnty <git@nfnty.se>2016-02-08 04:43:04 +0100
commit9645b056c6fc5d1b8882f500ed5e231ed16c02fa (patch)
tree20f43361610f95b8f70fdf6427f62fd50287b129 /ranger
parent1ca99394fccbfe1db8678530b1b7ab1c017d2310 (diff)
downloadranger-9645b056c6fc5d1b8882f500ed5e231ed16c02fa.tar.gz
VCS: Handle repodir paths
Diffstat (limited to 'ranger')
-rw-r--r--ranger/container/directory.py9
-rw-r--r--ranger/ext/vcs/vcs.py34
-rw-r--r--ranger/gui/widgets/browsercolumn.py7
3 files changed, 32 insertions, 18 deletions
diff --git a/ranger/container/directory.py b/ranger/container/directory.py
index 379e0830..6d6e3e88 100644
--- a/ranger/container/directory.py
+++ b/ranger/container/directory.py
@@ -306,7 +306,8 @@ class Directory(FileSystemObject, Accumulator, Loadable):
                 files = []
                 disk_usage = 0
 
-                if self.settings.vcs_aware and self.vcs.root:
+                if self.settings.vcs_aware and \
+                        self.vcs.root and not self.vcs.in_repodir:
                     self.vcs.update(self)
 
                 for name in filenames:
@@ -333,7 +334,8 @@ class Directory(FileSystemObject, Accumulator, Loadable):
                             except:
                                 item = Directory(name, preload=stats, path_is_abs=True)
                                 item.load()
-                        if item.settings.vcs_aware and item.vcs.root:
+                        if item.settings.vcs_aware and \
+                                item.vcs.root and not item.vcs.in_repodir:
                             item.vcs.update(item, child=True)
                             if item.vcs.is_root:
                                 self.has_vcschild = True
@@ -342,7 +344,8 @@ class Directory(FileSystemObject, Accumulator, Loadable):
                                     basename_is_rel_to=basename_is_rel_to)
                         item.load()
                         disk_usage += item.size
-                        if self.settings.vcs_aware and self.vcs.root:
+                        if self.settings.vcs_aware and \
+                                self.vcs.root and not self.vcs.in_repodir:
                             item.vcspathstatus = self.vcs.get_status_subpath(item.path)
 
                     files.append(item)
diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py
index ebd18385..1764122b 100644
--- a/ranger/ext/vcs/vcs.py
+++ b/ranger/ext/vcs/vcs.py
@@ -86,15 +86,16 @@ class Vcs(object):
         self.remotestatus = None
         self.branch = None
 
-        self.root, self.repotype = self.find_root(self.path)
+        self.root, self.repodir, self.repotype = self.find_root(self.path)
         self.is_root = True if self.path == self.root else False
 
         if self.root:
-            # Do not track the repo data directory
-            repodir = os.path.join(self.root, '.{0:s}'.format(self.repotype))
-            if self.path == repodir or self.path.startswith(repodir + '/'):
-                self.root = None
-                return
+            # Do not track self.repodir or its subpaths
+            if self.path == self.repodir or self.path.startswith(self.repodir + '/'):
+                self.in_repodir = True
+            else:
+                self.in_repodir = False
+
             if self.is_root:
                 self.root = self.path
                 self.__class__ = self.repotypes[self.repotype]
@@ -126,23 +127,30 @@ class Vcs(object):
     def get_repotype(self, path):
         """Returns the right repo type for path. None if no repo present in path"""
         for repotype in self.repotypes_settings:
-            if os.path.exists(os.path.join(path, '.{0:s}'.format(repotype))):
-                return repotype
-        return None
+            repodir = os.path.join(path, '.{0:s}'.format(repotype))
+            if os.path.exists(repodir):
+                return (repodir, repotype)
+        return (None, None)
 
     def find_root(self, path):
         """Finds the repository root path. Otherwise returns none"""
         while True:
-            repotype = self.get_repotype(path)
-            if repotype:
-                return (path, repotype)
+            repodir, repotype = self.get_repotype(path)
+            if repodir:
+                return (path, repodir, repotype)
             if path == '/':
                 break
             path = os.path.dirname(path)
-        return (None, None)
+        return (None, None, None)
 
     def update(self, directoryobject, child=False):
         """Update repository"""
+        if not os.path.exists(self.repodir):
+            self.__init__(directoryobject)
+            if not self.root:
+                directoryobject.vcspathstatus = None
+                return
+
         root = self if self.is_root else directoryobject.fm.get_directory(self.root).vcs
         if child and self.is_root:
             directoryobject.vcspathstatus = self.get_status_root_child()
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 2e31c976..50bf2e2f 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -379,11 +379,14 @@ class BrowserColumn(Pager):
             if drawn.vcspathstatus:
                 vcsstr, vcscol = self.vcspathstatus_symb[drawn.vcspathstatus]
                 vcsstring_display.append([vcsstr, ['vcsfile'] + vcscol])
+            else:
+                vcsstring_display.append([" ", []])
             if drawn.is_directory and drawn.vcs.remotestatus:
                 vcsstr, vcscol = self.vcsremotestatus_symb[drawn.vcs.remotestatus]
                 vcsstring_display.append([vcsstr, ['vcsremote'] + vcscol])
-        elif self.target.vcs.is_root:
-            vcsstring_display.append([" ", []])
+            else:
+                if self.target.has_vcschild:
+                    vcsstring_display.insert(-1, [" ", []])
         elif self.target.has_vcschild:
             vcsstring_display.append(["  ", []])