|
@@ -106,7 +106,7 @@ class DulwichClientTestBase(object):
|
|
with closing(repo.Repo(srcpath)) as src:
|
|
with closing(repo.Repo(srcpath)) as src:
|
|
sendrefs = dict(src.get_refs())
|
|
sendrefs = dict(src.get_refs())
|
|
del sendrefs[b'HEAD']
|
|
del sendrefs[b'HEAD']
|
|
- c.send_pack(self._build_path('/dest'), lambda _: sendrefs,
|
|
|
|
|
|
+ c.send_pack(self._build_path(b'/dest'), lambda _: sendrefs,
|
|
src.object_store.generate_pack_contents)
|
|
src.object_store.generate_pack_contents)
|
|
|
|
|
|
def test_send_pack(self):
|
|
def test_send_pack(self):
|
|
@@ -126,7 +126,7 @@ class DulwichClientTestBase(object):
|
|
with closing(repo.Repo(srcpath)) as src:
|
|
with closing(repo.Repo(srcpath)) as src:
|
|
sendrefs = dict(src.get_refs())
|
|
sendrefs = dict(src.get_refs())
|
|
del sendrefs[b'HEAD']
|
|
del sendrefs[b'HEAD']
|
|
- c.send_pack(self._build_path('/dest'), lambda _: sendrefs,
|
|
|
|
|
|
+ c.send_pack(self._build_path(b'/dest'), lambda _: sendrefs,
|
|
src.object_store.generate_pack_contents)
|
|
src.object_store.generate_pack_contents)
|
|
self.assertDestEqualsSrc()
|
|
self.assertDestEqualsSrc()
|
|
|
|
|
|
@@ -164,7 +164,7 @@ class DulwichClientTestBase(object):
|
|
sendrefs, gen_pack = self.compute_send(src)
|
|
sendrefs, gen_pack = self.compute_send(src)
|
|
c = self._client()
|
|
c = self._client()
|
|
try:
|
|
try:
|
|
- c.send_pack(self._build_path('/dest'), lambda _: sendrefs, gen_pack)
|
|
|
|
|
|
+ c.send_pack(self._build_path(b'/dest'), lambda _: sendrefs, gen_pack)
|
|
except errors.UpdateRefsError as e:
|
|
except errors.UpdateRefsError as e:
|
|
self.assertEqual('refs/heads/master failed to update',
|
|
self.assertEqual('refs/heads/master failed to update',
|
|
e.args[0])
|
|
e.args[0])
|
|
@@ -182,7 +182,7 @@ class DulwichClientTestBase(object):
|
|
sendrefs, gen_pack = self.compute_send(src)
|
|
sendrefs, gen_pack = self.compute_send(src)
|
|
c = self._client()
|
|
c = self._client()
|
|
try:
|
|
try:
|
|
- c.send_pack(self._build_path('/dest'), lambda _: sendrefs, gen_pack)
|
|
|
|
|
|
+ c.send_pack(self._build_path(b'/dest'), lambda _: sendrefs, gen_pack)
|
|
except errors.UpdateRefsError as e:
|
|
except errors.UpdateRefsError as e:
|
|
self.assertIn(str(e),
|
|
self.assertIn(str(e),
|
|
['{0}, {1} failed to update'.format(
|
|
['{0}, {1} failed to update'.format(
|
|
@@ -196,7 +196,7 @@ class DulwichClientTestBase(object):
|
|
def test_archive(self):
|
|
def test_archive(self):
|
|
c = self._client()
|
|
c = self._client()
|
|
f = BytesIO()
|
|
f = BytesIO()
|
|
- c.archive(self._build_path('/server_new.export'), b'HEAD', f.write)
|
|
|
|
|
|
+ c.archive(self._build_path(b'/server_new.export'), b'HEAD', f.write)
|
|
f.seek(0)
|
|
f.seek(0)
|
|
tf = tarfile.open(fileobj=f)
|
|
tf = tarfile.open(fileobj=f)
|
|
self.assertEqual(['baz', 'foo'], tf.getnames())
|
|
self.assertEqual(['baz', 'foo'], tf.getnames())
|
|
@@ -204,7 +204,7 @@ class DulwichClientTestBase(object):
|
|
def test_fetch_pack(self):
|
|
def test_fetch_pack(self):
|
|
c = self._client()
|
|
c = self._client()
|
|
with closing(repo.Repo(os.path.join(self.gitroot, 'dest'))) as dest:
|
|
with closing(repo.Repo(os.path.join(self.gitroot, 'dest'))) as dest:
|
|
- refs = c.fetch(self._build_path('/server_new.export'), dest)
|
|
|
|
|
|
+ refs = c.fetch(self._build_path(b'/server_new.export'), dest)
|
|
for r in refs.items():
|
|
for r in refs.items():
|
|
dest.refs.set_if_equals(r[0], None, r[1])
|
|
dest.refs.set_if_equals(r[0], None, r[1])
|
|
self.assertDestEqualsSrc()
|
|
self.assertDestEqualsSrc()
|
|
@@ -216,7 +216,7 @@ class DulwichClientTestBase(object):
|
|
c = self._client()
|
|
c = self._client()
|
|
repo_dir = os.path.join(self.gitroot, 'server_new.export')
|
|
repo_dir = os.path.join(self.gitroot, 'server_new.export')
|
|
with closing(repo.Repo(repo_dir)) as dest:
|
|
with closing(repo.Repo(repo_dir)) as dest:
|
|
- refs = c.fetch(self._build_path('/dest'), dest)
|
|
|
|
|
|
+ refs = c.fetch(self._build_path(b'/dest'), dest)
|
|
for r in refs.items():
|
|
for r in refs.items():
|
|
dest.refs.set_if_equals(r[0], None, r[1])
|
|
dest.refs.set_if_equals(r[0], None, r[1])
|
|
self.assertDestEqualsSrc()
|
|
self.assertDestEqualsSrc()
|
|
@@ -225,7 +225,7 @@ class DulwichClientTestBase(object):
|
|
c = self._client()
|
|
c = self._client()
|
|
c._fetch_capabilities.remove(b'side-band-64k')
|
|
c._fetch_capabilities.remove(b'side-band-64k')
|
|
with closing(repo.Repo(os.path.join(self.gitroot, 'dest'))) as dest:
|
|
with closing(repo.Repo(os.path.join(self.gitroot, 'dest'))) as dest:
|
|
- refs = c.fetch(self._build_path('/server_new.export'), dest)
|
|
|
|
|
|
+ refs = c.fetch(self._build_path(b'/server_new.export'), dest)
|
|
for r in refs.items():
|
|
for r in refs.items():
|
|
dest.refs.set_if_equals(r[0], None, r[1])
|
|
dest.refs.set_if_equals(r[0], None, r[1])
|
|
self.assertDestEqualsSrc()
|
|
self.assertDestEqualsSrc()
|
|
@@ -235,7 +235,7 @@ class DulwichClientTestBase(object):
|
|
# be ignored
|
|
# be ignored
|
|
c = self._client()
|
|
c = self._client()
|
|
with closing(repo.Repo(os.path.join(self.gitroot, 'dest'))) as dest:
|
|
with closing(repo.Repo(os.path.join(self.gitroot, 'dest'))) as dest:
|
|
- refs = c.fetch(self._build_path('/server_new.export'), dest,
|
|
|
|
|
|
+ refs = c.fetch(self._build_path(b'/server_new.export'), dest,
|
|
lambda refs: [protocol.ZERO_SHA])
|
|
lambda refs: [protocol.ZERO_SHA])
|
|
for r in refs.items():
|
|
for r in refs.items():
|
|
dest.refs.set_if_equals(r[0], None, r[1])
|
|
dest.refs.set_if_equals(r[0], None, r[1])
|
|
@@ -251,12 +251,12 @@ class DulwichClientTestBase(object):
|
|
gen_pack = lambda have, want: []
|
|
gen_pack = lambda have, want: []
|
|
c = self._client()
|
|
c = self._client()
|
|
self.assertEqual(dest.refs[b"refs/heads/abranch"], dummy_commit)
|
|
self.assertEqual(dest.refs[b"refs/heads/abranch"], dummy_commit)
|
|
- c.send_pack(self._build_path('/dest'), lambda _: sendrefs, gen_pack)
|
|
|
|
|
|
+ c.send_pack(self._build_path(b'/dest'), lambda _: sendrefs, gen_pack)
|
|
self.assertFalse(b"refs/heads/abranch" in dest.refs)
|
|
self.assertFalse(b"refs/heads/abranch" in dest.refs)
|
|
|
|
|
|
def test_get_refs(self):
|
|
def test_get_refs(self):
|
|
c = self._client()
|
|
c = self._client()
|
|
- refs = c.get_refs(self._build_path('/server_new.export'))
|
|
|
|
|
|
+ refs = c.get_refs(self._build_path(b'/server_new.export'))
|
|
|
|
|
|
repo_dir = os.path.join(self.gitroot, 'server_new.export')
|
|
repo_dir = os.path.join(self.gitroot, 'server_new.export')
|
|
with closing(repo.Repo(repo_dir)) as dest:
|
|
with closing(repo.Repo(repo_dir)) as dest:
|
|
@@ -312,7 +312,7 @@ class DulwichTCPClientTest(CompatTestCase, DulwichClientTestBase):
|
|
return client.TCPGitClient(b'localhost')
|
|
return client.TCPGitClient(b'localhost')
|
|
|
|
|
|
def _build_path(self, path):
|
|
def _build_path(self, path):
|
|
- return path.encode(sys.getfilesystemencoding())
|
|
|
|
|
|
+ return path
|
|
|
|
|
|
if sys.platform == 'win32':
|
|
if sys.platform == 'win32':
|
|
@expectedFailure
|
|
@expectedFailure
|
|
@@ -321,10 +321,11 @@ class DulwichTCPClientTest(CompatTestCase, DulwichClientTestBase):
|
|
|
|
|
|
|
|
|
|
class TestSSHVendor(object):
|
|
class TestSSHVendor(object):
|
|
|
|
+
|
|
@staticmethod
|
|
@staticmethod
|
|
def run_command(host, command, username=None, port=None):
|
|
def run_command(host, command, username=None, port=None):
|
|
cmd, path = command
|
|
cmd, path = command
|
|
- cmd = cmd.split('-', 1)
|
|
|
|
|
|
+ cmd = cmd.split(b'-', 1)
|
|
p = subprocess.Popen(cmd + [path], bufsize=0, env=get_safe_env(), stdin=subprocess.PIPE,
|
|
p = subprocess.Popen(cmd + [path], bufsize=0, env=get_safe_env(), stdin=subprocess.PIPE,
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
return client.SubprocessWrapper(p)
|
|
return client.SubprocessWrapper(p)
|
|
@@ -347,7 +348,7 @@ class DulwichMockSSHClientTest(CompatTestCase, DulwichClientTestBase):
|
|
return client.SSHGitClient(b'localhost')
|
|
return client.SSHGitClient(b'localhost')
|
|
|
|
|
|
def _build_path(self, path):
|
|
def _build_path(self, path):
|
|
- return self.gitroot + path
|
|
|
|
|
|
+ return self.gitroot.encode(sys.getfilesystemencoding()) + path
|
|
|
|
|
|
|
|
|
|
class DulwichSubprocessClientTest(CompatTestCase, DulwichClientTestBase):
|
|
class DulwichSubprocessClientTest(CompatTestCase, DulwichClientTestBase):
|
|
@@ -364,7 +365,7 @@ class DulwichSubprocessClientTest(CompatTestCase, DulwichClientTestBase):
|
|
return client.SubprocessGitClient(stderr=subprocess.PIPE)
|
|
return client.SubprocessGitClient(stderr=subprocess.PIPE)
|
|
|
|
|
|
def _build_path(self, path):
|
|
def _build_path(self, path):
|
|
- return self.gitroot + path
|
|
|
|
|
|
+ return self.gitroot.encode(sys.getfilesystemencoding()) + path
|
|
|
|
|
|
|
|
|
|
class GitHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|
class GitHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|