Show More
@@ -1,52 +1,52 b'' | |||||
1 | import os |
|
1 | import os | |
2 | from mercurial import hg, ui, context, encoding |
|
2 | from mercurial import hg, ui, context, encoding | |
3 |
|
3 | |||
4 | u = ui.ui() |
|
4 | u = ui.ui() | |
5 |
|
5 | |||
6 | repo = hg.repository(u, 'test1', create=1) |
|
6 | repo = hg.repository(u, 'test1', create=1) | |
7 | os.chdir('test1') |
|
7 | os.chdir('test1') | |
8 |
|
8 | |||
9 | # create 'foo' with fixed time stamp |
|
9 | # create 'foo' with fixed time stamp | |
10 | f = open('foo', 'w') |
|
10 | f = open('foo', 'wb') | |
11 | f.write('foo\n') |
|
11 | f.write('foo\n') | |
12 | f.close() |
|
12 | f.close() | |
13 | os.utime('foo', (1000, 1000)) |
|
13 | os.utime('foo', (1000, 1000)) | |
14 |
|
14 | |||
15 | # add+commit 'foo' |
|
15 | # add+commit 'foo' | |
16 | repo[None].add(['foo']) |
|
16 | repo[None].add(['foo']) | |
17 | repo.commit(text='commit1', date="0 0") |
|
17 | repo.commit(text='commit1', date="0 0") | |
18 |
|
18 | |||
19 | print "workingfilectx.date =", repo[None]['foo'].date() |
|
19 | print "workingfilectx.date =", repo[None]['foo'].date() | |
20 |
|
20 | |||
21 | # test memctx with non-ASCII commit message |
|
21 | # test memctx with non-ASCII commit message | |
22 |
|
22 | |||
23 | def filectxfn(repo, memctx, path): |
|
23 | def filectxfn(repo, memctx, path): | |
24 | return context.memfilectx(repo, "foo", "") |
|
24 | return context.memfilectx(repo, "foo", "") | |
25 |
|
25 | |||
26 | ctx = context.memctx(repo, ['tip', None], |
|
26 | ctx = context.memctx(repo, ['tip', None], | |
27 | encoding.tolocal("Gr\xc3\xbcezi!"), |
|
27 | encoding.tolocal("Gr\xc3\xbcezi!"), | |
28 | ["foo"], filectxfn) |
|
28 | ["foo"], filectxfn) | |
29 | ctx.commit() |
|
29 | ctx.commit() | |
30 | for enc in "ASCII", "Latin-1", "UTF-8": |
|
30 | for enc in "ASCII", "Latin-1", "UTF-8": | |
31 | encoding.encoding = enc |
|
31 | encoding.encoding = enc | |
32 | print "%-8s: %s" % (enc, repo["tip"].description()) |
|
32 | print "%-8s: %s" % (enc, repo["tip"].description()) | |
33 |
|
33 | |||
34 | # test performing a status |
|
34 | # test performing a status | |
35 |
|
35 | |||
36 | def getfilectx(repo, memctx, f): |
|
36 | def getfilectx(repo, memctx, f): | |
37 | fctx = memctx.parents()[0][f] |
|
37 | fctx = memctx.parents()[0][f] | |
38 | data, flags = fctx.data(), fctx.flags() |
|
38 | data, flags = fctx.data(), fctx.flags() | |
39 | if f == 'foo': |
|
39 | if f == 'foo': | |
40 | data += 'bar\n' |
|
40 | data += 'bar\n' | |
41 | return context.memfilectx(repo, f, data, 'l' in flags, 'x' in flags) |
|
41 | return context.memfilectx(repo, f, data, 'l' in flags, 'x' in flags) | |
42 |
|
42 | |||
43 | ctxa = repo.changectx(0) |
|
43 | ctxa = repo.changectx(0) | |
44 | ctxb = context.memctx(repo, [ctxa.node(), None], "test diff", ["foo"], |
|
44 | ctxb = context.memctx(repo, [ctxa.node(), None], "test diff", ["foo"], | |
45 | getfilectx, ctxa.user(), ctxa.date()) |
|
45 | getfilectx, ctxa.user(), ctxa.date()) | |
46 |
|
46 | |||
47 | print ctxb.status(ctxa) |
|
47 | print ctxb.status(ctxa) | |
48 |
|
48 | |||
49 | # test performing a diff on a memctx |
|
49 | # test performing a diff on a memctx | |
50 |
|
50 | |||
51 | for d in ctxb.diff(ctxa, git=True): |
|
51 | for d in ctxb.diff(ctxa, git=True): | |
52 | print d |
|
52 | print d |
General Comments 0
You need to be logged in to leave comments.
Login now