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

r6859:93690957 default
r9115:b55d4471 default
Show More
test-bisect2
153 lines | 2.9 KiB | text/plain | TextLexer
#!/bin/sh
# The tests in test-bisect are done on a linear history.
# Here the following repository history is used for testing:
#
# 17
# |
# 18 16
# \ /
# 15
# / \
# / \
# 10 13
# / \ |
# / \ | 14
# 7 6 9 12 /
# \ / \ | |/
# 4 \ | 11
# \ \ | /
# 3 5 | /
# \ / |/
# 2 8
# \ /
# 1
# |
# 0
set -e
echo % init
hg init
echo % committing changes
echo > a
echo '0' >> a
hg add a
hg ci -m "0" -d "0 0"
echo '1' >> a
hg ci -m "1" -d "1 0"
echo '2' >> a
hg ci -m "2" -d "2 0"
echo '3' >> a
hg ci -m "3" -d "3 0"
echo '4' >> a
hg ci -m "4" -d "4 0"
# create branch
hg up -r 2
echo '5' >> b
hg add b
hg ci -m "5" -d "5 0"
# merge
hg merge
hg ci -m "merge 4,5" -d "6 0"
# create branch
hg up -r 4
echo '7' > c
hg add c
hg ci -m "7" -d "7 0"
# create branch
hg up -r 1
echo '8' > d
hg add d
hg ci -m "8" -d "8 0"
echo '9' >> d
hg ci -m "9" -d "9 0"
# merge
hg merge -r 6
hg ci -m "merge 6,9" -d "10 0"
# create branch
hg up -r 8
echo '11' > e
hg add e
hg ci -m "11" -d "11 0"
echo '12' >> e
hg ci -m "12" -d "12 0"
echo '13' >> e
hg ci -m "13" -d "13 0"
# create branch
hg up -r 11
echo '14' > f
hg add f
hg ci -m "14" -d "14 0"
# merge
hg up -r 13 -C
hg merge -r 10
hg ci -m "merge 10,13" -d "15 0"
echo '16' >> e
hg ci -m "16" -d "16 0"
echo '17' >> e
hg ci -m "17" -d "17 0"
# create branch
hg up -r 15
echo '18' >> e
hg ci -m "18" -d "18 0"
echo % log
hg log
echo % hg up -C
hg up -C
echo % complex bisect test 1 # first bad rev is 9
hg bisect -r
hg bisect -g 0
hg bisect -b 17 # -> update to rev 6
hg bisect -g # -> update to rev 13
hg bisect -s # -> update to rev 10
hg bisect -b # -> update to rev 8
hg bisect -g # -> update to rev 9
hg bisect -b
echo % complex bisect test 2 # first good rev is 13
hg bisect -r
hg bisect -g 18
hg bisect -b 1 # -> update to rev 6
hg bisect -s # -> update to rev 10
hg bisect -b # -> update to rev 12
hg bisect -b # -> update to rev 13
hg bisect -g
echo % complex bisect test 3
# first bad rev is 15
# 10,9,13 are skipped an might be the first bad revisions as well
hg bisect -r
hg bisect -g 1
hg bisect -b 16 # -> update to rev 6
hg bisect -g # -> update to rev 13
hg bisect -s # -> update to rev 10
hg bisect -s # -> update to rev 12
hg bisect -g # -> update to rev 9
hg bisect -s # -> update to rev 15
hg bisect -b
echo % complex bisect test 4
# first good revision is 17
# 15,16 are skipped an might be the first good revisions as well
hg bisect -r
hg bisect -g 17
hg bisect -b 8 # -> update to rev 10
hg bisect -b # -> update to rev 13
hg bisect -b # -> update to rev 15
hg bisect -s # -> update to rev 16
hg bisect -s