summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2011-06-07 11:23:53 +0200
committerSebastian Thiel <byronimo@gmail.com>2011-06-07 11:23:53 +0200
commit65f2dd0ab990adbe1a1470905090391ab5f2ce4e (patch)
tree3e3906f4e9672291c986d08ff396249996e81ee3 /git
parent3c12de3762abcde33dd27151b49589da76c2132f (diff)
downloadgitpython-65f2dd0ab990adbe1a1470905090391ab5f2ce4e.tar.gz
Fixed fetch/push/pull implementation. Next up is to integrate the consolidation changes from master to make clone use the same facilities
Diffstat (limited to 'git')
-rw-r--r--git/db/cmd/base.py18
-rw-r--r--git/remote.py21
2 files changed, 25 insertions, 14 deletions
diff --git a/git/db/cmd/base.py b/git/db/cmd/base.py
index 735e71df..e30d8fe6 100644
--- a/git/db/cmd/base.py
+++ b/git/db/cmd/base.py
@@ -18,11 +18,15 @@ from git.util import (
isfile,
join_path,
join,
- Actor
+ Actor,
+ IterableList
)
from git.db.interface import FetchInfo as GitdbFetchInfo
from git.db.interface import PushInfo as GitdbPushInfo
-from git.db.interface import HighLevelRepository
+from git.db.interface import (
+ HighLevelRepository,
+ TransportDB
+ )
from git.cmd import Git
from git.refs import (
Reference,
@@ -332,7 +336,7 @@ class CmdObjectDBRMixin(object):
#} END odb interface
-class CmdTransportMixin(object):
+class CmdTransportMixin(TransportDB):
"""A mixin requiring the .git property as well as repository paths
It will create objects only in the loose object database.
@@ -399,13 +403,13 @@ class CmdTransportMixin(object):
# END for each line
# read head information
- fp = open(join(self.root_path(), 'FETCH_HEAD'),'r')
+ fp = open(join(self.git_dir, 'FETCH_HEAD'),'r')
fetch_head_info = fp.readlines()
fp.close()
assert len(fetch_info_lines) == len(fetch_head_info)
- output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line)
+ output.extend(FetchInfo._from_line(self, err_line, fetch_line)
for err_line,fetch_line in zip(fetch_info_lines, fetch_head_info))
self._finalize_proc(proc)
@@ -450,7 +454,7 @@ class CmdTransportMixin(object):
:param url: may be a remote name or a url
:param refspecs: see push()
:param progress: see push()"""
- proc = self._git.pull(url, refspec, with_extended_output=True, as_process=True, v=True, **kwargs)
+ proc = self._git.pull(url, refspecs, with_extended_output=True, as_process=True, v=True, **kwargs)
return self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
def fetch(self, url, refspecs=None, progress=None, **kwargs):
@@ -458,7 +462,7 @@ class CmdTransportMixin(object):
:param url: may be a remote name or a url
:param refspecs: see push()
:param progress: see push()"""
- proc = self._git.fetch(url, refspec, with_extended_output=True, as_process=True, v=True, **kwargs)
+ proc = self._git.fetch(url, refspecs, with_extended_output=True, as_process=True, v=True, **kwargs)
return self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
#} end transport db interface
diff --git a/git/remote.py b/git/remote.py
index 6f295869..f44f0150 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -16,7 +16,7 @@ from git.util import (
IterableList,
RemoteProgress
)
-
+from git.db.interface import TransportDB
from refs import RemoteReference
import os
@@ -53,6 +53,16 @@ class Remote(LazyMixin, Iterable):
:param repo: The repository we are a remote of
:param name: the name of the remote, i.e. 'origin'"""
+ if not hasattr(repo, 'git'):
+ # note: at some point we could just create a git command instance ourselves
+ # but lets just be lazy for now
+ raise AssertionError("Require repository to provide a git command instance currently")
+ #END assert git cmd
+
+ if not isinstance(repo, TransportDB):
+ raise AssertionError("Require TransportDB interface implementation")
+ #END verify interface
+
self.repo = repo
self.name = name
@@ -228,8 +238,7 @@ class Remote(LazyMixin, Iterable):
:note:
As fetch does not provide progress information to non-ttys, we cannot make
it available here unfortunately as in the 'push' method."""
- proc = self.repo.git.fetch(self, refspec, with_extended_output=True, as_process=True, v=True, **kwargs)
- return self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
+ return self.repo.fetch(self.name, refspec, progress, **kwargs)
def pull(self, refspec=None, progress=None, **kwargs):
"""Pull changes from the given branch, being the same as a fetch followed
@@ -239,8 +248,7 @@ class Remote(LazyMixin, Iterable):
:param progress: see 'push' method
:param kwargs: Additional arguments to be passed to git-pull
:return: Please see 'fetch' method """
- proc = self.repo.git.pull(self, refspec, with_extended_output=True, as_process=True, v=True, **kwargs)
- return self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
+ return self.repo.pull(self.name, refspec, progress, **kwargs)
def push(self, refspec=None, progress=None, **kwargs):
"""Push changes from source branch in refspec to target branch in refspec.
@@ -260,8 +268,7 @@ class Remote(LazyMixin, Iterable):
in their flags.
If the operation fails completely, the length of the returned IterableList will
be null."""
- proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True, **kwargs)
- return self._get_push_info(proc, progress or RemoteProgress())
+ return self.repo.push(self.name, refspec, progress, **Kwargs)
@property
def config_reader(self):