Mercurial > python-hglib
annotate tests/test-commit.py @ 136:dc63978871ed
client: add support for 'hg commit --amend'
author | David Douard <david.douard@logilab.fr> |
---|---|
date | Thu, 23 Oct 2014 10:50:09 +0200 |
parents | 1b47146a4a2c |
children | 4359cabcb0cc |
rev | line source |
---|---|
99
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
1 import common, hglib, datetime |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
2 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
3 class test_commit(common.basetest): |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
4 def test_user(self): |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
5 self.append('a', 'a') |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
6 rev, node = self.client.commit('first', addremove=True, user='foo') |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
7 rev = self.client.log(node)[0] |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
8 self.assertEquals(rev.author, 'foo') |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
9 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
10 def test_no_user(self): |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
11 self.append('a', 'a') |
134 | 12 self.assertRaises(hglib.error.CommandError, |
13 self.client.commit, 'first', user='') | |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
14 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
15 def test_close_branch(self): |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
16 self.append('a', 'a') |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
17 rev0, node0 = self.client.commit('first', addremove=True) |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
18 self.client.branch('foo') |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
19 self.append('a', 'a') |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
20 rev1, node1 = self.client.commit('second') |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
21 revclose = self.client.commit('closing foo', closebranch=True) |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
22 rev0, rev1, revclose = self.client.log([node0, node1, revclose[1]]) |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
23 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
24 self.assertEquals(self.client.branches(), |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
25 [(rev0.branch, int(rev0.rev), rev0.node[:12])]) |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
26 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
27 self.assertEquals(self.client.branches(closed=True), |
134 | 28 [(revclose.branch, int(revclose.rev), |
29 revclose.node[:12]), | |
16
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
30 (rev0.branch, int(rev0.rev), rev0.node[:12])]) |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
31 |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
32 def test_message_logfile(self): |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
33 self.assertRaises(ValueError, self.client.commit, 'foo', logfile='bar') |
943aff89b068
client: add missing options to commit()
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
34 self.assertRaises(ValueError, self.client.commit) |
99
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
35 |
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
36 def test_date(self): |
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
37 self.append('a', 'a') |
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
38 now = datetime.datetime.now().replace(microsecond=0) |
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
39 rev0, node0 = self.client.commit('first', addremove=True, |
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
40 date=now.isoformat(' ')) |
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
41 |
2b36619ec0a0
client: add date field to revision
Idan Kamara <idankk86@gmail.com>
parents:
16
diff
changeset
|
42 self.assertEquals(now, self.client.tip().date) |
136
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
43 |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
44 def test_amend(self): |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
45 self.append('a', 'a') |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
46 now = datetime.datetime.now().replace(microsecond=0) |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
47 rev0, node0 = self.client.commit('first', addremove=True, |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
48 date=now.isoformat(' ')) |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
49 |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
50 print rev0, node0 |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
51 self.assertEquals(now, self.client.tip().date) |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
52 |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
53 self.append('a', 'a') |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
54 rev1, node1 = self.client.commit(amend=True) |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
55 print rev1, node1 |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
56 self.assertEquals(now, self.client.tip().date) |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
57 self.assertNotEquals(node0, node1) |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
58 self.assertEqual(1, len(self.client.log())) |
dc63978871ed
client: add support for 'hg commit --amend'
David Douard <david.douard@logilab.fr>
parents:
134
diff
changeset
|
59 |