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

Side by Side Diff: ensure_dependencies.py

Issue 29360367: Issue 4584 - Ignore Mercurial dependencies explicitly (Closed)
Patch Set: Created Oct. 28, 2016, 1:21 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 2
3 # This Source Code Form is subject to the terms of the Mozilla Public 3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 6
7 import sys 7 import sys
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import re 10 import re
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 result = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subpro cess.PIPE).communicate()[0] 63 result = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subpro cess.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, revname): 69 def update(self, repo, rev, revname):
70 subprocess.check_call(['hg', 'update', '--repository', repo, '--quiet', '--check', '--rev', rev]) 70 subprocess.check_call(['hg', 'update', '--repository', repo, '--quiet', '--check', '--rev', rev])
71 71
72 def ignore(self, target, repo): 72 def ignore(self, target, repo):
73 config_path = os.path.join(repo, '.hg', 'hgrc')
74 ignore_path = os.path.join(repo, '.hg', 'dependencies')
73 75
74 if not self.istype(target): 76 config = RawConfigParser()
77 config.read(config_path)
75 78
76 config_path = os.path.join(repo, '.hg', 'hgrc') 79 if not config.has_section('ui'):
77 ignore_path = os.path.abspath(os.path.join(repo, '.hg', 'dependencie s')) 80 config.add_section('ui')
78 81
79 config = RawConfigParser() 82 config.set('ui', 'ignore.dependencies', ignore_path)
80 config.read(config_path) 83 with open(config_path, 'w') as stream:
84 config.write(stream)
81 85
82 if not config.has_section('ui'): 86 module = os.path.relpath(target, repo)
83 config.add_section('ui') 87 _ensure_line_exists(ignore_path, module)
84
85 config.set('ui', 'ignore.dependencies', ignore_path)
86 with open(config_path, 'w') as stream:
87 config.write(stream)
88
89 module = os.path.relpath(target, repo)
90 _ensure_line_exists(ignore_path, module)
91 88
92 def postprocess_url(self, url): 89 def postprocess_url(self, url):
93 return url 90 return url
94 91
95 92
96 class Git(): 93 class Git():
97 def istype(self, repodir): 94 def istype(self, repodir):
98 return os.path.exists(os.path.join(repodir, '.git')) 95 return os.path.exists(os.path.join(repodir, '.git'))
99 96
100 def clone(self, source, target): 97 def clone(self, source, target):
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 args = parser.parse_args() 370 args = parser.parse_args()
374 371
375 if args.quiet: 372 if args.quiet:
376 logging.disable(logging.INFO) 373 logging.disable(logging.INFO)
377 374
378 repos = args.repos 375 repos = args.repos
379 if not len(repos): 376 if not len(repos):
380 repos = [os.path.dirname(__file__)] 377 repos = [os.path.dirname(__file__)]
381 for repo in repos: 378 for repo in repos:
382 resolve_deps(repo) 379 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