about summary refs log tree commit diff stats
path: root/ranger/fsobject/directory.py
diff options
context:
space:
mode:
authorAbdo Roig-Maranges <abdo.roig@gmail.com>2013-02-10 11:59:09 +0100
committerAbdo Roig-Maranges <abdo.roig@gmail.com>2013-02-12 12:08:44 +0100
commit94bf56dd024b4fa33b5ae4c80f5091fec0995d1c (patch)
tree419756254da363b35116af708c3779805a959d35 /ranger/fsobject/directory.py
parente6b847b34d2f48a60dabde39d96d227f1f818c6c (diff)
downloadranger-94bf56dd024b4fa33b5ae4c80f5091fec0995d1c.tar.gz
Support for extracting metadata from version control systems
  * Makes fsobject aware of vcs.
  * Makes directory get vcs status data when loading content.
  * Adds a config option to enable/disable the vcs info feature.
Diffstat (limited to 'ranger/fsobject/directory.py')
-rw-r--r--ranger/fsobject/directory.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index 2aa47a64..fa5db6cf 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -72,6 +72,8 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware):
     content_outdated = False
     content_loaded = False
 
+    has_vcschild=False
+
     _cumulative_size_calculated = False
 
     sort_dict = {
@@ -224,6 +226,10 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware):
 
                 files = []
                 disk_usage = 0
+
+                self.has_vcschild = False
+                self.load_vcs()
+
                 for name in filenames:
                     try:
                         file_lstat = os_lstat(name)
@@ -248,10 +254,33 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware):
                         item = File(name, preload=stats, path_is_abs=True)
                         item.load()
                         disk_usage += item.size
+
+                    # Load vcs data
+                    if self.settings.vcs_aware:
+                        item.load_vcs()
+                        if item.vcs and item.vcs.vcsname in self.settings.vcs_backends:
+                            self.has_vcschild = True
+                            try:
+                                if self.vcs_outdated or item.vcs_outdated:
+                                    item.vcs_outdated = False
+                                    item.vcs.get_status()  # caches the file status for get_file_status()
+                                    item.vcsbranch = item.vcs.get_branch()
+                                    item.vcshead = item.vcs.get_info(item.vcs.HEAD)
+                                    if item.path == item.vcs.root:
+                                        item.vcsremotestatus = item.vcs.get_remote_status()
+                                else:
+                                    item.vcsbranch = self.vcsbranch
+                                    item.vcshead = self.vcshead
+                                item.vcsfilestatus = item.vcs.get_file_status(item.path)
+                            except:
+                                raise
+                                self.fm.notify("Can not load vcs data on %s" % item.path, bad=True)
+
                     files.append(item)
                     self.percent = 100 * len(files) // len(filenames)
                     yield
                 self.disk_usage = disk_usage
+                self.vcs_outdated = False
 
                 self.filenames = filenames
                 self.files = files