Exemple #1
0
    def set_display_revids(self, revids, repo):
        self._display_revids = revids
        self._all_loaded_revs = {}

        revids_to_load = set(revids)
        for revid in revids:
            revids_to_load.update(set(self.get_parents(revid)))
            revids_to_load.update(set(self.get_children(revid)))

        load_revisions(list(revids_to_load),
                       repo,
                       revisions_loaded=self.revisions_loaded,
                       pass_prev_loaded_rev=True)
Exemple #2
0
    def annotate(self, annotate_tree, fileId, path):
        self.now = time.time()
        self.rev_indexes = {}
        last_revid = None
        lines = []
        annotate = []
        ordered_revids = []

        self.processEvents()
        for revid, text in annotate_tree.annotate_iter(fileId):
            if revid == CURRENT_REVISION:
                revid = CURRENT_REVISION + annotate_tree.basedir

            text = text.decode(self.encoding, 'replace')

            lines.append(text)

            text = text.rstrip()
            if revid not in self.rev_indexes:
                self.rev_indexes[revid] = []
                ordered_revids.append(revid)
            self.rev_indexes[revid].append(len(annotate))

            is_top = last_revid != revid
            last_revid = revid

            annotate.append((revid, is_top))
            if len(annotate) % 100 == 0:
                self.processEvents()
        annotate.append((None, False))  # because the view has one more line

        new_positions = None
        if self.old_lines:
            # Try keep the scroll, and selection stable.
            old_positions, lines_to_center = self.text_edit.get_positions()
            new_positions = self.translate_positions(self.old_lines, lines,
                                                     old_positions)

        self.text_edit.annotate = None
        self.text_edit.setPlainText("".join(lines))
        if new_positions:
            self.text_edit.set_positions(new_positions, lines_to_center)

        self.old_lines = lines
        self.annotate_bar.adjustWidth(len(lines), 999)
        self.annotate_bar.annotate = annotate
        self.text_edit.annotate = annotate
        self.annotate_bar.show_current_line = False

        self.text_edit.emit(QtCore.SIGNAL("documentChangeFinished()"))

        self.processEvents()

        just_loaded_log = False
        if not self.log_branch_loaded:
            self.log_branch_loaded = True
            bi = BranchInfo('', self.working_tree, self.branch)
            self.log_list.load((bi, ), bi, [self.fileId], self.no_graph,
                               logmodel.WithWorkingTreeGraphVizLoader)

            gv = self.log_list.log_model.graph_viz
            self.annotate_bar.adjustWidth(len(lines),
                                          gv.revisions[0].revno_sequence[0])

            just_loaded_log = True

            # Show the revisions the we know about from the annotate.
            filter = self.log_list.log_model.file_id_filter
            changed_revs = []
            for revid in self.rev_indexes.keys():
                rev = gv.revid_rev[revid]
                filter.filter_file_id[rev.index] = True
                changed_revs.append(rev)
            filter.filter_changed_callback(changed_revs, last_call=True)

        self.processEvents()
        highlight_document(self.text_edit, path)
        self.processEvents()
        load_revisions(ordered_revids,
                       self.branch.repository,
                       revisions_loaded=self.revisions_loaded,
                       pass_prev_loaded_rev=True)
        self.processEvents()

        if just_loaded_log:
            # Check for any other revisions we don't know about

            filter = self.log_list.log_model.file_id_filter
            revids = [
                rev.revid for rev in gv.revisions
                if rev.revid not in self.rev_indexes
            ]
            filter.load(revids)
Exemple #3
0
 def load_revisions(self, revids):
     return load_revisions(revids, self.get_repo_revids)
Exemple #4
0
 def initial_load(self):
     self.throbber.show()
     load_revisions([self.revid],
                    self.branch.repository,
                    pass_prev_loaded_rev=True,
                    revisions_loaded=self.revisions_loaded)
Exemple #5
0
    def set_search(self, str, field):
        """Set search string for specified kind of data.
        @param  str:    string to search (interpreted based on field value)
        @param  field:  kind of data to search, based on some field
            of revision metadata. Possible values:
                - message
                - index (require bzr-search plugin)
                - author
                - tag
                - bug

        Value of `str` interpreted based on field value. For index it's used
        as input value for bzr-search engine.
        For message, author, tag and bug it's used as shell pattern
        (glob pattern) to search in corresponding metadata of revisions.
        """
        self.field = field
        
        def revisions_loaded(revisions, last_call):
            revs = [self.graph_viz.revid_rev[revid]
                    for revid in revisions.iterkeys()]
            self.filter_changed_callback(revs, last_call)
        
        def before_batch_load(repo, revids):
            if self.filter_re is None:
                return True
            return False

        def wildcard2regex(wildcard):
            """Translate shel pattern to regexp."""
            return fnmatch.translate(wildcard + '*')
        
        if str is None or str == u"":
            self.filter_re = None
            self.index_matched_revids = None
            self.filter_changed_callback(None, True)
        else:
            if self.field == "index":
                from bzrlib.plugins.search import index as search_index
                self.filter_re = None
                indexes = [bi.index for bi in self.graph_viz.branches
                           if bi.index is not None]
                if not indexes:
                    self.index_matched_revids = None
                else:
                    str = str.strip()
                    query = [(query_item,) for query_item in str.split(" ")]
                    self.index_matched_revids = {}
                    for index in indexes:
                        for result in index.search(query):
                            if isinstance(result, search_index.RevisionHit):
                                self.index_matched_revids\
                                        [result.revision_key[0]] = True
                            if isinstance(result, search_index.FileTextHit):
                                self.index_matched_revids\
                                        [result.text_key[1]] = True
                            if isinstance(result, search_index.PathHit):
                                pass
            elif self.field == "tag":
                self.filter_re = None
                filter_re = re.compile(wildcard2regex(str), re.IGNORECASE)
                self.index_matched_revids = {}
                for revid in self.graph_viz.tags:
                    for t in self.graph_viz.tags[revid]:
                        if filter_re.search(t):
                            self.index_matched_revids[revid] = True
                            break
            else:
                self.filter_re = re.compile(wildcard2regex(str),
                    re.IGNORECASE)
                self.index_matched_revids = None
            
            self.filter_changed_callback(None, True)
            
            if self.filter_re is not None\
               and not self.loading_revisions:
                
                self.loading_revisions = True
                try:
                    revids = [rev.revid
                              for rev in self.graph_viz.revisions ]
                    load_revisions(revids, self.graph_viz.get_repo_revids,
                                   time_before_first_ui_update = 0,
                                   local_batch_size = 100,
                                   remote_batch_size = 10,
                                   before_batch_load = before_batch_load,
                                   revisions_loaded = revisions_loaded)
                finally:
                    self.loading_revisions = False