OLD | NEW |
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 Loading... |
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 # equivilent to the hash of the last DEPS file, that means the DEPS file | 831 # equivalent 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 Loading... |
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(sln_dir): | 963 if not path.isdir(os.path.join(sln_dir, '.git')): |
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 Loading... |
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()) |
OLD | NEW |