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

r5764:8a5d8fb5 default
r9115:b55d4471 default
Show More
test-copy2.out
47 lines | 1.7 KiB | text/plain | TextLexer
Alexis S. L. Carvalho
Make hg add foo; hg mv foo bar work....
r4744 # should fail - foo is not managed
foo: not copying - file is not managed
abort: no files to copy
? foo
# dry-run; print a warning that this is not a real copy; foo is added
Alexis S. L. Carvalho
improve warning for hg add foo; hg mv foo bar
r4833 foo has not been committed yet, so no copy data will be stored for bar.
Alexis S. L. Carvalho
Make hg add foo; hg mv foo bar work....
r4744 A foo
# should print a warning that this is not a real copy; bar is added
Alexis S. L. Carvalho
improve warning for hg add foo; hg mv foo bar
r4833 foo has not been committed yet, so no copy data will be stored for bar.
Alexis S. L. Carvalho
Make hg add foo; hg mv foo bar work....
r4744 A bar
# should print a warning that this is not a real copy; foo is added
Alexis S. L. Carvalho
improve warning for hg add foo; hg mv foo bar
r4833 bar has not been committed yet, so no copy data will be stored for foo.
Alexis S. L. Carvalho
Make hg add foo; hg mv foo bar work....
r4744 A foo
# dry-run; should show that foo is clean
Matt Mackall
Backed out changeset c2a21fe60994...
r5764 C foo
mpm@selenic.com
fix some rename/copy bugs...
r1117 # should show copy
Alexis S. L. Carvalho
test-copy2: use status -C instead of debugstate | grep copy
r4743 A bar
foo
mpm@selenic.com
fix some rename/copy bugs...
r1117 # shouldn't show copy
# should match
rev offset length base linkrev nodeid p1 p2
0 0 5 0 0 2ed2a3912a0b 000000000000 000000000000
Matt Mackall
refactor debugrenamed
r3652 bar renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
mpm@selenic.com
fix some rename/copy bugs...
r1117 # should not be renamed
Matt Mackall
refactor debugrenamed
r3652 bar not renamed
mpm@selenic.com
fix some rename/copy bugs...
r1117 # should show copy
Alexis S. L. Carvalho
test-copy2: use status -C instead of debugstate | grep copy
r4743 M bar
foo
mpm@selenic.com
fix some rename/copy bugs...
r1117 # should show no parents for tip
rev offset length base linkrev nodeid p1 p2
0 0 69 0 1 6ca237634e1f 000000000000 000000000000
1 69 6 1 2 7a1ff8e75f5b 6ca237634e1f 000000000000
2 75 82 1 3 243dfe60f3d9 000000000000 000000000000
# should match
rev offset length base linkrev nodeid p1 p2
0 0 5 0 0 2ed2a3912a0b 000000000000 000000000000
1 5 7 1 2 dd12c926cf16 2ed2a3912a0b 000000000000
Matt Mackall
refactor debugrenamed
r3652 bar renamed from foo:dd12c926cf165e3eb4cf87b084955cb617221c17
mpm@selenic.com
fix some rename/copy bugs...
r1117 # should show no copies
Brendan Cully
Make copy --after work for files that have been hg added.
r4376 # copy --after on an added file
A baz
bar
Alexis S. L. Carvalho
dirstate.status: if a file is marked as copied, consider it modified...
r4677 # foo was clean:
Matt Mackall
Backed out changeset c2a21fe60994...
r5764 C foo
Alexis S. L. Carvalho
dirstate.status: if a file is marked as copied, consider it modified...
r4677 # but it's considered modified after a copy --after --force
M foo
bar