incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [3/15] git commit: [#5005] Allow fs_path option to be passed in, and remove warning if repo dir already exists
Date Thu, 01 Nov 2012 19:51:24 GMT
[#5005] Allow fs_path option to be passed in, and remove warning if repo dir already exists

Signed-off-by: Cory Johns <johnsca@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/709d5471
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/709d5471
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/709d5471

Branch: refs/heads/db/5080
Commit: 709d5471d1ebcbf1bb5b0d0683a85925c0799104
Parents: a37b35a
Author: Cory Johns <johnsca@geek.net>
Authored: Tue Oct 30 21:43:15 2012 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Wed Oct 31 18:08:34 2012 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py |   22 ++++++++++++----------
 ForgeGit/forgegit/git_main.py     |    3 ++-
 ForgeHg/forgehg/hg_main.py        |    3 ++-
 ForgeSVN/forgesvn/svn_main.py     |    3 ++-
 4 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/709d5471/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 30351fa..ba8df55 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -124,16 +124,18 @@ class RepositoryImplementation(object):
         return '%sci/%s/' % (self._repo.url(), object_id)
 
     def _setup_paths(self, create_repo_dir=True):
+        '''
+        Ensure that the base directory in which the repo lives exists.
+        If create_repo_dir is True, also ensure that the directory
+        of the repo itself exists.
+        '''
         if not self._repo.fs_path.endswith('/'): self._repo.fs_path += '/'
         fullname = self._repo.fs_path + self._repo.name
-        path = fullname if create_repo_dir else self._repo.fs_path
-        try:
-            os.makedirs(path)
-        except OSError, e: # pragma no cover
-            if e.errno != errno.EEXIST:
-                raise
-            else:
-                log.warn('setup_paths error %s' % path, exc_info=True)
+        # make the base dir for repo, regardless
+        if not os.path.exists(self._repo.fs_path):
+            os.makedirs(self._repo.fs_path)
+        if create_repo_dir and not os.path.exists(fullname):
+            os.mkdir(fullname)
         return fullname
 
     def _setup_special_files(self, source_path=None):
@@ -167,9 +169,9 @@ class Repository(Artifact, ActivityObject):
 
     def __init__(self, **kw):
         if 'name' in kw and 'tool' in kw:
-            if 'fs_path' not in kw:
+            if kw.get('fs_path') is None:
                 kw['fs_path'] = self.default_fs_path(c.project, kw['tool'])
-            if 'url_path' not in kw:
+            if kw.get('url_path') is None:
                 kw['url_path'] = self.default_url_path(c.project, kw['tool'])
         super(Repository, self).__init__(**kw)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/709d5471/ForgeGit/forgegit/git_main.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/git_main.py b/ForgeGit/forgegit/git_main.py
index c4a2e7b..95bce77 100644
--- a/ForgeGit/forgegit/git_main.py
+++ b/ForgeGit/forgegit/git_main.py
@@ -53,7 +53,8 @@ class ForgeGitApp(RepositoryApp):
         repo = GM.Repository(
             name=self.config.options.mount_point + '.git',
             tool='git',
-            status='initializing')
+            status='initializing',
+            fs_path=self.config.options.get('fs_path'))
         ThreadLocalORMSession.flush_all()
         cloned_from_project_id = self.config.options.get('cloned_from_project_id')
         cloned_from_repo_id = self.config.options.get('cloned_from_repo_id')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/709d5471/ForgeHg/forgehg/hg_main.py
----------------------------------------------------------------------
diff --git a/ForgeHg/forgehg/hg_main.py b/ForgeHg/forgehg/hg_main.py
index 77ccdbb..a2631ac 100644
--- a/ForgeHg/forgehg/hg_main.py
+++ b/ForgeHg/forgehg/hg_main.py
@@ -53,7 +53,8 @@ class ForgeHgApp(RepositoryApp):
         HM.Repository(
             name=self.config.options.mount_point,
             tool='hg',
-            status='initializing')
+            status='initializing',
+            fs_path=self.config.options.get('fs_path'))
         ThreadLocalORMSession.flush_all()
         cloned_from_project_id = self.config.options.get('cloned_from_project_id')
         cloned_from_repo_id = self.config.options.get('cloned_from_repo_id')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/709d5471/ForgeSVN/forgesvn/svn_main.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index f8aa748..3f0c8b6 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -62,7 +62,8 @@ class ForgeSVNApp(RepositoryApp):
         SM.Repository(
             name=self.config.options.mount_point,
             tool='svn',
-            status='initializing')
+            status='initializing',
+            fs_path=self.config.options.get('fs_path'))
         ThreadLocalORMSession.flush_all()
         init_from_url = self.config.options.get('init_from_url')
         init_from_path = self.config.options.get('init_from_path')


Mime
View raw message