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

Side by Side Diff: recipe_modules/bot_update/resources/bot_update.py

Issue 2173683003: Revert of bot_update: fix git dir check (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 4 years, 5 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 | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # TODO(hinoka): Use logging. 6 # TODO(hinoka): Use logging.
7 7
8 import cStringIO 8 import cStringIO
9 import codecs 9 import codecs
10 import collections 10 import collections
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 'status', '--porcelain', deps_file, cwd=repo_base).strip() 821 'status', '--porcelain', deps_file, cwd=repo_base).strip()
822 if deps_file_status and deps_file_status.startswith('M '): 822 if deps_file_status and deps_file_status.startswith('M '):
823 return True 823 return True
824 824
825 last_known_deps_ref = _last_commit_for_file(deps_file, repo_base) 825 last_known_deps_ref = _last_commit_for_file(deps_file, repo_base)
826 last_known_deps_git_ref = _last_commit_for_file(deps_git_file, repo_base) 826 last_known_deps_git_ref = _last_commit_for_file(deps_git_file, repo_base)
827 merge_base_ref = git('merge-base', last_known_deps_ref, 827 merge_base_ref = git('merge-base', last_known_deps_ref,
828 last_known_deps_git_ref, cwd=repo_base).strip() 828 last_known_deps_git_ref, cwd=repo_base).strip()
829 829
830 # If the merge base of the last DEPS and last .DEPS.git file is not 830 # If the merge base of the last DEPS and last .DEPS.git file is not
831 # equivalent to the hash of the last DEPS file, that means the DEPS file 831 # equivilent to the hash of the last DEPS file, that means the DEPS file
832 # was committed after the last .DEPS.git file. 832 # was committed after the last .DEPS.git file.
833 return last_known_deps_ref != merge_base_ref 833 return last_known_deps_ref != merge_base_ref
834 834
835 835
836 def ensure_deps2git(solution, shallow, git_cache_dir): 836 def ensure_deps2git(solution, shallow, git_cache_dir):
837 repo_base = path.join(os.getcwd(), solution['name']) 837 repo_base = path.join(os.getcwd(), solution['name'])
838 deps_file = path.join(repo_base, 'DEPS') 838 deps_file = path.join(repo_base, 'DEPS')
839 deps_git_file = path.join(repo_base, '.DEPS.git') 839 deps_git_file = path.join(repo_base, '.DEPS.git')
840 if (not git('ls-files', 'DEPS', cwd=repo_base).strip() or 840 if (not git('ls-files', 'DEPS', cwd=repo_base).strip() or
841 not git('ls-files', '.DEPS.git', cwd=repo_base).strip()): 841 not git('ls-files', '.DEPS.git', cwd=repo_base).strip()):
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 for ref in refs: 953 for ref in refs:
954 populate_cmd.extend(['--ref', ref]) 954 populate_cmd.extend(['--ref', ref])
955 git(*populate_cmd) 955 git(*populate_cmd)
956 mirror_dir = git( 956 mirror_dir = git(
957 'cache', 'exists', '--quiet', 957 'cache', 'exists', '--quiet',
958 '--cache-dir', git_cache_dir, url).strip() 958 '--cache-dir', git_cache_dir, url).strip()
959 clone_cmd = ( 959 clone_cmd = (
960 'clone', '--no-checkout', '--local', '--shared', mirror_dir, sln_dir) 960 'clone', '--no-checkout', '--local', '--shared', mirror_dir, sln_dir)
961 961
962 try: 962 try:
963 if not path.isdir(os.path.join(sln_dir, '.git')): 963 if not path.isdir(sln_dir):
964 git(*clone_cmd) 964 git(*clone_cmd)
965 else: 965 else:
966 git('remote', 'set-url', 'origin', mirror_dir, cwd=sln_dir) 966 git('remote', 'set-url', 'origin', mirror_dir, cwd=sln_dir)
967 git('fetch', 'origin', cwd=sln_dir) 967 git('fetch', 'origin', cwd=sln_dir)
968 for ref in refs: 968 for ref in refs:
969 refspec = '%s:%s' % (ref, ref.lstrip('+')) 969 refspec = '%s:%s' % (ref, ref.lstrip('+'))
970 git('fetch', 'origin', refspec, cwd=sln_dir) 970 git('fetch', 'origin', refspec, cwd=sln_dir)
971 971
972 revision = get_target_revision(name, url, revisions) or 'HEAD' 972 revision = get_target_revision(name, url, revisions) or 'HEAD'
973 force_revision(sln_dir, revision) 973 force_revision(sln_dir, revision)
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 except Exception: 1768 except Exception:
1769 # Unexpected failure. 1769 # Unexpected failure.
1770 emit_flag(options.flag_file) 1770 emit_flag(options.flag_file)
1771 raise 1771 raise
1772 else: 1772 else:
1773 emit_flag(options.flag_file) 1773 emit_flag(options.flag_file)
1774 1774
1775 1775
1776 if __name__ == '__main__': 1776 if __name__ == '__main__':
1777 sys.exit(main()) 1777 sys.exit(main())
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