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

Unified Diff: cms/sources.py

Issue 5488197752586240: Issue 2440 - implement Source.get_cache_dir() to be used by custom filters/globals (Closed)
Patch Set: Only consider last part of repository path Created April 30, 2015, 6:09 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/sources.py
===================================================================
--- a/cms/sources.py
+++ b/cms/sources.py
@@ -211,6 +211,8 @@
command = ["hg", "-R", repo, "id", "-n", "-r", "default"]
self.version = subprocess.check_output(command).strip()
+ self._name = os.path.basename(repo.rstrip(os.path.sep))
+
def __enter__(self):
return self
@@ -240,6 +242,10 @@
if filename.startswith(prefix):
yield filename[len(prefix):]
+ if os.name == "posix":
+ def get_cache_dir(self):
+ return "/var/cache/" + self._name
+
class FileSource(Source):
def __init__(self, dir):
self._dir = dir
@@ -280,3 +286,6 @@
do_list(path, relpath + filename + "/")
do_list(self.get_path(subdir), "")
return result
+
+ def get_cache_dir(self):
+ return os.path.join(self._dir, "cache")
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld