Mercurial > kallithea
comparison 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 |
comparison
equal
deleted
inserted
replaced
3396:3faf7a7eebb3 | 3397:64c194492aad |
---|---|
100 | 100 |
101 :param cmd: git command to be executed | 101 :param cmd: git command to be executed |
102 :param opts: env options to pass into Subprocess command | 102 :param opts: env options to pass into Subprocess command |
103 """ | 103 """ |
104 | 104 |
105 _copts = ['-c', 'core.quotepath=false', ] | 105 if '_bare' in opts: |
106 _copts = [] | |
107 del opts['_bare'] | |
108 else: | |
109 _copts = ['-c', 'core.quotepath=false', ] | |
110 safe_call = False | |
111 if '_safe' in opts: | |
112 #no exc on failure | |
113 del opts['_safe'] | |
114 safe_call = True | |
115 | |
106 _str_cmd = False | 116 _str_cmd = False |
107 if isinstance(cmd, basestring): | 117 if isinstance(cmd, basestring): |
108 cmd = [cmd] | 118 cmd = [cmd] |
109 _str_cmd = True | 119 _str_cmd = True |
110 | 120 |
124 shell=False, | 134 shell=False, |
125 ) | 135 ) |
126 _opts.update(opts) | 136 _opts.update(opts) |
127 p = subprocessio.SubprocessIOChunker(cmd, **_opts) | 137 p = subprocessio.SubprocessIOChunker(cmd, **_opts) |
128 except (EnvironmentError, OSError), err: | 138 except (EnvironmentError, OSError), err: |
129 log.error(traceback.format_exc()) | 139 tb_err = ("Couldn't run git command (%s).\n" |
130 raise RepositoryError("Couldn't run git command (%s).\n" | 140 "Original error was:%s\n" % (cmd, err)) |
131 "Original error was:%s" % (cmd, err)) | 141 log.error(tb_err) |
142 if safe_call: | |
143 return '', err | |
144 else: | |
145 raise RepositoryError(tb_err) | |
132 | 146 |
133 return ''.join(p.output), ''.join(p.error) | 147 return ''.join(p.output), ''.join(p.error) |
134 | 148 |
135 def run_git_command(self, cmd): | 149 def run_git_command(self, cmd): |
136 opts = {} | 150 opts = {} |