summaryrefslogtreecommitdiff
path: root/lib/git/remote.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-11-15 11:37:14 +0100
committerSebastian Thiel <byronimo@gmail.com>2010-11-15 11:37:14 +0100
commita1e2f63e64875a29e8c01a7ae17f5744680167a5 (patch)
tree8feb612ac5df79ec31300359b2bd28c40424bec0 /lib/git/remote.py
parenta1d1d2cb421f16bd277d7c4ce88398ff0f5afb29 (diff)
downloadgitpython-a1e2f63e64875a29e8c01a7ae17f5744680167a5.tar.gz
submodule: Fleshed out interface, and a partial test which is not yet usable. It showed that the ConfigParser needs some work. If the root is set, it also needs to refer to the root_commit instead of to the root-tree, as it will have to decide whether it works on the working tree's version of the .gitmodules file or the one in the repository
Diffstat (limited to 'lib/git/remote.py')
-rw-r--r--lib/git/remote.py30
1 files changed, 4 insertions, 26 deletions
diff --git a/lib/git/remote.py b/lib/git/remote.py
index 52dd787d..135e37d7 100644
--- a/lib/git/remote.py
+++ b/lib/git/remote.py
@@ -7,7 +7,8 @@
from exc import GitCommandError
from objects import Commit
-from ConfigParser import NoOptionError
+from ConfigParser import NoOptionError
+from config import SectionConstraint
from git.util import (
LazyMixin,
@@ -30,29 +31,6 @@ import os
__all__ = ('RemoteProgress', 'PushInfo', 'FetchInfo', 'Remote')
-class _SectionConstraint(object):
- """Constrains a ConfigParser to only option commands which are constrained to
- always use the section we have been initialized with.
-
- It supports all ConfigParser methods that operate on an option"""
- __slots__ = ("_config", "_section_name")
- _valid_attrs_ = ("get_value", "set_value", "get", "set", "getint", "getfloat", "getboolean", "has_option")
-
- def __init__(self, config, section):
- self._config = config
- self._section_name = section
-
- def __getattr__(self, attr):
- if attr in self._valid_attrs_:
- return lambda *args, **kwargs: self._call_config(attr, *args, **kwargs)
- return super(_SectionConstraint,self).__getattribute__(attr)
-
- def _call_config(self, method, *args, **kwargs):
- """Call the configuration at the given method which must take a section name
- as first argument"""
- return getattr(self._config, method)(self._section_name, *args, **kwargs)
-
-
class RemoteProgress(object):
"""
Handler providing an interface to parse progress information emitted by git-push
@@ -449,7 +427,7 @@ class Remote(LazyMixin, Iterable):
def _set_cache_(self, attr):
if attr == "_config_reader":
- self._config_reader = _SectionConstraint(self.repo.config_reader(), self._config_section_name())
+ self._config_reader = SectionConstraint(self.repo.config_reader(), self._config_section_name())
else:
super(Remote, self)._set_cache_(attr)
@@ -735,4 +713,4 @@ class Remote(LazyMixin, Iterable):
# clear our cache to assure we re-read the possibly changed configuration
del(self._config_reader)
- return _SectionConstraint(writer, self._config_section_name())
+ return SectionConstraint(writer, self._config_section_name())