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