summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/container/directory.py16
-rw-r--r--ranger/container/fsobject.py1
-rw-r--r--ranger/ext/vcs/vcs.py16
-rw-r--r--ranger/gui/widgets/__init__.py36
-rw-r--r--ranger/gui/widgets/browsercolumn.py13
-rw-r--r--ranger/gui/widgets/statusbar.py4
6 files changed, 42 insertions, 44 deletions
diff --git a/ranger/container/directory.py b/ranger/container/directory.py
index 608eda06..9e88d265 100644
--- a/ranger/container/directory.py
+++ b/ranger/container/directory.py
@@ -306,9 +306,6 @@ class Directory(FileSystemObject, Accumulator, Loadable):
                 files = []
                 disk_usage = 0
 
-                if self.vcs and self.vcs.track and not self.vcs.is_root:
-                    self.vcsstatus = self.vcs.status_subpath(self.path, is_directory=True)
-
                 for name in filenames:
                     try:
                         file_lstat = os_lstat(name)
@@ -335,15 +332,12 @@ class Directory(FileSystemObject, Accumulator, Loadable):
                             else:
                                 item.relative_path = item.basename
                             item.relative_path_lower = item.relative_path.lower()
-
-                        if item.vcs and item.vcs.track:
-                            if item.vcs.is_root:
-                                self.has_vcschild = True
-                            elif item.is_link and os.path.realpath(item.path) == item.vcs.root:
-                                item.vcsstatus = item.vcs.rootvcs.status_root()
+                        if item.vcs and item.vcs.track and item.is_link:
+                            if os.path.realpath(item.path) == item.vcs.root:
+                                item.vcsstatus = item.vcs.rootvcs.obj.vcsstatus
+                                item.vcsremotestatus = item.vcs.rootvcs.obj.vcsremotestatus
                             else:
-                                item.vcsstatus = item.vcs.status_subpath(
-                                    item.path, is_directory=True)
+                                item.vcsstatus = item.vcs.status_subpath(item.path)
                     else:
                         item = File(name, preload=stats, path_is_abs=True,
                                     basename_is_rel_to=basename_is_rel_to)
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py
index caf6974a..1daf6d70 100644
--- a/ranger/container/fsobject.py
+++ b/ranger/container/fsobject.py
@@ -74,6 +74,7 @@ class FileSystemObject(FileManagerAware, SettingsAware):
     size = 0
 
     vcsstatus = None
+    vcsremotestatus = None
 
     _linemode = DEFAULT_LINEMODE
     linemode_dict = dict(
diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py
index 1c62afe7..2552d955 100644
--- a/ranger/ext/vcs/vcs.py
+++ b/ranger/ext/vcs/vcs.py
@@ -77,14 +77,14 @@ class Vcs(object):
                 self.status_subpaths = None
 
                 if not os.access(self.repodir, os.R_OK):
-                    directoryobject.vcsstatus = 'unknown'
-                    self.remotestatus = 'unknown'
+                    self.obj.vcsremotestatus = 'unknown'
+                    self.obj.vcsstatus = 'unknown'
                     return
 
                 try:
                     self.head = self.data_info(self.HEAD)
                     self.branch = self.data_branch()
-                    self.remotestatus = self.data_status_remote()
+                    self.obj.vcsremotestatus = self.data_status_remote()
                     self.obj.vcsstatus = self.data_status_root()
                 except VcsError:
                     return
@@ -158,6 +158,7 @@ class Vcs(object):
                 wdirs[:] = []
                 continue
             if wroot_obj.content_loaded:
+                has_vcschild = False
                 for fileobj in wroot_obj.files_all:
                     if purge:
                         if fileobj.is_directory:
@@ -171,11 +172,14 @@ class Vcs(object):
                         fileobj.vcs.check()
                         if not fileobj.vcs.track:
                             continue
-                        if not fileobj.vcs.is_root:
+                        if fileobj.vcs.is_root:
+                            has_vcschild = True
+                        else:
                             fileobj.vcsstatus = wroot_obj.vcs.status_subpath(
                                 fileobj.path, is_directory=True)
                     else:
                         fileobj.vcsstatus = wroot_obj.vcs.status_subpath(fileobj.path)
+                wroot_obj.has_vcschild = has_vcschild
 
             # Remove dead directories
             for wdir in list(wdirs):
@@ -198,7 +202,7 @@ class Vcs(object):
                 continue
             if purge:
                 dirobj.vcsstatus = None
-                dirobj.vcs.__init__(dirobj.vcs.obj)
+                dirobj.vcs.__init__(dirobj)
             elif dirobj.vcs.path == self.root:
                 dirobj.vcsstatus = self.rootvcs.status_root()
             else:
@@ -212,7 +216,7 @@ class Vcs(object):
             self.rootvcs.head = self.rootvcs.data_info(self.HEAD)
             self.rootvcs.branch = self.rootvcs.data_branch()
             self.rootvcs.status_subpaths = self.rootvcs.data_status_subpaths()
-            self.rootvcs.remotestatus = self.rootvcs.data_status_remote()
+            self.rootvcs.obj.vcsremotestatus = self.rootvcs.data_status_remote()
             self.rootvcs.obj.vcsstatus = self.rootvcs.status_root()
         except VcsError:
             self.update_tree(purge=True)
diff --git a/ranger/gui/widgets/__init__.py b/ranger/gui/widgets/__init__.py
index ac1188ca..ca3e90ce 100644
--- a/ranger/gui/widgets/__init__.py
+++ b/ranger/gui/widgets/__init__.py
@@ -5,21 +5,25 @@ from ranger.gui.displayable import Displayable
 class Widget(Displayable):
     """A class for classification of widgets."""
 
-    vcsstatus_symb = {'conflict':  ('X', ["vcsconflict"]),
-                  'untracked': ('+', ["vcschanged"]),
-                  'deleted':   ('-', ["vcschanged"]),
-                  'changed':   ('*', ["vcschanged"]),
-                  'staged':    ('*', ["vcsstaged"]),
-                  'ignored':   ('·', ["vcsignored"]),
-                  'sync':      ('√', ["vcssync"]),
-                  'none':      (' ', []),
-                  'unknown':   ('?', ["vcsunknown"])}
+    vcsstatus_symb = {
+        'conflict':  ('X', ["vcsconflict"]),
+        'untracked': ('+', ["vcschanged"]),
+        'deleted':   ('-', ["vcschanged"]),
+        'changed':   ('*', ["vcschanged"]),
+        'staged':    ('*', ["vcsstaged"]),
+        'ignored':   ('·', ["vcsignored"]),
+        'sync':      ('√', ["vcssync"]),
+        'none':      (' ', []),
+        'unknown':   ('?', ["vcsunknown"]),
+    }
 
-    vcsremotestatus_symb = {'none':     ('⌂',  ["vcsnone"]),
-                'sync':     ('=', ["vcssync"]),
-                'behind':   ('<', ["vcsbehind"]),
-                'ahead':    ('>', ["vcsahead"]),
-                'diverged': ('Y', ["vcsdiverged"]),
-                'unknown':  ('?', ["vcsunknown"])}
+    vcsremotestatus_symb = {
+        'diverged': ('Y', ["vcsdiverged"]),
+        'ahead':    ('>', ["vcsahead"]),
+        'behind':   ('<', ["vcsbehind"]),
+        'sync':     ('=', ["vcssync"]),
+        'none':     ('⌂', ["vcsnone"]),
+        'unknown':  ('?', ["vcsunknown"]),
+    }
 
-    ellipsis = { False: '~', True: '…' }
+    ellipsis = {False: '~', True: '…'}
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 58d07072..944f5c58 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -257,13 +257,8 @@ class BrowserColumn(Pager):
             metakey = hash(repr(sorted(metadata.items()))) if metadata else 0
             key = (self.wid, selected_i == i, drawn.marked, self.main_column,
                    drawn.path in copied, tagged_marker, drawn.infostring,
-                   drawn.vcsstatus,
-                   drawn.vcs.remotestatus \
-                   if drawn.is_directory and drawn.vcs \
-                   and drawn.vcs.is_root and drawn.vcs.track \
-                   else None,
-                   self.fm.do_cut,
-                   current_linemode.name, metakey)
+                   drawn.vcsstatus, drawn.vcsremotestatus,
+                   self.fm.do_cut, current_linemode.name, metakey)
 
             if key in drawn.display_data:
                 self.execute_curses_batch(line, drawn.display_data[key])
@@ -379,8 +374,8 @@ class BrowserColumn(Pager):
         vcsstring_display = []
         directory = drawn if drawn.is_directory else self.target
         if directory.vcs and directory.vcs.track:
-            if drawn.is_directory and drawn.vcs.is_root:
-                vcsstr, vcscol = self.vcsremotestatus_symb[drawn.vcs.remotestatus]
+            if drawn.vcsremotestatus:
+                vcsstr, vcscol = self.vcsremotestatus_symb[drawn.vcsremotestatus]
                 vcsstring_display.append([vcsstr, ['vcsremote'] + vcscol])
             elif self.target.has_vcschild:
                 vcsstring_display.insert(-1, [" ", []])
diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py
index 978171e5..0fbd0113 100644
--- a/ranger/gui/widgets/statusbar.py
+++ b/ranger/gui/widgets/statusbar.py
@@ -192,8 +192,8 @@ class StatusBar(Widget):
             left.add(vcsinfo, 'vcsinfo')
 
             left.add_space()
-            if directory.vcs.rootvcs.remotestatus:
-                vcsstr, vcscol = self.vcsremotestatus_symb[directory.vcs.rootvcs.remotestatus]
+            if directory.vcs.rootvcs.obj.vcsremotestatus:
+                vcsstr, vcscol = self.vcsremotestatus_symb[directory.vcs.rootvcs.obj.vcsremotestatus]
                 left.add(vcsstr.strip(), 'vcsremote', *vcscol)
             if target.vcsstatus:
                 vcsstr, vcscol = self.vcsstatus_symb[target.vcsstatus]