aboutsummaryrefslogtreecommitdiff
path: root/pomu
diff options
context:
space:
mode:
Diffstat (limited to 'pomu')
-rw-r--r--pomu/repo/remote/git.py11
-rw-r--r--pomu/repo/remote/hg.py8
-rw-r--r--pomu/repo/remote/remote.py9
-rw-r--r--pomu/repo/remote/rsync.py9
-rw-r--r--pomu/repo/remote/svn.py4
-rw-r--r--pomu/util/remote.py2
6 files changed, 26 insertions, 17 deletions
diff --git a/pomu/repo/remote/git.py b/pomu/repo/remote/git.py
index 217a0c6..2cb00d2 100644
--- a/pomu/repo/remote/git.py
+++ b/pomu/repo/remote/git.py
@@ -1,17 +1,18 @@
"""A class for remote git repos"""
-from os import chdir, mkdtemp, path
+from os import chdir, path
from subprocess import call
+from tempfile import mkdtemp
from git import Repo
-from pomu.repo.remote import RemoteRepo, normalize_key
+from pomu.repo.remote.remote import RemoteRepo, normalize_key
from pomu.util.git import parse_object
from pomu.util.result import Result
class RemoteGitRepo(RemoteRepo):
"""A class responsible for git remotes"""
def __init__(self, url):
- self.uri = uri
+ self.uri = url
self.dir = mkdtemp()
chdir(self.dir)
if call('git', 'clone', '--depth=1', '--bare', url) > 0: # we've a problem
@@ -27,11 +28,11 @@ class RemoteGitRepo(RemoteRepo):
def get_object(self, oid):
head, tail = oid[0:2], oid[2:]
opath = path.join(self.dir, 'objects', head, tail)
- return a.read()
+ return opath.read()
def _fetch_tree(self, obj, tpath):
res = []
- ents = parse_object(self.get_object(tid), tpath).unwrap()
+ ents = parse_object(self.get_object(obj), tpath).unwrap()
for is_dir, sha, opath in ents:
res.append((opath + '/' if is_dir else '', sha))
if is_dir:
diff --git a/pomu/repo/remote/hg.py b/pomu/repo/remote/hg.py
index 678f843..de4290b 100644
--- a/pomu/repo/remote/hg.py
+++ b/pomu/repo/remote/hg.py
@@ -1,15 +1,15 @@
"""A class for remote hg repos"""
-from os import chdir, mkdtemp, path
+from os import chdir, mkdtemp
from shutil import rmtree
-from subprocess import call, run, check_output
+from subprocess import call, run
-from pomu.repo.remote import RemoteRepo, normalize_key
+from pomu.repo.remote.remote import RemoteRepo, normalize_key
from pomu.util.result import Result
class RemoteHgRepo(RemoteRepo):
"""A class responsible for hg remotes"""
def __init__(self, url):
- self.uri = uri
+ self.uri = url
self.dir = mkdtemp()
chdir(self.dir)
if call('hg', 'clone', '-U', url, '.') > 0: # we've a problem
diff --git a/pomu/repo/remote/remote.py b/pomu/repo/remote/remote.py
index 133c645..7fa75bf 100644
--- a/pomu/repo/remote/remote.py
+++ b/pomu/repo/remote/remote.py
@@ -1,6 +1,10 @@
"""A template class for remote repos"""
+from os import path
from urllib.parse import urlparse
+from pomu.package import Package
+from pomu.util.remote import get_full_cpv, filelist_to_cpvs
+
class RemoteRepo():
"""A class responsible for remotes"""
def __init__(self, url):
@@ -10,11 +14,14 @@ class RemoteRepo():
def from_url(cls, uri, type_=None):
tp = RemoteRepo.type_for_name(type_)
if not tp:
+ from pomu.repo.remote.git import RemoteGitRepo
+ from pomu.repo.remote.rsync import RemoteRsyncRepo
+ from pomu.repo.remote.svn import RemoteSvnRepo
try:
scheme, *_ = urlparse(uri)
except:
tp = RemoteGitRepo
- if (scheme.startswith('http') or scheme.startswith('git')
+ if (scheme.startswith('http') or scheme.startswith('git') or
scheme.startswith('ssh')):
tp = RemoteGitRepo
elif scheme.startswith('svn'):
diff --git a/pomu/repo/remote/rsync.py b/pomu/repo/remote/rsync.py
index 8f00e5e..b93719b 100644
--- a/pomu/repo/remote/rsync.py
+++ b/pomu/repo/remote/rsync.py
@@ -1,15 +1,14 @@
"""A class for remote rsync repos"""
-from os import mkdtemp, rmdir, mkfifo, unlink
-import re
+from os import mkdtemp, rmdir, mkfifo, unlink, path
from subprocess import run
-from pomu.repo.remote import RemoteRepo, normalize_key
+from pomu.repo.remote.remote import RemoteRepo, normalize_key
from pomu.util.result import Result
class RemoteRsyncRepo(RemoteRepo):
"""A class responsible for rsync remotes"""
def __init__(self, url):
- self.uri = uri
+ self.uri = url
def __enter__(self):
pass
@@ -22,7 +21,7 @@ class RemoteRsyncRepo(RemoteRepo):
if hasattr(self, '_tree'):
return self._tree
d = mkdtemp()
- p = run('rsync', '-rn', '--out-format="%n"' self.uri, d)
+ p = run('rsync', '-rn', '--out-format="%n"', self.uri, d)
rmdir(d)
if p.returncode:
return Result.Err()
diff --git a/pomu/repo/remote/svn.py b/pomu/repo/remote/svn.py
index 4b1e1d3..447a8a0 100644
--- a/pomu/repo/remote/svn.py
+++ b/pomu/repo/remote/svn.py
@@ -1,13 +1,13 @@
"""A class for remote svn repos"""
from subprocess import run
-from pomu.repo.remote import RemoteRepo, normalize_key
+from pomu.repo.remote.remote import RemoteRepo, normalize_key
from pomu.util.result import Result
class RemoteSvnRepo(RemoteRepo):
"""A class responsible for svn remotes"""
def __init__(self, url):
- self.uri = uri
+ self.uri = url
def __enter__(self):
pass
diff --git a/pomu/util/remote.py b/pomu/util/remote.py
index 20691e2..9e3875a 100644
--- a/pomu/util/remote.py
+++ b/pomu/util/remote.py
@@ -7,6 +7,8 @@ from portage.versions import best
from pomu.util.pkg import ver_str, cpv_split
from pomu.util.portage import misc_dirs
+from pomu.util.result import Result
+
def filelist_to_cpvs(tree):
"""Converts a list of files to list of cpvs"""
res = []