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

r8759:f584d63c default
r9115:b55d4471 default
Show More
test-win32text.out
304 lines | 5.4 KiB | text/plain | TextLexer
/ tests / test-win32text.out
Jesse Glick
Issue 882: add standard hook to reject text files with CRLF....
r5675 [hooks]
pretxncommit.crlf = python:hgext.win32text.forbidcrlf
pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
Bryan O'Sullivan
win32text: be more careful about rejecting violating changesets...
r8147 commit should succeed
Jesse Glick
Issue 882: add standard hook to reject text files with CRLF....
r5675
Adrian Buehlmann
clone: print "updating working directory" status message...
r6338 updating working directory
Jesse Glick
Issue 882: add standard hook to reject text files with CRLF....
r5675 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Bryan O'Sullivan
win32text: be more careful about rejecting violating changesets...
r8147 commit should fail
Attempt to commit or push text file(s) using CRLF line endings
in f583ea08d42a: f
transaction abort!
rollback completed
abort: pretxncommit.crlf hook failed
Jesse Glick
Issue 882: add standard hook to reject text files with CRLF....
r5675
Bryan O'Sullivan
win32text: be more careful about rejecting violating changesets...
r8147 commits should succeed
Jesse Glick
Issue 882: add standard hook to reject text files with CRLF....
r5675
Bryan O'Sullivan
win32text: be more careful about rejecting violating changesets...
r8147 push should fail
pushing to ../zoz
Jesse Glick
Issue 882: add standard hook to reject text files with CRLF....
r5675 searching for changes
adding changesets
adding manifests
adding file changes
Bryan O'Sullivan
win32text: be more careful about rejecting violating changesets...
r8147 added 2 changesets with 2 changes to 2 files
Jesse Glick
Issue 882: add standard hook to reject text files with CRLF....
r5675 Attempt to commit or push text file(s) using CRLF line endings
Bryan O'Sullivan
win32text: be more careful about rejecting violating changesets...
r8147 in b94ebd309a6d: g
in b1aa5cde7ff4: f
Jesse Glick
Issue 882: add standard hook to reject text files with CRLF....
r5675
To prevent this mistake in your local repository,
add to Mercurial.ini or .hg/hgrc:
[hooks]
pretxncommit.crlf = python:hgext.win32text.forbidcrlf
and also consider adding:
[extensions]
hgext.win32text =
[encode]
** = cleverencode:
[decode]
** = cleverdecode:
transaction abort!
rollback completed
abort: pretxnchangegroup.crlf hook failed
Bryan O'Sullivan
win32text: be more careful about rejecting violating changesets...
r8147 commit should succeed
push should succeed
pushing to ../zoz
searching for changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 3 changes to 2 files
and now for something completely different
Attempt to commit or push text file(s) using CRLF line endings
in cefdb8d0b741: d/f2
transaction abort!
rollback completed
abort: pretxncommit.crlf hook failed
forgetting d/f2
changeset: 5:d4ea9ae21be3
Jesse Glick
Issue 882: add standard hook to reject text files with CRLF....
r5675 tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: bin
description:
5
Bryan O'Sullivan
win32text: be more careful about rejecting violating changesets...
r8147 changeset: 4:6ba409927d51
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f
description:
4
changeset: 3:788a4e595187
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f g
description:
2.3
changeset: 2:b94ebd309a6d
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: g
description:
2.2
changeset: 1:b1aa5cde7ff4
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f
description:
2
changeset: 0:fcf06d5c4e1d
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f
description:
1
updating working directory
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
adding dupe/a
adding dupe/b
adding dupe/c
adding dupe/d
changeset: 8:7654104f33c3
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: d
description:
d
changeset: 7:9be4c2808cc9
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: b c
description:
b/c
changeset: 6:aa4367ed325a
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: a
description:
a
changeset: 5:d4ea9ae21be3
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: bin
description:
5
changeset: 4:6ba409927d51
Jesse Glick
Issue 882: add standard hook to reject text files with CRLF....
r5675 user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f
description:
4
Bryan O'Sullivan
win32text: be more careful about rejecting violating changesets...
r8147 changeset: 3:788a4e595187
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f g
description:
2.3
changeset: 2:b94ebd309a6d
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: g
description:
2.2
changeset: 1:b1aa5cde7ff4
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f
description:
2
changeset: 0:fcf06d5c4e1d
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f
description:
1
pulling from dupe
searching for changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 4 changes to 4 files
Attempt to commit or push text file(s) using CRLF line endings
in 7654104f33c3: d
in 9be4c2808cc9: b
in 9be4c2808cc9: c
To prevent this mistake in your local repository,
add to Mercurial.ini or .hg/hgrc:
[hooks]
pretxncommit.crlf = python:hgext.win32text.forbidcrlf
and also consider adding:
[extensions]
hgext.win32text =
[encode]
** = cleverencode:
[decode]
** = cleverdecode:
transaction abort!
rollback completed
abort: pretxnchangegroup.crlf hook failed
changeset: 5:d4ea9ae21be3
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: bin
description:
5
changeset: 4:6ba409927d51
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f
description:
4
changeset: 3:788a4e595187
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f g
description:
2.3
changeset: 2:b94ebd309a6d
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: g
description:
2.2
changeset: 1:b1aa5cde7ff4
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f
description:
2
Jesse Glick
Issue 882: add standard hook to reject text files with CRLF....
r5675 changeset: 0:fcf06d5c4e1d
user: test
date: Thu Jan 01 00:00:00 1970 +0000
files: f
description:
1
Jesse Glick
Provide better context for custom Python encode/decode filters....
r5967 hello<NUL><CR><LF>
some<LF>text<LF>
rem empty<CR><LF>
[extensions]
win32text =
[decode]
** = cleverdecode:
[encode]
** = cleverencode:
WARNING: f4.bat already has CRLF line endings
and does not need EOL conversion by the win32text plugin.
Before your next commit, please reconsider your encode/decode settings in
Mercurial.ini or ..../.hg/hgrc.
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
hello<NUL><CR><LF>
some<CR><LF>text<CR><LF>
rem empty<CR><LF>
# empty<CR><LF>
# empty<LF>
Alexis S. L. Carvalho
revert: update state of files in the "checkout" list...
r6299 % just linefeed<LF>
% just linefeed<LF>
no changes needed to linefeed
% just linefeed<LF>
M linefeed
reverting linefeed
% just linefeed<CR><LF>