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

Unified Diff: ensure_dependencies.py

Issue 29360030: Issue 4581 - Update buildtools dependency (Closed)
Patch Set: Update buildtools again while at it Created Oct. 30, 2016, 3:43 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dependencies ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ensure_dependencies.py
diff --git a/ensure_dependencies.py b/ensure_dependencies.py
index c1c71456560ec3ef06bde7ab45d6b925fa1cecfa..b5231e49ce2215c823775403a3c562a333d13b62 100755
--- a/ensure_dependencies.py
+++ b/ensure_dependencies.py
@@ -70,24 +70,22 @@ class Mercurial():
subprocess.check_call(['hg', 'update', '--repository', repo, '--quiet', '--check', '--rev', rev])
def ignore(self, target, repo):
+ config_path = os.path.join(repo, '.hg', 'hgrc')
+ ignore_file = os.path.join('.hg', 'dependencies')
+ ignore_path = os.path.join(repo, ignore_file)
- if not self.istype(target):
+ config = RawConfigParser()
+ config.read(config_path)
- config_path = os.path.join(repo, '.hg', 'hgrc')
- ignore_path = os.path.abspath(os.path.join(repo, '.hg', 'dependencies'))
+ if not config.has_section('ui'):
+ config.add_section('ui')
- config = RawConfigParser()
- config.read(config_path)
+ config.set('ui', 'ignore.dependencies', ignore_file)
+ with open(config_path, 'w') as stream:
+ config.write(stream)
- if not config.has_section('ui'):
- config.add_section('ui')
-
- config.set('ui', 'ignore.dependencies', ignore_path)
- with open(config_path, 'w') as stream:
- config.write(stream)
-
- module = os.path.relpath(target, repo)
- _ensure_line_exists(ignore_path, module)
+ module = os.path.relpath(target, repo)
+ _ensure_line_exists(ignore_path, module)
def postprocess_url(self, url):
return url
@@ -355,6 +353,7 @@ def resolve_deps(repodir, level=0, self_update=True, overrideroots=None, skipdep
def _ensure_line_exists(path, pattern):
with open(path, 'a+') as f:
+ f.seek(0, os.SEEK_SET)
file_content = [l.strip() for l in f.readlines()]
if not pattern in file_content:
file_content.append(pattern)
« no previous file with comments | « dependencies ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld