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

r8350:1f0f01bc default
r9115:b55d4471 default
Show More
test-convert-cvs-synthetic
120 lines | 2.5 KiB | text/plain | TextLexer
/ tests / test-convert-cvs-synthetic
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862 #!/bin/sh
# This feature requires use of builtin cvsps!
"$TESTDIR/hghave" cvs || exit 80
set -e
echo "[extensions]" >> $HGRCPATH
echo "convert = " >> $HGRCPATH
Greg Ward
Reproduce crash where synthetic revs break merge detection (issue1578)....
r8249 echo "graphlog = " >> $HGRCPATH
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862 echo "[convert]" >> $HGRCPATH
echo "cvsps=builtin" >> $HGRCPATH
echo % create cvs repository with one project
mkdir cvsrepo
cd cvsrepo
Martin Geisler
tests: avoid export FOO=bar bashism
r8350 CVSROOT=`pwd`
export CVSROOT
CVS_OPTIONS=-f
export CVS_OPTIONS
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862 cd ..
Greg Ward
issue1577: fix broken test by assuming less about CVS output....
r8081 filterpath()
{
eval "$@" | sed "s:$CVSROOT:*REPO*:g"
}
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862 cvscall()
{
Greg Ward
issue1577: fix broken test by assuming less about CVS output....
r8081 echo cvs -f "$@"
cvs -f "$@" 2>&1
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862 }
Greg Ward
issue1577: fix broken test by assuming less about CVS output....
r8081 # output of 'cvs ci' varies unpredictably, so just discard it
cvsci()
{
echo cvs -f ci "$@"
cvs -f ci "$@" >/dev/null 2>&1
}
filterpath cvscall -d "$CVSROOT" init
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862 mkdir cvsrepo/proj
Greg Ward
issue1577: fix broken test by assuming less about CVS output....
r8081 cvscall -q co proj
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862
echo % create file1 on the trunk
cd proj
touch file1
Greg Ward
issue1577: fix broken test by assuming less about CVS output....
r8081 cvscall -Q add file1
cvsci -m"add file1 on trunk" file1
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862
echo % create two branches
Greg Ward
issue1577: fix broken test by assuming less about CVS output....
r8081 cvscall -q tag -b v1_0
cvscall -q tag -b v1_1
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862
echo % create file2 on branch v1_0
Greg Ward
Reproduce crash where synthetic revs break merge detection (issue1578)....
r8249 cvscall -Q up -rv1_0
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862 touch file2
Greg Ward
issue1577: fix broken test by assuming less about CVS output....
r8081 cvscall -Q add file2
Greg Ward
Reproduce crash where synthetic revs break merge detection (issue1578)....
r8249 cvsci -m"add file2" file2
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862
echo % create file3, file4 on branch v1_1
Greg Ward
issue1577: fix broken test by assuming less about CVS output....
r8081 cvscall -Q up -rv1_1
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862 touch file3
touch file4
Greg Ward
issue1577: fix broken test by assuming less about CVS output....
r8081 cvscall -Q add file3 file4
cvsci -m"add file3, file4 on branch v1_1" file3 file4
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862
echo % merge file2 from v1_0 to v1_1
Greg Ward
Reproduce crash where synthetic revs break merge detection (issue1578)....
r8249 cvscall -Q up -jv1_0
cvsci -m"MERGE from v1_0: add file2"
# Step things up a notch: now we make the history really hairy, with
# changes bouncing back and forth between trunk and v1_2 and merges
# going both ways. (I.e., try to model the real world.)
echo "% create branch v1_2"
cvscall -Q up -A
cvscall -q tag -b v1_2
echo "% create file5 on branch v1_2"
cvscall -Q up -rv1_2
touch file5
cvs -Q add file5
cvsci -m"add file5 on v1_2"
echo "% create file6 on trunk post-v1_2"
cvscall -Q up -A
touch file6
cvscall -Q add file6
cvsci -m"add file6 on trunk post-v1_2"
echo "% merge file5 from v1_2 to trunk"
cvscall -Q up -A
cvscall -Q up -jv1_2 file5
cvsci -m"MERGE from v1_2: add file5"
echo "% merge file6 from trunk to v1_2"
cvscall -Q up -rv1_2
cvscall up -jHEAD file6
cvsci -m"MERGE from HEAD: add file6"
Greg Ward
issue1577: fix broken test by assuming less about CVS output....
r8081
echo % cvs rlog output
filterpath cvscall -q rlog proj | egrep '^(RCS file|revision)'
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862
Greg Ward
Reproduce crash where synthetic revs break merge detection (issue1578)....
r8249 echo "% convert to hg (#1)"
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862 cd ..
Greg Ward
Reproduce crash where synthetic revs break merge detection (issue1578)....
r8249 filterpath hg convert --datesort proj proj.hg
echo "% hg glog output (#1)"
hg -R proj.hg glog --template "{rev} {desc}\n"
Greg Ward
cvsps: recognize and eliminate CVS' synthetic "file added" revisions.
r7862
Greg Ward
Reproduce crash where synthetic revs break merge detection (issue1578)....
r8249 echo "% convert to hg (#2: with merge detection)"
filterpath hg convert \
--config convert.cvsps.mergefrom="\"^MERGE from (\S+):\"" \
--datesort \
proj proj.hg2
echo "% hg glog output (#2)"
hg -R proj.hg2 glog --template "{rev} {desc}\n"