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

r8523:5b7da468 default
r9115:b55d4471 default
Show More
test-convert-svn-source
89 lines | 2.0 KiB | text/plain | TextLexer
/ tests / test-convert-svn-source
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513 #!/bin/sh
"$TESTDIR/hghave" svn svn-bindings || exit 80
fix_path()
{
tr '\\' /
}
echo "[extensions]" >> $HGRCPATH
echo "convert = " >> $HGRCPATH
Patrick Mezard
test-convert-svn-source: remove redundant tests
r6401 echo 'hgext.graphlog =' >> $HGRCPATH
Bryan O'Sullivan
convert: add support for Subversion as a sink
r5513
svnadmin create svn-repo
svnpath=`pwd | fix_path`
# SVN wants all paths to start with a slash. Unfortunately,
# Windows ones don't. Handle that.
expr $svnpath : "\/" > /dev/null
if [ $? -ne 0 ]; then
svnpath='/'$svnpath
fi
Edouard Gomez
convert: separate trunk detection from branch layout detection...
r5854 echo "# now tests that it works with trunk/tags layout, but no branches yet"
echo
echo % initial svn import
mkdir projB
cd projB
mkdir trunk
mkdir tags
cd ..
Patrick Mezard
convert: properly encode subversion URLs (issue 1224)
r7074 svnurl=file://$svnpath/svn-repo/proj%20B
Edouard Gomez
convert: separate trunk detection from branch layout detection...
r5854 svn import -m "init projB" projB $svnurl | fix_path
echo % update svn repository
svn co $svnurl/trunk B | fix_path
cd B
Patrick Mezard
convert: properly encode subversion URLs (issue 1224)
r7074 echo hello > 'letter .txt'
svn add 'letter .txt'
Edouard Gomez
convert: separate trunk detection from branch layout detection...
r5854 svn ci -m hello
Patrick Mezard
convert: properly encode subversion URLs (issue 1224)
r7074 "$TESTDIR/svn-safe-append.py" world 'letter .txt'
Edouard Gomez
convert: separate trunk detection from branch layout detection...
r5854 svn ci -m world
svn copy -m "tag v0.1" $svnurl/trunk $svnurl/tags/v0.1
Patrick Mezard
convert: properly encode subversion URLs (issue 1224)
r7074 "$TESTDIR/svn-safe-append.py" 'nice day today!' 'letter .txt'
Edouard Gomez
convert: separate trunk detection from branch layout detection...
r5854 svn ci -m "nice day"
cd ..
echo % convert to hg once
hg convert $svnurl B-hg
echo % update svn repository again
cd B
Patrick Mezard
convert: properly encode subversion URLs (issue 1224)
r7074 "$TESTDIR/svn-safe-append.py" "see second letter" 'letter .txt'
Edouard Gomez
convert: separate trunk detection from branch layout detection...
r5854 echo "nice to meet you" > letter2.txt
svn add letter2.txt
svn ci -m "second letter"
svn copy -m "tag v0.2" $svnurl/trunk $svnurl/tags/v0.2
Peter Arrenbrecht
convert: fix test-convert-svn-* problems with mtime not changing...
r6439 "$TESTDIR/svn-safe-append.py" "blah-blah-blah" letter2.txt
Edouard Gomez
convert: separate trunk detection from branch layout detection...
r5854 svn ci -m "work in progress"
cd ..
Patrick Mezard
test-convert-svn-source: remove redundant tests
r6401 ########################################
Edouard Gomez
convert: separate trunk detection from branch layout detection...
r5854 echo % test incremental conversion
hg convert $svnurl B-hg
cd B-hg
Martin Geisler
tests: replace #...# syntax with {...}
r8523 hg glog --template '{rev} {desc|firstline} files: {files}\n'
Edouard Gomez
convert: separate trunk detection from branch layout detection...
r5854 hg tags -q
cd ..
Patrick Mezard
test-convert-svn-source: remove redundant tests
r6401
echo % test filemap
echo 'include letter2.txt' > filemap
hg convert --filemap filemap $svnurl/trunk fmap
Martin Geisler
tests: replace #...# syntax with {...}
r8523 hg glog -R fmap --template '{rev} {desc|firstline} files: {files}\n'
Patrick Mezard
test-convert-svn-source: remove redundant tests
r6401
echo % test stop revision
hg convert --rev 1 $svnurl/trunk stoprev
# Check convert_revision extra-records.
# This is also the only place testing more than one extra field
# in a revision.
hg --cwd stoprev tip --debug | grep extra | sed 's/=.*/=/'