You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/07/07 07:28:26 UTC

[1/3] git commit: [#3060] Removed unused repo models

Updated Branches:
  refs/heads/master 7fc9b7de2 -> 3ae3c3666


[#3060] Removed unused repo models

These models are from a previous implementation of repo indexing and
haven't been used in some time.  With this, the following collections
can also be removed:

    * project-data.last_commit_for
    * pyforge.repo_object

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/33e7fea7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/33e7fea7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/33e7fea7

Branch: refs/heads/master
Commit: 33e7fea7547e901a28d9cf45b26821b5feca43e5
Parents: 7fc9b7d
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue Jul 2 20:18:56 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Sun Jul 7 05:24:21 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py | 586 +--------------------------------
 1 file changed, 1 insertion(+), 585 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/33e7fea7/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 32cea30..2904a39 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -533,8 +533,7 @@ class Repository(Artifact, ActivityObject):
             log.info('... %r analyzing', self)
             self.status = 'analyzing'
             session(self).flush(self)
-            if asbool(tg.config.get('scm.new_refresh')):
-                refresh_repo(self, all_commits, notify, new_clone)
+            refresh_repo(self, all_commits, notify, new_clone)
         finally:
             log.info('... %s ready', self)
             self.status = 'ready'
@@ -654,589 +653,6 @@ class MergeRequest(VersionedArtifact, ActivityObject):
                 self.request_number, self.project.name, self.app.repo.name))
         return result
 
-class LastCommitFor(MappedClass):
-    class __mongometa__:
-        session = project_orm_session
-        name='last_commit_for'
-        unique_indexes = [ ('repo_id', 'object_id') ]
-
-    _id = FieldProperty(S.ObjectId)
-    repo_id = FieldProperty(S.ObjectId)
-    object_id = FieldProperty(str)
-    last_commit = FieldProperty(dict(
-        date=datetime,
-        author=str,
-        author_email=str,
-        author_url=str,
-        id=str,
-        href=str,
-        shortlink=str,
-        summary=str))
-
-    @classmethod
-    def upsert(cls, repo_id, object_id):
-        isnew = False
-        r = cls.query.get(repo_id=repo_id, object_id=object_id)
-        if r is not None: return r, isnew
-        try:
-            r = cls(repo_id=repo_id, object_id=object_id)
-            session(r).flush(r)
-            isnew = True
-        except pymongo.errors.DuplicateKeyError: # pragma no cover
-            session(r).expunge(r)
-            r = cls.query.get(repo_id=repo_id, object_id=object_id)
-        return r, isnew
-
-class RepoObject(MappedClass):
-    class __mongometa__:
-        session = repository_orm_session
-        name='repo_object'
-        polymorphic_on = 'type'
-        polymorphic_identity=None
-        indexes = [
-            ('parent_ids',),
-            ('repo_id','type'),
-            ('type', 'object_ids.object_id'),
-            ('type', 'tree_id'),
-            ]
-        unique_indexes = [ 'object_id' ]
-
-    # ID Fields
-    _id = FieldProperty(S.ObjectId)
-    type = FieldProperty(str)
-    repo_id = FieldProperty(S.Deprecated)
-    object_id = FieldProperty(str)
-    last_commit=FieldProperty(S.Deprecated)
-
-    @classmethod
-    def upsert(cls, object_id):
-        isnew = False
-        r = cls.query.get(object_id=object_id)
-        if r is not None:
-            return r, isnew
-        try:
-            r = cls(
-                type=cls.__mongometa__.polymorphic_identity,
-                object_id=object_id)
-            session(r).flush(r)
-            isnew = True
-        except pymongo.errors.DuplicateKeyError: # pragma no cover
-            session(r).expunge(r)
-            r = cls.query.get(object_id=object_id)
-        return r, isnew
-
-    def set_last_commit(self, ci, repo=None):
-        '''Update the last_commit_for object based on the passed in commit &
-        repo'''
-        if repo is None: repo = c.app.repo
-        lc, isnew = LastCommitFor.upsert(repo_id=repo._id, object_id=self.object_id)
-        if not ci.authored.date:
-            repo._impl.refresh_commit(ci)
-        if isnew:
-            lc.last_commit.author = ci.authored.name
-            lc.last_commit.author_email = ci.authored.email
-            lc.last_commit.author_url = ci.author_url
-            lc.last_commit.date = ci.authored.date
-            lc.last_commit.id = ci.object_id
-            lc.last_commit.href = ci.url()
-            lc.last_commit.shortlink = ci.shorthand_id()
-            lc.last_commit.summary = ci.summary
-            assert lc.last_commit.date
-        return lc, isnew
-
-    def get_last_commit(self, repo=None):
-        if repo is None: repo = c.app.repo
-        return repo.get_last_commit(self)
-
-    def __repr__(self):
-        return '<%s %s>' % (
-            self.__class__.__name__, self.object_id)
-
-    def index_id(self):
-        app_config = self.repo.app_config
-        return '%s %s in %s %s' % (
-            self.type, self.object_id,
-            app_config.project.name,
-            app_config.options.mount_label)
-
-    def set_context(self, context): # pragma no cover
-        '''Set ephemeral (unsaved) attributes based on a context object'''
-        raise NotImplementedError, 'set_context'
-
-    def primary(self): return self
-
-class LogCache(RepoObject):
-    '''Class to store nothing but lists of commit IDs in topo sort order'''
-    class __mongometa__:
-        polymorphic_identity='log_cache'
-    type_s = 'LogCache'
-
-    type = FieldProperty(str, if_missing='log_cache')
-    object_ids = FieldProperty([str])
-    candidates = FieldProperty([str])
-
-    @classmethod
-    def get(cls, repo, object_id):
-        lc, new = cls.upsert('$' + object_id)
-        if not lc.object_ids:
-            lc.object_ids, lc.candidates = repo._impl.log(object_id, 0, 50)
-        return lc
-
-class Commit(RepoObject):
-    class __mongometa__:
-        polymorphic_identity='commit'
-    type_s = 'Commit'
-
-    # File data
-    type = FieldProperty(str, if_missing='commit')
-    tree_id = FieldProperty(str)
-    diffs = FieldProperty(dict(
-            added=[str],
-            removed=[str],
-            changed=[str],
-            copied=[dict(old=str, new=str)]))
-    # Commit metadata
-    committed = FieldProperty(
-        dict(name=str,
-             email=str,
-             date=datetime))
-    authored = FieldProperty(
-        dict(name=str,
-             email=str,
-             date=datetime))
-    message = FieldProperty(str)
-    parent_ids = FieldProperty([str])
-    extra = FieldProperty([dict(name=str, value=str)])
-     # All repos that potentially reference this commit
-    repositories=FieldProperty([S.ObjectId])
-
-    # Ephemeral attrs
-    repo=None
-
-    def set_context(self, repo):
-        self.repo = repo
-
-    @property
-    def diffs_computed(self):
-        if self.diffs.added: return True
-        if self.diffs.removed: return True
-        if self.diffs.changed: return True
-        if self.diffs.copied: return True
-
-    @LazyProperty
-    def author_url(self):
-        u = User.by_email_address(self.authored.email)
-        if u: return u.url()
-
-    @LazyProperty
-    def committer_url(self):
-        u = User.by_email_address(self.committed.email)
-        if u: return u.url()
-
-    @LazyProperty
-    def tree(self):
-        if self.tree_id is None:
-            self.tree_id = self.repo.compute_tree(self)
-        if self.tree_id is None:
-            return None
-        t = Tree.query.get(object_id=self.tree_id)
-        if t is None:
-            self.tree_id = self.repo.compute_tree(self)
-            t = Tree.query.get(object_id=self.tree_id)
-        if t is not None: t.set_context(self)
-        return t
-
-    @LazyProperty
-    def summary(self):
-        message = h.really_unicode(self.message)
-        first_line = message.split('\n')[0]
-        return h.text.truncate(first_line, 50)
-
-    def get_path(self, path):
-        '''Return the blob on the given path'''
-        if path.startswith('/'): path = path[1:]
-        path_parts = path.split('/')
-        return self.tree.get_blob(path_parts[-1], path_parts[:-1])
-
-    def shorthand_id(self):
-        return self.repo.shorthand_for_commit(self.object_id)
-
-    @LazyProperty
-    def symbolic_ids(self):
-        return self.repo.symbolics_for_commit(self)
-
-    def url(self):
-        return self.repo.url_for_commit(self)
-
-    def log(self, skip, count):
-        oids = list(self.log_iter(skip, count))
-        commits = self.query.find(dict(
-                type='commit',
-                object_id={'$in':oids}))
-        commits_by_oid = {}
-        for ci in commits:
-            ci.set_context(self.repo)
-            commits_by_oid[ci.object_id] = ci
-        return [ commits_by_oid[oid] for oid in oids ]
-
-    def log_iter(self, skip, count):
-        seen_oids = set()
-        candidates = [ self.object_id ]
-        while candidates and count:
-            candidate = candidates.pop()
-            if candidate in seen_oids: continue
-            lc = LogCache.get(self.repo, candidate)
-            oids = lc.object_ids
-            candidates += lc.candidates
-            for oid in oids:
-                if oid in seen_oids: continue
-                seen_oids.add(oid)
-                if count == 0:
-                    break
-                elif skip == 0:
-                    yield oid
-                    count -= 1
-                else:
-                    skip -= 1
-
-    def compute_diffs(self):
-        self.diffs.added = []
-        self.diffs.removed = []
-        self.diffs.changed = []
-        self.diffs.copied = []
-        if self.parent_ids:
-            parent = self.repo.commit(self.parent_ids[0])
-            for diff in Tree.diff(parent.tree, self.tree):
-                if diff.is_new:
-                    self.diffs.added.append(diff.b_path)
-                    obj = RepoObject.query.get(object_id=diff.b_object_id)
-                    obj.set_last_commit(self, self.repo)
-                elif diff.is_delete:
-                    self.diffs.removed.append(diff.a_path)
-                else:
-                    self.diffs.changed.append(diff.a_path)
-                    obj = RepoObject.query.get(object_id=diff.b_object_id)
-                    obj.set_last_commit(self, self.repo)
-        else:
-            # Parent-less, so the whole tree is additions
-            tree = self.tree
-            for x in tree.object_ids:
-                self.diffs.added.append('/'+x.name)
-                obj = RepoObject.query.get(object_id=x.object_id)
-                obj.set_last_commit(self, self.repo)
-
-    def context(self):
-        return self.repo.commit_context(self)
-
-class Tree(RepoObject):
-    '''
-    A representation of files & directories.  E.g. what is present at a single commit
-
-    :var object_ids: dict(object_id: name)  Set by refresh_tree in the scm implementation
-    '''
-    class __mongometa__:
-        polymorphic_identity='tree'
-    type_s = 'Tree'
-
-    type = FieldProperty(str, if_missing='tree')
-    object_ids = FieldProperty([dict(object_id=str,name=str)])
-
-    # Ephemeral attrs
-    repo=None
-    commit=None
-    parent=None
-    name=None
-
-    def compute_hash(self):
-        '''Compute a hash based on the contents of the tree.  Note that this
-        hash does not necessarily correspond to any actual DVCS hash.
-        '''
-        lines = []
-        for x in self.object_ids:
-            obj = RepoObject.query.get(x.object_id)
-            lines.append(obj.type[0] + x.object_id + x.name)
-        sha_obj = sha1()
-        for line in sorted(lines):
-            sha_obj.update(line)
-        return sha_obj.hexdigest()
-
-    def set_last_commit(self, ci, repo=None):
-        lc, isnew = super(Tree, self).set_last_commit(ci, repo)
-        if isnew:
-            for x in self.object_ids:
-                obj = RepoObject.query.get(object_id=x.object_id)
-                obj.set_last_commit(ci, repo)
-        return lc, isnew
-
-    @LazyProperty
-    def object_id_index(self):
-        return dict((x.name, x.object_id) for x in self.object_ids)
-
-    @LazyProperty
-    def object_name_index(self):
-        result = defaultdict(list)
-        for x in self.object_ids:
-            result[x.object_id].append(x.name)
-        return result
-
-    def get(self, name, default=None):
-        try:
-            return self[name]
-        except KeyError:
-            return default
-
-    def __getitem__(self, name):
-        oid = self.object_id_index[name]
-        obj = RepoObject.query.get(object_id=oid)
-        if obj is None:
-            oid = self.repo.compute_tree(self.commit, self.path() + name + '/')
-            obj = RepoObject.query.get(object_id=oid)
-        if obj is None: raise KeyError, name
-        obj.set_context(self, name)
-        return obj
-
-    @classmethod
-    def diff(cls, a, b):
-        '''Recursive diff of two tree objects, yielding DiffObjects'''
-        if not isinstance(a, Tree) or not isinstance(b, Tree):
-            yield DiffObject(a, b)
-        else:
-            for a_x in a.object_ids:
-                b_oid = b.object_id_index.get(a_x.name)
-                if a_x.object_id == b_oid: continue
-                a_obj = a.get(a_x.name)
-                b_obj = b.get(a_x.name)
-                if b_obj is None:
-                    yield DiffObject(a_obj, None)
-                else:
-                    for x in cls.diff(a_obj, b_obj): yield x
-            for b_x in b.object_ids:
-                if b_x.name in a.object_id_index: continue
-                b_obj = b.get(b_x.name)
-                yield DiffObject(None, b_obj)
-
-    def set_context(self, commit_or_tree, name=None):
-        assert commit_or_tree is not self
-        self.repo = commit_or_tree.repo
-        if name:
-            self.commit = commit_or_tree.commit
-            self.parent = commit_or_tree
-            self.name = name
-        else:
-            self.commit = commit_or_tree
-
-    def readme(self):
-        'returns (filename, unicode text) if a readme file is found'
-        for x in self.object_ids:
-            if README_RE.match(x.name):
-                obj = self[x.name]
-                if isinstance(obj, Blob):
-                    return (x.name, h.really_unicode(obj.text))
-        return (None, '')
-
-    def ls(self):
-        results = []
-        for x in self.object_ids:
-            obj = self[x.name]
-            ci = obj.get_last_commit()
-            d = dict(last_commit=ci, name=x.name)
-            if isinstance(obj, Tree):
-                results.append(dict(d, kind='DIR', href=x.name + '/'))
-            else:
-                results.append(dict(d, kind='FILE', href=x.name))
-        results.sort(key=lambda d:(d['kind'], d['name']))
-        return results
-
-    def index_id(self):
-        return repr(self)
-
-    def path(self):
-        if self.parent:
-            assert self.parent is not self
-            return self.parent.path() + self.name + '/'
-        else:
-            return '/'
-
-    def url(self):
-        return self.commit.url() + 'tree' + self.path()
-
-    def is_blob(self, name):
-        obj = RepoObject.query.get(
-            object_id=self.object_id_index[name])
-        return isinstance(obj, Blob)
-
-    def get_tree(self, name):
-        t = self.get(name)
-        if isinstance(t, Tree): return t
-        return None
-
-    def get_blob(self, name, path_parts=None):
-        if not path_parts:
-            t = self
-        else:
-            t = self.get_object(*path_parts)
-        if t is None: return None
-        b = t.get(name)
-        if isinstance(b, Blob): return b
-        return None
-
-    def get_object(self, *path_parts):
-        cur = self
-        for part in path_parts:
-            if not isinstance(cur, Tree): return None
-            cur = cur.get(part)
-        return cur
-
-class Blob(RepoObject):
-    class __mongometa__:
-        polymorphic_identity='blob'
-    type_s = 'Blob'
-
-    type = FieldProperty(str, if_missing='blob')
-
-    # Ephemeral attrs
-    repo=None
-    commit=None
-    tree=None
-    name=None
-
-    def set_context(self, tree, name):
-        self.repo = tree.repo
-        self.commit = tree.commit
-        self.tree = tree
-        self.name = name
-        fn, ext = os.path.splitext(self.name)
-        self.extension = ext or fn
-
-    @LazyProperty
-    def _content_type_encoding(self):
-        return self.repo.guess_type(self.name)
-
-    @LazyProperty
-    def content_type(self):
-        return self._content_type_encoding[0]
-
-    @LazyProperty
-    def content_encoding(self):
-        return self._content_type_encoding[1]
-
-    @LazyProperty
-    def next_commit(self):
-        try:
-            path = self.path()
-            cur = self.commit
-            next = cur.context()['next']
-            while next:
-                cur = next[0]
-                next = cur.context()['next']
-                other_blob = cur.get_path(path)
-                if other_blob is None or other_blob.object_id != self.object_id:
-                    return cur
-        except:
-            log.exception('Lookup prev_commit')
-            return None
-
-    @LazyProperty
-    def prev_commit(self):
-        lc = self.get_last_commit()
-        if lc['id']:
-            last_commit = self.repo.commit(lc.id)
-            if last_commit.parent_ids:
-                return self.repo.commit(last_commit.parent_ids[0])
-        return None
-
-    def url(self):
-        return self.tree.url() + h.really_unicode(self.name)
-
-    def path(self):
-        return self.tree.path() + h.really_unicode(self.name)
-
-    @property
-    def has_pypeline_view(self):
-        if README_RE.match(self.name) or self.extension in ['.md', '.rst']:
-            return True
-        return False
-
-    @property
-    def has_html_view(self):
-        if (self.content_type.startswith('text/') or
-            self.extension in VIEWABLE_EXTENSIONS or
-            self.extension in self.repo._additional_viewable_extensions or
-            utils.is_text_file(self.text)):
-            return True
-        return False
-
-    @property
-    def has_image_view(self):
-        return self.content_type.startswith('image/')
-
-    def context(self):
-        path = self.path()[1:]
-        prev = self.prev_commit
-        next = self.next_commit
-        if prev is not None: prev = prev.get_path(path)
-        if next is not None: next = next.get_path(path)
-        return dict(
-            prev=prev,
-            next=next)
-
-    def compute_hash(self):
-        '''Compute a hash based on the contents of the blob.  Note that this
-        hash does not necessarily correspond to any actual DVCS hash.
-        '''
-        fp = self.open()
-        sha_obj = sha1()
-        while True:
-            buffer = fp.read(4096)
-            if not buffer: break
-            sha_obj.update(buffer)
-        return sha_obj.hexdigest()
-
-    def open(self):
-        return self.repo.open_blob(self)
-
-    def __iter__(self):
-        return iter(self.open())
-
-    @LazyProperty
-    def size(self):
-        return self.repo.blob_size(self)
-
-    @LazyProperty
-    def text(self):
-        return self.open().read()
-
-    @classmethod
-    def diff(cls, v0, v1):
-        differ = SequenceMatcher(v0, v1)
-        return differ.get_opcodes()
-
-class DiffObject(object):
-    a_path = b_path = None
-    a_object_id = b_object_id = None
-    is_new = False
-    is_delete = False
-
-    def __init__(self, a, b):
-        if a:
-            self.a_path = a.path()
-            self.a_object_id = a.object_id
-        else:
-            self.is_new = True
-        if b:
-            self.b_path = b.path()
-            self.b_object_id = b.object_id
-        else:
-            self.is_delete = True
-
-    def __repr__(self):
-        if self.is_new:
-            return '<new %s>' % self.b_path
-        elif self.is_delete:
-            return '<remove %s>' % self.a_path
-        else:
-            return '<change %s>' % (self.a_path)
-
 
 class GitLikeTree(object):
     '''


[2/3] git commit: [#3060] Removed redundant commit log iteration and updated tests to new method

Posted by tv...@apache.org.
[#3060] Removed redundant commit log iteration and updated tests to new method

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/1e27f3d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1e27f3d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1e27f3d8

Branch: refs/heads/master
Commit: 1e27f3d88ef9ef696e1e8a72600905247320f507
Parents: 33e7fea
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Jul 3 15:10:25 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Sun Jul 7 05:25:12 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repo.py                     | 20 ++---
 Allura/allura/model/repository.py               | 22 ------
 Allura/allura/tests/model/test_repo.py          |  9 ++-
 ForgeGit/forgegit/model/git_repo.py             | 14 ----
 .../forgegit/tests/model/test_repository.py     | 80 +++++++-------------
 ForgeSVN/forgesvn/model/svn.py                  | 39 ----------
 .../forgesvn/tests/model/test_repository.py     | 54 ++++---------
 7 files changed, 58 insertions(+), 180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e27f3d8/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index f683490..06a0853 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -783,13 +783,12 @@ class LastCommit(RepoObject):
 
     @classmethod
     def _last_commit_id(cls, commit, path):
-        commit_id = list(commit.repo.commits(path, commit._id, limit=1))
-        if commit_id:
-            commit_id = commit_id[0]
-        else:
+        try:
+            rev = commit.repo.log(commit._id, path, id_only=True).next()
+            return commit.repo.rev_to_commit_id(rev)
+        except StopIteration:
             log.error('Tree node not recognized by SCM: %s @ %s', path, commit._id)
-            commit_id = commit._id
-        return commit_id
+            return commit._id
 
     @classmethod
     def _prev_commit_id(cls, commit, path):
@@ -798,10 +797,13 @@ class LastCommit(RepoObject):
         lcid_cache = getattr(c, 'lcid_cache', '')
         if lcid_cache != '' and path in lcid_cache:
             return lcid_cache[path]
-        commit_id = list(commit.repo.commits(path, commit._id, skip=1, limit=1))
-        if not commit_id:
+        try:
+            log_iter = commit.repo.log(commit._id, path, id_only=True)
+            log_iter.next()
+            rev = log_iter.next()
+            return commit.repo.rev_to_commit_id(rev)
+        except StopIteration:
             return None
-        return commit_id[0]
 
     @classmethod
     def get(cls, tree, create=True):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e27f3d8/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 2904a39..3d893cc 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -135,14 +135,6 @@ class RepositoryImplementation(object):
         '''Return a blob size in bytes'''
         raise NotImplementedError, 'blob_size'
 
-    def commits(self, path=None, rev=None, skip=None, limit=None):
-        '''Return a list of the commits related to path'''
-        raise NotImplementedError, 'commits'
-
-    def commits_count(self, path=None, rev=None):
-        '''Return count of the commits related to path'''
-        raise NotImplementedError, 'commits_count'
-
     def tarball(self, revision, path=None):
         '''Create a tarball for the revision'''
         raise NotImplementedError, 'tarball'
@@ -346,10 +338,6 @@ class Repository(Artifact, ActivityObject):
         return self._impl.url_for_commit(commit, url_type)
     def compute_tree_new(self, commit, path='/'):
         return self._impl.compute_tree_new(commit, path)
-    def commits(self, path=None, rev=None, skip=None, limit=None):
-        return self._impl.commits(path, rev, skip, limit)
-    def commits_count(self, path=None, rev=None):
-        return self._impl.commits_count(path, rev)
     def last_commit_ids(self, commit, paths):
         return self._impl.last_commit_ids(commit, paths)
     def is_empty(self):
@@ -433,16 +421,6 @@ class Repository(Artifact, ActivityObject):
             exclude = [exclude]
         return self._impl.log(revs, path, exclude=exclude, id_only=id_only, **kw)
 
-    def commitlog(self, revs):
-        """
-        Return a generator that returns Commit model instances reachable by
-        the commits specified by revs.
-        """
-        for ci_id in self.log(revs, id_only=True):
-            commit = self.commit(ci_id)
-            commit.set_context(self)
-            yield commit
-
     def latest(self, branch=None):
         if self._impl is None:
             return None

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e27f3d8/Allura/allura/tests/model/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_repo.py b/Allura/allura/tests/model/test_repo.py
index 3880629..5d9e95e 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -98,7 +98,8 @@ class TestLastCommit(unittest.TestCase):
         setup_global_objects()
         self.repo = mock.Mock('repo', _commits=OrderedDict(), _last_commit=None)
         self.repo.shorthand_for_commit = lambda _id: _id[:6]
-        self.repo.commits = self._commits
+        self.repo.rev_to_commit_id = lambda rev: rev
+        self.repo.log = self._log
         lcids = M.repository.RepositoryImplementation.last_commit_ids.__func__
         self.repo.last_commit_ids = lambda *a, **k: lcids(self.repo, *a, **k)
         c.lcid_cache = {}
@@ -155,8 +156,10 @@ class TestLastCommit(unittest.TestCase):
         self.repo._commits[commit._id] = commit
         return commit
 
-    def _commits(self, path, commit_id, skip=0, limit=-1):
-        return [c._id for c in reversed(self.repo._commits.values()) if path in c.changed_paths][skip:limit]
+    def _log(self, revs, path, id_only=True):
+        for commit_id, commit in reversed(self.repo._commits.items()):
+            if path in commit.changed_paths:
+                yield commit_id
 
     def test_single_commit(self):
         commit1 = self._add_commit('Commit 1', [

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e27f3d8/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 0da371d..9906c0b 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -266,20 +266,6 @@ class GitImplementation(M.RepositoryImplementation):
         doc.m.save(safe=False)
         return doc
 
-    def commits(self, path=None, rev=None, skip=None, limit=None):
-        params = dict(paths=path)
-        if rev is not None:
-            params['rev'] = rev
-        if skip is not None:
-            params['skip'] = skip
-        if limit is not None:
-            params['max_count'] = limit
-        return (c.hexsha for c in self._git.iter_commits(**params))
-
-    def commits_count(self, path=None, rev=None):
-        commit = self._git.commit(rev)
-        return commit.count(path)
-
     def log(self, revs=None, path=None, exclude=None, id_only=True, **kw):
         """
         Returns a generator that returns information about commits reachable

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e27f3d8/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 dba95ae..85777e2 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -471,59 +471,35 @@ class TestGitCommit(unittest.TestCase):
         for d in diffs:
             print d
 
-    def test_commits(self):
+    def test_log(self):
         # path only
-        commits = list(self.repo.commits())
-        assert len(commits) == 4, 'Returned %s commits' % len(commits)
-        assert "9a7df788cf800241e3bb5a849c8870f2f8259d98" in commits, commits
-        commits = list(self.repo.commits('README'))
-        assert len(commits) == 2, 'Returned %s README commits' % len(commits)
-        assert "1e146e67985dcd71c74de79613719bef7bddca4a" in commits, commits
-        assert "df30427c488aeab84b2352bdf88a3b19223f9d7a" in commits, commits
-        assert list(self.repo.commits('does/not/exist')) == []
-        # with path and start rev
-        commits = list(self.repo.commits('README', 'df30427c488aeab84b2352bdf88a3b19223f9d7a'))
-        assert_equal(commits, ['df30427c488aeab84b2352bdf88a3b19223f9d7a'])
-        # skip and limit
-        commits = list(self.repo.commits(None, rev=None, skip=1, limit=2))
-        assert_equal(commits, ['df30427c488aeab84b2352bdf88a3b19223f9d7a', '6a45885ae7347f1cac5103b0050cc1be6a1496c8'])
-        commits = list(self.repo.commits(None, '6a45885ae7347f1cac5103b0050cc1be6a1496c8', skip=1))
-        assert_equal(commits, ['9a7df788cf800241e3bb5a849c8870f2f8259d98'])
-        commits = list(self.repo.commits('README', 'df30427c488aeab84b2352bdf88a3b19223f9d7a', skip=1))
-        assert commits == []
-        # path to dir
-        commits = list(self.repo.commits('a/b/c/'))
-        assert commits == ['6a45885ae7347f1cac5103b0050cc1be6a1496c8', '9a7df788cf800241e3bb5a849c8870f2f8259d98']
-        commits = list(self.repo.commits('a/b/c/', skip=1))
-        assert commits == ['9a7df788cf800241e3bb5a849c8870f2f8259d98']
-        commits = list(self.repo.commits('a/b/c/', limit=1))
-        assert commits == ['6a45885ae7347f1cac5103b0050cc1be6a1496c8']
-        commits = list(self.repo.commits('not/exist/'))
-        assert commits == []
-        # with missing add record
-        commit = M.repo.Commit.query.get(_id='df30427c488aeab84b2352bdf88a3b19223f9d7a')
-        commit.changed_paths = []
-        commits = list(self.repo.commits('README', 'df30427c488aeab84b2352bdf88a3b19223f9d7a'))
-        assert_equal(commits, ['df30427c488aeab84b2352bdf88a3b19223f9d7a'])
-        # with missing add record & no parent
-        commit = M.repo.Commit.query.get(_id='9a7df788cf800241e3bb5a849c8870f2f8259d98')
-        commit.changed_paths = ['a']
-        commits = list(self.repo.commits('a/b/c/hello.txt', '9a7df788cf800241e3bb5a849c8870f2f8259d98'))
-        assert_equal(commits, ['9a7df788cf800241e3bb5a849c8870f2f8259d98'])
-
-    def test_commits_count(self):
-        commits = self.repo.commits_count()
-        assert commits == 4, commits
-        commits = self.repo.commits_count('README')
-        assert commits == 2, commits
-        commits = self.repo.commits_count(None, 'df30427c488aeab84b2352bdf88a3b19223f9d7a')
-        assert commits == 3, commits
-        commits = self.repo.commits_count('a/b/c/hello.txt', '6a45885ae7347f1cac5103b0050cc1be6a1496c8')
-        assert commits == 2, commits
-        commits = self.repo.commits_count('a/b/c/')
-        assert commits == 2, commits
-        commits = self.repo.commits_count('not/exist/')
-        assert commits == 0, commits
+        commits = list(self.repo.log(id_only=True))
+        assert_equal(commits, [
+                "1e146e67985dcd71c74de79613719bef7bddca4a",
+                "df30427c488aeab84b2352bdf88a3b19223f9d7a",
+                "6a45885ae7347f1cac5103b0050cc1be6a1496c8",
+                "9a7df788cf800241e3bb5a849c8870f2f8259d98",
+            ])
+        commits = list(self.repo.log(self.repo.head, 'README', id_only=True))
+        assert_equal(commits, [
+                "1e146e67985dcd71c74de79613719bef7bddca4a",
+                "df30427c488aeab84b2352bdf88a3b19223f9d7a",
+            ])
+        commits = list(self.repo.log("df30427c488aeab84b2352bdf88a3b19223f9d7a", 'README', id_only=True))
+        assert_equal(commits, [
+                "df30427c488aeab84b2352bdf88a3b19223f9d7a",
+            ])
+        commits = list(self.repo.log(self.repo.head, '/a/b/c/', id_only=True))
+        assert_equal(commits, [
+                "6a45885ae7347f1cac5103b0050cc1be6a1496c8",
+                "9a7df788cf800241e3bb5a849c8870f2f8259d98",
+            ])
+        commits = list(self.repo.log("9a7df788cf800241e3bb5a849c8870f2f8259d98", '/a/b/c/', id_only=True))
+        assert_equal(commits, [
+                "9a7df788cf800241e3bb5a849c8870f2f8259d98",
+            ])
+        commits = list(self.repo.log(self.repo.head, '/does/not/exist/', id_only=True))
+        assert_equal(commits, [])
 
 
 class TestGitHtmlView(unittest.TestCase):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e27f3d8/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index e348850..1ff9564 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -620,45 +620,6 @@ class SVNImplementation(M.RepositoryImplementation):
     def _oid(self, revno):
         return '%s:%s' % (self._repo._id, revno)
 
-    def commits(self, path=None, rev=None, skip=None, limit=None):
-        if path is not None:
-            path = '%s/%s' % (self._url, path)
-        else:
-            path = self._url
-        opts = {}
-        if rev is not None:
-            opts['revision_start'] = pysvn.Revision(pysvn.opt_revision_kind.number, self._revno(rev))
-            opts['revision_end'] = pysvn.Revision(pysvn.opt_revision_kind.number, 0)
-        if skip is None: skip = 0
-        if limit:
-            # we need to expand limit to include skipped revs (pysvn doesn't support skip)
-            opts['limit'] = skip + limit
-        try:
-            revs = self._svn.log(path, **opts)
-        except pysvn.ClientError as e:
-            log.exception('ClientError processing commits for SVN: path %s, rev %s, skip=%s, limit=%s, treating as empty',
-                    path, rev, skip, limit)
-            return []
-        if skip:
-            # pysvn has already limited result for us, we just need to skip
-            revs = revs[skip:]
-        return [self._oid(r.revision.number) for r in revs]
-
-    def commits_count(self, path=None, rev=None):
-        if path is not None:
-            path = '%s/%s' % (self._url, path)
-        else:
-            path = self._url
-        opts = {}
-        if rev is not None:
-            opts['revision_start'] = pysvn.Revision(pysvn.opt_revision_kind.number, self._revno(rev))
-            opts['revision_end'] = pysvn.Revision(pysvn.opt_revision_kind.number, 0)
-        try:
-            return len(self._svn.log(path, **opts))
-        except pysvn.ClientError as e:
-            log.exception('ClientError processing commits for SVN: path %s, rev %s, treating as empty', path, rev)
-            return 0
-
     def last_commit_ids(self, commit, paths):
         '''
         Return a mapping {path: commit_id} of the _id of the last

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e27f3d8/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 3f5182a..e47158f 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -559,46 +559,19 @@ class TestSVNRev(unittest.TestCase):
     def _oid(self, rev_id):
         return '%s:%s' % (self.repo._id, rev_id)
 
-    def test_commits(self):
+    def test_log(self):
         # path only
-        commits = self.repo.commits()
-        assert len(commits) == 5, 'Returned %s commits' % len(commits)
-        assert self._oid(5) in commits, commits
-        assert self._oid(1) in commits, commits
-        commits = self.repo.commits('README')
-        assert commits == [self._oid(3), self._oid(1)]
-        assert self.repo.commits('does/not/exist') == []
-        # with path and start rev
-        commits = self.repo.commits('README', self._oid(1))
-        assert commits == [self._oid(1)], commits
-        # skip and limit
-        commits = self.repo.commits(None, rev=None, skip=1, limit=2)
-        assert commits == [self._oid(4), self._oid(3)]
-        commits = self.repo.commits(None, self._oid(2), skip=1)
-        assert commits == [self._oid(1)], commits
-        commits = self.repo.commits('README', self._oid(1), skip=1)
-        assert commits == []
-        # path to dir
-        commits = self.repo.commits('a/b/c/')
-        assert commits == [self._oid(4), self._oid(2)]
-        commits = self.repo.commits('a/b/c/', skip=1)
-        assert commits == [self._oid(2)]
-        commits = self.repo.commits('a/b/c/', limit=1)
-        assert commits == [self._oid(4)]
-        commits = self.repo.commits('not/exist/')
-        assert commits == []
-
-    def test_commits_count(self):
-        commits = self.repo.commits_count()
-        assert commits == 5, commits
-        commits = self.repo.commits_count('a/b/c/')
-        assert commits == 2, commits
-        commits = self.repo.commits_count(None, self._oid(3))
-        assert commits == 3, commits
-        commits = self.repo.commits_count('README', self._oid(1))
-        assert commits == 1, commits
-        commits = self.repo.commits_count('not/exist/')
-        assert commits == 0, commits
+        commits = list(self.repo.log(self.repo.head, id_only=True))
+        assert_equal(commits, [5, 4, 3, 2, 1])
+        commits = list(self.repo.log(self.repo.head, 'README', id_only=True))
+        assert_equal(commits, [3, 1])
+        commits = list(self.repo.log(1, 'README', id_only=True))
+        assert_equal(commits, [1])
+        commits = list(self.repo.log(self.repo.head, 'a/b/c/', id_only=True))
+        assert_equal(commits, [4, 2])
+        commits = list(self.repo.log(3, 'a/b/c/', id_only=True))
+        assert_equal(commits, [2])
+        assert_equal(list(self.repo.log(self.repo.head, 'does/not/exist', id_only=True)), [])
 
     def test_notification_email(self):
         setup_global_objects()
@@ -613,8 +586,7 @@ class TestSVNRev(unittest.TestCase):
             status = 'creating')
         self.repo.refresh()
         ThreadLocalORMSession.flush_all()
-        commits = self.repo.commits()
-        send_notifications(self.repo, [commits[4], ])
+        send_notifications(self.repo, [self.repo.rev_to_commit_id(1)])
         ThreadLocalORMSession.flush_all()
         n = M.Notification.query.find(
             dict(subject='[test:src] [r1] - rick446: Create readme')).first()


[3/3] git commit: Remove timer for deleted method

Posted by tv...@apache.org.
Remove timer for deleted method

Signed-off-by: Tim Van Steenburgh <tv...@gmail.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/3ae3c366
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/3ae3c366
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/3ae3c366

Branch: refs/heads/master
Commit: 3ae3c3666cae7368f30ee017356438b2e7706405
Parents: 1e27f3d
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Sun Jul 7 05:26:40 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Sun Jul 7 05:26:40 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/custom_middleware.py | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3ae3c366/Allura/allura/lib/custom_middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index e156e94..4458c48 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -241,7 +241,6 @@ class AlluraTimerMiddleware(TimerMiddleware):
     def repo_impl_timers(self):
         timers= []
         from allura.model.repository import Repository, RepositoryImplementation
-        timers.append(Timer('base_tool.{method_name}', Repository, 'commitlog'))
         timers.append(Timer('base_tool.{method_name}', RepositoryImplementation, 'last_commit_ids'))
         with pass_on_exc(ImportError):
             from forgegit.model.git_repo import GitImplementation