Skip to content

Commit 60e5413

Browse files
committed
test_remote works
And I have to wonder why git-daemon serves under py2.7, but really wants receive-pack to be allowed under 3.4. Maybe it's a repository override which for some reason doesn't work in py3.4 ? Maybe because the change is not flushed ?
1 parent a83eee5 commit 60e5413

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

git/cmd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def wait(self):
120120
:raise GitCommandError: if the return status is not 0"""
121121
status = self.proc.wait()
122122
if status != 0:
123-
raise GitCommandError(self.args, status, self.proc.stderr.read())
123+
raise GitCommandError(self.args, status, self.proc.stderr.read().decode(defenc))
124124
# END status handling
125125
return status
126126
# END auto interrupt

git/exc.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ def __init__(self, command, status, stderr=None, stdout=None):
2929
self.command = command
3030

3131
def __str__(self):
32-
ret = "'%s' returned exit status %i: %s" % \
33-
(' '.join(str(i) for i in self.command), self.status, self.stderr)
34-
if self.stdout is not None:
35-
ret += "\nstdout: %s" % self.stdout
32+
ret = "'%s' returned with exit code %i" % \
33+
(' '.join(str(i) for i in self.command), self.status)
34+
if self.stderr:
35+
ret += "\nstderr: '%s'" % self.stderr
36+
if self.stdout:
37+
ret += "\nstdout: '%s'" % self.stdout
3638
return ret
3739

3840

git/remote.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def remote_ref(self):
138138
@classmethod
139139
def _from_line(cls, remote, line):
140140
"""Create a new PushInfo instance as parsed from line which is expected to be like
141-
refs/heads/master:refs/heads/master 05d2687..1d0568e"""
141+
refs/heads/master:refs/heads/master 05d2687..1d0568e as bytes"""
142142
control_character, from_to, summary = line.split('\t', 3)
143143
flags = 0
144144

@@ -522,6 +522,7 @@ def update(self, **kwargs):
522522

523523
def _get_fetch_info_from_stderr(self, proc, progress):
524524
# skip first line as it is some remote info we are not interested in
525+
# TODO: Use poll() to process stdout and stderr at same time
525526
output = IterableList('name')
526527

527528
# lines which are no progress are fetch info lines
@@ -544,8 +545,8 @@ def _get_fetch_info_from_stderr(self, proc, progress):
544545
# END for each line
545546

546547
# read head information
547-
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'r')
548-
fetch_head_info = fp.readlines()
548+
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb')
549+
fetch_head_info = [l.decode(defenc) for l in fp.readlines()]
549550
fp.close()
550551

551552
# NOTE: We assume to fetch at least enough progress lines to allow matching each fetch head line with it.
@@ -562,18 +563,19 @@ def _get_push_info(self, proc, progress):
562563
# we hope stdout can hold all the data, it should ...
563564
# read the lines manually as it will use carriage returns between the messages
564565
# to override the previous one. This is why we read the bytes manually
566+
# TODO: poll() on file descriptors to know what to read next, process streams concurrently
565567
digest_process_messages(proc.stderr, progress)
566568

567569
output = IterableList('name')
568570
for line in proc.stdout.readlines():
571+
line = line.decode(defenc)
569572
try:
570573
output.append(PushInfo._from_line(self, line))
571574
except ValueError:
572575
# if an error happens, additional info is given which we cannot parse
573576
pass
574577
# END exception handling
575578
# END for each line
576-
577579
finalize_process(proc)
578580
return output
579581

git/repo/fun.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
def touch(filename):
24-
fp = open(filename, "a")
24+
fp = open(filename, "ab")
2525
fp.close()
2626

2727

git/test/lib/helper.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def remote_repo_creator(self):
193193
temp_dir = os.path.dirname(_mktemp())
194194
# On windows, this will fail ... we deal with failures anyway and default to telling the user to do it
195195
try:
196-
gd = Git().daemon(temp_dir, as_process=True)
196+
gd = Git().daemon(temp_dir, enable='receive-pack', as_process=True)
197197
# yes, I know ... fortunately, this is always going to work if sleep time is just large enough
198198
time.sleep(0.5)
199199
except Exception:
@@ -215,7 +215,8 @@ def remote_repo_creator(self):
215215
msg += 'Otherwise, run: git-daemon "%s"' % temp_dir
216216
raise AssertionError(msg)
217217
else:
218-
msg = 'Please start a git-daemon to run this test, execute: git-daemon "%s"' % temp_dir
218+
msg = 'Please start a git-daemon to run this test, execute: git daemon --enable=receive-pack "%s"'
219+
msg %= temp_dir
219220
raise AssertionError(msg)
220221
# END make assertion
221222
# END catch ls remote error
@@ -227,15 +228,17 @@ def remote_repo_creator(self):
227228
return func(self, rw_repo, rw_remote_repo)
228229
finally:
229230
# gd.proc.kill() ... no idea why that doesn't work
230-
os.kill(gd.proc.pid, 15)
231+
if gd is not None:
232+
os.kill(gd.proc.pid, 15)
231233

232234
os.chdir(prev_cwd)
233235
rw_repo.git.clear_cache()
234236
rw_remote_repo.git.clear_cache()
235237
shutil.rmtree(repo_dir, onerror=_rmtree_onerror)
236238
shutil.rmtree(remote_repo_dir, onerror=_rmtree_onerror)
237239

238-
gd.proc.wait()
240+
if gd is not None:
241+
gd.proc.wait()
239242
# END cleanup
240243
# END bare repo creator
241244
remote_repo_creator.__name__ = func.__name__

0 commit comments

Comments
 (0)