allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/3] allura git commit: [#7882] use null context manager, to remove duplication of merge_base and log lines
Date Tue, 02 Jun 2015 16:03:22 GMT
[#7882] use null context manager, to remove duplication of merge_base and log lines


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

Branch: refs/heads/master
Commit: de1244251907570f3d18414b55538d3dbd2ddc6d
Parents: a685c72
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Tue Jun 2 15:55:24 2015 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Tue Jun 2 15:55:24 2015 +0000

----------------------------------------------------------------------
 Allura/allura/lib/helpers.py        |  4 ++--
 ForgeGit/forgegit/model/git_repo.py | 18 +++++++++---------
 2 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/de124425/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 36932a3..76e8db3 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -976,11 +976,11 @@ def notifications_disabled(project, disabled=True):
 
 
 @contextmanager
-def null_contextmanager(*args, **kw):
+def null_contextmanager(returning=None, *args, **kw):
     """A no-op contextmanager.
 
     """
-    yield
+    yield returning
 
 
 class exceptionless(object):

http://git-wip-us.apache.org/repos/asf/allura/blob/de124425/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index bb3b8d8..d08fe1f 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -653,15 +653,15 @@ class GitImplementation(M.RepositoryImplementation):
         """
         use_tmp_dir = tg.config.get('scm.merge_list.git.use_tmp_dir', False)
         use_tmp_dir = asbool(use_tmp_dir)
-        if not use_tmp_dir:
-            base = self.merge_base(mr)
-            return list(c.app.repo.log(
-                mr.downstream.commit_id,
-                exclude=base,
-                id_only=False))
-        with self._shared_clone(self._repo.full_fs_path) as tmp_repo:
-            base = tmp_repo.merge_base(mr)
-            return list(tmp_repo.log(
+
+        if use_tmp_dir:
+            ctx_mgr = self._shared_clone(self._repo.full_fs_path)
+        else:
+            ctx_mgr = h.null_contextmanager(returning=self)
+
+        with ctx_mgr as repo:
+            base = repo.merge_base(mr)
+            return list(repo.log(
                 [mr.downstream.commit_id],
                 exclude=[base],
                 id_only=False))


Mime
View raw message