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/bzr.py3
-rw-r--r--ranger/ext/vcs/git.py30
-rw-r--r--ranger/ext/vcs/hg.py4
-rw-r--r--ranger/ext/vcs/svn.py4
-rw-r--r--ranger/ext/vcs/vcs.py70
6 files changed, 27 insertions, 86 deletions
diff --git a/ranger/container/directory.py b/ranger/container/directory.py
index 1b658063..c96633b9 100644
--- a/ranger/container/directory.py
+++ b/ranger/container/directory.py
@@ -337,6 +337,8 @@ class Directory(FileSystemObject, Accumulator, Loadable):
                         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.vcspathstatus = item.vcs.rootvcs.get_status_root()
                             else:
                                 item.vcspathstatus = item.vcs.get_status_subpath(
                                     item.path, is_directory=True)
diff --git a/ranger/ext/vcs/bzr.py b/ranger/ext/vcs/bzr.py
index 7b457997..8e9f44d3 100644
--- a/ranger/ext/vcs/bzr.py
+++ b/ranger/ext/vcs/bzr.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # This file is part of ranger, the console file manager.
 # License: GNU GPL version 3, see the file "AUTHORS" for details.
 # Author: Abdó Roig-Maranges <abdo.roig@gmail.com>, 2012
@@ -265,5 +264,3 @@ class Bzr(Vcs):
             return raw.split('\n')
         else:
             return []
-
-# vim: expandtab:shiftwidth=4:tabstop=4:softtabstop=4:textwidth=80
diff --git a/ranger/ext/vcs/git.py b/ranger/ext/vcs/git.py
index 214fe63e..b7c51fa6 100644
--- a/ranger/ext/vcs/git.py
+++ b/ranger/ext/vcs/git.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # This file is part of ranger, the console file manager.
 # License: GNU GPL version 3, see the file "AUTHORS" for details.
 # Author: Abdó Roig-Maranges <abdo.roig@gmail.com>, 2011-2012
@@ -268,20 +267,19 @@ class Git(Vcs):
 
     def get_remote(self):
         """Returns the url for the remote repo attached to head"""
-        if self.is_repo():
-            try:
-                ref = self._head_ref()
-                remote = self._remote_ref(ref)
-            except VcsError:
-                ref = remote = None
-            if not remote:
-                return None
-
-            match = re.match('refs/remotes/([^/]+)/', remote)
-            if match:
-                return self._git(['config', '--get', 'remote.{0:s}.url'.format(match.group(1))],
-                                 catchout=True).strip() \
-                    or None
+        try:
+            ref = self._head_ref()
+            remote = self._remote_ref(ref)
+        except VcsError:
+            ref = remote = None
+        if not remote:
+            return None
+
+        match = re.match('refs/remotes/([^/]+)/', remote)
+        if match:
+            return self._git(['config', '--get', 'remote.{0:s}.url'.format(match.group(1))],
+                             catchout=True).strip() \
+                or None
         return None
 
 
@@ -325,5 +323,3 @@ class Git(Vcs):
         else:
             return self._git(['ls-tree', '--name-only', '-r', '-z', rev],
                              catchout=True, bytes=True).decode('utf-8').split('\x00')
-
-# vim: expandtab:shiftwidth=4:tabstop=4:softtabstop=4:textwidth=80
diff --git a/ranger/ext/vcs/hg.py b/ranger/ext/vcs/hg.py
index f91d18cc..77587408 100644
--- a/ranger/ext/vcs/hg.py
+++ b/ranger/ext/vcs/hg.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # This file is part of ranger, the console file manager.
 # License: GNU GPL version 3, see the file "AUTHORS" for details.
 # Author: Abdó Roig-Maranges <abdo.roig@gmail.com>, 2011-2012
@@ -265,6 +264,3 @@ class Hg(Vcs):
             return raw.split('\n')
         else:
             return []
-
-
-# vim: expandtab:shiftwidth=4:tabstop=4:softtabstop=4:textwidth=80
diff --git a/ranger/ext/vcs/svn.py b/ranger/ext/vcs/svn.py
index 64a690c1..9868b5fd 100644
--- a/ranger/ext/vcs/svn.py
+++ b/ranger/ext/vcs/svn.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # This file is part of ranger, the console file manager.
 # License: GNU GPL version 3, see the file "AUTHORS" for details.
 # Author: Abdó Roig-Maranges <abdo.roig@gmail.com>, 2011-2012
@@ -268,6 +267,3 @@ class SVN(Vcs):
 
         raw = self._svn(self.path, ['ls', "-r", rev], catchout=True)
         return raw.split('\n')
-
-
-# vim: expandtab:shiftwidth=4:tabstop=4:softtabstop=4:textwidth=80
diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py
index 4bb3ee99..6cb4809d 100644
--- a/ranger/ext/vcs/vcs.py
+++ b/ranger/ext/vcs/vcs.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # This file is part of ranger, the console file manager.
 # License: GNU GPL version 3, see the file "AUTHORS" for details.
 # Author: Abdó Roig-Maranges <abdo.roig@gmail.com>, 2011-2012
@@ -47,7 +46,7 @@ class Vcs(object):
         'svn': {'class': 'SVN', 'setting': 'vcs_backend_svn'},
     }
 
-    # Possible status responses in order of importance with statuses that
+    # Possible directory statuses in order of importance with statuses that
     # don't make sense disabled
     DIR_STATUS = (
         'conflict',
@@ -60,14 +59,6 @@ class Vcs(object):
         # 'none',
         'unknown',
     )
-    # REMOTE_STATUS = (
-    #     'diverged',
-    #     'behind',
-    #     'ahead',
-    #     'sync',
-    #     'none',
-    #     'unknown',
-    # )
 
     def __init__(self, directoryobject):
         self.obj = directoryobject
@@ -230,48 +221,19 @@ class Vcs(object):
     def update_tree(self, purge=False):
         """Update tree"""
         self._update_walk(self.root, purge)
-        for path in self.rootvcs.links:
+        for path in self.rootvcs.links.copy():
             self._update_walk(path, purge)
             try:
-                fileobj = self.obj.fm.directories[path]
+                dirobj = self.obj.fm.directories[path]
             except KeyError:
                 continue
-            if fileobj.vcs.path == self.root:
-                fileobj.vcspathstatus = self.rootvcs.get_status_root()
+            if purge:
+                dirobj.vcspathstatus = None
+            elif dirobj.vcs.path == self.root:
+                dirobj.vcspathstatus = self.rootvcs.get_status_root()
             else:
-                fileobj.vcspathstatus = fileobj.vcs.get_status_subpath(
-                    fileobj.path, is_directory=True)
-
-    # Repo creation
-    #---------------------------
-
-    def init(self, repotype):
-        """Initializes a repo in current path"""
-        if not repotype in self.repo_types:
-            raise VcsError("Unrecognized repo type {0:s}".format(repotype))
-
-        if not os.path.exists(self.path):
-            os.makedirs(self.path)
-        try:
-            self.__class__ = self.repo_types[repotype]
-            self.init()
-        except:
-            self.__class__ = Vcs
-            raise
-
-    def clone(self, repotype, src):
-        """Clones a repo from src"""
-        if not repotype in self.repo_types:
-            raise VcsError("Unrecognized repo type {0:s}".format(repotype))
-
-        if not os.path.exists(self.path):
-            os.makedirs(self.path)
-        try:
-            self.__class__ = self.repo_types[repotype]
-            self.clone(src)
-        except:
-            self.__class__ = Vcs
-            raise
+                dirobj.vcspathstatus = dirobj.vcs.get_status_subpath(
+                    dirobj.path, is_directory=True)
 
     # Action interface
     #---------------------------
@@ -307,16 +269,8 @@ class Vcs(object):
     # Data
     #---------------------------
 
-    def is_repo(self):
-        """Checks wether there is an initialized repo in self.path"""
-        return self.path and os.path.exists(self.path) and self.root is not None
-
-    def is_tracking(self):
-        """Checks whether HEAD is tracking a remote repo"""
-        return self.get_remote(self.HEAD) is not None
-
     def get_status_root_cheap(self):
-        """Returns the status of a child root, very cheap"""
+        """Returns the status of self.root, very cheap"""
         raise NotImplementedError
 
     def get_status_root(self):
@@ -359,7 +313,7 @@ class Vcs(object):
 
     def get_status_subpaths(self):
         """Returns a dict indexed by subpaths not in sync their status as values.
-           Paths are given relative to the root.  Strips trailing '/' from dirs."""
+           Paths are given relative to self.root.  Strips trailing '/' from dirs."""
         raise NotImplementedError
 
     def get_status_remote(self):
@@ -437,8 +391,8 @@ class VcsThread(threading.Thread):
                 self.ui.redraw()
             roots.clear()
 
-            self.wake.clear()
             self.wake.wait(timeout=self.delay)
+            self.wake.clear()
 
     def wakeup(self):
         """Wakeup thread"""