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

r8811:8b35b087 default
r9115:b55d4471 default
Show More
test-record
318 lines | 3.9 KiB | text/plain | TextLexer
#!/bin/sh
echo "[ui]" >> $HGRCPATH
echo "interactive=true" >> $HGRCPATH
echo "[extensions]" >> $HGRCPATH
echo "record=" >> $HGRCPATH
echo % help
hg help record
hg init a
cd a
echo % select no files
touch empty-rw
hg add empty-rw
hg record empty-rw<<EOF
n
EOF
echo; hg tip -p
echo % select files but no hunks
hg record empty-rw<<EOF
y
n
EOF
echo; hg tip -p
echo % record empty file
hg record -d '0 0' -m empty empty-rw<<EOF
y
y
EOF
echo; hg tip -p
echo % rename empty file
hg mv empty-rw empty-rename
hg record -d '1 0' -m rename<<EOF
y
EOF
echo; hg tip -p
echo % copy empty file
hg cp empty-rename empty-copy
hg record -d '2 0' -m copy<<EOF
y
EOF
echo; hg tip -p
echo % delete empty file
hg rm empty-copy
hg record -d '3 0' -m delete<<EOF
y
EOF
echo; hg tip -p
echo % add binary file
hg bundle --base -2 tip.bundle
hg add tip.bundle
hg record -d '4 0' -m binary<<EOF
y
EOF
echo; hg tip -p
echo % change binary file
hg bundle --base -2 tip.bundle
hg record -d '5 0' -m binary-change<<EOF
y
EOF
echo; hg tip -p
echo % rename and change binary file
hg mv tip.bundle top.bundle
hg bundle --base -2 top.bundle
hg record -d '6 0' -m binary-change-rename<<EOF
y
EOF
echo; hg tip -p
echo % add plain file
for i in 1 2 3 4 5 6 7 8 9 10; do
echo $i >> plain
done
hg add plain
hg record -d '7 0' -m plain plain<<EOF
y
y
EOF
echo; hg tip -p
echo % modify end of plain file
echo 11 >> plain
hg record -d '8 0' -m end plain <<EOF
y
y
EOF
echo % modify end of plain file, no EOL
hg tip --template '{node}' >> plain
hg record -d '9 0' -m noeol plain <<EOF
y
y
EOF
echo % modify end of plain file, add EOL
echo >> plain
hg record -d '10 0' -m eol plain <<EOF
y
y
y
EOF
echo % modify beginning, trim end, record both
rm plain
for i in 2 2 3 4 5 6 7 8 9 10; do
echo $i >> plain
done
hg record -d '10 0' -m begin-and-end plain <<EOF
y
y
y
EOF
echo; hg tip -p
echo % trim beginning, modify end
rm plain
for i in 4 5 6 7 8 9 10.new; do
echo $i >> plain
done
echo % record end
hg record -d '11 0' -m end-only plain <<EOF
y
n
y
EOF
echo; hg tip -p
echo % record beginning
hg record -d '12 0' -m begin-only plain <<EOF
y
y
EOF
echo; hg tip -p
echo % add to beginning, trim from end
rm plain
for i in 1 2 3 4 5 6 7 8 9; do
echo $i >> plain
done
echo % record end
hg record --traceback -d '13 0' -m end-again plain<<EOF
y
n
y
EOF
echo % add to beginning, middle, end
rm plain
for i in 1 2 3 4 5 5.new 5.reallynew 6 7 8 9 10 11; do
echo $i >> plain
done
echo % record beginning, middle
hg record -d '14 0' -m middle-only plain <<EOF
y
y
y
n
EOF
echo; hg tip -p
echo % record end
hg record -d '15 0' -m end-only plain <<EOF
y
y
EOF
echo; hg tip -p
mkdir subdir
cd subdir
echo a > a
hg ci -d '16 0' -Amsubdir
echo a >> a
hg record -d '16 0' -m subdir-change a <<EOF
y
y
EOF
echo; hg tip -p
echo a > f1
echo b > f2
hg add f1 f2
hg ci -mz -d '17 0'
echo a >> f1
echo b >> f2
echo % help, quit
hg record <<EOF
?
q
EOF
echo % skip
hg record <<EOF
s
EOF
echo % no
hg record <<EOF
n
EOF
echo % f, quit
hg record <<EOF
f
q
EOF
echo % s, all
hg record -d '18 0' -mx <<EOF
s
a
EOF
echo; hg tip -p
echo % f
hg record -d '19 0' -my <<EOF
f
EOF
echo; hg tip -p
echo % preserve chmod +x
chmod +x f1
echo a >> f1
hg record -d '20 0' -mz <<EOF
y
y
y
EOF
echo; hg tip --config diff.git=True -p
echo % preserve execute permission on original
echo b >> f1
hg record -d '21 0' -maa <<EOF
y
y
y
EOF
echo; hg tip --config diff.git=True -p
echo % preserve chmod -x
chmod -x f1
echo c >> f1
hg record -d '22 0' -mab <<EOF
y
y
y
EOF
echo; hg tip --config diff.git=True -p
echo % with win32ext
cd ..
echo '[extensions]' >> .hg/hgrc
echo 'win32text = ' >> .hg/hgrc
echo '[decode]' >> .hg/hgrc
echo '** = cleverdecode:' >> .hg/hgrc
echo '[encode]' >> .hg/hgrc
echo '** = cleverencode:' >> .hg/hgrc
echo '[patch]' >> .hg/hgrc
echo 'eol = crlf' >> .hg/hgrc
echo d >> subdir/f1
hg record -d '23 0' -mw1 <<EOF
y
y
EOF
echo; hg tip -p