/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/__init__.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2007-05-17 12:18:40 UTC
  • mto: This revision was merged to the branch mainline in revision 201.
  • Revision ID: szilveszter.farkas@gmail.com-20070517121840-tlyfh1mp4122fj45
Workaround for bug #115209 (in Bazaar itself).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1015
1015
            dirs = []
1016
1016
            files = []
1017
1017
            
 
1018
            self._show_stock_image(gtk.STOCK_REFRESH)
 
1019
            
1018
1020
            tstart = time.time()
1019
1021
            for (name, type) in self.remote_entries:
1020
1022
                if type.kind == 'directory':
1024
1026
            tend = time.time()
1025
1027
            print "DEBUG: separating files and dirs =", tend - tstart
1026
1028
            
 
1029
            class HistoryCache:
 
1030
                """ Cache based on revision history. """
 
1031
                def __init__(self, history):
 
1032
                    self._history = history
 
1033
                
 
1034
                def _lookup_revision(self, revid):
 
1035
                    print "DEBUG: looking up revision =", revid
 
1036
                    for r in self._history:
 
1037
                        if r.revision_id == revid:
 
1038
                            print "DEBUG: revision found =", r
 
1039
                            return r
 
1040
                    print "DEBUG: revision not found, adding it to the cache."
 
1041
                    rev = repo.get_revision(revid)
 
1042
                    self._history.append(rev)
 
1043
                    return rev
 
1044
            
1027
1045
            repo = self.remote_branch.repository
1028
1046
            
1029
1047
            tstart = time.time()
1030
 
            revs = repo.get_revisions(self.remote_branch.revision_history())
 
1048
            revhistory = self.remote_branch.revision_history()
 
1049
            try:
 
1050
                revs = repo.get_revisions(revhistory)
 
1051
                cache = HistoryCache(revs)
 
1052
            except bzrerrors.InvalidHttpResponse:
 
1053
                # Fallback to dummy algorithm, because of LP: #115209
 
1054
                cache = HistoryCache([])
 
1055
            
1031
1056
            tend = time.time()
1032
1057
            print "DEBUG: fetching all revisions =", tend - tstart
1033
1058
            
1034
 
            def _lookup_revision(revid):
1035
 
                print "DEBUG: looking up revision =", revid
1036
 
                for r in revs:
1037
 
                    if r.revision_id == revid:
1038
 
                        print "DEBUG: revision found =", r
1039
 
                        return r
1040
 
                print "DEBUG: revision not found, adding it to the cache."
1041
 
                rev = repo.get_revision(revid)
1042
 
                revs.append(rev)
1043
 
                return rev
1044
 
            
1045
1059
            tstart = time.time()
1046
1060
            for item in dirs:
1047
1061
                ts = time.time()
1048
1062
                if item.parent_id == self.remote_parent:
1049
 
                    rev = _lookup_revision(item.revision)
 
1063
                    rev = cache._lookup_revision(item.revision)
1050
1064
                    print "DEBUG: revision result =", rev
1051
1065
                    liststore.append([ gtk.STOCK_DIRECTORY,
1052
1066
                                       True,
1069
1083
            for item in files:
1070
1084
                ts = time.time()
1071
1085
                if item.parent_id == self.remote_parent:
1072
 
                    rev = _lookup_revision(item.revision)
 
1086
                    rev = cache._lookup_revision(item.revision)
1073
1087
                    liststore.append([ gtk.STOCK_FILE,
1074
1088
                                       False,
1075
1089
                                       item.name,
1086
1100
                print "DEBUG: processed", item.name, "in", te - ts
1087
1101
            tend = time.time()
1088
1102
            print "DEBUG: filling up files =", tend - tstart
 
1103
            
 
1104
            self.image_location_error.destroy()
1089
1105
 
1090
1106
        # Columns should auto-size
1091
1107
        self.treeview_right.columns_autosize()