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
 
 
e='Blame the previous revision' href='/akkartik/mu/blame/020run.cc?h=main&id=a1968ebb48c06e1cbc2b813a73e4be235da7b3ee'>^
69e14325 ^
95b2a140 ^
1228ec73 ^

7da71d03 ^
0edf822f ^
b24eb476 ^


7da71d03 ^
9fc64bbc ^
363be37f ^
b75e94b3 ^


9fc64bbc ^

b75e94b3 ^
68329610 ^
69e14325 ^
c475ccc3 ^
a7d70735 ^
a767dbd3 ^
9f95c745 ^
795f5244 ^
1b76245c ^
795f5244 ^
35064671 ^
dc269891 ^
fca0ebbe ^
e74a2940 ^
b24eb476 ^
e74a2940 ^
0487a30e ^
dc269891 ^
fca0ebbe ^
dcfca05e ^
f1a6f323 ^
d241c9c4 ^
827898fc ^
d241c9c4 ^

f1a6f323 ^
d241c9c4 ^
dcfca05e ^
d241c9c4 ^
9cf71627 ^
cfb142b9 ^
acc4792d ^
cfb142b9 ^

b24eb476 ^
cfb142b9 ^

0487a30e ^
2dab0edb ^
0d302187 ^
1066660e ^
9fc64bbc ^
9d670bb5 ^
9fc64bbc ^

e74a2940 ^




3c435756 ^


2199940a ^
b24eb476 ^
8eff7919 ^
ec926027 ^

7c8493b3 ^
795f5244 ^
ec926027 ^

dcfca05e ^
795f5244 ^
dcfca05e ^

69e14325 ^
795f5244 ^
ec926027 ^

95b2a140 ^



e5e9f7db ^



0d3f30c2 ^
785a60fa ^

2429c65c ^
8aa4b664 ^

e5e9f7db ^

b39ceb27 ^
2186422c ^
db50f43a ^
e7f76736 ^
cea49fde ^





2429c65c ^
cea49fde ^

e7f76736 ^
ae5f0b6f ^
b39ceb27 ^
2429c65c ^

e7f76736 ^
e5e9f7db ^

b39ceb27 ^
ae5f0b6f ^
0d3f30c2 ^
b39ceb27 ^
6c1376f8 ^

4f10b93a ^
7858a06a ^
cea49fde ^





ae5f0b6f ^
e7f76736 ^
e7f76736 ^

267ebb59 ^
e0551d78 ^
b24eb476 ^
e0551d78 ^

c062021a ^
b24eb476 ^
c062021a ^


b24eb476 ^
c062021a ^

e0551d78 ^
e5e9f7db ^

e0551d78 ^

f78f92c5 ^
11312cec ^
24047016 ^
f78f92c5 ^







2429c65c ^
9f78ec2d ^
2429c65c ^
9f78ec2d ^

267ebb59 ^
f5f4b698 ^
1b76245c ^
f5f4b698 ^

b2ec0969 ^
8c9e97ae ^
267ebb59 ^


9f78ec2d ^





2429c65c ^
9f78ec2d ^



55fc43b7 ^
2429c65c ^
9f78ec2d ^






9c362f85 ^
9f78ec2d ^
7284d503 ^

e5e9f7db ^
fca0ebbe ^
fca0ebbe ^
ab6ed192 ^
a4ef18b1 ^
a26cc359 ^

6700f9f2 ^
b24eb476 ^

6700f9f2 ^

b291f85b ^

cae5461b ^


a2739bc6 ^
0c0bc3ae ^
1b76245c ^
0c0bc3ae ^

6b6dfb0c ^
18429d40 ^
6700f9f2 ^

70179d1f ^
acc4792d ^
35064671 ^
70179d1f ^
6700f9f2 ^
b24eb476 ^
6700f9f2 ^


b291f85b ^
cae5461b ^

c1a50c82 ^
b24eb476 ^
c6034af3 ^
93b7d983 ^
c6034af3 ^
3076bab4 ^
b24eb476 ^
c6034af3 ^

f48f6c14 ^
eaa75c87 ^
decaddb4 ^
70179d1f ^
c6034af3 ^
c91caafd ^
6c1376f8 ^
70179d1f ^


78164bab ^
c6034af3 ^



a0fc38c9 ^

b24eb476 ^
78164bab ^





e5e9f7db ^




7ac8feef ^
390f4097 ^





e5e9f7db ^

decaddb4 ^
1ead3562 ^
decaddb4 ^
bc643692 ^
5497090a ^
decaddb4 ^
acc4792d ^

d7494165 ^
fc55fea0 ^

1ead3562 ^
bc643692 ^
fc55fea0 ^
acc4792d ^
18429d40 ^
bc643692 ^
5f98a10c ^
1ead3562 ^
a0fc38c9 ^
18429d40 ^
bc643692 ^
6d2b1168 ^
677fa104 ^



1ead3562 ^
578327f1 ^
677fa104 ^
578327f1 ^
677fa104 ^

1ead3562 ^
578327f1 ^
677fa104 ^
578327f1 ^
677fa104 ^

1ead3562 ^
578327f1 ^
677fa104 ^
578327f1 ^
677fa104 ^

1ead3562 ^
578327f1 ^
677fa104 ^
578327f1 ^
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385