##// END OF EJS Templates
localrepo: handle ValueError during repository opening...
localrepo: handle ValueError during repository opening Python 3.8 can raise ValueError on attempt of an I/O operation against an illegal path. This was causing test-remotefilelog-gc.t to fail on Python 3.8. This commit teaches repository opening to handle ValueError and re-raise an Abort on failure. An arguably better solution would be to implement this logic in the vfs layer. But that seems like a bag of worms and I don't want to go down that rabbit hole. Until users report uncaught ValueError exceptions in the wild, I think it is fine to patch this at the only occurrence our test harness is finding it. Differential Revision: https://phab.mercurial-scm.org/D7944

File last commit:

r42984:d82e9f7e default
r45469:9e5b4dbe default
Show More
test-fix-metadata.t
95 lines | 3.0 KiB | text/troff | Tads3Lexer
/ tests / test-fix-metadata.t
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 A python hook for "hg fix" that prints out the number of files and revisions
that were affected, along with which fixer tools were applied. Also checks how
many times it sees a specific key generated by one of the fixer tools defined
below.
$ cat >> $TESTTMP/postfixhook.py <<EOF
> import collections
Pulkit Goyal
py3: fix test-fix-metadata.t...
r42622 > def file(ui, repo, rev=None, path=b'', metadata=None, **kwargs):
> ui.status(b'fixed %s in revision %d using %s\n' %
> (path, rev, b', '.join(metadata.keys())))
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 > def summarize(ui, repo, replacements=None, wdirwritten=False,
> metadata=None, **kwargs):
> counts = collections.defaultdict(int)
> keys = 0
> for fixername, metadatalist in metadata.items():
> for metadata in metadatalist:
> if metadata is None:
> continue
> counts[fixername] += 1
> if 'key' in metadata:
> keys += 1
Pulkit Goyal
py3: fix test-fix-metadata.t...
r42622 > ui.status(b'saw "key" %d times\n' % (keys,))
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 > for name, count in sorted(counts.items()):
Pulkit Goyal
py3: fix test-fix-metadata.t...
r42622 > ui.status(b'fixed %d files with %s\n' % (count, name))
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 > if replacements:
Pulkit Goyal
py3: fix test-fix-metadata.t...
r42622 > ui.status(b'fixed %d revisions\n' % (len(replacements),))
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 > if wdirwritten:
Pulkit Goyal
py3: fix test-fix-metadata.t...
r42622 > ui.status(b'fixed the working copy\n')
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 > EOF
Some mock output for fixer tools that demonstrate what could go wrong with
expecting the metadata output format.
$ printf 'new content\n' > $TESTTMP/missing
$ printf 'not valid json\0new content\n' > $TESTTMP/invalid
$ printf '{"key": "value"}\0new content\n' > $TESTTMP/valid
Configure some fixer tools based on the output defined above, and enable the
hooks defined above. Disable parallelism to make output of the parallel file
processing phase stable.
$ cat >> $HGRCPATH <<EOF
> [extensions]
> fix =
> [fix]
Danny Hooper
fix: correctly parse the :metadata subconfig...
r43002 > metadatafalse:command=cat $TESTTMP/missing
> metadatafalse:pattern=metadatafalse
> metadatafalse:metadata=false
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 > missing:command=cat $TESTTMP/missing
> missing:pattern=missing
> missing:metadata=true
> invalid:command=cat $TESTTMP/invalid
> invalid:pattern=invalid
> invalid:metadata=true
> valid:command=cat $TESTTMP/valid
> valid:pattern=valid
> valid:metadata=true
> [hooks]
> postfixfile = python:$TESTTMP/postfixhook.py:file
> postfix = python:$TESTTMP/postfixhook.py:summarize
> [worker]
> enabled=false
> EOF
See what happens when we execute each of the fixer tools. Some print warnings,
some write back to the file.
$ hg init repo
$ cd repo
Danny Hooper
fix: correctly parse the :metadata subconfig...
r43002 $ printf "old content\n" > metadatafalse
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 $ printf "old content\n" > invalid
$ printf "old content\n" > missing
$ printf "old content\n" > valid
$ hg add -q
$ hg fix -w
ignored invalid output from fixer tool: invalid
Danny Hooper
fix: correctly parse the :metadata subconfig...
r43002 fixed metadatafalse in revision 2147483647 using metadatafalse
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 ignored invalid output from fixer tool: missing
fixed valid in revision 2147483647 using valid
saw "key" 1 times
fixed 1 files with valid
fixed the working copy
Danny Hooper
fix: correctly parse the :metadata subconfig...
r43002 $ cat metadatafalse
new content
$ cat missing
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 old content
Danny Hooper
fix: correctly parse the :metadata subconfig...
r43002 $ cat invalid
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 old content
Danny Hooper
fix: correctly parse the :metadata subconfig...
r43002 $ cat valid
Danny Hooper
fix: allow fixer tools to return metadata in addition to the file content...
r42372 new content
$ cd ..