about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/ext/vcs/bzr.py10
-rw-r--r--ranger/ext/vcs/git.py15
-rw-r--r--ranger/ext/vcs/hg.py4
-rw-r--r--ranger/ext/vcs/vcs.py43
4 files changed, 43 insertions, 29 deletions
diff --git a/ranger/ext/vcs/bzr.py b/ranger/ext/vcs/bzr.py
index a63eea54..ad82ce4d 100644
--- a/ranger/ext/vcs/bzr.py
+++ b/ranger/ext/vcs/bzr.py
@@ -80,7 +80,7 @@ class Bzr(Vcs):
         return log
 
 
-    def _hg_file_status(self, st):
+    def _bzr_file_status(self, st):
         st = st.strip()
         if   st in "AM":     return 'staged'
         elif st in "D":      return 'deleted'
@@ -162,20 +162,20 @@ class Bzr(Vcs):
 
     def get_status_allfiles(self):
         """Returns a dict indexed by files not in sync their status as values.
-           Paths are given relative to the root."""
+           Paths are given relative to the root. Strips trailing '/' from dirs."""
         raw = self._bzr(self.path, ['status', '--short', '--no-classify'], catchout=True, bytes=True)
         L = re.findall('^(..)\s*(.*?)\s*$', raw.decode('utf-8'), re.MULTILINE)
         ret = {}
         for st, p in L:
             sta = self._bzr_file_status(st)
-            ret[p.strip()] = sta
+            ret[os.path.normpath(p.strip())] = sta
         return ret
 
 
     def get_ignore_allfiles(self):
-        """Returns a set of all the ignored files in the repo"""
+        """Returns a set of all the ignored files in the repo. Strips trailing '/' from dirs."""
         raw = self._bzr(self.path, ['ls', '--ignored'], catchout=True)
-        return set(raw.split('\n'))
+        return set(os.path.normpath(p) for p in raw.split('\n'))
 
 
     # TODO: slow due to net access
diff --git a/ranger/ext/vcs/git.py b/ranger/ext/vcs/git.py
index b2e79a06..e462b003 100644
--- a/ranger/ext/vcs/git.py
+++ b/ranger/ext/vcs/git.py
@@ -180,7 +180,7 @@ class Git(Vcs):
 
     def get_status_allfiles(self):
         """Returns a dict indexed by files not in sync their status as values.
-           Paths are given relative to the root."""
+           Paths are given relative to the root. Strips trailing '/' from dirs."""
         raw = self._git(self.path, ['status', '--porcelain'], catchout=True, bytes=True)
         L = re.findall('^(..)\s*(.*?)\s*$', raw.decode('utf-8'), re.MULTILINE)
         ret = {}
@@ -188,17 +188,16 @@ class Git(Vcs):
             sta = self._git_file_status(st)
             if 'R' in st:
                 m = re.match('^(.*)\->(.*)$', p)
-                if m: ret[m.group(2).strip()] = sta
-                else: ret[p.strip()] = sta
-            else:
-                ret[p.strip()] = sta
+                if m: p = m.group(2).strip()
+            ret[os.path.normpath(p.strip())] = sta
         return ret
 
 
     def get_ignore_allfiles(self):
-        """Returns a set of all the ignored files in the repo"""
-        raw = self._git(self.path, ['ls-files', '--others', '-i', '--exclude-standard'], catchout=True)
-        return set(raw.split('\n'))
+        """Returns a set of all the ignored files in the repo. Strips trailing '/' from dirs."""
+        raw = self._git(self.path, ['ls-files', '--others', '--directory', '-i', '--exclude-standard'],
+                        catchout=True)
+        return set(os.path.normpath(p) for p in raw.split('\n'))
 
 
     def get_remote_status(self):
diff --git a/ranger/ext/vcs/hg.py b/ranger/ext/vcs/hg.py
index 08e5753b..92aae349 100644
--- a/ranger/ext/vcs/hg.py
+++ b/ranger/ext/vcs/hg.py
@@ -168,7 +168,7 @@ class Hg(Vcs):
 
     def get_status_allfiles(self):
         """Returns a dict indexed by files not in sync their status as values.
-           Paths are given relative to the root."""
+           Paths are given relative to the root. Strips trailing '/' from dirs."""
         raw = self._hg(self.path, ['status'], catchout=True, bytes=True)
         L = re.findall('^(.)\s*(.*?)\s*$', raw.decode('utf-8'), re.MULTILINE)
         ret = {}
@@ -176,7 +176,7 @@ class Hg(Vcs):
             # Detect conflict by the existence of .orig files
             if st == '?' and re.match('^.*\.orig\s*$', p):  st = 'X'
             sta = self._hg_file_status(st)
-            ret[p.strip()] = sta
+            ret[os.path.normpath(p.strip())] = sta
         return ret
 
 
diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py
index e0d434e0..dfd187cb 100644
--- a/ranger/ext/vcs/vcs.py
+++ b/ranger/ext/vcs/vcs.py
@@ -95,6 +95,8 @@ class Vcs(object):
     def _path_contains(self, parent, path):
         """Checks wether path is an object belonging to the subtree in parent"""
         if parent == path: return True
+        parent = os.path.normpath(parent + '/')
+        path = os.path.normpath(path)
         return os.path.commonprefix([parent, path]) == parent
 
 
@@ -229,20 +231,33 @@ class Vcs(object):
         # if path is relative, join it with root. otherwise do nothing
         path = os.path.join(self.root, path)
 
-        if os.path.commonprefix([self.root, path]) == self.root:
-            prel = os.path.relpath(path, self.root)
-            if prel in self.ignored:   return "ignored"
-            if os.path.isdir(path):
-                sts = set([st for p, st in self.status.items()
-                           if self._path_contains(path, os.path.join(self.root, p))]) | set(['sync'])
-                for st in self.FILE_STATUS:
-                    if st in sts: return st
-            else:
-                if prel in self.status:  return self.status[prel]
-                else:                    return "sync"
-        else:
+        # path is not in the repo
+        if not self._path_contains(self.root, path):
             return "none"
 
+        # check if prel or some parent of prel is ignored
+        prel = os.path.relpath(path, self.root)
+        while len(prel) > 0 and prel != '/' and prel != '.':
+            if prel in self.ignored: return "ignored"
+            prel, tail = os.path.split(prel)
+
+        # check if prel or some parent of prel is listed in status
+        prel = os.path.relpath(path, self.root)
+        while len(prel) > 0 and prel != '/' and prel != '.':
+            if prel in self.status: return self.status[prel]
+            prel, tail = os.path.split(prel)
+
+        # check if prel is a directory that contains some file in status
+        prel = os.path.relpath(path, self.root)
+        if os.path.isdir(path):
+            sts = set(st for p, st in self.status.items()
+                      if self._path_contains(path, os.path.join(self.root, p)))
+            for st in self.FILE_STATUS:
+                if st in sts: return st
+
+        # it seems prel is in sync
+        return "sync"
+
 
     def get_status(self, path=None):
         """Returns a dict with changed files under path and their status.
@@ -262,12 +277,12 @@ class Vcs(object):
 
     def get_status_allfiles(self):
         """Returns a dict indexed by files not in sync their status as values.
-           Paths are given relative to the root."""
+           Paths are given relative to the root.  Strips trailing '/' from dirs."""
         raise NotImplementedError
 
 
     def get_ignore_allfiles(self):
-        """Returns a set of all the ignored files in the repo"""
+        """Returns a set of all the ignored files in the repo. Strips trailing '/' from dirs."""
         raise NotImplementedError
 
 
cc?h=hlt&id=bbe7cd53cb37e5d318c87626a0169987c3841e88'>^
414d9413 ^
96b2216b ^


414d9413 ^
96b2216b ^
708eae31 ^

96b2216b ^


414d9413 ^
96b2216b ^

fd7198b2 ^
96b2216b ^


708eae31 ^
9527eda9 ^
96b2216b ^
9527eda9 ^
708eae31 ^
6602c82f ^
9527eda9 ^
630433cd ^
9527eda9 ^
a1305217 ^
6602c82f ^

708eae31 ^
f1b3d7b9 ^


a413105a ^
630433cd ^
f1b3d7b9 ^
a413105a ^
a413105a ^
f1b3d7b9 ^
9527eda9 ^
f1b3d7b9 ^

4a99a6e0 ^
f1b3d7b9 ^

a413105a ^
f1b3d7b9 ^



6362c51d ^



9ad81331 ^
6362c51d ^
c442a5ad ^

f1b3d7b9 ^
708eae31 ^

9527eda9 ^
96b2216b ^
fd7198b2 ^
96b2216b ^
fd7198b2 ^
96b2216b ^



414d9413 ^
96b2216b ^



630433cd ^
96b2216b ^

414d9413 ^
4a99a6e0 ^

630433cd ^

fd7198b2 ^
630433cd ^

9527eda9 ^

665a4d70 ^
9527eda9 ^

630433cd ^
96b2216b ^


1f4d0aaf ^
fbc21293 ^
44fdc79f ^






6f6d458f ^




c88b9e31 ^

e5998f74 ^

1f4d0aaf ^
e0a0484c ^
e5998f74 ^
c442a5ad ^
e0a0484c ^
7a22a219 ^

e0a0484c ^
7a22a219 ^
e0a0484c ^

708eae31 ^



96b2216b ^



414d9413 ^


1a33d221 ^
708eae31 ^
cd23c8b6 ^
414d9413 ^


2097401c ^
708eae31 ^


708eae31 ^
087a998e ^
a066ad7e ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190