Switch to unified view

a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
...
...
781
    def __repr__(self):
781
    def __repr__(self):
782
        return '<LastCommit /%s %s>' % (self.path, self.commit_id)
782
        return '<LastCommit /%s %s>' % (self.path, self.commit_id)
783
783
784
    @classmethod
784
    @classmethod
785
    def _last_commit_id(cls, commit, path):
785
    def _last_commit_id(cls, commit, path):
786
        commit_id = list(commit.repo.commits(path, commit._id, limit=1))
786
        try:
787
        if commit_id:
787
            rev = commit.repo.log(commit._id, path, id_only=True).next()
788
            commit_id = commit_id[0]
788
            return commit.repo.rev_to_commit_id(rev)
789
        else:
789
        except StopIteration:
790
            log.error('Tree node not recognized by SCM: %s @ %s', path, commit._id)
790
            log.error('Tree node not recognized by SCM: %s @ %s', path, commit._id)
791
            commit_id = commit._id
792
        return commit_id
791
            return commit._id
793
792
794
    @classmethod
793
    @classmethod
795
    def _prev_commit_id(cls, commit, path):
794
    def _prev_commit_id(cls, commit, path):
796
        if not commit.parent_ids or path in commit.added_paths:
795
        if not commit.parent_ids or path in commit.added_paths:
797
            return None  # new paths by definition have no previous LCD
796
            return None  # new paths by definition have no previous LCD
798
        lcid_cache = getattr(c, 'lcid_cache', '')
797
        lcid_cache = getattr(c, 'lcid_cache', '')
799
        if lcid_cache != '' and path in lcid_cache:
798
        if lcid_cache != '' and path in lcid_cache:
800
            return lcid_cache[path]
799
            return lcid_cache[path]
801
        commit_id = list(commit.repo.commits(path, commit._id, skip=1, limit=1))
800
        try:
802
        if not commit_id:
801
            log_iter = commit.repo.log(commit._id, path, id_only=True)
802
            log_iter.next()
803
            rev = log_iter.next()
804
            return commit.repo.rev_to_commit_id(rev)
805
        except StopIteration:
803
            return None
806
            return None
804
        return commit_id[0]
805
807
806
    @classmethod
808
    @classmethod
807
    def get(cls, tree, create=True):
809
    def get(cls, tree, create=True):
808
        '''Find or build the LastCommitDoc for the given tree.'''
810
        '''Find or build the LastCommitDoc for the given tree.'''
809
        cache = getattr(c, 'model_cache', '') or ModelCache()
811
        cache = getattr(c, 'model_cache', '') or ModelCache()