##// END OF EJS Templates
inotify: fix replacing a folder with a file (issue1375)
Benoit Boissinot -
r7350:c5dbe86b default
parent child Browse files
Show More
@@ -19,6 +19,9 b' except ImportError:'
19
19
20 class AlreadyStartedException(Exception): pass
20 class AlreadyStartedException(Exception): pass
21
21
22 class statusdict(dict):
23 status = None
24
22 def join(a, b):
25 def join(a, b):
23 if a:
26 if a:
24 if a[-1] == '/':
27 if a[-1] == '/':
@@ -222,7 +225,7 b' class Watcher(object):'
222 def dir(self, tree, path):
225 def dir(self, tree, path):
223 if path:
226 if path:
224 for name in path.split('/'):
227 for name in path.split('/'):
225 tree.setdefault(name, {})
228 tree.setdefault(name, statusdict())
226 tree = tree[name]
229 tree = tree[name]
227 return tree
230 return tree
228
231
@@ -232,9 +235,11 b' class Watcher(object):'
232 for name in path.split('/'):
235 for name in path.split('/'):
233 tree = tree[name]
236 tree = tree[name]
234 except KeyError:
237 except KeyError:
235 return 'x'
238 tree = statusdict()
239 tree.status = 'x'
236 except TypeError:
240 except TypeError:
237 return 'd'
241 tree = statusdict()
242 tree.status = 'd'
238 return tree
243 return tree
239
244
240 def split(self, path):
245 def split(self, path):
@@ -272,7 +277,7 b' class Watcher(object):'
272 self.statcache.pop(wfn, None)
277 self.statcache.pop(wfn, None)
273 root, fn = self.split(wfn)
278 root, fn = self.split(wfn)
274 d = self.dir(self.tree, root)
279 d = self.dir(self.tree, root)
275 oldstatus = d.get(fn)
280 oldstatus = d.setdefault(fn, statusdict()).status
276 isdir = False
281 isdir = False
277 if oldstatus:
282 if oldstatus:
278 try:
283 try:
@@ -297,11 +302,11 b' class Watcher(object):'
297 (wfn, oldstatus, status))
302 (wfn, oldstatus, status))
298 if not isdir:
303 if not isdir:
299 if status and status != 'i':
304 if status and status != 'i':
300 d[fn] = status
305 d[fn].status = status
301 if status in self.statuskeys:
306 if status in self.statuskeys:
302 dd = self.dir(self.statustrees[status], root)
307 dd = self.dir(self.statustrees[status], root)
303 if oldstatus != status or fn not in dd:
308 if oldstatus != status or fn not in dd:
304 dd[fn] = status
309 dd.setdefault(fn, statusdict()).status = status
305 else:
310 else:
306 d.pop(fn, None)
311 d.pop(fn, None)
307
312
@@ -363,12 +368,10 b' class Watcher(object):'
363
368
364 for name, val in tree.iteritems():
369 for name, val in tree.iteritems():
365 path = join(prefix, name)
370 path = join(prefix, name)
366 try:
371 if val.status is not None and val.status in states:
367 if val in states:
372 yield path, val
368 yield path, val
373 for p in self.walk(states, val, path):
369 except TypeError:
374 yield p
370 for p in self.walk(states, val, path):
371 yield p
372
375
373 def update_hgignore(self):
376 def update_hgignore(self):
374 # An update of the ignore file can potentially change the
377 # An update of the ignore file can potentially change the
@@ -619,12 +622,10 b' class Server(object):'
619 def genresult(states, tree):
622 def genresult(states, tree):
620 for fn in names:
623 for fn in names:
621 l = self.watcher.lookup(fn, tree)
624 l = self.watcher.lookup(fn, tree)
622 try:
625 if l.status is not None and l.status in states:
623 if l in states:
626 yield fn
624 yield fn
627 for f, s in self.watcher.walk(states, l, fn):
625 except TypeError:
628 yield f
626 for f, s in self.watcher.walk(states, l, fn):
627 yield f
628
629
629 results = ['\0'.join(r) for r in [
630 results = ['\0'.join(r) for r in [
630 genresult('l', self.watcher.statustrees['l']),
631 genresult('l', self.watcher.statustrees['l']),
@@ -13,6 +13,9 b' hg ci -Am m'
13
13
14 echo "[extensions]" >> $HGRCPATH
14 echo "[extensions]" >> $HGRCPATH
15 echo "inotify=" >> $HGRCPATH
15 echo "inotify=" >> $HGRCPATH
16 echo "[inotify]" >> $HGRCPATH
17 echo "debug=1" >> $HGRCPATH
18 echo "log=/tmp/inot.log" >> $HGRCPATH
16
19
17 echo % inserve
20 echo % inserve
18 hg inserve -d --pid-file=hg.pid
21 hg inserve -d --pid-file=hg.pid
@@ -27,4 +30,28 b' hg status -c'
27 echo % all
30 echo % all
28 hg status -A
31 hg status -A
29
32
33 #issue 1375
34 #Testing that we can remove a folder and then add a file with the same name
35
36 mkdir h f g
37 echo h > h/h
38 echo f > f/f
39 echo g > g/g
40
41 hg ci -Am t
42 sleep 1
43 hg rm h
44 hg rm f
45 sleep 1
46 echo h >h
47 ln -s g f
48
49 hg add h
50 sleep 1
51 hg add f
52
53 hg status
54 hg ci -m0
55 hg status
30 kill `cat hg.pid`
56 kill `cat hg.pid`
57
@@ -8,6 +8,8 b' touch a b c d e f'
8
8
9 echo "[extensions]" >> $HGRCPATH
9 echo "[extensions]" >> $HGRCPATH
10 echo "inotify=" >> $HGRCPATH
10 echo "inotify=" >> $HGRCPATH
11 echo "[inotify]" >> $HGRCPATH
12 echo "debug = 1" >> $HGRCPATH
11 echo inserv1
13 echo inserv1
12
14
13 echo % inserve
15 echo % inserve
@@ -27,6 +29,7 b' echo c >> c'
27 touch g
29 touch g
28 hg add g
30 hg add g
29 hg mv e h
31 hg mv e h
32 sleep 1
30 hg status
33 hg status
31
34
32 sleep 1
35 sleep 1
@@ -27,3 +27,13 b' C dir/bar/foo'
27 C dir/x
27 C dir/x
28 C dir/y
28 C dir/y
29 C e
29 C e
30 adding f/f
31 adding g/g
32 adding h/h
33 adding hg.pid
34 removing h/h
35 removing f/f
36 A f
37 A h
38 R f/f
39 R h/h
General Comments 0
You need to be logged in to leave comments. Login now