[apycotlib] kill _apycotlib.repositories draft
authorDavid Douard <david.douard@logilab.fr>
Thu, 13 Nov 2014 14:57:28 +0100
changeset 1754 e541bef11cff
parent 1753 2fc1207a3ba7
child 1755 0c3fd79885cb
[apycotlib] kill _apycotlib.repositories it's now handled by checkout recipes
_apycotlib/repositories.py
test/unittest_repositories.py
--- a/_apycotlib/repositories.py	Thu Nov 13 14:56:29 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-"""Some standard sources repositories, + factory function
-
-:organization: Logilab
-:copyright: 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: General Public License version 2 - http://www.gnu.org/licenses
-"""
-__docformat__ = "restructuredtext en"
-
-from os import path as osp, environ
-from time import localtime
-
-from logilab.common.textutils import split_url_or_path
-
-from apycotlib import register, get_registered, ConfigError
-
-
-def get_repository(**attrs):
-    """factory method: return a repository implementation according to
-    <attrs> (a dictionary)
-    """
-    repo_type = attrs['repository']['type']
-    return get_registered('repository', repo_type)(attrs)
-
-class VCSRepository(objet):
-    """base class for clonable repository"""
-
-    id = None
-    default_branch = None
-
-    def __init__(self, repository, changeset):
-        self.repository = repository
-        if not self.repository:
-            raise ConfigError('Repository must be specified')
-        self.cset = changeset
-        if not self.ref_repo:
-            raise ConfigError('Missing information to checkout repository %s'
-                              % self.repository)
-
-    def __eq__(self, other):
-        return (isinstance(other, self.__class__) and
-                self.repository == other.repository and
-                self.path == other.path)
-
-    def __ne__(self, other):
-        return not self == other
-
-    def __repr__(self):
-        """get a string synthetizing the location"""
-        myrepr = '%s:%s' % (self.id, self.ref_repo)
-        myrepr += '@%s' % self.cset
-        return myrepr
-
-    @property
-    def co_path(self):
-        """return the path where the project will be located in the test
-        environment
-        """
-        copath = split_url_or_path(self.ref_repo)[1]
-        if self.path:
-            copath = osp.join(copath, self.path)
-        return osp.join(environ['APYCOT_ROOT'], copath)
-
-    def co_command(self, quiet=True):
-        """return a command that may be given to os.system to check out a given
-        package
-        """
-        raise NotImplementedError()
-
-
-class HGRepository(VCSRepository):
-    """extract sources/information for a project from a Mercurial repository"""
-    id = 'mercurial'
-
-    @property
-    def ref_repo(self):
-        return self.repository['source_url']
-
-    def co_command(self, quiet=True):
-        """return a command that may be given to os.system to check out a given
-        package
-        """
-        if quiet:
-            return "hg clone -q %s && hg -R %s up '::. and public()'" % (self.ref_repo, self.co_path)
-        return "hg clone %s && hg -R %s up '::. and public()'" % (self.ref_repo, self.co_path)
-
-
-register('repository', HGRepository)
-
--- a/test/unittest_repositories.py	Thu Nov 13 14:56:29 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-#!/usr/bin/python
-"""unit tests for apycot.repositories"""
-
-import os
-from copy import copy
-
-from logilab.common import testlib
-
-import cubicweb.devtools
-from cubes.apycot.testutils import MockVCSFile as VCSFile
-
-from apycotlib.repositories import *
-
-def setUpModule():
-    os.environ['APYCOT_ROOT'] = ''
-
-def tearDownModule():
-    del os.environ['APYCOT_ROOT']
-
-class GetRepositoryTC(testlib.TestCase):
-    def test(self):
-        vcsfile = VCSFile('mercurial', source_url='http://www.labas.org')
-        repo = get_repository({'repository': vcsfile, 'path': 'toto'})
-        self.assert_(isinstance(repo, HGRepository))
-
-
-class HGRepositoryTC(testlib.TestCase):
-    def test_co_path(self):
-        vcsfile = VCSFile('mercurial', source_url=u'file://' + os.path.join(self.datadir, 'badsyntax'))
-        repo = HGRepository({'repository': vcsfile, 'local_cache': 'common'})
-        self.assertEqual(repo.co_path, 'badsyntax/common')
-        repo = HGRepository({'repository': vcsfile, 'local_cache': 'common/sub'})
-        self.assertEqual(repo.co_path, 'badsyntax/common/sub')
-
-if __name__ == '__main__':
-    testlib.unittest_main()