##// END OF EJS Templates
test-filelog: move from dict() construction to {} literals...
Augie Fackler -
r20684:2761a791 default
parent child Browse files
Show More
@@ -1,55 +1,55 b''
1 1 #!/usr/bin/env python
2 2 """
3 3 Tests the behaviour of filelog w.r.t. data starting with '\1\n'
4 4 """
5 5 from mercurial import ui, hg
6 6 from mercurial.node import nullid, hex
7 7
8 8 myui = ui.ui()
9 9 repo = hg.repository(myui, path='.', create=True)
10 10
11 11 fl = repo.file('foobar')
12 12
13 13 def addrev(text, renamed=False):
14 14 if renamed:
15 15 # data doesn't matter. Just make sure filelog.renamed() returns True
16 meta = dict(copyrev=hex(nullid), copy='bar')
16 meta = {'copyrev': hex(nullid), 'copy': 'bar'}
17 17 else:
18 18 meta = {}
19 19
20 20 lock = t = None
21 21 try:
22 22 lock = repo.lock()
23 23 t = repo.transaction('commit')
24 24 node = fl.add(text, meta, t, 0, nullid, nullid)
25 25 return node
26 26 finally:
27 27 if t:
28 28 t.close()
29 29 if lock:
30 30 lock.release()
31 31
32 32 def error(text):
33 33 print 'ERROR: ' + text
34 34
35 35 textwith = '\1\nfoo'
36 36 without = 'foo'
37 37
38 38 node = addrev(textwith)
39 39 if not textwith == fl.read(node):
40 40 error('filelog.read for data starting with \\1\\n')
41 41 if fl.cmp(node, textwith) or not fl.cmp(node, without):
42 42 error('filelog.cmp for data starting with \\1\\n')
43 43 if fl.size(0) != len(textwith):
44 44 error('FIXME: This is a known failure of filelog.size for data starting '
45 45 'with \\1\\n')
46 46
47 47 node = addrev(textwith, renamed=True)
48 48 if not textwith == fl.read(node):
49 49 error('filelog.read for a renaming + data starting with \\1\\n')
50 50 if fl.cmp(node, textwith) or not fl.cmp(node, without):
51 51 error('filelog.cmp for a renaming + data starting with \\1\\n')
52 52 if fl.size(1) != len(textwith):
53 53 error('filelog.size for a renaming + data starting with \\1\\n')
54 54
55 55 print 'OK.'
General Comments 0
You need to be logged in to leave comments. Login now