Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1678)

Unified Diff: appengine/findit/libs/gitiles/gitiles_repository.py

Issue 2605943002: Removing the mutation in the factories for getting dep repositories (Closed)
Patch Set: rebase Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/findit/libs/gitiles/gitiles_repository.py
diff --git a/appengine/findit/libs/gitiles/gitiles_repository.py b/appengine/findit/libs/gitiles/gitiles_repository.py
index 599724c3195c934eb3ca78be2afefe04a1bed192..2e446aec0be3178016536f3c15eb8dddcb69de6f 100644
--- a/appengine/findit/libs/gitiles/gitiles_repository.py
+++ b/appengine/findit/libs/gitiles/gitiles_repository.py
@@ -39,22 +39,34 @@ class GitilesRepository(GitRepository):
self._http_client = http_client
+ @classmethod
+ def Factory(cls, http_client): # pragma: no cover
+ """Construct a factory for creating ``GitilesRepository`` instances.
+
+ Args:
+ http_client: the http client to be shared among all created repository
+ instances.
+
+ Returns:
+ A function from repo urls to ``GitilesRepository`` instances. All
+ instances produced by the returned function are novel (i.e., newly
+ allocated), but they all share the same underlying ``http_client``.
+ """
+ return lambda repo_url: cls(http_client, repo_url)
+
@property
def repo_url(self):
return self._repo_url
- @repo_url.setter
- def repo_url(self, repo_url):
- self._repo_url = repo_url
+ @property
+ def identifier(self): # pragma: no cover
+ """This is used by ``_DefaultKeyGenerator`` in cache_decorator.py."""
+ return self.repo_url
@property
def http_client(self):
return self._http_client
- @property
- def identifier(self):
- return self.repo_url
-
def _SendRequestForJsonResponse(self, url, params=None):
if params is None: # pragma: no cover
params = {}

Powered by Google App Engine
This is Rietveld 408576698