You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/11/05 22:09:04 UTC

[allura] branch db/8379 created (now 4380454)

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a change to branch db/8379
in repository https://gitbox.apache.org/repos/asf/allura.git.


      at 4380454  [#8379] use unicode for tarball_url building

This branch includes the following new commits:

     new 66c4e6c  [#8379] remove old adhoc scm script
     new f5f7979  [#8379] preserve same pickle format as used on py2 for db consistency and interoperability if py2 procs (taskd) in use during a transition
     new 5712107  [#8379] fix akismet tests
     new 4380454  [#8379] use unicode for tarball_url building

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[allura] 02/04: [#8379] preserve same pickle format as used on py2 for db consistency and interoperability if py2 procs (taskd) in use during a transition

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8379
in repository https://gitbox.apache.org/repos/asf/allura.git

commit f5f7979f76524a19333b920334705b4bff86174b
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Thu Nov 5 10:29:16 2020 -0500

    [#8379] preserve same pickle format as used on py2 for db consistency and interoperability if py2 procs (taskd) in use during a transition
---
 Allura/allura/model/index.py        | 2 +-
 Allura/allura/model/repo_refresh.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Allura/allura/model/index.py b/Allura/allura/model/index.py
index 0b8a3a4..790667a 100644
--- a/Allura/allura/model/index.py
+++ b/Allura/allura/model/index.py
@@ -84,7 +84,7 @@ class ArtifactReference(object):
             obj = cls(
                 _id=artifact.index_id(),
                 artifact_reference=dict(
-                    cls=bson.Binary(dumps(artifact.__class__)),
+                    cls=bson.Binary(dumps(artifact.__class__, protocol=2)),
                     project_id=artifact.app_config.project_id,
                     app_config_id=artifact.app_config._id,
                     artifact_id=artifact._id))
diff --git a/Allura/allura/model/repo_refresh.py b/Allura/allura/model/repo_refresh.py
index 8eb6b32..fa4a9d7 100644
--- a/Allura/allura/model/repo_refresh.py
+++ b/Allura/allura/model/repo_refresh.py
@@ -137,7 +137,7 @@ def refresh_commit_repos(all_commit_ids, repo):
             ref = ArtifactReferenceDoc(dict(
                 _id=index_id,
                 artifact_reference=dict(
-                    cls=bson.Binary(dumps(Commit)),
+                    cls=bson.Binary(dumps(Commit, protocol=2)),
                     project_id=repo.app.config.project_id,
                     app_config_id=repo.app.config._id,
                     artifact_id=oid),


[allura] 01/04: [#8379] remove old adhoc scm script

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8379
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 66c4e6cc316e45c2187f61ab0f3b98f6b9f111d5
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Thu Nov 5 09:53:51 2020 -0500

    [#8379] remove old adhoc scm script
---
 scripts/perf/benchmark-scm.py | 161 ------------------------------------------
 1 file changed, 161 deletions(-)

diff --git a/scripts/perf/benchmark-scm.py b/scripts/perf/benchmark-scm.py
deleted file mode 100755
index 1e23cb9..0000000
--- a/scripts/perf/benchmark-scm.py
+++ /dev/null
@@ -1,161 +0,0 @@
-#!/bin/env python
-
-#       Licensed to the Apache Software Foundation (ASF) under one
-#       or more contributor license agreements.  See the NOTICE file
-#       distributed with this work for additional information
-#       regarding copyright ownership.  The ASF licenses this file
-#       to you under the Apache License, Version 2.0 (the
-#       "License"); you may not use this file except in compliance
-#       with the License.  You may obtain a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#       Unless required by applicable law or agreed to in writing,
-#       software distributed under the License is distributed on an
-#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#       KIND, either express or implied.  See the License for the
-#       specific language governing permissions and limitations
-#       under the License.
-
-
-from __future__ import unicode_literals
-from __future__ import print_function
-from __future__ import absolute_import
-import os
-import sys
-import argparse
-from datetime import datetime
-
-import git
-import pysvn
-from mercurial import ui, hg, cmdutil
-import six
-from six.moves import range
-
-
-def main(opts):
-    if opts.type == 'git':
-        repo = git.Repo(opts.repo_path, odbt=git.GitCmdObjectDB)
-        cid = opts.cid
-        path = opts.path.strip('/')
-        tree = repo.commit(opts.cid).tree
-        if path:
-            tree = tree[path]
-        names = [n.name for n in tree]
-        impl = impl_git_tree if opts.full_tree else impl_git_node
-    elif opts.type == 'hg':
-        repo = hg.repository(HgUI(), six.ensure_str(opts.repo_path))
-        cid = None if opts.cid == 'HEAD' else ['%s:0' % opts.cid]
-        path = opts.path.strip('/')
-        filenames = list(repo[
-            'tip' if opts.cid == 'HEAD' else opts.cid].manifest().keys())
-        filenames = [
-            name for name in filenames if name.startswith(('%s/' % path).lstrip('/'))]
-        names = set()
-        for name in filenames:
-            names.add(name.split('/')[0])
-        names = list(names)
-        impl = impl_hg_tree if opts.full_tree else impl_hg_node
-    elif opts.type == 'svn':
-        repo = pysvn.Client()
-        if opts.cid == 'HEAD':
-            cid = pysvn.Revision(pysvn.opt_revision_kind.head)
-        else:
-            cid = pysvn.Revision(pysvn.opt_revision_kind.number, opts.cid)
-        path = opts.path.strip('/')
-        names = []
-        impl = impl_svn_tree if opts.full_tree else impl_svn_node
-
-    sys.stdout.write('Timing %s' % ('full tree' if opts.full_tree else 'node'))
-    sys.stdout.flush()
-    total = 0.0
-    for i in range(opts.count):
-        sys.stdout.write('.')
-        sys.stdout.flush()
-        start = datetime.now()
-        impl(repo, cid, path, names, opts.repo_path)
-        end = datetime.now()
-        total += (end - start).total_seconds()
-    print()
-    print('Total time:           %s' % total)
-    print('Average time per run: %s' % (total / opts.count))
-
-
-def impl_git_tree(repo, cid, path, names, *args):
-    data = {}
-    for name in names:
-        #data[name] = repo.git.rev_list(cid, '--', os.path.join(path, name), max_count=1)
-        data[name] = git.Commit.iter_items(
-            repo, cid, os.path.join(path, name), max_count=1).next().hexsha
-    return data
-
-
-def impl_git_node(repo, cid, path, *args):
-    # return repo.git.rev_list(cid, '--', path, max_count=1)
-    return git.Commit.iter_items(repo, cid, path, max_count=1).next().hexsha
-
-
-def impl_hg_tree(repo, cid, path, names, *args):
-    m = cmdutil.match(repo, pats=[path], default=path)
-    data = {}
-    for name in names:
-        rev_iter = cmdutil.walkchangerevs(
-            repo, m, {'rev': cid}, lambda c, f: None)
-        data[name] = rev_iter.next().hex()
-    return data
-
-
-def impl_hg_node(repo, cid, path, *args):
-    m = cmdutil.match(repo, pats=[path], default=path)
-    rev_iter = cmdutil.walkchangerevs(repo, m, {'rev': cid}, lambda c, f: None)
-    return rev_iter.next().hex()
-
-
-def impl_svn_tree(repo, cid, path, names, repo_path, *args):
-    infos = repo.info2(
-        'file://%s/%s' % (repo_path, path),
-        revision=cid,
-        depth=pysvn.depth.immediates)
-    data = {}
-    for name, info in infos[1:]:
-        data[name] = info.last_changed_rev
-    return data
-
-
-def impl_svn_node(repo, cid, path, names, repo_path, *args):
-    logs = repo.log(
-        'file://%s/%s' % (repo_path, path),
-        revision_start=cid,
-        limit=1)
-    return logs[0].revision.number
-
-
-class HgUI(ui.ui):
-
-    '''Hg UI subclass that suppresses reporting of untrusted hgrc files.'''
-
-    def __init__(self, *args, **kwargs):
-        super(HgUI, self).__init__(*args, **kwargs)
-        self._reportuntrusted = False
-
-
-def parse_opts():
-    parser = argparse.ArgumentParser(
-        description='Benchmark getting LCD from repo tool')
-    parser.add_argument('--type', default='git', dest='type',
-                        help='Type of repository being tested.')
-    parser.add_argument('--repo-path', dest='repo_path', required=True,
-                        help='Path to the repository to test against')
-    parser.add_argument('--commit', default='HEAD', dest='cid',
-                        help='Commit ID or revision number to test against')
-    parser.add_argument('--path', default='', dest='path',
-                        help='Path within the repository to test against')
-    parser.add_argument('--count', type=int, default=100, dest='count',
-                        help='Number of times to execute')
-    parser.add_argument(
-        '--full-tree', action='store_true', default=False, dest='full_tree',
-        help='Time full tree listing instead of just the single node')
-    return parser.parse_args()
-
-if __name__ == '__main__':
-    main(parse_opts())


[allura] 03/04: [#8379] fix akismet tests

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8379
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 571210772c5d97fa8e34201e8a3f814fcb8cfdb6
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Thu Nov 5 16:04:18 2020 -0500

    [#8379] fix akismet tests
---
 Allura/allura/tests/unit/spam/test_akismet.py | 44 +++++++++++++--------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/Allura/allura/tests/unit/spam/test_akismet.py b/Allura/allura/tests/unit/spam/test_akismet.py
index 670c98f..7dec31d 100644
--- a/Allura/allura/tests/unit/spam/test_akismet.py
+++ b/Allura/allura/tests/unit/spam/test_akismet.py
@@ -67,10 +67,10 @@ class TestAkismet(unittest.TestCase):
         self.content = 'spåm text'
         self.expected_data = dict(
             comment_content=self.content.encode('utf8'),
-            comment_type='comment',
-            user_ip='some ip',
-            user_agent='some browser',
-            referrer='some url')
+            comment_type=b'comment',
+            user_ip=b'some ip',
+            user_agent=b'some browser',
+            referrer=b'some url')
 
     @mock.patch('allura.lib.spam.akismetfilter.c')
     @mock.patch('allura.lib.spam.akismetfilter.request')
@@ -89,7 +89,7 @@ class TestAkismet(unittest.TestCase):
         request.remote_addr = 'some ip'
         c.user = None
         self.akismet.check(self.content, content_type='some content type')
-        self.expected_data['comment_type'] = 'some content type'
+        self.expected_data['comment_type'] = b'some content type'
         self.akismet.service.comment_check.assert_called_once_with(**self.expected_data)
 
     @mock.patch('allura.lib.spam.akismetfilter.c')
@@ -100,9 +100,9 @@ class TestAkismet(unittest.TestCase):
         c.user = None
         self.akismet.check(self.content, artifact=self.fake_artifact)
         expected_data = self.expected_data
-        expected_data['permalink'] = 'http://localhost/artifact-url'
-        expected_data['comment_date_gmt'] = '2019-05-17T00:00:00'
-        expected_data['comment_post_modified_gmt'] = '2019-05-17T00:05:01'
+        expected_data['permalink'] = b'http://localhost/artifact-url'
+        expected_data['comment_date_gmt'] = b'2019-05-17T00:00:00'
+        expected_data['comment_post_modified_gmt'] = b'2019-05-17T00:05:01'
         self.akismet.service.comment_check.assert_called_once_with(**expected_data)
 
     @mock.patch('allura.lib.spam.akismetfilter.c')
@@ -114,7 +114,7 @@ class TestAkismet(unittest.TestCase):
         self.akismet.check(self.content, user=self.fake_user)
         expected_data = self.expected_data
         expected_data.update(comment_author='Søme User'.encode('utf8'),
-                             comment_author_email='user@domain')
+                             comment_author_email=b'user@domain')
         self.akismet.service.comment_check.assert_called_once_with(**expected_data)
 
     @mock.patch('allura.lib.spam.akismetfilter.c')
@@ -126,7 +126,7 @@ class TestAkismet(unittest.TestCase):
         self.akismet.check(self.content)
         expected_data = self.expected_data
         expected_data.update(comment_author='Søme User'.encode('utf8'),
-                             comment_author_email='user@domain')
+                             comment_author_email=b'user@domain')
         self.akismet.service.comment_check.assert_called_once_with(**expected_data)
 
     @mock.patch('allura.lib.spam.akismetfilter.c')
@@ -137,9 +137,9 @@ class TestAkismet(unittest.TestCase):
 
         # no IP addr, UA, etc, since this isn't the original request
         expected_data = dict(comment_content='spåm text'.encode('utf8'),
-                             comment_type='comment',
-                             user_ip='',
-                             user_agent='',
+                             comment_type=b'comment',
+                             user_ip=b'',
+                             user_agent=b'',
                              )
         self.akismet.service.submit_spam.assert_called_once_with(**expected_data)
 
@@ -151,9 +151,9 @@ class TestAkismet(unittest.TestCase):
 
         # no IP addr, UA, etc, since this isn't the original request
         expected_data = dict(comment_content='spåm text'.encode('utf8'),
-                             comment_type='comment',
-                             user_ip='',
-                             user_agent='',
+                             comment_type=b'comment',
+                             user_ip=b'',
+                             user_agent=b'',
                              )
         self.akismet.service.submit_ham.assert_called_once_with(**expected_data)
 
@@ -164,11 +164,11 @@ class TestAkismet(unittest.TestCase):
         self.akismet.submit_ham(self.content, artifact=self.fake_artifact)
 
         expected_data = dict(comment_content='spåm text'.encode('utf8'),
-                             comment_type='comment',
-                             user_ip='33.4.5.66',
-                             user_agent='',
-                             permalink='http://localhost/artifact-url',
-                             comment_date_gmt='2019-05-17T00:00:00',
-                             comment_post_modified_gmt='2019-05-17T00:05:01',
+                             comment_type=b'comment',
+                             user_ip=b'33.4.5.66',
+                             user_agent=b'',
+                             permalink=b'http://localhost/artifact-url',
+                             comment_date_gmt=b'2019-05-17T00:00:00',
+                             comment_post_modified_gmt=b'2019-05-17T00:05:01',
                              )
         self.akismet.service.submit_ham.assert_called_once_with(**expected_data)


[allura] 04/04: [#8379] use unicode for tarball_url building

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8379
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 438045424923f74c12e4ab350ecf5ebd4872a63d
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Thu Nov 5 17:08:35 2020 -0500

    [#8379] use unicode for tarball_url building
---
 Allura/allura/controllers/repository.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 7ee5e95..53a64e5 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -779,10 +779,10 @@ class TreeBrowser(BaseController, DispatchIndex):
         tool_subscribed = M.Mailbox.subscribed()
         tarball_url = None
         if asbool(tg.config.get('scm.repos.tarball.enable', False)):
-            cutout = len(b'tree' + self._path.encode('utf8'))
+            cutout = len('tree' + self._path)
             if request.path.endswith('/') and not self._path.endswith('/'):
                 cutout += 1
-            tarball_url = h.urlquote('%starball' % unquote(request.path)[:-cutout])
+            tarball_url = h.urlquote(request.path_info[:-cutout] + 'tarball')
         return dict(
             repo=c.app.repo,
             commit=self._commit,