aboutsummaryrefslogtreecommitdiff
path: root/git_remote_helpers/git
diff options
context:
space:
mode:
authorSverre Rabbelier <srabbelier@gmail.com>2011-07-16 15:03:31 +0200
committerJunio C Hamano <gitster@pobox.com>2011-07-19 11:17:47 -0700
commit460d10262dae14b54123ff45e7548d872ff63983 (patch)
treee1c53cb7ea5fdf097d80bf305731affdc7e09142 /git_remote_helpers/git
parent0fb56ce716090248ed4895aff69dd3953b00882f (diff)
downloadgit-460d10262dae14b54123ff45e7548d872ff63983.tar.gz
git-460d10262dae14b54123ff45e7548d872ff63983.tar.xz
git-remote-testgit: fix error handling
If fast-export did not complete successfully the error handling code itself would error out. This was broken in commit 23b093ee0 (Brandon Casey, Wed Jun 9 2010, Remove python 2.5'isms). Revert that commit an introduce our own copy of check_call in util.py instead. Tested by changing 'if retcode' to 'if not retcode' temporarily. Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git_remote_helpers/git')
-rw-r--r--git_remote_helpers/git/exporter.py6
-rw-r--r--git_remote_helpers/git/importer.py6
-rw-r--r--git_remote_helpers/git/non_local.py18
-rw-r--r--git_remote_helpers/git/repo.py7
4 files changed, 15 insertions, 22 deletions
diff --git a/git_remote_helpers/git/exporter.py b/git_remote_helpers/git/exporter.py
index bc39163d7..9ee5f96d4 100644
--- a/git_remote_helpers/git/exporter.py
+++ b/git_remote_helpers/git/exporter.py
@@ -2,6 +2,8 @@ import os
import subprocess
import sys
+from git_remote_helpers.util import check_call
+
class GitExporter(object):
"""An exporter for testgit repositories.
@@ -53,6 +55,4 @@ class GitExporter(object):
args = ["sed", "s_refs/heads/_" + self.repo.prefix + "_g"]
- child = subprocess.Popen(args, stdin=p1.stdout)
- if child.wait() != 0:
- raise CalledProcessError
+ check_call(args, stdin=p1.stdout)
diff --git a/git_remote_helpers/git/importer.py b/git_remote_helpers/git/importer.py
index 70a712729..02a719ac0 100644
--- a/git_remote_helpers/git/importer.py
+++ b/git_remote_helpers/git/importer.py
@@ -1,6 +1,8 @@
import os
import subprocess
+from git_remote_helpers.util import check_call
+
class GitImporter(object):
"""An importer for testgit repositories.
@@ -35,6 +37,4 @@ class GitImporter(object):
if os.path.exists(path):
args.append("--import-marks=" + path)
- child = subprocess.Popen(args)
- if child.wait() != 0:
- raise CalledProcessError
+ check_call(args)
diff --git a/git_remote_helpers/git/non_local.py b/git_remote_helpers/git/non_local.py
index c53e07445..e70025095 100644
--- a/git_remote_helpers/git/non_local.py
+++ b/git_remote_helpers/git/non_local.py
@@ -1,7 +1,7 @@
import os
import subprocess
-from git_remote_helpers.util import die, warn
+from git_remote_helpers.util import check_call, die, warn
class NonLocalGit(object):
@@ -29,9 +29,7 @@ class NonLocalGit(object):
os.makedirs(path)
args = ["git", "clone", "--bare", "--quiet", self.repo.gitpath, path]
- child = subprocess.Popen(args)
- if child.wait() != 0:
- raise CalledProcessError
+ check_call(args)
return path
@@ -45,14 +43,10 @@ class NonLocalGit(object):
die("could not find repo at %s", path)
args = ["git", "--git-dir=" + path, "fetch", "--quiet", self.repo.gitpath]
- child = subprocess.Popen(args)
- if child.wait() != 0:
- raise CalledProcessError
+ check_call(args)
args = ["git", "--git-dir=" + path, "update-ref", "refs/heads/master", "FETCH_HEAD"]
- child = subprocess.Popen(args)
- if child.wait() != 0:
- raise CalledProcessError
+ child = check_call(args)
def push(self, base):
"""Pushes from the non-local repo to base.
@@ -64,6 +58,4 @@ class NonLocalGit(object):
die("could not find repo at %s", path)
args = ["git", "--git-dir=" + path, "push", "--quiet", self.repo.gitpath, "--all"]
- child = subprocess.Popen(args)
- if child.wait() != 0:
- raise CalledProcessError
+ child = check_call(args)
diff --git a/git_remote_helpers/git/repo.py b/git_remote_helpers/git/repo.py
index 58e1cdb56..acbf8d778 100644
--- a/git_remote_helpers/git/repo.py
+++ b/git_remote_helpers/git/repo.py
@@ -1,6 +1,9 @@
import os
import subprocess
+from git_remote_helpers.util import check_call
+
+
def sanitize(rev, sep='\t'):
"""Converts a for-each-ref line to a name/value pair.
"""
@@ -53,9 +56,7 @@ class GitRepo(object):
path = ".cached_revs"
ofile = open(path, "w")
- child = subprocess.Popen(args, stdout=ofile)
- if child.wait() != 0:
- raise CalledProcessError
+ check_call(args, stdout=ofile)
output = open(path).readlines()
self.revmap = dict(sanitize(i) for i in output)
if "HEAD" in self.revmap: