annotate tests/test-context.py @ 102:cc2b7540fa2b 0.2

tests: don't set the time zone There seems to be no need and it misbehaves on Windows.
author Idan Kamara <idankk86@gmail.com>
date Wed, 18 Jan 2012 00:39:25 +0200
parents bd23bc72e662
children c635e6e7054f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
94
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1 import common, hglib
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
2 from hglib import context
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 class test_context(common.basetest):
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 def test_non_existent(self):
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 self.assertRaises(ValueError, context.changectx, self.client, 'foo')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8 def test_basic(self):
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 self.append('a', 'a')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10 self.append('b', 'b')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11 rev0, node0 = self.client.commit('first', addremove=True)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13 self.append('c', 'c')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 rev1, node1 = self.client.commit('second', addremove=True)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15
95
bd23bc72e662 client: add a convenience method __getitem__ to return a changectx
Idan Kamara <idankk86@gmail.com>
parents: 94
diff changeset
16 ctx = self.client[node0]
94
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18 self.assertEquals(ctx.description(), 'first')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19 self.assertEquals(str(ctx), node0[:12])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20 self.assertEquals(ctx.node(), node0)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21 self.assertEquals(int(ctx), rev0)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 self.assertEquals(ctx.rev(), rev0)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 self.assertEquals(ctx.branch(), 'default')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25 self.assertTrue(ctx)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27 self.assertTrue('a' in ctx and 'b' in ctx)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28 self.assertFalse('c' in ctx)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29 self.assertEquals(list(ctx), ['a', 'b'])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
30 self.assertEquals(ctx.files(), ['a', 'b'])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
31
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
32 self.assertEquals(ctx.modified(), [])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
33 self.assertEquals(ctx.added(), ['a', 'b'])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
34 self.assertEquals(ctx.removed(), [])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
35 self.assertEquals(ctx.ignored(), [])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
36 self.assertEquals(ctx.clean(), [])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
37
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
38 man = {'a' : '047b75c6d7a3ef6a2243bd0e99f94f6ea6683597',
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
39 'b' : '62452855512f5b81522aa3895892760bb8da9f3f'}
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
40 self.assertEquals(ctx.manifest(), man)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
41
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
42 self.assertEquals([int(c) for c in ctx.parents()], [-1])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
43 self.assertEquals(int(ctx.p1()), -1)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
44 self.assertEquals(int(ctx.p2()), -1)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
45
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
46 self.assertEquals([int(c) for c in ctx.children()], [1])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
47 self.assertEquals([int(c) for c in ctx.descendants()], [0, 1])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
48 self.assertEquals([int(c) for c in ctx.ancestors()], [0])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
49
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
50 self.client.bookmark('bookmark', inactive=True, rev=node0)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
51 self.assertEquals(ctx.bookmarks(), ['bookmark'])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
52
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
53 self.client.tag('tag', rev=node0)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
54 # tags are read on construction
95
bd23bc72e662 client: add a convenience method __getitem__ to return a changectx
Idan Kamara <idankk86@gmail.com>
parents: 94
diff changeset
55 self.assertEquals(self.client[node0].tags(), ['tag'])
94
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
56
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
57 def test_construction(self):
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
58 self.append('a', 'a')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
59 rev0, node0 = self.client.commit('first', addremove=True)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
60 tip = self.client.tip()
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
61
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
62 # from client.revision
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
63 ctx = context.changectx(self.client, tip)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
64 self.assertEquals(ctx.node(), tip.node)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
65
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
66 # from revset
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
67 ctx = context.changectx(self.client, 'all()')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
68 self.assertEquals(ctx.node(), tip.node)