Mercurial > public > mercurial-scm > python-hglib
annotate tests/test-branch.py @ 216:68588c652ac6
client: handle commit messages with \0 characters
Mercurial allows commit messages containing \0 characters,
but hglib does not properly handle them.
By using the json template, these characters are correctly escaped.
Note: initial change only modifies this for the 'log' command,
I'll follow-up for other commands if this is ok.
author | Mathias De Mare <mathias.de_mare@nokia.com> |
---|---|
date | Wed, 08 Mar 2023 16:22:21 +0100 |
parents | c1b966866ed7 |
children |
rev | line source |
---|---|
148
c1b966866ed7
hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents:
143
diff
changeset
|
1 from tests import common |
7
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
2 import hglib |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
3 from hglib.util import b |
7
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
4 |
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
5 class test_branch(common.basetest): |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
6 def test_empty(self): |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
7 self.assertEquals(self.client.branch(), b('default')) |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
8 |
7
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
9 def test_basic(self): |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
10 self.assertEquals(self.client.branch(b('foo')), b('foo')) |
7
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
11 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
12 rev, node = self.client.commit(b('first'), addremove=True) |
15
f1af31960414
client: change return value of commit() to (rev, node)
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
13 |
f1af31960414
client: change return value of commit() to (rev, node)
Idan Kamara <idankk86@gmail.com>
parents:
12
diff
changeset
|
14 rev = self.client.log(node)[0] |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
15 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
16 self.assertEquals(rev.branch, b('foo')) |
12
c2a9b716cd80
client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents:
11
diff
changeset
|
17 self.assertEquals(self.client.branches(), |
c2a9b716cd80
client: rewrite branches(), return a list of (branchname, rev, node)
Idan Kamara <idankk86@gmail.com>
parents:
11
diff
changeset
|
18 [(rev.branch, int(rev.rev), rev.node[:12])]) |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
19 |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
20 def test_reset_with_name(self): |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
21 self.assertRaises(ValueError, self.client.branch, b('foo'), clean=True) |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
22 |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
23 def test_reset(self): |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
24 self.client.branch(b('foo')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
25 self.assertEquals(self.client.branch(clean=True), b('default')) |
7
eac8be119d81
tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
26 |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
27 def test_exists(self): |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
28 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
29 self.client.commit(b('first'), addremove=True) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
30 self.client.branch(b('foo')) |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
31 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
32 self.client.commit(b('second')) |
134 | 33 self.assertRaises(hglib.error.CommandError, |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
34 self.client.branch, b('default')) |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
35 |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
36 def test_force(self): |
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
37 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
38 self.client.commit(b('first'), addremove=True) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
39 self.client.branch(b('foo')) |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
40 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
41 self.client.commit(b('second')) |
11
0549d00a617d
client: add missing options to branch()
Idan Kamara <idankk86@gmail.com>
parents:
7
diff
changeset
|
42 |
134 | 43 self.assertRaises(hglib.error.CommandError, |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
44 self.client.branch, b('default')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
45 self.assertEquals(self.client.branch(b('default'), force=True), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
46 b('default')) |