##// END OF EJS Templates
test: end printed diff "hunks" with an empty string in test-context.py...
Denis Laxalde -
r31270:59aec562 default
parent child Browse files
Show More
@@ -1,148 +1,148 b''
1 from __future__ import absolute_import, print_function
1 from __future__ import absolute_import, print_function
2 import os
2 import os
3 from mercurial import (
3 from mercurial import (
4 context,
4 context,
5 encoding,
5 encoding,
6 hg,
6 hg,
7 ui as uimod,
7 ui as uimod,
8 )
8 )
9
9
10 u = uimod.ui.load()
10 u = uimod.ui.load()
11
11
12 repo = hg.repository(u, 'test1', create=1)
12 repo = hg.repository(u, 'test1', create=1)
13 os.chdir('test1')
13 os.chdir('test1')
14
14
15 # create 'foo' with fixed time stamp
15 # create 'foo' with fixed time stamp
16 f = open('foo', 'wb')
16 f = open('foo', 'wb')
17 f.write(b'foo\n')
17 f.write(b'foo\n')
18 f.close()
18 f.close()
19 os.utime('foo', (1000, 1000))
19 os.utime('foo', (1000, 1000))
20
20
21 # add+commit 'foo'
21 # add+commit 'foo'
22 repo[None].add(['foo'])
22 repo[None].add(['foo'])
23 repo.commit(text='commit1', date="0 0")
23 repo.commit(text='commit1', date="0 0")
24
24
25 if os.name == 'nt':
25 if os.name == 'nt':
26 d = repo[None]['foo'].date()
26 d = repo[None]['foo'].date()
27 print("workingfilectx.date = (%d, %d)" % (d[0], d[1]))
27 print("workingfilectx.date = (%d, %d)" % (d[0], d[1]))
28 else:
28 else:
29 print("workingfilectx.date =", repo[None]['foo'].date())
29 print("workingfilectx.date =", repo[None]['foo'].date())
30
30
31 # test memctx with non-ASCII commit message
31 # test memctx with non-ASCII commit message
32
32
33 def filectxfn(repo, memctx, path):
33 def filectxfn(repo, memctx, path):
34 return context.memfilectx(repo, "foo", "")
34 return context.memfilectx(repo, "foo", "")
35
35
36 ctx = context.memctx(repo, ['tip', None],
36 ctx = context.memctx(repo, ['tip', None],
37 encoding.tolocal("Gr\xc3\xbcezi!"),
37 encoding.tolocal("Gr\xc3\xbcezi!"),
38 ["foo"], filectxfn)
38 ["foo"], filectxfn)
39 ctx.commit()
39 ctx.commit()
40 for enc in "ASCII", "Latin-1", "UTF-8":
40 for enc in "ASCII", "Latin-1", "UTF-8":
41 encoding.encoding = enc
41 encoding.encoding = enc
42 print("%-8s: %s" % (enc, repo["tip"].description()))
42 print("%-8s: %s" % (enc, repo["tip"].description()))
43
43
44 # test performing a status
44 # test performing a status
45
45
46 def getfilectx(repo, memctx, f):
46 def getfilectx(repo, memctx, f):
47 fctx = memctx.parents()[0][f]
47 fctx = memctx.parents()[0][f]
48 data, flags = fctx.data(), fctx.flags()
48 data, flags = fctx.data(), fctx.flags()
49 if f == 'foo':
49 if f == 'foo':
50 data += 'bar\n'
50 data += 'bar\n'
51 return context.memfilectx(repo, f, data, 'l' in flags, 'x' in flags)
51 return context.memfilectx(repo, f, data, 'l' in flags, 'x' in flags)
52
52
53 ctxa = repo.changectx(0)
53 ctxa = repo.changectx(0)
54 ctxb = context.memctx(repo, [ctxa.node(), None], "test diff", ["foo"],
54 ctxb = context.memctx(repo, [ctxa.node(), None], "test diff", ["foo"],
55 getfilectx, ctxa.user(), ctxa.date())
55 getfilectx, ctxa.user(), ctxa.date())
56
56
57 print(ctxb.status(ctxa))
57 print(ctxb.status(ctxa))
58
58
59 # test performing a diff on a memctx
59 # test performing a diff on a memctx
60
60
61 for d in ctxb.diff(ctxa, git=True):
61 for d in ctxb.diff(ctxa, git=True):
62 print(d)
62 print(d, end='')
63
63
64 # test safeness and correctness of "ctx.status()"
64 # test safeness and correctness of "ctx.status()"
65 print('= checking context.status():')
65 print('= checking context.status():')
66
66
67 # ancestor "wcctx ~ 2"
67 # ancestor "wcctx ~ 2"
68 actx2 = repo['.']
68 actx2 = repo['.']
69
69
70 repo.wwrite('bar-m', 'bar-m\n', '')
70 repo.wwrite('bar-m', 'bar-m\n', '')
71 repo.wwrite('bar-r', 'bar-r\n', '')
71 repo.wwrite('bar-r', 'bar-r\n', '')
72 repo[None].add(['bar-m', 'bar-r'])
72 repo[None].add(['bar-m', 'bar-r'])
73 repo.commit(text='add bar-m, bar-r', date="0 0")
73 repo.commit(text='add bar-m, bar-r', date="0 0")
74
74
75 # ancestor "wcctx ~ 1"
75 # ancestor "wcctx ~ 1"
76 actx1 = repo['.']
76 actx1 = repo['.']
77
77
78 repo.wwrite('bar-m', 'bar-m bar-m\n', '')
78 repo.wwrite('bar-m', 'bar-m bar-m\n', '')
79 repo.wwrite('bar-a', 'bar-a\n', '')
79 repo.wwrite('bar-a', 'bar-a\n', '')
80 repo[None].add(['bar-a'])
80 repo[None].add(['bar-a'])
81 repo[None].forget(['bar-r'])
81 repo[None].forget(['bar-r'])
82
82
83 # status at this point:
83 # status at this point:
84 # M bar-m
84 # M bar-m
85 # A bar-a
85 # A bar-a
86 # R bar-r
86 # R bar-r
87 # C foo
87 # C foo
88
88
89 from mercurial import scmutil
89 from mercurial import scmutil
90
90
91 print('== checking workingctx.status:')
91 print('== checking workingctx.status:')
92
92
93 wctx = repo[None]
93 wctx = repo[None]
94 print('wctx._status=%s' % (str(wctx._status)))
94 print('wctx._status=%s' % (str(wctx._status)))
95
95
96 print('=== with "pattern match":')
96 print('=== with "pattern match":')
97 print(actx1.status(other=wctx,
97 print(actx1.status(other=wctx,
98 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
98 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
99 print('wctx._status=%s' % (str(wctx._status)))
99 print('wctx._status=%s' % (str(wctx._status)))
100 print(actx2.status(other=wctx,
100 print(actx2.status(other=wctx,
101 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
101 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
102 print('wctx._status=%s' % (str(wctx._status)))
102 print('wctx._status=%s' % (str(wctx._status)))
103
103
104 print('=== with "always match" and "listclean=True":')
104 print('=== with "always match" and "listclean=True":')
105 print(actx1.status(other=wctx, listclean=True))
105 print(actx1.status(other=wctx, listclean=True))
106 print('wctx._status=%s' % (str(wctx._status)))
106 print('wctx._status=%s' % (str(wctx._status)))
107 print(actx2.status(other=wctx, listclean=True))
107 print(actx2.status(other=wctx, listclean=True))
108 print('wctx._status=%s' % (str(wctx._status)))
108 print('wctx._status=%s' % (str(wctx._status)))
109
109
110 print("== checking workingcommitctx.status:")
110 print("== checking workingcommitctx.status:")
111
111
112 wcctx = context.workingcommitctx(repo,
112 wcctx = context.workingcommitctx(repo,
113 scmutil.status(['bar-m'],
113 scmutil.status(['bar-m'],
114 ['bar-a'],
114 ['bar-a'],
115 [],
115 [],
116 [], [], [], []),
116 [], [], [], []),
117 text='', date='0 0')
117 text='', date='0 0')
118 print('wcctx._status=%s' % (str(wcctx._status)))
118 print('wcctx._status=%s' % (str(wcctx._status)))
119
119
120 print('=== with "always match":')
120 print('=== with "always match":')
121 print(actx1.status(other=wcctx))
121 print(actx1.status(other=wcctx))
122 print('wcctx._status=%s' % (str(wcctx._status)))
122 print('wcctx._status=%s' % (str(wcctx._status)))
123 print(actx2.status(other=wcctx))
123 print(actx2.status(other=wcctx))
124 print('wcctx._status=%s' % (str(wcctx._status)))
124 print('wcctx._status=%s' % (str(wcctx._status)))
125
125
126 print('=== with "always match" and "listclean=True":')
126 print('=== with "always match" and "listclean=True":')
127 print(actx1.status(other=wcctx, listclean=True))
127 print(actx1.status(other=wcctx, listclean=True))
128 print('wcctx._status=%s' % (str(wcctx._status)))
128 print('wcctx._status=%s' % (str(wcctx._status)))
129 print(actx2.status(other=wcctx, listclean=True))
129 print(actx2.status(other=wcctx, listclean=True))
130 print('wcctx._status=%s' % (str(wcctx._status)))
130 print('wcctx._status=%s' % (str(wcctx._status)))
131
131
132 print('=== with "pattern match":')
132 print('=== with "pattern match":')
133 print(actx1.status(other=wcctx,
133 print(actx1.status(other=wcctx,
134 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
134 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
135 print('wcctx._status=%s' % (str(wcctx._status)))
135 print('wcctx._status=%s' % (str(wcctx._status)))
136 print(actx2.status(other=wcctx,
136 print(actx2.status(other=wcctx,
137 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
137 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
138 print('wcctx._status=%s' % (str(wcctx._status)))
138 print('wcctx._status=%s' % (str(wcctx._status)))
139
139
140 print('=== with "pattern match" and "listclean=True":')
140 print('=== with "pattern match" and "listclean=True":')
141 print(actx1.status(other=wcctx,
141 print(actx1.status(other=wcctx,
142 match=scmutil.matchfiles(repo, ['bar-r', 'foo']),
142 match=scmutil.matchfiles(repo, ['bar-r', 'foo']),
143 listclean=True))
143 listclean=True))
144 print('wcctx._status=%s' % (str(wcctx._status)))
144 print('wcctx._status=%s' % (str(wcctx._status)))
145 print(actx2.status(other=wcctx,
145 print(actx2.status(other=wcctx,
146 match=scmutil.matchfiles(repo, ['bar-r', 'foo']),
146 match=scmutil.matchfiles(repo, ['bar-r', 'foo']),
147 listclean=True))
147 listclean=True))
148 print('wcctx._status=%s' % (str(wcctx._status)))
148 print('wcctx._status=%s' % (str(wcctx._status)))
@@ -1,48 +1,46 b''
1 workingfilectx.date = (1000, 0)
1 workingfilectx.date = (1000, 0)
2 ASCII : Gr?ezi!
2 ASCII : Gr?ezi!
3 Latin-1 : GrοΏ½ezi!
3 Latin-1 : GrοΏ½ezi!
4 UTF-8 : GrΓΌezi!
4 UTF-8 : GrΓΌezi!
5 <status modified=['foo'], added=[], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
5 <status modified=['foo'], added=[], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
6 diff --git a/foo b/foo
6 diff --git a/foo b/foo
7
8 --- a/foo
7 --- a/foo
9 +++ b/foo
8 +++ b/foo
10 @@ -1,1 +1,2 @@
9 @@ -1,1 +1,2 @@
11 foo
10 foo
12 +bar
11 +bar
13
14 = checking context.status():
12 = checking context.status():
15 == checking workingctx.status:
13 == checking workingctx.status:
16 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
14 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
17 === with "pattern match":
15 === with "pattern match":
18 <status modified=['bar-m'], added=[], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
16 <status modified=['bar-m'], added=[], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
19 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
17 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
20 <status modified=[], added=['bar-m'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
18 <status modified=[], added=['bar-m'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
21 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
19 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
22 === with "always match" and "listclean=True":
20 === with "always match" and "listclean=True":
23 <status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=['foo']>
21 <status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=['foo']>
24 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
22 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
25 <status modified=[], added=['bar-a', 'bar-m'], removed=[], deleted=[], unknown=[], ignored=[], clean=['foo']>
23 <status modified=[], added=['bar-a', 'bar-m'], removed=[], deleted=[], unknown=[], ignored=[], clean=['foo']>
26 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
24 wctx._status=<status modified=['bar-m'], added=['bar-a'], removed=['bar-r'], deleted=[], unknown=[], ignored=[], clean=[]>
27 == checking workingcommitctx.status:
25 == checking workingcommitctx.status:
28 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
26 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
29 === with "always match":
27 === with "always match":
30 <status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
28 <status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
31 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
29 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
32 <status modified=[], added=['bar-a', 'bar-m', 'bar-r'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
30 <status modified=[], added=['bar-a', 'bar-m', 'bar-r'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
33 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
31 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
34 === with "always match" and "listclean=True":
32 === with "always match" and "listclean=True":
35 <status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=['bar-r', 'foo']>
33 <status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=['bar-r', 'foo']>
36 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
34 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
37 <status modified=[], added=['bar-a', 'bar-m', 'bar-r'], removed=[], deleted=[], unknown=[], ignored=[], clean=['foo']>
35 <status modified=[], added=['bar-a', 'bar-m', 'bar-r'], removed=[], deleted=[], unknown=[], ignored=[], clean=['foo']>
38 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
36 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
39 === with "pattern match":
37 === with "pattern match":
40 <status modified=['bar-m'], added=[], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
38 <status modified=['bar-m'], added=[], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
41 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
39 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
42 <status modified=[], added=['bar-m'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
40 <status modified=[], added=['bar-m'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
43 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
41 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
44 === with "pattern match" and "listclean=True":
42 === with "pattern match" and "listclean=True":
45 <status modified=[], added=[], removed=[], deleted=[], unknown=[], ignored=[], clean=['bar-r', 'foo']>
43 <status modified=[], added=[], removed=[], deleted=[], unknown=[], ignored=[], clean=['bar-r', 'foo']>
46 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
44 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
47 <status modified=[], added=['bar-r'], removed=[], deleted=[], unknown=[], ignored=[], clean=['foo']>
45 <status modified=[], added=['bar-r'], removed=[], deleted=[], unknown=[], ignored=[], clean=['foo']>
48 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
46 wcctx._status=<status modified=['bar-m'], added=['bar-a'], removed=[], deleted=[], unknown=[], ignored=[], clean=[]>
General Comments 0
You need to be logged in to leave comments. Login now