allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [23/50] [abbrv] allura git commit: [#7836] ticket:739 Delegate MergeRequest._commits to repo implementation
Date Wed, 27 May 2015 11:57:55 GMT
[#7836] ticket:739 Delegate MergeRequest._commits to repo implementation

This way we can implement it for Hg, which is quite different from Git (merge
base + log approach doesn't work for it).


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

Branch: refs/heads/ib/7868
Commit: d1310c61cd9cde87067b32622978a7fe9aee7937
Parents: f0bede1
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Apr 21 10:53:50 2015 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed May 20 19:43:17 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py   | 18 +++++++-----------
 ForgeGit/forgegit/model/git_repo.py | 12 ++++++++++++
 ForgeSVN/forgesvn/model/svn.py      |  4 ----
 3 files changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d1310c61/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 9162117..ec623a3 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -321,9 +321,9 @@ class RepositoryImplementation(object):
         """
         raise NotImplementedError('paged_diffs')
 
-    def merge_base(self, mr):
-        """Given MergeRequest :param mr: find common ancestor for the merge"""
-        raise NotImplementedError('merge_base')
+    def merge_request_commits(self, mr):
+        """Given MergeRequest :param mr: return list of commits to be merged"""
+        raise NotImplementedError('merge_request_commits')
 
 
 class Repository(Artifact, ActivityObject):
@@ -717,9 +717,9 @@ class Repository(Artifact, ActivityObject):
             self.set_default_branch(branch_name)
         return branch_name
 
-    def merge_base(self, mr):
-        """Given MergeRequest :param mr: find common ancestor for the merge"""
-        return self._impl.merge_base(mr)
+    def merge_request_commits(self, mr):
+        """Given MergeRequest :param mr: return list of commits to be merged"""
+        return self._impl.merge_request_commits(mr)
 
 
 class MergeRequest(VersionedArtifact, ActivityObject):
@@ -788,11 +788,7 @@ class MergeRequest(VersionedArtifact, ActivityObject):
 
     def _commits(self):
         with self.push_downstream_context():
-            base = c.app.repo.merge_base(self)
-            return list(c.app.repo.log(
-                self.downstream.commit_id,
-                exclude=base,
-                id_only=False))
+            return c.app.repo.merge_request_commits(self)
 
     @classmethod
     def upsert(cls, **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/d1310c61/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index a0f3f5a..99c5afe 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -636,6 +636,18 @@ class GitImplementation(M.RepositoryImplementation):
         g.fetch(mr.app.repo.full_fs_path, mr.target_branch)
         return g.merge_base(mr.downstream.commit_id, 'FETCH_HEAD')
 
+    def merge_request_commits(self, mr):
+        """
+        Return list of commits to be merged
+
+        Must be called within mr.push_downstream_context()
+        """
+        base = self.merge_base(mr)
+        return list(mr.app.repo.log(
+            mr.downstream.commit_id,
+            exclude=base,
+            id_only=False))
+
 
 class _OpenedGitBlob(object):
     CHUNK_SIZE = 4096

http://git-wip-us.apache.org/repos/asf/allura/blob/d1310c61/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 53b4190..cd410e3 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -91,10 +91,6 @@ class Repository(M.Repository):
     def rev_to_commit_id(self, rev):
         return self._impl.rev_parse(rev)
 
-    def merge_base(self, mr):
-        rev = self.latest(branch=mr.target_branch)
-        return rev._id if rev else self.head
-
 
 class SVNCalledProcessError(Exception):
 


Mime
View raw message