From a1e2f63e64875a29e8c01a7ae17f5744680167a5 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 15 Nov 2010 11:37:14 +0100 Subject: 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 --- lib/git/remote.py | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'lib/git/remote.py') 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()) -- cgit v1.2.1 From 9f73e8ba55f33394161b403bf7b8c2e0e05f47b0 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 16 Nov 2010 11:05:31 +0100 Subject: remote: added methods to set and query the tracking branch status of normal heads, including test. Config: SectionConstraint was updated with additional callable methods, the complete ConfigParser interface should be covered now Remote: refs methods is much more efficient now as it will set the search path to the directory containing the remote refs - previously it used the remotes/ base directory and pruned the search result --- lib/git/remote.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'lib/git/remote.py') diff --git a/lib/git/remote.py b/lib/git/remote.py index 135e37d7..5124c603 100644 --- a/lib/git/remote.py +++ b/lib/git/remote.py @@ -468,11 +468,7 @@ class Remote(LazyMixin, Iterable): you to omit the remote path portion, i.e.:: remote.refs.master # yields RemoteReference('/refs/remotes/origin/master')""" out_refs = IterableList(RemoteReference._id_attribute_, "%s/" % self.name) - for ref in RemoteReference.list_items(self.repo): - if ref.remote_name == self.name: - out_refs.append(ref) - # END if names match - # END for each ref + out_refs.extend(RemoteReference.list_items(self.repo, remote=self.name)) assert out_refs, "Remote %s did not have any references" % self.name return out_refs -- cgit v1.2.1 From cf5eaddde33e983bc7b496f458bdd49154f6f498 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 18 Nov 2010 20:44:21 +0100 Subject: Updated tests and implementation to verify functionality for handling submodule removals, as well as url changes --- lib/git/remote.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/git/remote.py') diff --git a/lib/git/remote.py b/lib/git/remote.py index 5124c603..a06da222 100644 --- a/lib/git/remote.py +++ b/lib/git/remote.py @@ -28,6 +28,7 @@ from gitdb.util import join import re import os +import sys __all__ = ('RemoteProgress', 'PushInfo', 'FetchInfo', 'Remote') @@ -591,6 +592,10 @@ class Remote(LazyMixin, Iterable): for line in self._digest_process_messages(proc.stderr, progress): if line.startswith('From') or line.startswith('remote: Total'): continue + elif line.startswith('warning:'): + print >> sys.stderr, line + continue + # END handle special messages fetch_info_lines.append(line) # END for each line -- cgit v1.2.1