Mercurial > hg-stable
annotate tests/test-filelog.py @ 43874:bc7d8f45c3b6
rust-dirs: handle forgotten `Result`s
In 1fe2e574616e I introduced a temporary bugfix to align Rust code with a new
behavior from C/Python and forgot about a few `Result`s (cargo's compiler cache
does not re-emit warnings on cached modules). This fixes it.
For the record, I am still unsure that this behavior change is a good idea.
Note: I was already quite unhappy with the setters and getters for the
`DirstateMap` and, indirectly, `Dirs`, and this only further reinforces my
feelings. I hope we can one day fix that situation at the type level; Georges
Racinet and I were just talking about devising a POC for using the builder
pattern in the context of FFI with Python, we'll see what comes out of it.
Differential Revision: https://phab.mercurial-scm.org/D7609
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Thu, 12 Dec 2019 15:55:25 +0100 |
parents | 2372284d9457 |
children | c102b704edb5 |
rev | line source |
---|---|
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
2 """ |
26098 | 3 Tests the behavior of filelog w.r.t. data starting with '\1\n' |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
4 """ |
28744
6537e14301ef
py3: use print_function in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28743
diff
changeset
|
5 from __future__ import absolute_import, print_function |
29205
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28805
diff
changeset
|
6 |
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28805
diff
changeset
|
7 from mercurial.node import ( |
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28805
diff
changeset
|
8 hex, |
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28805
diff
changeset
|
9 nullid, |
a0939666b836
py3: move up symbol imports to enforce import-checker rules
Yuya Nishihara <yuya@tcha.org>
parents:
28805
diff
changeset
|
10 ) |
28743
83373fc2b287
py3: use absolute_import in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
26098
diff
changeset
|
11 from mercurial import ( |
83373fc2b287
py3: use absolute_import in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
26098
diff
changeset
|
12 hg, |
28805
efc739551c17
test-filelog: alias ui as uimod
Yuya Nishihara <yuya@tcha.org>
parents:
28744
diff
changeset
|
13 ui as uimod, |
28743
83373fc2b287
py3: use absolute_import in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
26098
diff
changeset
|
14 ) |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
15 |
30564
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29205
diff
changeset
|
16 myui = uimod.ui.load() |
37977
f71c97d9b97b
tests: port test-filelog.py to Python 3
Augie Fackler <augie@google.com>
parents:
30564
diff
changeset
|
17 repo = hg.repository(myui, path=b'.', create=True) |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
18 |
37977
f71c97d9b97b
tests: port test-filelog.py to Python 3
Augie Fackler <augie@google.com>
parents:
30564
diff
changeset
|
19 fl = repo.file(b'foobar') |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
20 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37977
diff
changeset
|
21 |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
22 def addrev(text, renamed=False): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
23 if renamed: |
17486 | 24 # data doesn't matter. Just make sure filelog.renamed() returns True |
37977
f71c97d9b97b
tests: port test-filelog.py to Python 3
Augie Fackler <augie@google.com>
parents:
30564
diff
changeset
|
25 meta = {b'copyrev': hex(nullid), b'copy': b'bar'} |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
26 else: |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
27 meta = {} |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
28 |
15876
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
29 lock = t = None |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
30 try: |
15876
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
31 lock = repo.lock() |
37977
f71c97d9b97b
tests: port test-filelog.py to Python 3
Augie Fackler <augie@google.com>
parents:
30564
diff
changeset
|
32 t = repo.transaction(b'commit') |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
33 node = fl.add(text, meta, t, 0, nullid, nullid) |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
34 return node |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
35 finally: |
15876
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
36 if t: |
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
37 t.close() |
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
38 if lock: |
2de1244361aa
tests: lock before creating transaction in test-filelog
Mads Kiilerich <mads@kiilerich.com>
parents:
11540
diff
changeset
|
39 lock.release() |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
40 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37977
diff
changeset
|
41 |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
42 def error(text): |
28744
6537e14301ef
py3: use print_function in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28743
diff
changeset
|
43 print('ERROR: ' + text) |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
44 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37977
diff
changeset
|
45 |
37977
f71c97d9b97b
tests: port test-filelog.py to Python 3
Augie Fackler <augie@google.com>
parents:
30564
diff
changeset
|
46 textwith = b'\1\nfoo' |
f71c97d9b97b
tests: port test-filelog.py to Python 3
Augie Fackler <augie@google.com>
parents:
30564
diff
changeset
|
47 without = b'foo' |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
48 |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
49 node = addrev(textwith) |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
50 if not textwith == fl.read(node): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
51 error('filelog.read for data starting with \\1\\n') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
52 if fl.cmp(node, textwith) or not fl.cmp(node, without): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
53 error('filelog.cmp for data starting with \\1\\n') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
54 if fl.size(0) != len(textwith): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37977
diff
changeset
|
55 error( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37977
diff
changeset
|
56 'FIXME: This is a known failure of filelog.size for data starting ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37977
diff
changeset
|
57 'with \\1\\n' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37977
diff
changeset
|
58 ) |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
59 |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
60 node = addrev(textwith, renamed=True) |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
61 if not textwith == fl.read(node): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
62 error('filelog.read for a renaming + data starting with \\1\\n') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
63 if fl.cmp(node, textwith) or not fl.cmp(node, without): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
64 error('filelog.cmp for a renaming + data starting with \\1\\n') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
65 if fl.size(1) != len(textwith): |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
66 error('filelog.size for a renaming + data starting with \\1\\n') |
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
diff
changeset
|
67 |
28744
6537e14301ef
py3: use print_function in test-filelog.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28743
diff
changeset
|
68 print('OK.') |