Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: gclient_scm.py

Issue 474002: Fix default cwd value and the timing of the result code check (Closed)
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Gclient-specific SCM-specific operations.""" 5 """Gclient-specific SCM-specific operations."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import re 9 import re
10 import subprocess 10 import subprocess
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 print('\n________ couldn\'t run status in %s:\nThe directory ' 180 print('\n________ couldn\'t run status in %s:\nThe directory '
181 'does not exist.' % self.checkout_path) 181 'does not exist.' % self.checkout_path)
182 else: 182 else:
183 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) 183 merge_base = self._Run(['merge-base', 'HEAD', 'origin'])
184 self._Run(['diff', '--name-status', merge_base], redirect_stdout=False) 184 self._Run(['diff', '--name-status', merge_base], redirect_stdout=False)
185 files = self._Run(['diff', '--name-only', merge_base]).split() 185 files = self._Run(['diff', '--name-only', merge_base]).split()
186 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) 186 file_list.extend([os.path.join(self.checkout_path, f) for f in files])
187 187
188 def _Run(self, args, cwd=None, checkrc=True, redirect_stdout=True): 188 def _Run(self, args, cwd=None, checkrc=True, redirect_stdout=True):
189 # TODO(maruel): Merge with Capture? 189 # TODO(maruel): Merge with Capture?
190 if cwd is None:
191 cwd = self.checkout_path
190 stdout=None 192 stdout=None
191 if redirect_stdout: 193 if redirect_stdout:
192 stdout=subprocess.PIPE 194 stdout=subprocess.PIPE
193 if cwd == None: 195 if cwd == None:
194 cwd = self.checkout_path 196 cwd = self.checkout_path
195 cmd = [self.COMMAND] 197 cmd = [self.COMMAND]
196 cmd.extend(args) 198 cmd.extend(args)
197 sp = subprocess.Popen(cmd, cwd=cwd, stdout=stdout) 199 sp = subprocess.Popen(cmd, cwd=cwd, stdout=stdout)
200 output = sp.communicate()[0]
198 if checkrc and sp.returncode: 201 if checkrc and sp.returncode:
199 raise gclient_utils.Error('git command %s returned %d' % 202 raise gclient_utils.Error('git command %s returned %d' %
200 (args[0], sp.returncode)) 203 (args[0], sp.returncode))
201 output = sp.communicate()[0]
202 if output is not None: 204 if output is not None:
203 return output.strip() 205 return output.strip()
204 206
205 207
206 class SVNWrapper(SCMWrapper, scm.SVN): 208 class SVNWrapper(SCMWrapper, scm.SVN):
207 """ Wrapper for SVN """ 209 """ Wrapper for SVN """
208 210
209 def cleanup(self, options, args, file_list): 211 def cleanup(self, options, args, file_list):
210 """Cleanup working copy.""" 212 """Cleanup working copy."""
211 __pychecker__ = 'unusednames=file_list,options' 213 __pychecker__ = 'unusednames=file_list,options'
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 self.ReplaceAndPrint(line) 460 self.ReplaceAndPrint(line)
459 else: 461 else:
460 if (line.startswith(self.original_prefix) or 462 if (line.startswith(self.original_prefix) or
461 line.startswith(self.working_prefix)): 463 line.startswith(self.working_prefix)):
462 self.ReplaceAndPrint(line) 464 self.ReplaceAndPrint(line)
463 else: 465 else:
464 print line 466 print line
465 467
466 filterer = DiffFilterer(self.relpath) 468 filterer = DiffFilterer(self.relpath)
467 self.RunAndFilterOutput(command, path, False, False, filterer.Filter) 469 self.RunAndFilterOutput(command, path, False, False, filterer.Filter)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698