[Pkg-mozext-commits] [adblock-plus] 15/24: Issue 1377 - Blacklist dependencies from SCM tracking
David Prévot
taffit at moszumanska.debian.org
Mon Oct 20 02:15:23 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit 2efd35c9b63564a185db7399b32653b7854a3acf
Author: Matze <mathias at adblockplus.org>
Date: Fri Oct 10 13:41:35 2014 +0200
Issue 1377 - Blacklist dependencies from SCM tracking
---
ensure_dependencies.py | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/ensure_dependencies.py b/ensure_dependencies.py
index 4a4a474..ffe04a0 100755
--- a/ensure_dependencies.py
+++ b/ensure_dependencies.py
@@ -14,7 +14,9 @@ import errno
import logging
import subprocess
import urlparse
+
from collections import OrderedDict
+from ConfigParser import RawConfigParser
USAGE = """
A dependencies file should look like this:
@@ -56,6 +58,26 @@ class Mercurial():
def update(self, repo, rev):
subprocess.check_call(["hg", "update", "--repository", repo, "--quiet", "--check", "--rev", rev])
+ def ignore(self, target, repo):
+
+ if not self.istype(target):
+
+ config_path = os.path.join(repo, ".hg", "hgrc")
+ ignore_path = os.path.abspath(os.path.join(repo, ".hg", "dependencies"))
+
+ config = RawConfigParser()
+ config.read(config_path)
+
+ 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)
+
class Git():
def istype(self, repodir):
return os.path.exists(os.path.join(repodir, ".git"))
@@ -76,6 +98,11 @@ class Git():
def update(self, repo, rev):
subprocess.check_call(["git", "checkout", "--quiet", rev], cwd=repo)
+ def ignore(self, target, repo):
+ module = os.path.relpath(target, repo)
+ exclude_file = os.path.join(repo, ".git", "info", "exclude")
+ _ensure_line_exists(exclude_file, module)
+
repo_types = OrderedDict((
("hg", Mercurial()),
("git", Git()),
@@ -163,6 +190,10 @@ def ensure_repo(parentrepo, target, roots, sourcename):
logging.info("Cloning repository %s into %s" % (url, target))
repo_types[type].clone(url, target)
+ for repo in repo_types.itervalues():
+ if repo.istype(parentrepo):
+ repo.ignore(target, parentrepo)
+
def update_repo(target, revisions):
type = get_repo_type(target)
if type is None:
@@ -235,6 +266,16 @@ def resolve_deps(repodir, level=0, self_update=True, overrideroots=None, skipdep
else:
logging.warning("Cannot restart %s automatically, please rerun" % target)
+def _ensure_line_exists(path, pattern):
+ with open(path, 'a+') as f:
+ file_content = [l.strip() for l in f.readlines()]
+ if not pattern in file_content:
+ file_content.append(pattern)
+ f.seek(0, os.SEEK_SET)
+ f.truncate()
+ for l in file_content:
+ print >>f, l
+
if __name__ == "__main__":
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
repos = sys.argv[1:]
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list