##// END OF EJS Templates
extensions: register functions always at loading extension (issue5601)...
extensions: register functions always at loading extension (issue5601) Before this patch, functions defined in extensions are registered via extra loaders only in _dispatch(). Therefore, loading extensions in other code paths like below omits registration of functions. - WSGI service - operation across repositories (e.g. subrepo) - test-duplicateoptions.py, using extensions.loadall() directly To register functions always at loading new extension, this patch moves implementation for extra loading from dispatch._dispatch() to extensions.loadall(). AFAIK, only commands module causes cyclic dependency between extensions module, but this patch imports all related modules just before extra loading in loadall(), in order to centralize them. This patch makes extensions.py depend on many other modules, even though extensions.py itself doesn't. It should be avoided if possible, but I don't have any better idea. Some other places like below aren't reasonable for extra loading, IMHO. - specific function in newly added module: existing callers of extensions.loadall() should invoke it, too - hg.repository() or so: no-repo commands aren't covered by this. BTW, this patch removes _loaded.add(name) on relocation, because dispatch._loaded is used only for extraloaders (for similar reason, "exts" variable is removed, too).

File last commit:

r27524:f5b6b4e5 default
r33052:45b0e9d0 default
Show More
test-eol-hook.t
218 lines | 5.9 KiB | text/troff | Tads3Lexer
Matt Mackall
tests: unify test-eol-hook
r12423 Test the EOL hook
$ hg init main
$ cat > main/.hg/hgrc <<EOF
> [hooks]
> pretxnchangegroup = python:hgext.eol.hook
> EOF
$ hg clone main fork
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd fork
Create repo
$ cat > .hgeol <<EOF
> [patterns]
> mixed.txt = BIN
Antoine Pitrou
eol: stop after first matched rule in hook (issue2660)...
r13501 > crlf.txt = CRLF
Matt Mackall
tests: unify test-eol-hook
r12423 > **.txt = native
> EOF
$ hg add .hgeol
$ hg commit -m 'Commit .hgeol'
$ printf "first\nsecond\nthird\n" > a.txt
$ hg add a.txt
$ hg commit -m 'LF a.txt'
$ hg push ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
$ printf "first\r\nsecond\r\nthird\n" > a.txt
$ hg commit -m 'CRLF a.txt'
$ hg push ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Patrick Mezard
eol: improve hook failure output...
r13649 error: pretxnchangegroup hook failed: end-of-line check failed:
a.txt in a8ee6548cd86 should not have CRLF line endings
Matt Mackall
tests: unify test-eol-hook
r12423 transaction abort!
rollback completed
Patrick Mezard
eol: improve hook failure output...
r13649 abort: end-of-line check failed:
a.txt in a8ee6548cd86 should not have CRLF line endings
Matt Mackall
tests: unify test-eol-hook
r12423 [255]
$ printf "first\nsecond\nthird\n" > a.txt
$ hg commit -m 'LF a.txt (fixed)'
$ hg push ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
Antoine Pitrou
eol: stop after first matched rule in hook (issue2660)...
r13501
$ printf "first\nsecond\nthird\n" > crlf.txt
$ hg add crlf.txt
$ hg commit -m 'LF crlf.txt'
$ hg push ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Patrick Mezard
eol: improve hook failure output...
r13649 error: pretxnchangegroup hook failed: end-of-line check failed:
crlf.txt in 004ba2132725 should not have LF line endings
Antoine Pitrou
eol: stop after first matched rule in hook (issue2660)...
r13501 transaction abort!
rollback completed
Patrick Mezard
eol: improve hook failure output...
r13649 abort: end-of-line check failed:
crlf.txt in 004ba2132725 should not have LF line endings
Antoine Pitrou
eol: stop after first matched rule in hook (issue2660)...
r13501 [255]
$ printf "first\r\nsecond\r\nthird\r\n" > crlf.txt
$ hg commit -m 'CRLF crlf.txt (fixed)'
$ hg push ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
Patrick Mezard
eol: make the hook check all new heads, not only tip (issue2666)...
r13616
$ printf "first\r\nsecond" > b.txt
$ hg add b.txt
$ hg commit -m 'CRLF b.txt'
$ hg push ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Patrick Mezard
eol: improve hook failure output...
r13649 error: pretxnchangegroup hook failed: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
Patrick Mezard
eol: make the hook check all new heads, not only tip (issue2666)...
r13616 transaction abort!
rollback completed
Patrick Mezard
eol: improve hook failure output...
r13649 abort: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
Patrick Mezard
eol: make the hook check all new heads, not only tip (issue2666)...
r13616 [255]
$ hg up -r -2
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ printf "some\nother\nfile" > c.txt
$ hg add c.txt
$ hg commit -m "LF c.txt, b.txt doesn't exist here"
created new head
$ hg push -f ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files (+1 heads)
Patrick Mezard
eol: improve hook failure output...
r13649 error: pretxnchangegroup hook failed: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
Patrick Mezard
eol: make the hook check all new heads, not only tip (issue2666)...
r13616 transaction abort!
rollback completed
Patrick Mezard
eol: improve hook failure output...
r13649 abort: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
Patrick Mezard
eol: make the hook check all new heads, not only tip (issue2666)...
r13616 [255]
Patrick Mezard
eol: rename hook into checkheadshook, add checkallhook (issue2665)...
r13617
Test checkheadshook alias
$ cat > ../main/.hg/hgrc <<EOF
> [hooks]
> pretxnchangegroup = python:hgext.eol.checkheadshook
> EOF
$ hg push -f ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files (+1 heads)
Patrick Mezard
eol: improve hook failure output...
r13649 error: pretxnchangegroup hook failed: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
Patrick Mezard
eol: rename hook into checkheadshook, add checkallhook (issue2665)...
r13617 transaction abort!
rollback completed
Patrick Mezard
eol: improve hook failure output...
r13649 abort: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
Patrick Mezard
eol: rename hook into checkheadshook, add checkallhook (issue2665)...
r13617 [255]
We can fix the head and push again
$ hg up 6
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ printf "first\nsecond" > b.txt
$ hg ci -m "remove CRLF from b.txt"
$ hg push -f ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 3 changes to 2 files (+1 heads)
$ hg -R ../main rollback
repository tip rolled back to revision 5 (undo push)
Test it still fails with checkallhook
$ cat > ../main/.hg/hgrc <<EOF
> [hooks]
> pretxnchangegroup = python:hgext.eol.checkallhook
> EOF
$ hg push -f ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 3 changes to 2 files (+1 heads)
Patrick Mezard
eol: improve hook failure output...
r13649 error: pretxnchangegroup hook failed: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
Patrick Mezard
eol: rename hook into checkheadshook, add checkallhook (issue2665)...
r13617 transaction abort!
rollback completed
Patrick Mezard
eol: improve hook failure output...
r13649 abort: end-of-line check failed:
b.txt in fbcf9b1025f5 should not have CRLF line endings
Patrick Mezard
eol: rename hook into checkheadshook, add checkallhook (issue2665)...
r13617 [255]
But we can push the clean head
$ hg push -r7 -f ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Patrick Mezard
eol: improve hook failure output...
r13649 Test multiple files/revisions output
$ printf "another\r\nbad\r\none" > d.txt
$ hg add d.txt
$ hg ci -m "add d.txt"
$ hg push -f ../main
pushing to ../main
searching for changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 3 changes to 2 files (+1 heads)
error: pretxnchangegroup hook failed: end-of-line check failed:
Bryan O'Sullivan
eol: make output stable...
r27524 b.txt in fbcf9b1025f5 should not have CRLF line endings
Patrick Mezard
eol: improve hook failure output...
r13649 d.txt in a7040e68714f should not have CRLF line endings
transaction abort!
rollback completed
abort: end-of-line check failed:
Bryan O'Sullivan
eol: make output stable...
r27524 b.txt in fbcf9b1025f5 should not have CRLF line endings
Patrick Mezard
eol: improve hook failure output...
r13649 d.txt in a7040e68714f should not have CRLF line endings
[255]
Mads Kiilerich
tests: add missing trailing 'cd ..'...
r16913
$ cd ..