You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2012/10/29 21:10:46 UTC

[5/25] git commit: [#5076] Removed _copy_hooks from ForgeHg (moved to ForgeClassic)

[#5076] Removed _copy_hooks from ForgeHg (moved to ForgeClassic)

Signed-off-by: Cory Johns <jo...@geek.net>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/0d96d939
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0d96d939
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0d96d939

Branch: refs/heads/cj/5076
Commit: 0d96d9395d5ef99861c8cbc1ec6cff6fbe01c5a1
Parents: 3c462c7
Author: Cory Johns <jo...@geek.net>
Authored: Thu Oct 25 19:17:42 2012 +0000
Committer: Cory Johns <jo...@geek.net>
Committed: Mon Oct 29 20:08:19 2012 +0000

----------------------------------------------------------------------
 ForgeHg/forgehg/model/hg.py                    |   46 -------------------
 ForgeHg/forgehg/tests/model/test_repository.py |   20 ++------
 2 files changed, 5 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d96d939/ForgeHg/forgehg/model/hg.py
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/model/hg.py b/ForgeHg/forgehg/model/hg.py
index ebed574..09d815d 100644
--- a/ForgeHg/forgehg/model/hg.py
+++ b/ForgeHg/forgehg/model/hg.py
@@ -55,29 +55,6 @@ class HgUI(ui.ui):
 
 class HgImplementation(M.RepositoryImplementation):
     re_hg_user = re.compile('(.*) <(.*)>')
-    skip_internal_files = set([
-            '00changelog.i',
-            'requires',
-            'branch',
-            'branch.cache',
-            'dirstate',
-            'inotify.sock',
-            'patches',
-            'wlock',
-            'undo.dirstate',
-            'undo.branch',
-            'journal.dirstate',
-            'journal.branch',
-            'store',
-            'lock',
-            'journal',
-            'undo',
-            'fncache',
-            'data',
-            'branchheads.cache',  # older versions have these cache files
-            'tags.cache',         # directly in the .hg directory
-            'cache',  # newer versions have cache directory (see http://selenic.com/repo/hg/rev/5ccdca7df211)
-        ])
 
     def __init__(self, repo):
         self._repo = repo
@@ -279,31 +256,8 @@ class HgImplementation(M.RepositoryImplementation):
         fctx = self._hg[blob.commit._id][h.really_unicode(blob.path()).encode('utf-8')[1:]]
         return fctx.size()
 
-    def _copy_hooks(self, source_path):
-        '''Copy existing hooks if source path is given and exists.'''
-        if source_path is None or not os.path.exists(source_path):
-            return
-        hgrc = os.path.join(self._repo.fs_path, self._repo.name, '.hg', 'hgrc')
-        try:
-            os.remove(hgrc)
-        except OSError as e:
-            if os.path.exists(hgrc):
-                raise
-        for name in os.listdir(os.path.join(source_path, '.hg')):
-            source = os.path.join(source_path, '.hg', name)
-            target = os.path.join(
-                    self._repo.full_fs_path, '.hg', os.path.basename(source))
-            if name in self.skip_internal_files:
-                continue
-            if os.path.isdir(source):
-                shutil.copytree(source, target)
-            else:
-                shutil.copy2(source, target)
-
     def _setup_hooks(self, source_path=None, copy_hooks=False):
         'Set up the hg changegroup hook'
-        if copy_hooks:
-            self._copy_hooks(source_path)
         hgrc = os.path.join(self._repo.fs_path, self._repo.name, '.hg', 'hgrc')
         cp = ConfigParser()
         cp.read(hgrc)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d96d939/ForgeHg/forgehg/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/tests/model/test_repository.py b/ForgeHg/forgehg/tests/model/test_repository.py
index 6f546d5..7f14d5f 100644
--- a/ForgeHg/forgehg/tests/model/test_repository.py
+++ b/ForgeHg/forgehg/tests/model/test_repository.py
@@ -158,26 +158,16 @@ class TestHgRepo(unittest.TestCase, RepoImplTestBase):
         repo.init()
         repo._impl.clone_from(repo_path, copy_hooks=True)
         assert len(repo.log())
-        assert os.path.exists('/tmp/testrepo.hg/.hg/external-changegroup')
-        assert os.access('/tmp/testrepo.hg/.hg/external-changegroup', os.X_OK)
-        with open('/tmp/testrepo.hg/.hg/external-changegroup') as f: c = f.read()
-        self.assertEqual(c,
-                '#!/bin/bash\n'
-                '\n'
-                'echo external-changegroup\n')
-        assert os.path.exists('/tmp/testrepo.hg/.hg/nested/nested-file')
-        assert os.access('/tmp/testrepo.hg/.hg/nested/nested-file', os.X_OK)
-        with open('/tmp/testrepo.hg/.hg/nested/nested-file') as f: c = f.read()
-        self.assertEqual(c, 'nested-file\n')
+        assert not os.path.exists('/tmp/testrepo.hg/.hg/external-changegroup')
+        assert not os.path.exists('/tmp/testrepo.hg/.hg/nested/nested-file')
         assert os.path.exists('/tmp/testrepo.hg/.hg/hgrc')
         cp = ConfigParser()
         cp.read('/tmp/testrepo.hg/.hg/hgrc')
-        assert cp.has_section('other')
-        self.assertEquals(cp.get('other', 'custom'), 'custom value')
+        assert not cp.has_section('other')
         assert cp.has_section('hooks')
         self.assertEquals(cp.get('hooks', 'changegroup.sourceforge'), 'curl -s http://localhost//auth/refresh_repo/p/test/src-hg/')
-        self.assertEquals(cp.get('hooks', 'changegroup.external'), '.hg/external-changegroup')
-        self.assertEquals(cp.get('hooks', 'commit'), 'python:hgext.notify.hook')
+        assert not cp.has_option('hook', 'changegroup.external')
+        assert not cp.has_option('hook', 'commit')
         assert not os.path.exists('/tmp/testrepo.hg/.hg/undo.branch')
         shutil.rmtree(dirname)