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

Delta Between Two Patch Sets: ensure_dependencies.py

Issue 29329559: Noissue - Avoid "detached head" when using Git branches (Closed)
Left Patch Set: Created Oct. 30, 2015, 8:05 p.m.
Right Patch Set: Name parameters consistently Created Nov. 10, 2015, 12:20 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 command.extend(["--rev", rev]) 59 command.extend(["--rev", rev])
60 60
61 # Ignore stderr output and return code here: if revision lookup failed we 61 # Ignore stderr output and return code here: if revision lookup failed we
62 # should simply return an empty string. 62 # should simply return an empty string.
63 result = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess .PIPE).communicate()[0] 63 result = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess .PIPE).communicate()[0]
64 return result.strip() 64 return result.strip()
65 65
66 def pull(self, repo): 66 def pull(self, repo):
67 subprocess.check_call(["hg", "pull", "--repository", repo, "--quiet"]) 67 subprocess.check_call(["hg", "pull", "--repository", repo, "--quiet"])
68 68
69 def update(self, repo, rev, _): 69 def update(self, repo, rev, revname):
Wladimir Palant 2015/11/10 10:53:17 Please replace _ by revname so that the parameters
kzar 2015/11/10 12:21:29 Done.
70 subprocess.check_call(["hg", "update", "--repository", repo, "--quiet", "--c heck", "--rev", rev]) 70 subprocess.check_call(["hg", "update", "--repository", repo, "--quiet", "--c heck", "--rev", rev])
71 71
72 def ignore(self, target, repo): 72 def ignore(self, target, repo):
73 73
74 if not self.istype(target): 74 if not self.istype(target):
75 75
76 config_path = os.path.join(repo, ".hg", "hgrc") 76 config_path = os.path.join(repo, ".hg", "hgrc")
77 ignore_path = os.path.abspath(os.path.join(repo, ".hg", "dependencies")) 77 ignore_path = os.path.abspath(os.path.join(repo, ".hg", "dependencies"))
78 78
79 config = RawConfigParser() 79 config = RawConfigParser()
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 for match in re.finditer(r"^\s*(origin/(\S+))$", remotes, re.M): 115 for match in re.finditer(r"^\s*(origin/(\S+))$", remotes, re.M):
116 remote, local = match.groups() 116 remote, local = match.groups()
117 with open(os.devnull, "wb") as devnull: 117 with open(os.devnull, "wb") as devnull:
118 if subprocess.call(["git", "branch", "--track", local, remote], 118 if subprocess.call(["git", "branch", "--track", local, remote],
119 cwd=repo, stdout=devnull, stderr=devnull) == 0: 119 cwd=repo, stdout=devnull, stderr=devnull) == 0:
120 newly_tracked = True 120 newly_tracked = True
121 # Finally fetch any newly tracked remote branches 121 # Finally fetch any newly tracked remote branches
122 if newly_tracked: 122 if newly_tracked:
123 subprocess.check_call(["git", "fetch", "--quiet", "origin"], cwd=repo) 123 subprocess.check_call(["git", "fetch", "--quiet", "origin"], cwd=repo)
124 124
125 def update(self, repo, _, rev): 125 def update(self, repo, rev, revname):
Wladimir Palant 2015/11/10 10:53:17 Please replace _ by rev and rev by revname so that
kzar 2015/11/10 12:21:29 Done.
126 subprocess.check_call(["git", "checkout", "--quiet", rev], cwd=repo) 126 subprocess.check_call(["git", "checkout", "--quiet", revname], cwd=repo)
127 127
128 def ignore(self, target, repo): 128 def ignore(self, target, repo):
129 module = os.path.sep + os.path.relpath(target, repo) 129 module = os.path.sep + os.path.relpath(target, repo)
130 exclude_file = os.path.join(repo, ".git", "info", "exclude") 130 exclude_file = os.path.join(repo, ".git", "info", "exclude")
131 _ensure_line_exists(exclude_file, module) 131 _ensure_line_exists(exclude_file, module)
132 132
133 def postprocess_url(self, url): 133 def postprocess_url(self, url):
134 # Handle alternative syntax of SSH URLS 134 # Handle alternative syntax of SSH URLS
135 if "@" in url and ":" in url and not urlparse.urlsplit(url).scheme: 135 if "@" in url and ":" in url and not urlparse.urlsplit(url).scheme:
136 return "ssh://" + url.replace(":", "/", 1) 136 return "ssh://" + url.replace(":", "/", 1)
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 args = parser.parse_args() 362 args = parser.parse_args()
363 363
364 if args.quiet: 364 if args.quiet:
365 logging.disable(logging.INFO) 365 logging.disable(logging.INFO)
366 366
367 repos = args.repos 367 repos = args.repos
368 if not len(repos): 368 if not len(repos):
369 repos = [os.path.dirname(__file__)] 369 repos = [os.path.dirname(__file__)]
370 for repo in repos: 370 for repo in repos:
371 resolve_deps(repo) 371 resolve_deps(repo)
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld