allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [2/2] git commit: [#5963] Minor fixups to code-snapshots
Date Fri, 29 Mar 2013 18:16:41 GMT
[#5963] Minor fixups to code-snapshots

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


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

Branch: refs/heads/cj/5963
Commit: 9dc95933076afcc1c34ce468a07f3f9846517ad7
Parents: ba609ec
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Fri Mar 29 15:15:42 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Fri Mar 29 15:38:15 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py                |    6 ++--
 ForgeGit/forgegit/model/git_repo.py              |   10 +++++--
 ForgeGit/forgegit/tests/model/test_repository.py |    2 +-
 ForgeSVN/forgesvn/model/svn.py                   |   22 ++++++++++-------
 4 files changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9dc95933/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 82f3cf2..110d410 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -240,8 +240,8 @@ class Repository(Artifact, ActivityObject):
                             self.name)
 
     def tarball_filename(self, revision):
-        shortname = c.app.repo.project.shortname.replace('/', '-')
-        mount_point = c.app.repo.app.config.options.mount_point
+        shortname = c.project.shortname.replace('/', '-')
+        mount_point = c.app.config.options.mount_point
         filename = '%s-%s-%s' % (shortname, mount_point, revision)
         return filename
 
@@ -262,7 +262,7 @@ class Repository(Artifact, ActivityObject):
 
         if os.path.isfile(filename):
             return 'ready'
-        elif os.path.isfile(tmpfilename) or os.path.isdir(pathname):
+        elif os.path.isfile(tmpfilename):
             return 'busy'
 
     def __repr__(self): # pragma no cover

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9dc95933/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 27fc8e4..d7c9d49 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -329,9 +329,13 @@ class GitImplementation(M.RepositoryImplementation):
         archive_name = self._repo.tarball_filename(commit)
         filename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.tar.gz'))
         tmpfilename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.tmp'))
-        with gzip.open(tmpfilename, 'w') as fp:
-            self._git.archive(fp, format='tar', treeish=commit, prefix=archive_name + '/')
-        os.rename(tmpfilename, filename)
+        try:
+            with gzip.open(tmpfilename, 'w') as fp:
+                self._git.archive(fp, format='tar', treeish=commit, prefix=archive_name +
'/')
+            os.rename(tmpfilename, filename)
+        finally:
+            if os.path.exists(tmpfilename):
+                os.remove(tmpfilename)
 
 
 class _OpenedGitBlob(object):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9dc95933/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index ba52de5..08de37b 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -261,7 +261,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         os.remove("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tmp")
         assert_equal(self.repo.get_tarball_status('HEAD'), None)
         os.makedirs("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD")
-        assert_equal(self.repo.get_tarball_status('HEAD'), 'busy')
+        assert_equal(self.repo.get_tarball_status('HEAD'), None)
 
 
 class TestGitCommit(unittest.TestCase):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9dc95933/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 902c829..171c709 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -614,18 +614,22 @@ class SVNImplementation(M.RepositoryImplementation):
         if not os.path.exists(self._repo.tarball_path):
             os.makedirs(self._repo.tarball_path)
         path = os.path.join(self._repo.tarball_path, commit)
-        if os.path.exists(path):
-            rmtree(path)
-        self._svn.export(self._url,
-                         path,
-                         revision=pysvn.Revision(pysvn.opt_revision_kind.number, commit))
         archive_name = self._repo.tarball_filename(commit)
         filename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.tar.gz'))
         tmpfilename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.tmp'))
-        with tarfile.open(tmpfilename, "w:gz") as tar:
-            tar.add(path, arcname=archive_name)
-        rmtree(path)
-        os.rename(tmpfilename, filename)
+        if os.path.exists(path):
+            rmtree(path)
+        try:
+            self._svn.export(self._url,
+                             path,
+                             revision=pysvn.Revision(pysvn.opt_revision_kind.number, commit))
+            with tarfile.open(tmpfilename, "w:gz") as tar:
+                tar.add(path, arcname=archive_name)
+            os.rename(tmpfilename, filename)
+        finally:
+            rmtree(path)
+            if os.path.exists(tmpfilename):
+                os.remove(tmpfilename)
 
 
 Mapper.compile_all()


Mime
View raw message