annotate tests/test-context.py @ 120:5d3783aebe5f 1.2

log: fix 'hidden' option We were passing -h, which is 'help', not 'hidden'.
author Julien Cristau <julien.cristau@logilab.fr>
date Mon, 27 Jan 2014 09:29:55 +0100
parents 27591b5bb9d9
children e05b0cf920bb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110
c635e6e7054f context: raise same error when not found for all hg versions
Alexander Plavin <me@aplavin.ru>
parents: 95
diff changeset
1 from hglib.error import CommandError
94
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
2 import common, hglib
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3 from hglib import context
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 class test_context(common.basetest):
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 def test_non_existent(self):
113
27591b5bb9d9 tests: remove usage of assertRaisesRegexp
Alexander Plavin <me@aplavin.ru>
parents: 110
diff changeset
7 self.assertRaises(ValueError, context.changectx, self.client, 'foo')
94
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 def test_basic(self):
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10 self.append('a', 'a')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11 self.append('b', 'b')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12 rev0, node0 = self.client.commit('first', addremove=True)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 self.append('c', 'c')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15 rev1, node1 = self.client.commit('second', addremove=True)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16
95
bd23bc72e662 client: add a convenience method __getitem__ to return a changectx
Idan Kamara <idankk86@gmail.com>
parents: 94
diff changeset
17 ctx = self.client[node0]
94
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19 self.assertEquals(ctx.description(), 'first')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20 self.assertEquals(str(ctx), node0[:12])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21 self.assertEquals(ctx.node(), node0)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 self.assertEquals(int(ctx), rev0)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 self.assertEquals(ctx.rev(), rev0)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 self.assertEquals(ctx.branch(), 'default')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 self.assertTrue(ctx)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28 self.assertTrue('a' in ctx and 'b' in ctx)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29 self.assertFalse('c' in ctx)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
30 self.assertEquals(list(ctx), ['a', 'b'])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
31 self.assertEquals(ctx.files(), ['a', 'b'])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
32
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
33 self.assertEquals(ctx.modified(), [])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
34 self.assertEquals(ctx.added(), ['a', 'b'])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
35 self.assertEquals(ctx.removed(), [])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
36 self.assertEquals(ctx.ignored(), [])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
37 self.assertEquals(ctx.clean(), [])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
38
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
39 man = {'a' : '047b75c6d7a3ef6a2243bd0e99f94f6ea6683597',
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
40 'b' : '62452855512f5b81522aa3895892760bb8da9f3f'}
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
41 self.assertEquals(ctx.manifest(), man)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
42
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
43 self.assertEquals([int(c) for c in ctx.parents()], [-1])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
44 self.assertEquals(int(ctx.p1()), -1)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
45 self.assertEquals(int(ctx.p2()), -1)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
46
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
47 self.assertEquals([int(c) for c in ctx.children()], [1])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
48 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
49 self.assertEquals([int(c) for c in ctx.ancestors()], [0])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
50
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
51 self.client.bookmark('bookmark', inactive=True, rev=node0)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
52 self.assertEquals(ctx.bookmarks(), ['bookmark'])
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
53
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
54 self.client.tag('tag', rev=node0)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
55 # 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
56 self.assertEquals(self.client[node0].tags(), ['tag'])
94
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
57
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
58 def test_construction(self):
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
59 self.append('a', 'a')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
60 rev0, node0 = self.client.commit('first', addremove=True)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
61 tip = self.client.tip()
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
62
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
63 # from client.revision
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
64 ctx = context.changectx(self.client, tip)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
65 self.assertEquals(ctx.node(), tip.node)
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
66
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
67 # from revset
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
68 ctx = context.changectx(self.client, 'all()')
4da6bb8abfcc context: initial implementation of changectx
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
69 self.assertEquals(ctx.node(), tip.node)