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

r8049:99e5f97c default
r9115:b55d4471 default
Show More
test-convert-svn-sink
136 lines | 2.5 KiB | text/plain | TextLexer
/ tests / test-convert-svn-sink
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 #!/bin/sh
Mads Kiilerich
tests: Skip tests if they will fail because of outer repo...
r7429 "$TESTDIR/hghave" svn svn-bindings no-outer-repo || exit 80
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 fixpath()
{
tr '\\' /
}
svnupanddisplay()
{
(
Thomas Arendsen Hein
Removed trailing spaces from everything except test output
r6210 cd $1;
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 svn up;
Augie Fackler
test-convert-svn-sink: rewrite output for svn compatibility...
r8049 svn st -v | fixpath | sed 's/ */ /g'
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 limit=''
if [ $2 -gt 0 ]; then
limit="--limit=$2"
fi
Augie Fackler
test-convert-svn-sink: rewrite output for svn compatibility...
r8049 svn log --xml -v $limit | fixpath | sed 's,<date>.*,<date/>,' | grep -v 'kind="'
Thomas Arendsen Hein
Removed trailing spaces from everything except test output
r6210 )
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 }
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 echo "[extensions]" >> $HGRCPATH
echo "convert = " >> $HGRCPATH
hg init a
echo a > a/a
Patrick Mezard
test-convert-svn-sink: test directory additions
r5538 mkdir -p a/d1/d2
echo b > a/d1/d2/b
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 echo % add
hg --cwd a ci -d '0 0' -A -m 'add a file'
Peter Arrenbrecht
convert: fix test-convert-svn-* problems with mtime not changing...
r6439 "$TESTDIR/svn-safe-append.py" a a/a
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 echo % modify
hg --cwd a ci -d '1 0' -m 'modify a file'
hg --cwd a tip -q
hg convert -d svn a
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 svnupanddisplay a-hg-wc 2
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 ls a a-hg-wc
cmp a/a a-hg-wc/a && echo same || echo different
hg --cwd a mv a b
echo % rename
hg --cwd a ci -d '2 0' -m 'rename a file'
hg --cwd a tip -q
hg convert -d svn a
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 svnupanddisplay a-hg-wc 1
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 ls a a-hg-wc
hg --cwd a cp b c
echo % copy
hg --cwd a ci -d '3 0' -m 'copy a file'
hg --cwd a tip -q
hg convert -d svn a
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 svnupanddisplay a-hg-wc 1
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 ls a a-hg-wc
hg --cwd a rm b
echo % remove
hg --cwd a ci -d '4 0' -m 'remove a file'
hg --cwd a tip -q
hg convert -d svn a
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 svnupanddisplay a-hg-wc 1
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 ls a a-hg-wc
chmod +x a/c
echo % executable
hg --cwd a ci -d '5 0' -m 'make a file executable'
hg --cwd a tip -q
hg convert -d svn a
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 svnupanddisplay a-hg-wc 1
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 test -x a-hg-wc/c && echo executable || echo not executable
Maxim Dounin
convert: svn-sink: copy and set properties after adding dirs/files...
r5698 echo % executable in new directory
rm -rf a a-hg a-hg-wc
hg init a
mkdir a/d1
echo a > a/d1/a
chmod +x a/d1/a
hg --cwd a ci -d '0 0' -A -m 'add executable file in new directory'
hg convert -d svn a
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 svnupanddisplay a-hg-wc 1
Maxim Dounin
convert: svn-sink: copy and set properties after adding dirs/files...
r5698 test -x a-hg-wc/d1/a && echo executable || echo not executable
echo % copy to new directory
mkdir a/d2
hg --cwd a cp d1/a d2/a
hg --cwd a ci -d '1 0' -A -m 'copy file to new directory'
hg convert -d svn a
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 svnupanddisplay a-hg-wc 1
Maxim Dounin
convert: svn-sink: copy and set properties after adding dirs/files...
r5698
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 echo % branchy history
hg init b
echo base > b/b
hg --cwd b ci -d '0 0' -Ambase
Peter Arrenbrecht
convert: fix test-convert-svn-* problems with mtime not changing...
r6439 "$TESTDIR/svn-safe-append.py" left-1 b/b
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 echo left-1 > b/left-1
hg --cwd b ci -d '1 0' -Amleft-1
Peter Arrenbrecht
convert: fix test-convert-svn-* problems with mtime not changing...
r6439 "$TESTDIR/svn-safe-append.py" left-2 b/b
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 echo left-2 > b/left-2
hg --cwd b ci -d '2 0' -Amleft-2
hg --cwd b up 0
Peter Arrenbrecht
convert: fix test-convert-svn-* problems with mtime not changing...
r6439 "$TESTDIR/svn-safe-append.py" right-1 b/b
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 echo right-1 > b/right-1
hg --cwd b ci -d '3 0' -Amright-1
Peter Arrenbrecht
convert: fix test-convert-svn-* problems with mtime not changing...
r6439 "$TESTDIR/svn-safe-append.py" right-2 b/b
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 echo right-2 > b/right-2
hg --cwd b ci -d '4 0' -Amright-2
hg --cwd b up -C 2
hg --cwd b merge
hg --cwd b revert -r 2 b
Stefano Tortarolo
make commit fail when committing unresolved files
r6888 hg resolve -m b
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 hg --cwd b ci -d '5 0' -m 'merge'
hg convert -d svn b
echo % expect 4 changes
Patrick Mezard
test-convert-svn-sink: wrap repetitive svn checks in a function
r5808 svnupanddisplay b-hg-wc 0