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 2014/02/18 22:39:19 UTC

[1/2] git commit: [#7128] Added direct SCM implementation of commit_browser_data for SVN

Repository: incubator-allura
Updated Branches:
  refs/heads/cj/7128 [created] 33fa75608


[#7128] Added direct SCM implementation of commit_browser_data for SVN

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

Branch: refs/heads/cj/7128
Commit: 0b099be58173d16fcc46a710c95d197c948ec2a0
Parents: ef2fcae
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue Feb 18 19:54:03 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Feb 18 19:54:03 2014 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/svn_main.py | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0b099be5/ForgeSVN/forgesvn/svn_main.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index dd72214..6e2ae00 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -25,6 +25,7 @@ from ming.orm.ormsession import ThreadLocalORMSession
 from tg import expose, redirect, validate, flash
 from tg.decorators import with_trailing_slash, without_trailing_slash
 from timermiddleware import Timer
+from paste.deploy.converters import asint
 
 # Pyforge-specific imports
 import allura.tasks.repo_tasks
@@ -71,7 +72,7 @@ class ForgeSVNApp(RepositoryApp):
         default_root = RepoRootController()
         self.root.refresh = default_root.refresh
         self.root.commit_browser = default_root.commit_browser
-        self.root.commit_browser_data = default_root.commit_browser_data
+        self.root.commit_browser_data = SVNCommitBrowserController().commit_browser_data
         self.root.status = default_root.status
         self.admin = SVNRepoAdminController(self)
 
@@ -178,6 +179,36 @@ class SVNImportController(BaseController):
         redirect(c.project.url() + 'admin/tools')
 
 
+class SVNCommitBrowserController(BaseController):
+
+    @without_trailing_slash
+    @expose('json:')
+    def commit_browser_data(self, start=None, limit=None, **kw):
+        data = {
+            'commits': [],
+            'next_column': 1,
+            'max_row': 0,
+            'built_tree': {},
+            'next_commit': None,
+        }
+        for i, commit in enumerate(c.app.repo.log(revs=start, id_only=False)):
+            if limit and i >= asint(limit):
+                data['next_commit'] = str(commit['id'])
+                break
+            data['commits'].append(str(commit['id']))
+            data['built_tree'][commit['id']] = {
+                'column': 0,
+                'parents': map(str, commit['parents']),
+                'short_id': '[%s]' % commit['id'],
+                'message': commit['message'],
+                'oid': str(commit['id']),
+                'row': i,
+                'url': c.app.repo.url_for_commit(commit['id']),
+            }
+        data['max_row'] = len(data['commits'])
+        return data
+
+
 def svn_timers():
     return Timer(
         'svn_lib.{method_name}', SM.svn.SVNLibWrapper, 'checkout', 'add',


[2/2] git commit: [#7128] Added support for paging to commit_browser

Posted by jo...@apache.org.
[#7128] Added support for paging to commit_browser

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

Branch: refs/heads/cj/7128
Commit: 33fa756089923cff6775074077770527cbd46751
Parents: 0b099be
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue Feb 18 19:54:22 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Feb 18 19:54:22 2014 +0000

----------------------------------------------------------------------
 .../lib/widgets/resources/js/commit_browser.js  | 79 +++++++++++++-------
 1 file changed, 53 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/33fa7560/Allura/allura/lib/widgets/resources/js/commit_browser.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/commit_browser.js b/Allura/allura/lib/widgets/resources/js/commit_browser.js
index 37c4408..e288800 100644
--- a/Allura/allura/lib/widgets/resources/js/commit_browser.js
+++ b/Allura/allura/lib/widgets/resources/js/commit_browser.js
@@ -65,11 +65,11 @@ if($('#commit_graph')){
     var point_size = 10;
     var page_size = 15;
 
-    var data;
+    var data = {'commits': [], 'built_tree': {}};
     var offset = 1;
     var selected_commit = -1;
     var y_offset = offset * y_space;
-    var tree, next_column, max_x_pos, max_row;
+    var tree, next_column, max_x_pos, max_row = 0, last_row = 0;
 
     var $graph_holder = $('#graph_holder');
     var $scroll_placeholder = $('#graph_scroll_placeholder');
@@ -100,36 +100,55 @@ if($('#commit_graph')){
       $scroll_placeholder.height(graph_height);
     }
 
-    $.getJSON(document.location.href+'_data', function(data) {
-        data = data;
-        tree = data['built_tree'];
-        next_column = data['next_column'];
-        max_x_pos = x_space*next_column;
-        max_row = data['max_row']
-        setHeight(max_row);
+    function get_data(select_first) {
+        var params = {'limit': 25};
+        if (data['next_commit']) {
+            params['start'] = data['next_commit'];
+        }
+        $.getJSON(document.location.href+'_data', params, function(new_data) {
+            $.extend(true, data, new_data);
+            tree = data['built_tree'];
+            next_column = data['next_column'];
+            max_x_pos = x_space*next_column;
+            max_row += data['max_row']
+            for (var c in new_data['built_tree']) {
+                tree[c].row += last_row;
+            }
+            last_row = max_row;
+            setHeight(max_row);
 
-        // Calculate the (x,y) positions of all the commits
-        for(var c in tree){
-            var commit = tree[c];
-            var x_pos = x_space+(commit.column*x_space);
-            var y_pos = y_space+((commit.row)*y_space);
-            if (!taken_coords[x_pos]){
-                taken_coords[x_pos] = [y_pos]
+            // Calculate the (x,y) positions of all the commits
+            for(var c in tree){
+                var commit = tree[c];
+                var x_pos = x_space+(commit.column*x_space);
+                var y_pos = y_space+((commit.row)*y_space);
+                if (!taken_coords[x_pos]){
+                    taken_coords[x_pos] = [y_pos]
+                }
+                else if(taken_coords[x_pos].indexOf(y_pos) == -1){
+                    taken_coords[x_pos].push(y_pos);
+                }
+                commit_rows[commit.row] = {
+                    url: commit.url,
+                    x_pos: x_pos,
+                    y_pos: y_pos }
             }
-            else if(taken_coords[x_pos].indexOf(y_pos) == -1){
-                taken_coords[x_pos].push(y_pos);
+            drawGraph(offset);
+            if (select_first) {
+                selectCommit(0);
             }
-            commit_rows[commit.row] = {
-                url: commit.url,
-                x_pos: x_pos,
-                y_pos: y_pos }
-        }
-        drawGraph(offset);
-        selectCommit(0);
-    });
+        });
+    }
+    get_data(true);
 
     function selectCommit(index) {
       if (index < 0 || index > max_row) return;
+      if (index == max_row) {
+          if (data['next_commit']) {
+              get_data();
+          }
+          return;
+      }
       var commit = commit_rows[index];
       highlighter_ctx.clearRect(0, 0, canvas.width, canvas.height);
       highlighter_ctx.fillRect(
@@ -179,6 +198,9 @@ if($('#commit_graph')){
 
             for(var i=0,len=commit.parents.length;i<len;i++){
                 var parent = tree[commit.parents[i]];
+                if (!parent) {
+                    continue;
+                }
                 var parent_x = x_space+parent.column*x_space
                 var parent_y = y_space+(parent.row-offset)*y_space;
 
@@ -212,6 +234,11 @@ if($('#commit_graph')){
             canvas_ctx.fillStyle = "#000";
             canvas_ctx.fillText(commit.short_id + " " + commit.message, (1+next_column) * x_space, y_pos);
         }
+        if (data['next_commit']) {
+            var y_pos = y_space+((max_row-offset)*y_space);
+            canvas_ctx.fillStyle = 'rgb(0,0,256)';
+            canvas_ctx.fillText('Show more', (1+next_column) * x_space, y_pos);
+        }
     }
 
     function setOffset(x) {