Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: ensure_dependencies.py

Issue 5254149566365696: 1398 - Improve compatibility with older git(1) versions (Closed)
Patch Set: Created Sept. 22, 2014, 1:18 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 # This Source Code Form is subject to the terms of the Mozilla Public 4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this 5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 7
8 import sys 8 import sys
9 import os 9 import os
10 import posixpath 10 import posixpath
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 def istype(self, repodir): 60 def istype(self, repodir):
61 return os.path.exists(os.path.join(repodir, ".git")) 61 return os.path.exists(os.path.join(repodir, ".git"))
62 62
63 def clone(self, source, target): 63 def clone(self, source, target):
64 source = source.rstrip("/") 64 source = source.rstrip("/")
65 if not source.endswith(".git"): 65 if not source.endswith(".git"):
66 source += ".git" 66 source += ".git"
67 subprocess.check_call(["git", "clone", "--quiet", source, target]) 67 subprocess.check_call(["git", "clone", "--quiet", source, target])
68 68
69 def get_revision_id(self, repo, rev="HEAD"): 69 def get_revision_id(self, repo, rev="HEAD"):
70 command = ["git", "-C", repo, "rev-parse", "--revs-only", rev] 70 command = ["git", "rev-parse", "--revs-only", rev]
71 return subprocess.check_output(command).strip() 71 return subprocess.check_output(command, cwd=repo).strip()
72 72
73 def pull(self, repo): 73 def pull(self, repo):
74 subprocess.check_call(["git", "-C", repo, "fetch", "--quiet", "--all", "--ta gs"]) 74 subprocess.check_call(["git", "fetch", "--quiet", "--all", "--tags"], cwd=re po)
75 75
76 def update(self, repo, rev): 76 def update(self, repo, rev):
77 subprocess.check_call(["git", "-C", repo, "checkout", "--quiet", rev]) 77 subprocess.check_call(["git", "checkout", "--quiet", rev], cwd=repo)
78 78
79 repo_types = { 79 repo_types = {
80 "hg": Mercurial(), 80 "hg": Mercurial(),
81 "git": Git(), 81 "git": Git(),
82 } 82 }
83 83
84 def parse_spec(path, line): 84 def parse_spec(path, line):
85 if "=" not in line: 85 if "=" not in line:
86 logging.warning("Invalid line in file %s: %s" % (path, line)) 86 logging.warning("Invalid line in file %s: %s" % (path, line))
87 return None, None 87 return None, None
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 else: 235 else:
236 logging.warning("Cannot restart %s automatically, please rerun" % target ) 236 logging.warning("Cannot restart %s automatically, please rerun" % target )
237 237
238 if __name__ == "__main__": 238 if __name__ == "__main__":
239 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) 239 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
240 repos = sys.argv[1:] 240 repos = sys.argv[1:]
241 if not len(repos): 241 if not len(repos):
242 repos = [os.getcwd()] 242 repos = [os.getcwd()]
243 for repo in repos: 243 for repo in repos:
244 resolve_deps(repo) 244 resolve_deps(repo)
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