##// 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:

r8489:1a96f1d9 default
r9115:b55d4471 default
Show More
test-addremove-similar.out
32 lines | 986 B | text/plain | TextLexer
/ tests / test-addremove-similar.out
Erling Ellingsen
Avoid some false positives for addremove -s...
r4135 adding empty-file
adding large-file
adding another-file
removing empty-file
removing large-file
recording removal of large-file as rename to another-file (99% similar)
Thomas Arendsen Hein
addremove: comparing two empty files caused ZeroDivisionError...
r4472 % comparing two empty files caused ZeroDivisionError in the past
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
adding another-empty-file
removing empty-file
Erling Ellingsen
Avoid some false positives for addremove -s...
r4135 adding large-file
adding tiny-file
Matt Mackall
dirstate.walk: push sorting up
r6827 removing large-file
Erling Ellingsen
Avoid some false positives for addremove -s...
r4135 adding small-file
removing tiny-file
recording removal of tiny-file as rename to small-file (82% similar)
Bryan O'Sullivan
addremove: print meaningful error message if --similar not numeric
r4966 % should all fail
abort: similarity must be a number
abort: similarity must be between 0 and 100
abort: similarity must be between 0 and 100
Benoit Boissinot
addremove/findrenames: find renames according to the match object (issue1527)...
r8489 % issue 1527
removing d/a
adding d/b
recording removal of d/a as rename to d/b (100% similar)
r 0 0 1970-01-01 00:00:00 d/a
a 0 -1 unset d/b
copy: d/a -> d/b
% no copies found here (since the target isn't in d
removing d/b
% copies here
adding c
recording removal of d/a as rename to c (100% similar)