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

Unified Diff: infra/libs/git2/git2.py

Issue 355153002: Refactor infra git libs and testing. (Closed) Base URL: https://chromium.googlesource.com/infra/infra@fake_testing_support
Patch Set: Change config ref to have a sandard naming scheme Created 6 years, 6 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: infra/libs/git2/git2.py
diff --git a/infra/services/gnumbd/support/git.py b/infra/libs/git2/git2.py
similarity index 94%
rename from infra/services/gnumbd/support/git.py
rename to infra/libs/git2/git2.py
index b337ac20c4a65e682839ac350a1f56d5783eb255..3dfdafae7097fc1f07595a759f243b540c023407 100644
--- a/infra/services/gnumbd/support/git.py
+++ b/infra/libs/git2/git2.py
@@ -10,28 +10,14 @@ import sys
import tempfile
import urlparse
-from infra.services.gnumbd.support.util import (
- cached_property, CalledProcessError)
+from infra.libs.decorators import cached_property
-from infra.services.gnumbd.support.data import CommitData
+from infra.libs.git2.util import CalledProcessError
+from infra.libs.git2.util import INVALID
+from infra.libs.git2.data import CommitData
-LOGGER = logging.getLogger(__name__)
-
-
-class _Invalid(object):
- def __call__(self, *_args, **_kwargs):
- return self
-
- def __getattr__(self, _key):
- return self
- def __eq__(self, _other):
- return False
-
- def __ne__(self, _other): # pylint: disable=R0201
- return True
-
-INVALID = _Invalid()
+LOGGER = logging.getLogger(__name__)
class Repo(object):
@@ -50,6 +36,10 @@ class Repo(object):
self._commit_cache = collections.OrderedDict()
self._log = LOGGER.getChild('Repo')
+ def __getitem__(self, ref):
+ """Get a Ref attached to this Repo."""
+ return Ref(self, ref)
+
def reify(self):
"""Ensures the local mirror of this Repo exists."""
assert self.repos_dir is not None

Powered by Google App Engine
This is Rietveld 408576698