Mercurial > kallithea
diff rhodecode/lib/vcs/backends/git/repository.py @ 3397:64c194492aad beta
--version command should be safe, and bare no modifications
- improved subprocess calls error detection
- fixed I/O read on closed file errors
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 25 Feb 2013 17:16:45 +0100 |
parents | 3faf7a7eebb3 |
children | cf1fbc9fed89 |
line wrap: on
line diff
--- a/rhodecode/lib/vcs/backends/git/repository.py Mon Feb 25 16:49:05 2013 +0100 +++ b/rhodecode/lib/vcs/backends/git/repository.py Mon Feb 25 17:16:45 2013 +0100 @@ -102,7 +102,17 @@ :param opts: env options to pass into Subprocess command """ - _copts = ['-c', 'core.quotepath=false', ] + if '_bare' in opts: + _copts = [] + del opts['_bare'] + else: + _copts = ['-c', 'core.quotepath=false', ] + safe_call = False + if '_safe' in opts: + #no exc on failure + del opts['_safe'] + safe_call = True + _str_cmd = False if isinstance(cmd, basestring): cmd = [cmd] @@ -126,9 +136,13 @@ _opts.update(opts) p = subprocessio.SubprocessIOChunker(cmd, **_opts) except (EnvironmentError, OSError), err: - log.error(traceback.format_exc()) - raise RepositoryError("Couldn't run git command (%s).\n" - "Original error was:%s" % (cmd, err)) + tb_err = ("Couldn't run git command (%s).\n" + "Original error was:%s\n" % (cmd, err)) + log.error(tb_err) + if safe_call: + return '', err + else: + raise RepositoryError(tb_err) return ''.join(p.output), ''.join(p.error)