Stop using Repository.path, gone in vcsfile 2
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 23 Dec 2014 14:17:50 +0100
changeset 1674 7e66dbf04a09
parent 1673 4bfa0476e0a0
child 1675 533a3f8bbebb
Stop using Repository.path, gone in vcsfile 2 Use a file:// source_url instead. Related to #4786982.
_apycotlib/repositories.py
test/unittest_hooks.py
test/unittest_preprocessors.py
test/unittest_repositories.py
testutils.py
--- a/_apycotlib/repositories.py	Tue Dec 23 12:24:45 2014 +0100
+++ b/_apycotlib/repositories.py	Tue Dec 23 14:17:50 2014 +0100
@@ -148,14 +148,6 @@
     default_branch = "default"
 
     def _ref_repo(self):
-        if False and self.repository['local_cache']:
-            cnx = self.repository._cw.cnx
-            cacheroot = cnx.get_option_value('local-repo-cache-root')
-            path = osp.join(cacheroot, self.repository.local_cache)
-            if osp.exists(path):
-                return path
-        if self.repository['path'] and osp.exists(self.repository['path']):
-            return self.repository['path']
         return self.repository['source_url']
 
     def _co_path(self):
--- a/test/unittest_hooks.py	Tue Dec 23 12:24:45 2014 +0100
+++ b/test/unittest_hooks.py	Tue Dec 23 14:17:50 2014 +0100
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 import os
 import re
+import shutil
 
 from logilab.common.testlib import unittest_main
 
@@ -135,7 +136,9 @@
         r = self.repo
         with self.admin_access.repo_cnx() as cnx:
             vcsrepo = cnx.entity_from_eid(self.vcsrepo)
-            r.path = vcsrepo.path
+            r.path = vcsrepo.localcachepath
+        if os.path.exists(r.path):
+            shutil.rmtree(r.path)
         os.system('hg init %s' % r.path)
         os.system('echo data > %s/tutu.png' % r.path)
         os.system('hg -R %s add %s/tutu.png' % (r.path, r.path))
--- a/test/unittest_preprocessors.py	Tue Dec 23 12:24:45 2014 +0100
+++ b/test/unittest_preprocessors.py	Tue Dec 23 14:17:50 2014 +0100
@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+import os
 import json
 
 from logilab.common.testlib import unittest_main
@@ -9,6 +10,8 @@
 import preprocessors.apycot.distutils
 from cubicweb.utils import json_dumps
 
+os.environ['HGRCPATH'] = os.devnull
+
 class FakeCnxh(object):
     def __init__(self, msgcfg, msgdep):
         self.msgcfg = msgcfg
@@ -63,7 +66,7 @@
 
             self.vcsrepo2 = cnx.create_entity('Repository', type=u'mercurial',
                     # use path to avoid clone attempt when using url
-                    path=unicode(self.datapath('project1')), source_url=u'http://gna.com',
+                    source_url=u'file://' + unicode(self.datapath('project1')),
                     reverse_local_repository=self.lgce)
 
             pe_dep1 = cnx.create_entity('ProjectEnvironment',
--- a/test/unittest_repositories.py	Tue Dec 23 12:24:45 2014 +0100
+++ b/test/unittest_repositories.py	Tue Dec 23 14:17:50 2014 +0100
@@ -59,7 +59,7 @@
 
 class HGRepositoryTC(testlib.TestCase):
     def test_co_path(self):
-        vcsfile = VCSFile('mercurial', path=os.path.join(self.datadir, 'badsyntax'))
+        vcsfile = VCSFile('mercurial', source_url=u'file://' + os.path.join(self.datadir, 'badsyntax'))
         repo = HGRepository({'repository': vcsfile, 'path': 'common'})
         self.assertEqual(repo.co_path, 'badsyntax/common')
         repo = HGRepository({'repository': vcsfile, 'path': 'common/sub'})
--- a/testutils.py	Tue Dec 23 12:24:45 2014 +0100
+++ b/testutils.py	Tue Dec 23 14:17:50 2014 +0100
@@ -161,7 +161,7 @@
                 ).eid
             self.vcsrepo = cnx.create_entity('Repository', type=u'mercurial',
                                              # use path to avoid clone attempt when using url
-                                             path=unicode(self.datapath('project')),
+                                             source_url=u'file://' + unicode(self.datapath('project')),
                                              reverse_local_repository=self.lgce).eid
             self.pyp = cnx.create_entity('TestConfig', name=u'PYTHONPACKAGE',
                                          check_config=u'python_lint_treshold=7\n'