Index: ensure_dependencies.py |
=================================================================== |
--- a/ensure_dependencies.py |
+++ b/ensure_dependencies.py |
@@ -67,6 +67,10 @@ |
def update(self, repo, rev): |
subprocess.check_call(["hg", "update", "--repository", repo, "--quiet", "--check", "--rev", rev]) |
+ def ignore(self, target): |
+ if not self.istype(target): |
+ logging.warning("Mercurial won't ignore dependency %s by default. You should do it manually." % (target)) |
Wladimir Palant
2014/09/23 15:04:13
Quite the opposite actually - Mercurial will autom
mathias
2014/09/23 16:20:05
Mercurial does not ignore Git submodules (just ver
Wladimir Palant
2014/09/25 19:52:20
You are right, so a local hgignore file should be
mathias
2014/09/26 05:06:39
Thank you for the "local" keyword! I've been searc
mathias
2014/09/28 00:24:25
Done.
|
+ |
class Git(): |
def istype(self, repodir): |
return os.path.exists(os.path.join(repodir, ".git")) |
@@ -87,6 +91,18 @@ |
def update(self, repo, rev): |
subprocess.check_call(["git", "checkout", "--quiet", rev], cwd=repo) |
+ def ignore(self, target): |
+ module = str(target).replace(os.getcwd(),'')[1:] |
Wladimir Palant
2014/09/23 15:04:13
There is a reason why this script never relies on
mathias
2014/09/23 16:20:05
Agreed, will be addressed in the next patch-set.
mathias
2014/09/28 00:24:25
Done.
|
+ exclude_file = '.git/info/exclude' |
+ if os.path.exists(exclude_file): |
Wladimir Palant
2014/09/23 15:04:13
1) Please don't use relative file paths (see above
mathias
2014/09/23 16:20:05
Agreed, will be addressed in the next patch-set.
mathias
2014/09/28 00:24:25
Done.
|
+ with open(exclude_file, 'r') as f: |
+ exclude_file_content = f.read().splitlines() |
Wladimir Palant
2014/09/23 15:04:13
I'd rather do [l.strip() for l in f.readlines()] h
mathias
2014/09/23 16:20:05
Agreed, will be addressed in the next patch-set.
mathias
2014/09/28 00:24:25
Done.
|
+ if not module in exclude_file_content: |
+ logging.warning("Adding dependency %s to %s" % (module, exclude_file) ) |
Wladimir Palant
2014/09/23 15:04:13
1) Why is this a warning? Nothing is wrong, a comp
mathias
2014/09/23 16:20:05
Agreed, we just remove the line entirely.
mathias
2014/09/28 00:24:25
Done.
|
+ exclude_file_content = open(exclude_file, 'a') |
Wladimir Palant
2014/09/23 15:04:13
This will fail on Windows - you are opening a file
mathias
2014/09/23 16:20:05
Agreed, will be addressed in the next patch-set.
mathias
2014/09/28 00:24:25
Done.
|
+ exclude_file_content.write("\n"+module) |
Wladimir Palant
2014/09/23 15:04:13
What if there is already a line break at the end o
mathias
2014/09/23 16:20:05
Agreed, will be addressed in the next patch-set.
mathias
2014/09/28 00:24:25
Done.
|
+ exclude_file_content.close() |
Wladimir Palant
2014/09/23 15:04:13
If your code throws an exception that file will ne
mathias
2014/09/23 16:20:05
Agreed, will be addressed as well.
mathias
2014/09/28 00:24:25
Done.
|
+ |
repo_types = { |
"hg": Mercurial(), |
"git": Git(), |
@@ -220,6 +236,9 @@ |
ensure_repo(repodir, target, config.get("_root", {}), revisions["_source"]) |
update_repo(target, revisions) |
resolve_deps(target, level + 1, self_update=False, overrideroots=overrideroots, skipdependencies=skipdependencies) |
+ for repo in repo_types.itervalues(): |
+ if repo.istype(repodir): |
+ repo.ignore(target) |
Wladimir Palant
2014/09/23 15:04:13
IMHO, this should be part of ensure_repo():
1) Th
mathias
2014/09/23 16:20:05
Valid point, we move it to `ensure_repo()`. Note,
mathias
2014/09/28 00:24:25
Done.
|
if self_update and "_self" in config and "*" in config["_self"]: |
source = safe_join(repodir, config["_self"]["*"]) |