changeset 143:4359cabcb0cc

hglib: move string literals in the test code to util.b() (issue4520)
author Brett Cannon <brett@python.org>
date Mon, 09 Mar 2015 18:26:25 -0400
parents fe74d5599539
children 3c59643a2bc3
files tests/test-annotate.py tests/test-bookmarks.py tests/test-branch.py tests/test-branches.py tests/test-bundle.py tests/test-clone.py tests/test-commit.py tests/test-config.py tests/test-context.py tests/test-copy.py tests/test-diff.py tests/test-encoding.py tests/test-forget.py tests/test-grep.py tests/test-heads.py tests/test-hidden.py tests/test-import.py tests/test-init.py tests/test-log.py tests/test-manifest.py tests/test-merge.py tests/test-move.py tests/test-outgoing-incoming.py tests/test-parents.py tests/test-paths.py tests/test-phase.py tests/test-pull.py tests/test-push.py tests/test-remove.py tests/test-resolve.py tests/test-status.py tests/test-summary.py tests/test-tags.py tests/test-update.py
diffstat 34 files changed, 384 insertions(+), 334 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-annotate.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-annotate.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,30 +1,32 @@
 import common
+from hglib.util import b
 
 class test_annotate(common.basetest):
     def test_basic(self):
         self.append('a', 'a\n')
-        rev, node0 = self.client.commit('first', addremove=True)
+        rev, node0 = self.client.commit(b('first'), addremove=True)
         self.append('a', 'a\n')
-        rev, node1 = self.client.commit('second')
+        rev, node1 = self.client.commit(b('second'))
 
-        self.assertEquals(list(self.client.annotate('a')), [('0',
-                                                             'a'), ('1', 'a')])
+        self.assertEquals(list(self.client.annotate(b('a'))),
+                          [(b('0'), b('a')), (b('1'), b('a'))])
         self.assertEquals(list(
             self.client.annotate(
-                'a', user=True, file=True,
+                b('a'), user=True, file=True,
                 number=True, changeset=True, line=True, verbose=True)),
-                          [('test 0 %s a:1' % node0[:12], 'a'),
-                           ('test 1 %s a:2' % node1[:12], 'a')])
+                          [(b('test 0 ') + node0[:12] + b(' a:1'), b('a')),
+                           (b('test 1 ') + node1[:12] + b(' a:2'), b('a'))])
 
     def test_files(self):
         self.append('a', 'a\n')
-        rev, node0 = self.client.commit('first', addremove=True)
+        rev, node0 = self.client.commit(b('first'), addremove=True)
         self.append('b', 'b\n')
-        rev, node1 = self.client.commit('second', addremove=True)
-        self.assertEquals(list(self.client.annotate(['a', 'b'])),
-                          [('0', 'a'), ('1', 'b')])
+        rev, node1 = self.client.commit(b('second'), addremove=True)
+        self.assertEquals(list(self.client.annotate([b('a'), b('b')])),
+                          [(b('0'), b('a')), (b('1'), b('b'))])
 
     def test_two_colons(self):
         self.append('a', 'a: b\n')
-        self.client.commit('first', addremove=True)
-        self.assertEquals(list(self.client.annotate('a')), [('0', 'a: b')])
+        self.client.commit(b('first'), addremove=True)
+        self.assertEquals(list(self.client.annotate(b('a'))),
+                          [(b('0'), b('a: b'))])
--- a/tests/test-bookmarks.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-bookmarks.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,4 +1,5 @@
 import common
+from hglib.util import b
 
 class test_bookmarks(common.basetest):
     def test_empty(self):
@@ -6,18 +7,18 @@
 
     def test_basic(self):
         self.append('a', 'a')
-        rev0, node0 = self.client.commit('first', addremove=True)
+        rev0, node0 = self.client.commit(b('first'), addremove=True)
         self.append('a', 'a')
-        rev1, node1 = self.client.commit('second')
+        rev1, node1 = self.client.commit(b('second'))
 
-        self.client.bookmark('zero', rev0)
+        self.client.bookmark(b('zero'), rev0)
         self.assertEquals(self.client.bookmarks(),
-                          ([('zero', rev0, node0[:12])], -1))
+                          ([(b('zero'), rev0, node0[:12])], -1))
 
-        self.client.bookmark('one', rev1)
+        self.client.bookmark(b('one'), rev1)
         self.assertEquals(self.client.bookmarks()[0],
-                          [('one', rev1, node1[:12]),
-                           ('zero', rev0, node0[:12])])
+                          [(b('one'), rev1, node1[:12]),
+                           (b('zero'), rev0, node0[:12])])
 
     #def test_spaces(self):
     #    self.client.bookmark('s pace', self.rev0)
--- a/tests/test-branch.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-branch.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,44 +1,46 @@
 import common
 import hglib
+from hglib.util import b
 
 class test_branch(common.basetest):
     def test_empty(self):
-        self.assertEquals(self.client.branch(), 'default')
+        self.assertEquals(self.client.branch(), b('default'))
 
     def test_basic(self):
-        self.assertEquals(self.client.branch('foo'), 'foo')
+        self.assertEquals(self.client.branch(b('foo')), b('foo'))
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
 
         rev = self.client.log(node)[0]
 
-        self.assertEquals(rev.branch, 'foo')
+        self.assertEquals(rev.branch, b('foo'))
         self.assertEquals(self.client.branches(),
                           [(rev.branch, int(rev.rev), rev.node[:12])])
 
     def test_reset_with_name(self):
-        self.assertRaises(ValueError, self.client.branch, 'foo', clean=True)
+        self.assertRaises(ValueError, self.client.branch, b('foo'), clean=True)
 
     def test_reset(self):
-        self.client.branch('foo')
-        self.assertEquals(self.client.branch(clean=True), 'default')
+        self.client.branch(b('foo'))
+        self.assertEquals(self.client.branch(clean=True), b('default'))
 
     def test_exists(self):
         self.append('a', 'a')
-        self.client.commit('first', addremove=True)
-        self.client.branch('foo')
+        self.client.commit(b('first'), addremove=True)
+        self.client.branch(b('foo'))
         self.append('a', 'a')
-        self.client.commit('second')
+        self.client.commit(b('second'))
         self.assertRaises(hglib.error.CommandError,
-                          self.client.branch, 'default')
+                          self.client.branch, b('default'))
 
     def test_force(self):
         self.append('a', 'a')
-        self.client.commit('first', addremove=True)
-        self.client.branch('foo')
+        self.client.commit(b('first'), addremove=True)
+        self.client.branch(b('foo'))
         self.append('a', 'a')
-        self.client.commit('second')
+        self.client.commit(b('second'))
 
         self.assertRaises(hglib.error.CommandError,
-                          self.client.branch, 'default')
-        self.assertEquals(self.client.branch('default', force=True), 'default')
+                          self.client.branch, b('default'))
+        self.assertEquals(self.client.branch(b('default'), force=True),
+                          b('default'))
--- a/tests/test-branches.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-branches.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,4 +1,5 @@
 import common, hglib
+from hglib.util import b
 
 class test_branches(common.basetest):
     def test_empty(self):
@@ -6,10 +7,10 @@
 
     def test_basic(self):
         self.append('a', 'a')
-        rev0 = self.client.commit('first', addremove=True)
-        self.client.branch('foo')
+        rev0 = self.client.commit(b('first'), addremove=True)
+        self.client.branch(b('foo'))
         self.append('a', 'a')
-        rev1 = self.client.commit('second')
+        rev1 = self.client.commit(b('second'))
         branches = self.client.branches()
 
         expected = []
--- a/tests/test-bundle.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-bundle.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,17 +1,18 @@
 import common
+from hglib.util import b
 
 class test_bundle(common.basetest):
     def test_no_changes(self):
         self.append('a', 'a')
-        rev, node0 = self.client.commit('first', addremove=True)
-        self.assertFalse(self.client.bundle('bundle', destrepo='.'))
+        rev, node0 = self.client.commit(b('first'), addremove=True)
+        self.assertFalse(self.client.bundle(b('bundle'), destrepo=b('.')))
 
     def test_basic(self):
         self.append('a', 'a')
-        rev, node0 = self.client.commit('first', addremove=True)
-        self.client.clone(dest='other')
+        rev, node0 = self.client.commit(b('first'), addremove=True)
+        self.client.clone(dest=b('other'))
 
         self.append('a', 'a')
-        rev, node1 = self.client.commit('second')
+        rev, node1 = self.client.commit(b('second'))
 
-        self.assertTrue(self.client.bundle('bundle', destrepo='other'))
+        self.assertTrue(self.client.bundle(b('bundle'), destrepo=b('other')))
--- a/tests/test-clone.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-clone.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,12 +1,13 @@
 import os
 import common
 import hglib
+from hglib.util import b
 
 class test_clone(common.basetest):
     def test_basic(self):
         self.append('a', 'a')
-        self.client.commit('first', addremove=True)
-        cloned = hglib.clone('.', 'cloned')
+        self.client.commit(b('first'), addremove=True)
+        cloned = hglib.clone(b('.'), b('cloned'))
         self.assertRaises(ValueError, cloned.log)
         cloned.open()
         self.assertEquals(self.client.log(), cloned.log())
--- a/tests/test-commit.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-commit.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,24 +1,26 @@
 import common, hglib, datetime
+from hglib.util import b
 
 class test_commit(common.basetest):
     def test_user(self):
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True, user='foo')
+        rev, node = self.client.commit(b('first'), addremove=True,
+                                       user=b('foo'))
         rev = self.client.log(node)[0]
-        self.assertEquals(rev.author, 'foo')
+        self.assertEquals(rev.author, b('foo'))
 
     def test_no_user(self):
         self.append('a', 'a')
         self.assertRaises(hglib.error.CommandError,
-                          self.client.commit, 'first', user='')
+                          self.client.commit, b('first'), user=b(''))
 
     def test_close_branch(self):
         self.append('a', 'a')
-        rev0, node0 = self.client.commit('first', addremove=True)
-        self.client.branch('foo')
+        rev0, node0 = self.client.commit(b('first'), addremove=True)
+        self.client.branch(b('foo'))
         self.append('a', 'a')
-        rev1, node1 = self.client.commit('second')
-        revclose = self.client.commit('closing foo', closebranch=True)
+        rev1, node1 = self.client.commit(b('second'))
+        revclose = self.client.commit(b('closing foo'), closebranch=True)
         rev0, rev1, revclose = self.client.log([node0, node1, revclose[1]])
 
         self.assertEquals(self.client.branches(),
@@ -30,22 +32,25 @@
                            (rev0.branch, int(rev0.rev), rev0.node[:12])])
 
     def test_message_logfile(self):
-        self.assertRaises(ValueError, self.client.commit, 'foo', logfile='bar')
+        self.assertRaises(ValueError, self.client.commit, b('foo'),
+                          logfile=b('bar'))
         self.assertRaises(ValueError, self.client.commit)
 
     def test_date(self):
         self.append('a', 'a')
         now = datetime.datetime.now().replace(microsecond=0)
-        rev0, node0 = self.client.commit('first', addremove=True,
-                                         date=now.isoformat(' '))
+        rev0, node0 = self.client.commit(
+            b('first'), addremove=True,
+            date=now.isoformat(' ').encode('latin-1'))
 
         self.assertEquals(now, self.client.tip().date)
 
     def test_amend(self):
         self.append('a', 'a')
         now = datetime.datetime.now().replace(microsecond=0)
-        rev0, node0 = self.client.commit('first', addremove=True,
-                                         date=now.isoformat(' '))
+        rev0, node0 = self.client.commit(
+            b('first'), addremove=True,
+            date=now.isoformat(' ').encode('latin-1'))
 
         print rev0, node0
         self.assertEquals(now, self.client.tip().date)
@@ -56,4 +61,3 @@
         self.assertEquals(now, self.client.tip().date)
         self.assertNotEquals(node0, node1)
         self.assertEqual(1, len(self.client.log()))
-
--- a/tests/test-config.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-config.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,4 +1,5 @@
 import os, common, hglib
+from hglib.util import b
 
 class test_config(common.basetest):
     def setUp(self):
@@ -11,23 +12,25 @@
     def test_basic(self):
         config = self.client.config()
 
-        self.assertTrue(('section', 'key', 'value') in self.client.config())
+        self.assertTrue(
+                (b('section'), b('key'), b('value')) in self.client.config())
 
-        self.assertTrue([('section', 'key', 'value')],
-                        self.client.config('section'))
-        self.assertTrue([('section', 'key', 'value')],
-                        self.client.config(['section', 'foo']))
+        self.assertTrue([(b('section'), b('key'), b('value'))],
+                        self.client.config(b('section')))
+        self.assertTrue([(b('section'), b('key'), b('value'))],
+                        self.client.config([b('section'), b('foo')]))
         self.assertRaises(hglib.error.CommandError,
-                          self.client.config, ['a.b', 'foo'])
+                          self.client.config, [b('a.b'), b('foo')])
 
     def test_show_source(self):
         config = self.client.config(showsource=True)
 
-        self.assertTrue((os.path.abspath('.hg/hgrc') + ':2',
-                         'section', 'key', 'value') in config)
+        self.assertTrue((os.path.abspath(b('.hg/hgrc')) + b(':2'),
+                         b('section'), b('key'), b('value')) in config)
 
 class test_config_arguments(common.basetest):
     def test_basic(self):
-        client = hglib.open(configs=['diff.unified=5', 'a.b=foo'])
-        self.assertEqual(client.config('a'), [('a', 'b', 'foo')])
-        self.assertEqual(client.config('diff'), [('diff', 'unified', '5')])
+        client = hglib.open(configs=[b('diff.unified=5'), b('a.b=foo')])
+        self.assertEqual(client.config(b('a')), [(b('a'), b('b'), b('foo'))])
+        self.assertEqual(client.config(b('diff')),
+                         [(b('diff'), b('unified'), b('5'))])
--- a/tests/test-context.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-context.py	Mon Mar 09 18:26:25 2015 -0400
@@ -2,43 +2,44 @@
 from hglib.error import CommandError
 import common, hglib
 from hglib import context
+from hglib.util import b
 
 class test_context(common.basetest):
     def test_non_existent(self):
-        self.assertRaises(ValueError, context.changectx, self.client, 'foo')
+        self.assertRaises(ValueError, context.changectx, self.client, b('foo'))
 
     def test_basic(self):
         self.append('a', 'a')
         self.append('b', 'b')
-        rev0, node0 = self.client.commit('first', addremove=True)
+        rev0, node0 = self.client.commit(b('first'), addremove=True)
 
         self.append('c', 'c')
-        rev1, node1 = self.client.commit('second', addremove=True)
+        rev1, node1 = self.client.commit(b('second'), addremove=True)
 
         ctx = self.client[node0]
 
-        self.assertEquals(ctx.description(), 'first')
-        self.assertEquals(str(ctx), node0[:12])
+        self.assertEquals(ctx.description(), b('first'))
+        self.assertEquals(str(ctx), node0[:12].decode('latin-1'))
         self.assertEquals(ctx.node(), node0)
         self.assertEquals(int(ctx), rev0)
         self.assertEquals(ctx.rev(), rev0)
-        self.assertEquals(ctx.branch(), 'default')
+        self.assertEquals(ctx.branch(), b('default'))
 
         self.assertTrue(ctx)
 
-        self.assertTrue('a' in ctx and 'b' in ctx)
-        self.assertFalse('c' in ctx)
-        self.assertEquals(list(ctx), ['a', 'b'])
-        self.assertEquals(ctx.files(), ['a', 'b'])
+        self.assertTrue(b('a') in ctx and b('b') in ctx)
+        self.assertFalse(b('c') in ctx)
+        self.assertEquals(list(ctx), [b('a'), b('b')])
+        self.assertEquals(ctx.files(), [b('a'), b('b')])
 
         self.assertEquals(ctx.modified(), [])
-        self.assertEquals(ctx.added(), ['a', 'b'])
+        self.assertEquals(ctx.added(), [b('a'), b('b')])
         self.assertEquals(ctx.removed(), [])
         self.assertEquals(ctx.ignored(), [])
         self.assertEquals(ctx.clean(), [])
 
-        man = {'a' : '047b75c6d7a3ef6a2243bd0e99f94f6ea6683597',
-               'b' : '62452855512f5b81522aa3895892760bb8da9f3f'}
+        man = {b('a') : b('047b75c6d7a3ef6a2243bd0e99f94f6ea6683597'),
+               b('b') : b('62452855512f5b81522aa3895892760bb8da9f3f')}
         self.assertEquals(ctx.manifest(), man)
 
         self.assertEquals([int(c) for c in ctx.parents()], [-1])
@@ -49,16 +50,16 @@
         self.assertEquals([int(c) for c in ctx.descendants()], [0, 1])
         self.assertEquals([int(c) for c in ctx.ancestors()], [0])
 
-        self.client.bookmark('bookmark', inactive=True, rev=node0)
-        self.assertEquals(ctx.bookmarks(), ['bookmark'])
+        self.client.bookmark(b('bookmark'), inactive=True, rev=node0)
+        self.assertEquals(ctx.bookmarks(), [b('bookmark')])
 
-        self.client.tag('tag', rev=node0)
+        self.client.tag(b('tag'), rev=node0)
         # tags are read on construction
-        self.assertEquals(self.client[node0].tags(), ['tag'])
+        self.assertEquals(self.client[node0].tags(), [b('tag')])
 
     def test_construction(self):
         self.append('a', 'a')
-        rev0, node0 = self.client.commit('first', addremove=True)
+        rev0, node0 = self.client.commit(b('first'), addremove=True)
         tip = self.client.tip()
 
         # from client.revision
@@ -66,7 +67,7 @@
         self.assertEquals(ctx.node(), tip.node)
 
         # from revset
-        ctx = context.changectx(self.client, 'all()')
+        ctx = context.changectx(self.client, b('all()'))
         self.assertEquals(ctx.node(), tip.node)
 
     def test_in_keyword(self):
@@ -77,9 +78,9 @@
             return
 
         self.append('a', 'a')
-        rev0, node0 = self.client.commit('first', addremove=True)
+        rev0, node0 = self.client.commit(b('first'), addremove=True)
         self.append('a', 'a')
-        rev1, node1 = self.client.commit('second')
+        rev1, node1 = self.client.commit(b('second'))
 
         self.assertIn(1, self.client)
         hash_1 = self.client.log(0)[0][1]
@@ -87,5 +88,5 @@
         self.assertNotIn(2, self.client)
         hash_2 = self.client.log(1)[0][1]
         self.assertIn(hash_2, self.client)
-        hash_2 = 'deadbeef'
+        hash_2 = b('deadbeef')
         self.assertNotIn(hash_2, self.client)
--- a/tests/test-copy.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-copy.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,16 +1,18 @@
 import common
 import hglib
+from hglib.util import b
 
 class test_copy(common.basetest):
     def test_basic(self):
         self.append('a', 'a')
-        self.client.commit('first', addremove=True)
+        self.client.commit(b('first'), addremove=True)
 
-        self.assertTrue(self.client.copy('a', 'b'))
-        self.assertEquals(self.client.status(), [('A', 'b')])
+        self.assertTrue(self.client.copy(b('a'), b('b')))
+        self.assertEquals(self.client.status(), [(b('A'), b('b'))])
         self.append('c', 'a')
-        self.assertTrue(self.client.copy('a', 'c', after=True))
-        self.assertEquals(self.client.status(), [('A', 'b'), ('A', 'c')])
+        self.assertTrue(self.client.copy(b('a'), b('c'), after=True))
+        self.assertEquals(self.client.status(),
+                          [(b('A'), b('b')), (b('A'), b('c'))])
 
     # hg returns 0 even if there were warnings
     #def test_warnings(self):
--- a/tests/test-diff.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-diff.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,42 +1,44 @@
 import common
+from hglib.util import b
 
 class test_diff(common.basetest):
     def test_basic(self):
         self.append('a', 'a\n')
-        self.client.add('a')
-        diff1 = """diff -r 000000000000 a
+        self.client.add(b('a'))
+        diff1 = b("""diff -r 000000000000 a
 --- /dev/null
 +++ b/a
 @@ -0,0 +1,1 @@
 +a
-"""
+""")
         self.assertEquals(diff1, self.client.diff(nodates=True))
-        self.assertEquals(diff1, self.client.diff(['a'], nodates=True))
-        rev0, node0 = self.client.commit('first')
-        diff2 = """diff -r 000000000000 -r %s a
+        self.assertEquals(diff1, self.client.diff([b('a')], nodates=True))
+        rev0, node0 = self.client.commit(b('first'))
+        diff2 = b("""diff -r 000000000000 -r """) + node0[:12] + b(""" a
 --- /dev/null
 +++ b/a
 @@ -0,0 +1,1 @@
 +a
-""" % node0[:12]
+""")
         self.assertEquals(diff2, self.client.diff(change=rev0, nodates=True))
         self.append('a', 'a\n')
-        rev1, node1 = self.client.commit('second')
-        diff3 = """diff -r %s a
+        rev1, node1 = self.client.commit(b('second'))
+        diff3 = b("""diff -r """) + node0[:12] + b(""" a
 --- a/a
 +++ b/a
 @@ -1,1 +1,2 @@
  a
 +a
-""" % node0[:12]
+""")
         self.assertEquals(diff3, self.client.diff(revs=[rev0], nodates=True))
-        diff4 = """diff -r %s -r %s a
+        diff4 = b("""diff -r """) + node0[:12] + b(" -r ") + node1[:12] + b(
+            """ a
 --- a/a
 +++ b/a
 @@ -1,1 +1,2 @@
  a
 +a
-""" % (node0[:12], node1[:12])
+""")
         self.assertEquals(diff4, self.client.diff(revs=[rev0, rev1],
                                                   nodates=True))
 
--- a/tests/test-encoding.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-encoding.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,7 +1,8 @@
 import common
 import hglib
+from hglib.util import b
 
 class test_encoding(common.basetest):
     def test_basic(self):
         self.client = hglib.open(encoding='utf-8')
-        self.assertEquals(self.client.encoding, 'utf-8')
+        self.assertEquals(self.client.encoding, b('utf-8'))
--- a/tests/test-forget.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-forget.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,13 +1,14 @@
 import common
+from hglib.util import b
 
 class test_forget(common.basetest):
     def test_basic(self):
         self.append('a', 'a')
-        self.client.add(['a'])
-        self.assertTrue(self.client.forget('a'))
+        self.client.add([b('a')])
+        self.assertTrue(self.client.forget(b('a')))
 
     def test_warnings(self):
-        self.assertFalse(self.client.forget('a'))
+        self.assertFalse(self.client.forget(b('a')))
         self.append('a', 'a')
-        self.client.add(['a'])
-        self.assertFalse(self.client.forget(['a', 'b']))
+        self.client.add([b('a')])
+        self.assertFalse(self.client.forget([b('a'), b('b')]))
--- a/tests/test-grep.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-grep.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,39 +1,45 @@
 import common
+from hglib.util import b
 
 class test_grep(common.basetest):
     def test_basic(self):
         self.append('a', 'a\n')
         self.append('b', 'ab\n')
-        self.client.commit('first', addremove=True)
+        self.client.commit(b('first'), addremove=True)
 
         # no match
-        self.assertEquals(list(self.client.grep('c')), [])
+        self.assertEquals(list(self.client.grep(b('c'))), [])
 
-        self.assertEquals(list(self.client.grep('a')),
-                          [('a', '0', 'a'), ('b', '0', 'ab')])
-        self.assertEquals(list(self.client.grep('a', 'a')), [('a', '0', 'a')])
+        self.assertEquals(list(self.client.grep(b('a'))),
+                          [(b('a'), b('0'), b('a')), (b('b'), b('0'), b('ab'))])
+        self.assertEquals(list(self.client.grep(b('a'), b('a'))),
+                          [(b('a'), b('0'), b('a'))])
 
-        self.assertEquals(list(self.client.grep('b')), [('b', '0', 'ab')])
+        self.assertEquals(list(self.client.grep(b('b'))),
+                          [(b('b'), b('0'), b('ab'))])
 
     def test_options(self):
         self.append('a', 'a\n')
         self.append('b', 'ab\n')
-        rev, node = self.client.commit('first', addremove=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
 
-        self.assertEquals([('a', '0', '+', 'a'), ('b', '0', '+', 'ab')],
-                          list(self.client.grep('a', all=True)))
+        self.assertEquals([(b('a'), b('0'), b('+'), b('a')),
+                           (b('b'), b('0'), b('+'), b('ab'))],
+                          list(self.client.grep(b('a'), all=True)))
 
-        self.assertEquals([('a', '0'), ('b', '0')],
-                          list(self.client.grep('a', fileswithmatches=True)))
+        self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))],
+                          list(self.client.grep(b('a'), fileswithmatches=True)))
 
-        self.assertEquals([('a', '0', '1', 'a'), ('b', '0', '1', 'ab')],
-                          list(self.client.grep('a', line=True)))
+        self.assertEquals([(b('a'), b('0'), b('1'), b('a')),
+                           (b('b'), b('0'), b('1'), b('ab'))],
+                          list(self.client.grep(b('a'), line=True)))
 
-        self.assertEquals([('a', '0', 'test', 'a'), ('b', '0', 'test', 'ab')],
-                          list(self.client.grep('a', user=True)))
+        self.assertEquals([(b('a'), b('0'), b('test'), b('a')),
+                           (b('b'), b('0'), b('test'), b('ab'))],
+                          list(self.client.grep(b('a'), user=True)))
 
-        self.assertEquals([('a', '0', '1', '+', 'test'),
-                           ('b', '0', '1', '+', 'test')],
-                          list(self.client.grep('a', all=True, user=True,
+        self.assertEquals([(b('a'), b('0'), b('1'), b('+'), b('test')),
+                           (b('b'), b('0'), b('1'), b('+'), b('test'))],
+                          list(self.client.grep(b('a'), all=True, user=True,
                                                 line=True,
                                                 fileswithmatches=True)))
--- a/tests/test-heads.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-heads.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,4 +1,5 @@
 import common
+from hglib.util import b
 
 class test_heads(common.basetest):
     def test_empty(self):
@@ -6,11 +7,11 @@
 
     def test_basic(self):
         self.append('a', 'a')
-        rev, node0 = self.client.commit('first', addremove=True)
+        rev, node0 = self.client.commit(b('first'), addremove=True)
         self.assertEquals(self.client.heads(), [self.client.tip()])
 
-        self.client.branch('foo')
+        self.client.branch(b('foo'))
         self.append('a', 'a')
-        rev, node1 = self.client.commit('second')
+        rev, node1 = self.client.commit(b('second'))
 
         self.assertEquals(self.client.heads(node0, topological=True), [])
--- a/tests/test-hidden.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-hidden.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,5 +1,6 @@
 import common, hglib, datetime
 from hglib.error import CommandError
+from hglib.util import b
 
 class test_obsolete_reference(common.basetest):
     """make sure obsolete changesets are disabled"""
@@ -7,10 +8,10 @@
         f = open('gna1','w')
         f.write('g')
         f.close()
-        self.client.add('gna1')
-        cs = self.client.commit('gna1')[1] #get id
+        self.client.add(b('gna1'))
+        cs = self.client.commit(b('gna1'))[1] #get id
         self.assertRaises(CommandError,
-                          self.client.rawcommand, ['debugobsolete', cs])
+                          self.client.rawcommand, [b('debugobsolete'), cs])
 
 
 class test_obsolete_baselib(common.basetest):
@@ -28,21 +29,21 @@
     def test_debugobsolete_success(self):
         """check the obsolete extension is available"""
         self.append('gna1','ga')
-        self.client.add('gna1')
-        cs = self.client.commit('gna1')[1] #get id
-        self.client.rawcommand(['debugobsolete', cs])
+        self.client.add(b('gna1'))
+        cs = self.client.commit(b('gna1'))[1] #get id
+        self.client.rawcommand([b('debugobsolete'), cs])
 
     def test_obsolete_in(self):
         """test the 'hidden' keyword with the 'in' method"""
         if self.client.version < (2, 9, 0):
             return
         self.append('gna1','ga')
-        self.client.add('gna1')
-        cs0 = self.client.commit('gna1')[1] #get id
+        self.client.add(b('gna1'))
+        cs0 = self.client.commit(b('gna1'))[1] #get id
         self.append('gna2','gaaa')
-        self.client.add('gna2')
-        cs1 = self.client.commit('gna2')[1] #get id
-        self.client.rawcommand(['debugobsolete', cs1])
+        self.client.add(b('gna2'))
+        cs1 = self.client.commit(b('gna2'))[1] #get id
+        self.client.rawcommand([b('debugobsolete'), cs1])
         self.client.update(cs0)
         self.assertFalse(cs1 in self.client)
         self.assertTrue(cs0 in self.client)
@@ -56,16 +57,14 @@
         if self.client.version < (2, 9, 0):
             return
         self.append('gna1','ga')
-        self.client.add('gna1')
-        cs0 = self.client.commit('gna1')[1] #get id
+        self.client.add(b('gna1'))
+        cs0 = self.client.commit(b('gna1'))[1] #get id
         ctx0 = self.client[cs0]
         self.append('gna2','gaaa')
-        self.client.add('gna2')
-        cs1 = self.client.commit('gna2')[1] #get id
+        self.client.add(b('gna2'))
+        cs1 = self.client.commit(b('gna2'))[1] #get id
         ctx1 = self.client[cs1]
-        self.client.rawcommand(['debugobsolete', cs1])
+        self.client.rawcommand([b('debugobsolete'), cs1])
         self.client.update(cs0)
         self.assertTrue(ctx1.hidden())
         self.assertFalse(ctx0.hidden())
-
-
--- a/tests/test-import.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-import.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,7 +1,8 @@
 import common, cStringIO, os
 import hglib
+from hglib.util import b
 
-patch = """
+patch = b("""
 # HG changeset patch
 # User test
 # Date 0 0
@@ -14,12 +15,12 @@
 +++ b/a	Thu Jan 01 00:00:00 1970 +0000
 @@ -0,0 +1,1 @@
 +1
-"""
+""")
 
 class test_import(common.basetest):
     def test_basic_cstringio(self):
         self.client.import_(cStringIO.StringIO(patch))
-        self.assertEquals(self.client.cat(['a']), '1\n')
+        self.assertEquals(self.client.cat([b('a')]), b('1\n'))
 
     def test_basic_file(self):
         f = open('patch', 'wb')
@@ -27,11 +28,11 @@
         f.close()
 
         # --no-commit
-        self.client.import_(['patch'], nocommit=True)
+        self.client.import_([b('patch')], nocommit=True)
         self.assertEquals(open('a').read(), '1\n')
 
         self.client.update(clean=True)
         os.remove('a')
 
-        self.client.import_(['patch'])
-        self.assertEquals(self.client.cat(['a']), '1\n')
+        self.client.import_([b('patch')])
+        self.assertEquals(self.client.cat([b('a')]), b('1\n'))
--- a/tests/test-init.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-init.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,4 +1,5 @@
 import hglib, common, shutil
+from hglib.util import b
 
 class test_init(common.basetest):
     def test_exists(self):
@@ -10,4 +11,4 @@
         shutil.rmtree('.hg')
 
         self.client = hglib.init().open()
-        self.assertTrue(self.client.root().endswith('test_init'))
+        self.assertTrue(self.client.root().endswith(b('test_init')))
--- a/tests/test-log.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-log.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,12 +1,13 @@
 import common
 import hglib
+from hglib.util import b
 
 class test_log(common.basetest):
     def test_basic(self):
         self.append('a', 'a')
-        rev0, node0 = self.client.commit('first', addremove=True)
+        rev0, node0 = self.client.commit(b('first'), addremove=True)
         self.append('a', 'a')
-        rev1, node1 = self.client.commit('second')
+        rev1, node1 = self.client.commit(b('second'))
 
         revs = self.client.log()
         revs.reverse()
@@ -14,8 +15,8 @@
         self.assertTrue(len(revs) == 2)
         self.assertEquals(revs[1].node, node1)
 
-        self.assertEquals(revs[0], self.client.log('0')[0])
-        self.assertEquals(self.client.log(), self.client.log(files=['a']))
+        self.assertEquals(revs[0], self.client.log(b('0'))[0])
+        self.assertEquals(self.client.log(), self.client.log(files=[b('a')]))
 
         self.assertEquals(self.client.log(), self.client.log(hidden=True))
 
--- a/tests/test-manifest.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-manifest.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,24 +1,25 @@
 import common, hglib, os, stat
+from hglib.util import b
 
 class test_manifest(common.basetest):
     def test_basic(self):
         self.append('a', 'a')
-        files = ['a']
-        manifest = [('047b75c6d7a3ef6a2243bd0e99f94f6ea6683597', '644', False,
-                     False, 'a')]
+        files = [b('a')]
+        manifest = [(b('047b75c6d7a3ef6a2243bd0e99f94f6ea6683597'), b('644'),
+                     False, False, b('a'))]
 
         if os.name == 'posix':
             self.append('b', 'b')
             os.chmod('b', os.stat('b')[0] | stat.S_IEXEC)
             os.symlink('b', 'c')
 
-            files.extend(['b', 'c'])
-            manifest.extend([('62452855512f5b81522aa3895892760bb8da9f3f', '755',
-                              True, False, 'b'),
-                             ('62452855512f5b81522aa3895892760bb8da9f3f', '644',
-                              False, True, 'c')])
+            files.extend([b('b'), b('c')])
+            manifest.extend([(b('62452855512f5b81522aa3895892760bb8da9f3f'),
+                              b('755'), True, False, b('b')),
+                             (b('62452855512f5b81522aa3895892760bb8da9f3f'),
+                              b('644'), False, True, b('c'))])
 
-        self.client.commit('first', addremove=True)
+        self.client.commit(b('first'), addremove=True)
 
         self.assertEquals(list(self.client.manifest(all=True)), files)
 
--- a/tests/test-merge.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-merge.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,22 +1,23 @@
 import common, hglib
+from hglib.util import b
 
 class test_merge(common.basetest):
     def setUp(self):
         common.basetest.setUp(self)
 
         self.append('a', 'a')
-        rev, self.node0 = self.client.commit('first', addremove=True)
+        rev, self.node0 = self.client.commit(b('first'), addremove=True)
 
         self.append('a', 'a')
-        rev, self.node1 = self.client.commit('change')
+        rev, self.node1 = self.client.commit(b('change'))
 
     def test_basic(self):
         self.client.update(self.node0)
         self.append('b', 'a')
-        rev, node2 = self.client.commit('new file', addremove=True)
+        rev, node2 = self.client.commit(b('new file'), addremove=True)
         self.client.merge(self.node1)
-        rev, node = self.client.commit('merge')
-        diff = """diff -r %s -r %s a
+        rev, node = self.client.commit(b('merge'))
+        diff = b("diff -r ") + node2[:12] + b(" -r ") + node[:12] + b(""" a
 --- a/a
 +++ b/a
 @@ -1,1 +1,1 @@
@@ -24,48 +25,48 @@
 \ No newline at end of file
 +aa
 \ No newline at end of file
-""" % (node2[:12], node[:12])
+""")
 
         self.assertEquals(diff, self.client.diff(change=node, nodates=True))
 
     def test_merge_prompt_abort(self):
         self.client.update(self.node0)
-        self.client.remove('a')
-        self.client.commit('remove')
+        self.client.remove(b('a'))
+        self.client.commit(b('remove'))
 
         self.assertRaises(hglib.error.CommandError, self.client.merge)
 
     def test_merge_prompt_noninteractive(self):
         self.client.update(self.node0)
-        self.client.remove('a')
-        rev, node = self.client.commit('remove')
+        self.client.remove(b('a'))
+        rev, node = self.client.commit(b('remove'))
 
         self.client.merge(cb=hglib.merge.handlers.noninteractive)
 
-        diff = """diff -r %s a
+        diff = b("diff -r ") + node[:12] + b(""" a
 --- /dev/null
 +++ b/a
 @@ -0,0 +1,1 @@
 +aa
 \ No newline at end of file
-""" % node[:12]
+""")
         self.assertEquals(diff, self.client.diff(nodates=True))
 
     def test_merge_prompt_cb(self):
         self.client.update(self.node0)
-        self.client.remove('a')
-        rev, node = self.client.commit('remove')
+        self.client.remove(b('a'))
+        rev, node = self.client.commit(b('remove'))
 
         def cb(output):
-            return 'c'
+            return b('c')
 
         self.client.merge(cb=cb)
 
-        diff = """diff -r %s a
+        diff = b("diff -r ") + node[:12] + b(""" a
 --- /dev/null
 +++ b/a
 @@ -0,0 +1,1 @@
 +aa
 \ No newline at end of file
-""" % node[:12]
+""")
         self.assertEquals(diff, self.client.diff(nodates=True))
--- a/tests/test-move.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-move.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,10 +1,11 @@
 import common, os
+from hglib.util import b
 
 class test_move(common.basetest):
     def test_basic(self):
         self.append('a', 'a')
-        self.client.add('a')
-        self.assertTrue(self.client.move('a', 'b'))
+        self.client.add(b('a'))
+        self.assertTrue(self.client.move(b('a'), b('b')))
 
     # hg returns 0 even if there were warnings
     #def test_warnings(self):
--- a/tests/test-outgoing-incoming.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-outgoing-incoming.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,32 +1,34 @@
 import common
 import hglib
+from hglib.util import b
 
 class test_outgoing_incoming(common.basetest):
     def test_no_path(self):
         self.assertRaises(hglib.error.CommandError, self.client.incoming)
 
     def test_empty(self):
-        self.client.clone(dest='other')
-        self.other = hglib.open('other')
+        self.client.clone(dest=b('other'))
+        self.other = hglib.open(b('other'))
 
         self.assertEquals(self.other.incoming(), [])
         self.assertEquals(self.other.outgoing(), [])
 
     def test_basic(self):
         self.append('a', 'a')
-        self.client.commit('first', addremove=True)
+        self.client.commit(b('first'), addremove=True)
         self.append('a', 'a')
-        self.client.commit('second')
+        self.client.commit(b('second'))
 
-        self.client.clone(dest='other')
-        other = hglib.open('other')
+        self.client.clone(dest=b('other'))
+        other = hglib.open(b('other'))
 
         self.assertEquals(self.client.log(), other.log())
-        self.assertEquals(self.client.outgoing(path='other'), other.incoming())
+        self.assertEquals(self.client.outgoing(path=b('other')),
+                          other.incoming())
 
         self.append('a', 'a')
-        rev, node = self.client.commit('third')
-        out = self.client.outgoing(path='other')
+        rev, node = self.client.commit(b('third'))
+        out = self.client.outgoing(path=b('other'))
 
         self.assertEquals(len(out), 1)
         self.assertEquals(out[0].node, node)
@@ -35,17 +37,17 @@
 
     def test_bookmarks(self):
         self.append('a', 'a')
-        self.client.commit('first', addremove=True)
+        self.client.commit(b('first'), addremove=True)
         self.append('a', 'a')
-        self.client.commit('second')
+        self.client.commit(b('second'))
 
-        self.client.clone(dest='other')
-        other = hglib.open('other')
+        self.client.clone(dest=b('other'))
+        other = hglib.open(b('other'))
 
-        self.client.bookmark('bm1', 1)
+        self.client.bookmark(b('bm1'), 1)
 
         self.assertEquals(other.incoming(bookmarks=True),
-                          [('bm1', self.client.tip().node[:12])])
+                          [(b('bm1'), self.client.tip().node[:12])])
 
-        self.assertEquals(self.client.outgoing(path='other', bookmarks=True),
-                          [('bm1', self.client.tip().node[:12])])
+        self.assertEquals(self.client.outgoing(path=b('other'), bookmarks=True),
+                          [(b('bm1'), self.client.tip().node[:12])])
--- a/tests/test-parents.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-parents.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,4 +1,5 @@
 import common
+from hglib.util import b
 
 class test_parents(common.basetest):
     def test_noparents(self):
@@ -6,9 +7,9 @@
 
     def test_basic(self):
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
         self.assertEquals(node, self.client.parents()[0].node)
-        self.assertEquals(node, self.client.parents(file='a')[0].node)
+        self.assertEquals(node, self.client.parents(file=b('a'))[0].node)
 
     def test_two_parents(self):
         pass
--- a/tests/test-paths.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-paths.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,5 +1,6 @@
 import common, os
 import hglib
+from hglib.util import b
 
 class test_paths(common.basetest):
     def test_basic(self):
@@ -11,5 +12,7 @@
         self.client = hglib.open()
         paths = self.client.paths()
         self.assertEquals(len(paths), 1)
-        self.assertEquals(paths['foo'], os.path.abspath('bar'))
-        self.assertEquals(self.client.paths('foo'), os.path.abspath('bar'))
+        self.assertEquals(paths[b('foo')],
+                          os.path.abspath('bar').encode('latin-1'))
+        self.assertEquals(self.client.paths(b('foo')),
+                          os.path.abspath('bar').encode('latin-1'))
--- a/tests/test-phase.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-phase.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,45 +1,46 @@
 import common, hglib
+from hglib.util import b
 
 class test_phase(common.basetest):
     """test the different ways to use the phase command"""
     def test_phase(self):
         """test getting data from a single changeset"""
         self.append('a', 'a')
-        rev, node0 = self.client.commit('first', addremove=True)
-        self.assertEqual([(0, 'draft')], self.client.phase(node0))
+        rev, node0 = self.client.commit(b('first'), addremove=True)
+        self.assertEqual([(0, b('draft'))], self.client.phase(node0))
         ctx = self.client[rev]
-        self.assertEqual('draft', ctx.phase())
+        self.assertEqual(b('draft'), ctx.phase())
 
     def test_phase_public(self):
         """test phase change from draft to public"""
         self.append('a', 'a')
-        rev, node0 = self.client.commit('first', addremove=True)
+        rev, node0 = self.client.commit(b('first'), addremove=True)
         self.client.phase(node0, public=True)
-        self.assertEqual([(0, 'public')], self.client.phase(node0))
+        self.assertEqual([(0, b('public'))], self.client.phase(node0))
         ctx = self.client[rev]
-        self.assertEqual('public', ctx.phase())
+        self.assertEqual(b('public'), ctx.phase())
 
     def test_phase_secret(self):
         """test phase change from draft to secret"""
         self.append('a', 'a')
-        rev, node0 = self.client.commit('first', addremove=True)
+        rev, node0 = self.client.commit(b('first'), addremove=True)
         self.assertRaises(hglib.error.CommandError,
                           self.client.phase, node0, secret=True)
         self.client.phase(node0, secret=True, force=True)
-        self.assertEqual([(0, 'secret')], self.client.phase(node0))
+        self.assertEqual([(0, b('secret'))], self.client.phase(node0))
         ctx = self.client[rev]
-        self.assertEqual('secret', ctx.phase())
+        self.assertEqual(b('secret'), ctx.phase())
 
 
     def test_phase_multiple(self):
         """test phase changes and show the phases of the different changesets"""
         self.append('a', 'a')
-        rev, node0 = self.client.commit('a', addremove=True)
+        rev, node0 = self.client.commit(b('a'), addremove=True)
         self.client.phase(node0, public=True)
         self.append('b', 'b')
-        rev, node1 = self.client.commit('b', addremove=True)
+        rev, node1 = self.client.commit(b('b'), addremove=True)
         self.append('c', 'c')
-        rev, node2 = self.client.commit('c', addremove=True)
+        rev, node2 = self.client.commit(b('c'), addremove=True)
         self.client.phase(node2, secret=True, force=True)
-        self.assertEqual([(0, 'public'), (2, 'secret'), (1, 'draft')],
+        self.assertEqual([(0, b('public')), (2, b('secret')), (1, b('draft'))],
                          self.client.phase([node0, node2, node1]))
--- a/tests/test-pull.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-pull.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,29 +1,30 @@
 import common, hglib
+from hglib.util import b
 
 class test_pull(common.basetest):
     def test_basic(self):
         self.append('a', 'a')
-        self.client.commit('first', addremove=True)
+        self.client.commit(b('first'), addremove=True)
 
-        self.client.clone(dest='other')
-        other = hglib.open('other')
+        self.client.clone(dest=b('other'))
+        other = hglib.open(b('other'))
 
         self.append('a', 'a')
-        self.client.commit('second')
+        self.client.commit(b('second'))
 
         self.assertTrue(other.pull())
         self.assertEquals(self.client.log(), other.log())
 
     def test_unresolved(self):
         self.append('a', 'a')
-        self.client.commit('first', addremove=True)
+        self.client.commit(b('first'), addremove=True)
 
-        self.client.clone(dest='other')
-        other = hglib.open('other')
+        self.client.clone(dest=b('other'))
+        other = hglib.open(b('other'))
 
         self.append('a', 'a')
-        self.client.commit('second')
+        self.client.commit(b('second'))
 
         self.append('other/a', 'b')
         self.assertFalse(other.pull(update=True))
-        self.assertTrue(('M', 'a') in other.status())
+        self.assertTrue((b('M'), b('a')) in other.status())
--- a/tests/test-push.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-push.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,18 +1,19 @@
 import common, hglib
+from hglib.util import b
 
 class test_push(common.basetest):
     def test_basic(self):
         self.append('a', 'a')
-        self.client.commit('first', addremove=True)
+        self.client.commit(b('first'), addremove=True)
 
-        self.client.clone(dest='other')
-        other = hglib.open('other')
+        self.client.clone(dest=b('other'))
+        other = hglib.open(b('other'))
 
         # broken in hg, doesn't return 1 if nothing to push
         #self.assertFalse(self.client.push('other'))
 
         self.append('a', 'a')
-        self.client.commit('second')
+        self.client.commit(b('second'))
 
-        self.assertTrue(self.client.push('other'))
+        self.assertTrue(self.client.push(b('other')))
         self.assertEquals(self.client.log(), other.log())
--- a/tests/test-remove.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-remove.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,12 +1,13 @@
 import common
+from hglib.util import b
 
 class test_remove(common.basetest):
     def test_basic(self):
         self.append('a', 'a')
-        self.client.commit('first', addremove=True)
-        self.assertTrue(self.client.remove(['a']))
+        self.client.commit(b('first'), addremove=True)
+        self.assertTrue(self.client.remove([b('a')]))
 
     def test_warnings(self):
         self.append('a', 'a')
-        self.client.commit('first', addremove=True)
-        self.assertFalse(self.client.remove(['a', 'b']))
+        self.client.commit(b('first'), addremove=True)
+        self.assertFalse(self.client.remove([b('a'), b('b')]))
--- a/tests/test-resolve.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-resolve.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,4 +1,5 @@
 import common, hglib
+from hglib.util import b
 
 class test_resolve(common.basetest):
     def setUp(self):
@@ -6,26 +7,26 @@
 
         self.append('a', 'a')
         self.append('b', 'b')
-        rev, self.node0 = self.client.commit('first', addremove=True)
+        rev, self.node0 = self.client.commit(b('first'), addremove=True)
 
         self.append('a', 'a')
         self.append('b', 'b')
-        rev, self.node1 = self.client.commit('second')
+        rev, self.node1 = self.client.commit(b('second'))
 
     def test_basic(self):
         self.client.update(self.node0)
         self.append('a', 'b')
         self.append('b', 'a')
-        rev, self.node3 = self.client.commit('third')
+        rev, self.node3 = self.client.commit(b('third'))
 
         self.assertRaises(hglib.error.CommandError, self.client.merge,
                           self.node1)
         self.assertRaises(hglib.error.CommandError,
                           self.client.resolve, all=True)
 
-        self.assertEquals([('U', 'a'), ('U', 'b')],
+        self.assertEquals([(b('U'), b('a')), (b('U'), b('b'))],
                           self.client.resolve(listfiles=True))
 
-        self.client.resolve('a', mark=True)
-        self.assertEquals([('R', 'a'), ('U', 'b')],
+        self.client.resolve(b('a'), mark=True)
+        self.assertEquals([(b('R'), b('a')), (b('U'), b('b'))],
                           self.client.resolve(listfiles=True))
--- a/tests/test-status.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-status.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,4 +1,5 @@
 import common, os
+from hglib.util import b
 
 class test_status(common.basetest):
     def test_empty(self):
@@ -11,22 +12,22 @@
         self.append('modified', 'a')
         self.append('removed', 'a')
         self.append('missing', 'a')
-        self.client.commit('first', addremove=True)
+        self.client.commit(b('first'), addremove=True)
         self.append('modified', 'a')
         self.append('added', 'a')
-        self.client.add(['added'])
+        self.client.add([b('added')])
         os.remove('missing')
-        self.client.remove(['removed'])
+        self.client.remove([b('removed')])
         self.append('untracked')
 
-        l = [('M', 'modified'),
-             ('A', 'added'),
-             ('R', 'removed'),
-             ('C', '.hgignore'),
-             ('C', 'clean'),
-             ('!', 'missing'),
-             ('?', 'untracked'),
-             ('I', 'ignored')]
+        l = [(b('M'), b('modified')),
+             (b('A'), b('added')),
+             (b('R'), b('removed')),
+             (b('C'), b('.hgignore')),
+             (b('C'), b('clean')),
+             (b('!'), b('missing')),
+             (b('?'), b('untracked')),
+             (b('I'), b('ignored'))]
 
         st = self.client.status(all=True)
 
@@ -35,14 +36,14 @@
 
     def test_copy(self):
         self.append('source', 'a')
-        self.client.commit('first', addremove=True)
-        self.client.copy('source', 'dest')
-        l = [('A', 'dest'), (' ', 'source')]
+        self.client.commit(b('first'), addremove=True)
+        self.client.copy(b('source'), b('dest'))
+        l = [(b('A'), b('dest')), (b(' '), b('source'))]
         self.assertEquals(self.client.status(copies=True), l)
 
     def test_copy_origin_space(self):
         self.append('s ource', 'a')
-        self.client.commit('first', addremove=True)
-        self.client.copy('s ource', 'dest')
-        l = [('A', 'dest'), (' ', 's ource')]
+        self.client.commit(b('first'), addremove=True)
+        self.client.copy(b('s ource'), b('dest'))
+        l = [(b('A'), b('dest')), (b(' '), b('s ource'))]
         self.assertEquals(self.client.status(copies=True), l)
--- a/tests/test-summary.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-summary.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,114 +1,115 @@
 import common
 import hglib
+from hglib.util import b
 
 class test_summary(common.basetest):
     def test_empty(self):
-        d = {'parent' : [(-1, '000000000000', 'tip', None)],
-             'branch' : 'default',
-             'commit' : True,
-             'update' : 0}
+        d = {b('parent') : [(-1, b('000000000000'), b('tip'), None)],
+             b('branch') : b('default'),
+             b('commit') : True,
+             b('update') : 0}
 
         self.assertEquals(self.client.summary(), d)
 
     def test_basic(self):
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
 
-        d = {'parent' : [(0, node[:12], 'tip', 'first')],
-             'branch' : 'default',
-             'commit' : True,
-             'update' : 0}
+        d = {b('parent') : [(0, node[:12], b('tip'), b('first'))],
+             b('branch') : b('default'),
+             b('commit') : True,
+             b('update') : 0}
 
         self.assertEquals(self.client.summary(), d)
 
     def test_commit_dirty(self):
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
         self.append('a', 'a')
 
-        d = {'parent' : [(0, node[:12], 'tip', 'first')],
-             'branch' : 'default',
-             'commit' : False,
-             'update' : 0}
+        d = {b('parent') : [(0, node[:12], b('tip'), b('first'))],
+             b('branch') : b('default'),
+             b('commit') : False,
+             b('update') : 0}
 
         self.assertEquals(self.client.summary(), d)
 
     def test_update(self):
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
         self.append('a', 'a')
-        self.client.commit('second')
+        self.client.commit(b('second'))
         self.client.update(0)
 
-        d = {'parent' : [(0, node[:12], None, 'first')],
-             'branch' : 'default',
-             'commit' : True,
-             'update' : 1}
+        d = {b('parent') : [(0, node[:12], None, b('first'))],
+             b('branch') : b('default'),
+             b('commit') : True,
+             b('update') : 1}
 
         self.assertEquals(self.client.summary(), d)
 
     def test_remote(self):
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
 
-        self.client.clone(dest='other')
+        self.client.clone(dest=b('other'))
         other = hglib.open('other')
 
-        d = {'parent' : [(0, node[:12], 'tip', 'first')],
-             'branch' : 'default',
-             'commit' : True,
-             'update' : 0,
-             'remote' : (0, 0, 0, 0)}
+        d = {b('parent') : [(0, node[:12], b('tip'), b('first'))],
+             b('branch') : b('default'),
+             b('commit') : True,
+             b('update') : 0,
+             b('remote') : (0, 0, 0, 0)}
 
         self.assertEquals(other.summary(remote=True), d)
 
         self.append('a', 'a')
-        self.client.commit('second')
+        self.client.commit(b('second'))
 
-        d['remote'] = (1, 0, 0, 0)
+        d[b('remote')] = (1, 0, 0, 0)
         self.assertEquals(other.summary(remote=True), d)
 
-        self.client.bookmark('bm')
-        d['remote'] = (1, 1, 0, 0)
+        self.client.bookmark(b('bm'))
+        d[b('remote')] = (1, 1, 0, 0)
         self.assertEquals(other.summary(remote=True), d)
 
-        other.bookmark('bmother')
-        d['remote'] = (1, 1, 0, 1)
+        other.bookmark(b('bmother'))
+        d[b('remote')] = (1, 1, 0, 1)
         if self.client.version < (2, 0, 0):
-            d['parent'] = [(0, node[:12], 'tip bmother', 'first')]
+            d[b('parent')] = [(0, node[:12], b('tip bmother'), b('first'))]
         else:
-            d['bookmarks'] = '*bmother'
+            d[b('bookmarks')] = b('*bmother')
         self.assertEquals(other.summary(remote=True), d)
 
         self.append('other/a', 'a')
-        rev, node = other.commit('second in other')
+        rev, node = other.commit(b('second in other'))
 
-        d['remote'] = (1, 1, 1, 1)
+        d[b('remote')] = (1, 1, 1, 1)
         if self.client.version < (2, 0, 0):
-            tags = 'tip bmother'
+            tags = b('tip bmother')
         else:
-            tags = 'tip'
-        d['parent'] = [(1, node[:12], tags, 'second in other')]
+            tags = b('tip')
+        d[b('parent')] = [(1, node[:12], tags, b('second in other'))]
 
         self.assertEquals(other.summary(remote=True), d)
 
     def test_two_parents(self):
         self.append('a', 'a')
-        rev0, node = self.client.commit('first', addremove=True)
+        rev0, node = self.client.commit(b('first'), addremove=True)
 
         self.append('a', 'a')
-        rev1, node1 = self.client.commit('second')
+        rev1, node1 = self.client.commit(b('second'))
 
         self.client.update(rev0)
         self.append('b', 'a')
-        rev2, node2 = self.client.commit('third', addremove=True)
+        rev2, node2 = self.client.commit(b('third'), addremove=True)
 
         self.client.merge(rev1)
 
-        d = {'parent' : [(2, node2[:12], 'tip', 'third'),
-                         (1, node1[:12], None, 'second')],
-             'branch' : 'default',
-             'commit' : False,
-             'update' : 0}
+        d = {b('parent') : [(2, node2[:12], b('tip'), b('third')),
+                         (1, node1[:12], None, b('second'))],
+             b('branch') : b('default'),
+             b('commit') : False,
+             b('update') : 0}
 
         self.assertEquals(self.client.summary(), d)
--- a/tests/test-tags.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-tags.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,12 +1,13 @@
 import common
 import hglib
+from hglib.util import b
 
 class test_tags(common.basetest):
     def test_basic(self):
         self.append('a', 'a')
-        rev, node = self.client.commit('first', addremove=True)
-        self.client.tag('my tag')
-        self.client.tag('local tag', rev=rev, local=True)
+        rev, node = self.client.commit(b('first'), addremove=True)
+        self.client.tag(b('my tag'))
+        self.client.tag(b('local tag'), rev=rev, local=True)
 
         # filecache that was introduced in 2.0 makes us see the local tag, for
         # now we have to reconnect
@@ -14,6 +15,7 @@
             self.client = hglib.open()
 
         tags = self.client.tags()
-        self.assertEquals(tags, [('tip', 1, self.client.tip().node[:12], False),
-                                 ('my tag', 0, node[:12], False),
-                                 ('local tag', 0, node[:12], True)])
+        self.assertEquals(tags,
+                          [(b('tip'), 1, self.client.tip().node[:12], False),
+                           (b('my tag'), 0, node[:12], False),
+                           (b('local tag'), 0, node[:12], True)])
--- a/tests/test-update.py	Sun Mar 08 13:08:37 2015 -0400
+++ b/tests/test-update.py	Mon Mar 09 18:26:25 2015 -0400
@@ -1,13 +1,14 @@
 import common
 from hglib import error
+from hglib.util import b
 
 class test_update(common.basetest):
     def setUp(self):
         common.basetest.setUp(self)
         self.append('a', 'a')
-        self.rev0, self.node0 = self.client.commit('first', addremove=True)
+        self.rev0, self.node0 = self.client.commit(b('first'), addremove=True)
         self.append('a', 'a')
-        self.rev1, self.node1 = self.client.commit('second')
+        self.rev1, self.node1 = self.client.commit(b('second'))
 
     def test_basic(self):
         u, m, r, ur = self.client.update(self.rev0)
@@ -24,24 +25,24 @@
         self.assertEquals(m, 0)
         self.assertEquals(r, 0)
         self.assertEquals(ur, 1)
-        self.assertTrue(('M', 'a') in self.client.status())
+        self.assertTrue((b('M'), b('a')) in self.client.status())
 
     def test_merge(self):
         self.append('a', '\n\n\n\nb')
-        rev2, node2 = self.client.commit('third')
+        rev2, node2 = self.client.commit(b('third'))
         self.append('a', 'b')
-        self.client.commit('fourth')
+        self.client.commit(b('fourth'))
         self.client.update(rev2)
         old = open('a').read()
         f = open('a', 'wb')
-        f.write('a' + old)
+        f.write(b('a') + old.encode('latin-1'))
         f.close()
         u, m, r, ur = self.client.update()
         self.assertEquals(u, 0)
         self.assertEquals(m, 1)
         self.assertEquals(r, 0)
         self.assertEquals(ur, 0)
-        self.assertEquals(self.client.status(), [('M', 'a')])
+        self.assertEquals(self.client.status(), [(b('M'), b('a'))])
 
     def test_tip(self):
         self.client.update(self.rev0)
@@ -51,7 +52,7 @@
 
         self.client.update(self.rev0)
         self.append('a', 'b')
-        rev2, node2 = self.client.commit('new head')
+        rev2, node2 = self.client.commit(b('new head'))
         self.client.update(self.rev0)
 
         self.client.update()
@@ -85,13 +86,13 @@
         f.close()
         self.append('b', 'a')
         try:
-            self.client.rawcommand(['add', 'b', '--large'])
+            self.client.rawcommand([b('add'), b('b'), b('--large')])
         except error.CommandError:
             return
 
-        rev2, node2 = self.client.commit('third')
+        rev2, node2 = self.client.commit(b('third'))
         # Go back to 0
-        self.client.rawcommand(['update', str(self.rev0)],
+        self.client.rawcommand([b('update'), str(self.rev0).encode('latin-1')],
                                 # Keep the 'changed' version
                                prompt=lambda s, d: 'c\n')
         u, m, r, ur = self.client.update(rev2, clean=True)