~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/history.py

  • Committer: Michael Hudson
  • Date: 2008-06-18 04:26:13 UTC
  • mto: This revision was merged to the branch mainline in revision 164.
  • Revision ID: michael.hudson@canonical.com-20080618042613-ycnc9nsj7txhdby3
re-enable daemonization, remove require("TurboGears")

Show diffs side-by-side

added added

removed removed

Lines of Context:
352
352
        return revid_list[index:]
353
353
 
354
354
    @with_branch_lock
355
 
    def get_revision_history_matching(self, revid_list, text):
356
 
        self.log.debug('searching %d revisions for %r', len(revid_list), text)
357
 
        z = time.time()
358
 
        # this is going to be painfully slow. :(
359
 
        out = []
360
 
        text = text.lower()
361
 
        for revid in revid_list:
362
 
            change = self.get_changes([ revid ])[0]
363
 
            if text in change.comment.lower():
364
 
                out.append(revid)
365
 
        self.log.debug('searched %d revisions for %r in %r secs', len(revid_list), text, time.time() - z)
366
 
        return out
367
 
 
368
 
    @with_branch_lock
369
355
    def get_search_revid_list(self, query, revid_list):
370
356
        """
371
357
        given a "quick-search" query, try a few obvious possible meanings:
490
476
        else:
491
477
            revid_list = None
492
478
 
493
 
        try:
494
 
            revid_list = self.get_search_revid_list(query, revid_list)
495
 
            if len(revid_list) > 0:
496
 
                if revid not in revid_list:
497
 
                    revid = revid_list[0]
498
 
                return revid, start_revid, revid_list
499
 
        except:
500
 
            # no results
 
479
        revid_list = self.get_search_revid_list(query, revid_list)
 
480
        if revid_list and len(revid_list) > 0:
 
481
            if revid not in revid_list:
 
482
                revid = revid_list[0]
 
483
            return revid, start_revid, revid_list
 
484
        else:
501
485
            return None, None, []
502
486
 
503
487
    @with_branch_lock
519
503
            path = '/' + path
520
504
        return self._branch.repository.get_revision_inventory(revid).path2id(path)
521
505
 
522
 
 
523
506
    def get_merge_point_list(self, revid):
524
507
        """
525
508
        Return the list of revids that have merged this node.
620
603
 
621
604
        return changes
622
605
 
623
 
    # alright, let's profile this sucka. (FIXME remove this eventually...)
624
 
    def _get_changes_profiled(self, revid_list):
625
 
        from loggerhead.lsprof import profile
626
 
        import cPickle
627
 
        ret, stats = profile(self.get_changes_uncached, revid_list)
628
 
        stats.sort()
629
 
        stats.freeze()
630
 
        cPickle.dump(stats, open('lsprof.stats', 'w'), 2)
631
 
        self.log.info('lsprof complete!')
632
 
        return ret
633
 
 
634
606
    @with_branch_lock
635
607
    @with_bzrlib_read_lock
636
608
    def get_changes_uncached(self, revid_list):
 
609
        # FIXME: deprecated method in getting a null revision
637
610
        revid_list = filter(lambda revid: not bzrlib.revision.is_null(revid),
638
611
                            revid_list)
639
612
        parent_map = self._branch.repository.get_graph().get_parent_map(revid_list)