##// END OF EJS Templates
inotify: server: new data structure to keep track of changes....
inotify: server: new data structure to keep track of changes. == Rationale for the new structure == Current structure was a dictionary tree. One directory was tracked as a dictionary: - keys: file/subdir name - values: - for a file, the status (a/r/m/...) - for a subdir, the directory representing the subdir It allowed efficient lookups, no matter of the type of the terminal leaf: for part in path.split('/'): tree = tree[part] However, there is no way to represent a directory and a file with the same name because keys are conflicting in the dictionary. Concrete example: Initial state: root dir |- foo (file) |- bar (file) # data state is: {'foo': 'n', 'bar': 'n'} Remove foo: root dir |- bar (file) # Data becomes {'foo': 'r'} until next commit. Add foo, as a directory, and foo/barbar file: root dir |- bar (file) |-> foo (dir) |- barbar (file) # New state should be represented as: {'foo': {'barbar': 'a'}, 'bar': 'n'} however, the key "foo" is already used and represents the old file. The dirstate: D foo A foo/barbar cannot be represented, hence the need for a new structure. == The new structure == 'directory' class. Represents one directory level. * Notable attributes: Two dictionaries: - 'files' Maps filename -> status for the current dir. - 'dirs' Maps subdir's name -> directory object representing the subdir * methods - walk(), formerly server.walk - lookup(), old server.lookup - dir(), old server.dir This new class allows embedding all the tree walks/lookups in its own class, instead of having everything mixed together in server. Incidently, since files and directories are not stored in the same dictionaries, we are solving the previous key conflict problem. The small drawback is that lookup operation is a bit more complex: for a path a/b/c/d/e we have to check twice the leaf, if e is a directory or a file.

File last commit:

r4308:a5cde03c default
r9115:b55d4471 default
Show More
test-locate
56 lines | 915 B | text/plain | TextLexer
Benoit Boissinot
fix locate broken since 63799b01985c...
r1622 #!/bin/sh
Alexis S. L. Carvalho
make the output of test-locate more readable
r4234
hglocate()
{
echo "hg locate $@"
hg locate "$@"
ret=$?
echo
return $ret
}
Benoit Boissinot
fix locate broken since 63799b01985c...
r1622 mkdir t
cd t
hg init
echo 0 > a
echo 0 > b
Brendan Cully
Test case for #294
r2487 echo 0 > t.h
Vadim Gelfer
fix -I/-X when relative paths used or in subdir
r2480 mkdir t
echo 0 > t/x
Alexis S. L. Carvalho
add some more tests to hg locate
r4235 echo 0 > t/b
echo 0 > t/e.h
Alexis S. L. Carvalho
change relglob: patterns to be consistent with glob: patterns...
r4307 mkdir dir.h
echo 0 > dir.h/foo
Thomas Arendsen Hein
Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero....
r1933 hg ci -A -m m -d "1000000 0"
Benoit Boissinot
fix locate broken since 63799b01985c...
r1622 touch nottracked
Alexis S. L. Carvalho
make the output of test-locate more readable
r4234 hglocate a && echo locate succeeded || echo locate failed
hglocate NONEXISTENT && echo locate succeeded || echo locate failed
hglocate
Benoit Boissinot
fix locate broken since 63799b01985c...
r1622 hg rm a
Thomas Arendsen Hein
Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero....
r1933 hg ci -m m -d "1000000 0"
Alexis S. L. Carvalho
make the output of test-locate more readable
r4234 hglocate a
hglocate NONEXISTENT
Alexis S. L. Carvalho
locate: don't print "file not found" messages....
r4308 hglocate relpath:NONEXISTENT
Alexis S. L. Carvalho
make the output of test-locate more readable
r4234 hglocate
hglocate -r 0 a
hglocate -r 0 NONEXISTENT
Alexis S. L. Carvalho
locate: don't print "file not found" messages....
r4308 hglocate -r 0 relpath:NONEXISTENT
Alexis S. L. Carvalho
make the output of test-locate more readable
r4234 hglocate -r 0
Vadim Gelfer
fix -I/-X when relative paths used or in subdir
r2480 echo % -I/-X with relative path should work
cd t
Alexis S. L. Carvalho
make the output of test-locate more readable
r4234 hglocate
hglocate -I ../t
Brendan Cully
Test case for #294
r2487 # test issue294
cd ..
Thomas Arendsen Hein
Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
r3988 rm -r t
Alexis S. L. Carvalho
change relglob: patterns to be consistent with glob: patterns...
r4307 hglocate 't/**'
Alexis S. L. Carvalho
add some more tests to hg locate
r4235 mkdir otherdir
cd otherdir
hglocate b
hglocate '*.h'
hglocate path:t/x
Alexis S. L. Carvalho
change relglob: patterns to be consistent with glob: patterns...
r4307 hglocate 're:.*\.h$'
Alexis S. L. Carvalho
add some more tests to hg locate
r4235 hglocate -r 0 b
hglocate -r 0 '*.h'
hglocate -r 0 path:t/x
Alexis S. L. Carvalho
change relglob: patterns to be consistent with glob: patterns...
r4307 hglocate -r 0 're:.*\.h$'