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

Side by Side Diff: gclient_scm.py

Issue 8161009: Restore 103787 (fix git progress message), and update test expectations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 9 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gclient_utils.py » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 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 posixpath 9 import posixpath
10 import re 10 import re
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 Once we've cloned the repo, we checkout a working branch if the specified 487 Once we've cloned the repo, we checkout a working branch if the specified
488 revision is a branch head. If it is a tag or a specific commit, then we 488 revision is a branch head. If it is a tag or a specific commit, then we
489 leave HEAD detached as it makes future updates simpler -- in this case the 489 leave HEAD detached as it makes future updates simpler -- in this case the
490 user should first create a new branch or switch to an existing branch before 490 user should first create a new branch or switch to an existing branch before
491 making changes in the repo.""" 491 making changes in the repo."""
492 if not options.verbose: 492 if not options.verbose:
493 # git clone doesn't seem to insert a newline properly before printing 493 # git clone doesn't seem to insert a newline properly before printing
494 # to stdout 494 # to stdout
495 print('') 495 print('')
496 496
497 clone_cmd = ['clone'] 497 clone_cmd = ['clone', '--progress']
498 if revision.startswith('refs/heads/'): 498 if revision.startswith('refs/heads/'):
499 clone_cmd.extend(['-b', revision.replace('refs/heads/', '')]) 499 clone_cmd.extend(['-b', revision.replace('refs/heads/', '')])
500 detach_head = False 500 detach_head = False
501 else: 501 else:
502 detach_head = True 502 detach_head = True
503 if options.verbose: 503 if options.verbose:
504 clone_cmd.append('--verbose') 504 clone_cmd.append('--verbose')
505 clone_cmd.extend([url, self.checkout_path]) 505 clone_cmd.extend([url, self.checkout_path])
506 506
507 # If the parent directory does not exist, Git clone on Windows will not 507 # If the parent directory does not exist, Git clone on Windows will not
508 # create it, so we need to do it manually. 508 # create it, so we need to do it manually.
509 parent_dir = os.path.dirname(self.checkout_path) 509 parent_dir = os.path.dirname(self.checkout_path)
510 if not os.path.exists(parent_dir): 510 if not os.path.exists(parent_dir):
511 os.makedirs(parent_dir) 511 os.makedirs(parent_dir)
512 512
513 percent_re = re.compile('.* ([0-9]{1,2})% .*')
514 def _GitFilter(line):
515 # git uses an escape sequence to clear the line; elide it.
516 esc = line.find(unichr(033))
517 if esc > -1:
518 line = line[:esc]
519 match = percent_re.match(line)
520 if not match or not int(match.group(1)) % 10:
521 print '%s' % line
522
513 for _ in range(3): 523 for _ in range(3):
514 try: 524 try:
515 self._Run(clone_cmd, options, cwd=self._root_dir) 525 self._Run(clone_cmd, options, cwd=self._root_dir, filter_fn=_GitFilter,
526 print_stdout=False)
516 break 527 break
517 except subprocess2.CalledProcessError, e: 528 except subprocess2.CalledProcessError, e:
518 # Too bad we don't have access to the actual output yet. 529 # Too bad we don't have access to the actual output yet.
519 # We should check for "transfer closed with NNN bytes remaining to 530 # We should check for "transfer closed with NNN bytes remaining to
520 # read". In the meantime, just make sure .git exists. 531 # read". In the meantime, just make sure .git exists.
521 if (e.returncode == 128 and 532 if (e.returncode == 128 and
522 os.path.exists(os.path.join(self.checkout_path, '.git'))): 533 os.path.exists(os.path.join(self.checkout_path, '.git'))):
523 print(str(e)) 534 print(str(e))
524 print('Retrying...') 535 print('Retrying...')
525 continue 536 continue
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 return branch 683 return branch
673 684
674 def _Capture(self, args): 685 def _Capture(self, args):
675 return subprocess2.check_output( 686 return subprocess2.check_output(
676 ['git'] + args, 687 ['git'] + args,
677 stderr=subprocess2.PIPE, 688 stderr=subprocess2.PIPE,
678 cwd=self.checkout_path).strip() 689 cwd=self.checkout_path).strip()
679 690
680 def _Run(self, args, options, **kwargs): 691 def _Run(self, args, options, **kwargs):
681 kwargs.setdefault('cwd', self.checkout_path) 692 kwargs.setdefault('cwd', self.checkout_path)
682 gclient_utils.CheckCallAndFilterAndHeader(['git'] + args, 693 kwargs.setdefault('print_stdout', True)
683 always=options.verbose, **kwargs) 694 stdout = kwargs.get('stdout', sys.stdout)
695 stdout.write('\n________ running \'git %s\' in \'%s\'\n' % (
696 ' '.join(args), kwargs['cwd']))
697 gclient_utils.CheckCallAndFilter(['git'] + args, **kwargs)
684 698
685 699
686 class SVNWrapper(SCMWrapper): 700 class SVNWrapper(SCMWrapper):
687 """ Wrapper for SVN """ 701 """ Wrapper for SVN """
688 702
689 def GetRevisionDate(self, revision): 703 def GetRevisionDate(self, revision):
690 """Returns the given revision's date in ISO-8601 format (which contains the 704 """Returns the given revision's date in ISO-8601 format (which contains the
691 time zone).""" 705 time zone)."""
692 date = scm.SVN.Capture(['propget', '--revprop', 'svn:date', '-r', revision, 706 date = scm.SVN.Capture(['propget', '--revprop', 'svn:date', '-r', revision,
693 os.path.join(self.checkout_path, '.')]) 707 os.path.join(self.checkout_path, '.')])
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 992
979 This method returns a new list to be used as a command.""" 993 This method returns a new list to be used as a command."""
980 new_command = command[:] 994 new_command = command[:]
981 if revision: 995 if revision:
982 new_command.extend(['--revision', str(revision).strip()]) 996 new_command.extend(['--revision', str(revision).strip()])
983 # --force was added to 'svn update' in svn 1.5. 997 # --force was added to 'svn update' in svn 1.5.
984 if ((options.force or options.manually_grab_svn_rev) and 998 if ((options.force or options.manually_grab_svn_rev) and
985 scm.SVN.AssertVersion("1.5")[0]): 999 scm.SVN.AssertVersion("1.5")[0]):
986 new_command.append('--force') 1000 new_command.append('--force')
987 return new_command 1001 return new_command
OLDNEW
« no previous file with comments | « no previous file | gclient_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698