~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/graph.py

Merge pt1 hooks branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1537
1537
 
1538
1538
 
1539
1539
class AbstractSearchResult(object):
 
1540
    """The result of a search, describing a set of keys.
 
1541
    
 
1542
    Search results are typically used as the 'fetch_spec' parameter when
 
1543
    fetching revisions.
 
1544
 
 
1545
    :seealso: AbstractSearch
 
1546
    """
1540
1547
 
1541
1548
    def get_recipe(self):
1542
1549
        """Return a recipe that can be used to replay this search.
1575
1582
 
1576
1583
 
1577
1584
class AbstractSearch(object):
1578
 
 
1579
 
    def get_search_result(self):
 
1585
    """A search that can be executed, producing a search result.
 
1586
 
 
1587
    :seealso: AbstractSearchResult
 
1588
    """
 
1589
 
 
1590
    def execute(self):
1580
1591
        """Construct a network-ready search result from this search description.
1581
1592
 
1582
1593
        This may take some time to search repositories, etc.
1583
1594
 
1584
 
        :return: A search result.
 
1595
        :return: A search result (an object that implements
 
1596
            AbstractSearchResult's API).
1585
1597
        """
1586
 
        raise NotImplementedError(self.get_search_result)
 
1598
        raise NotImplementedError(self.execute)
1587
1599
 
1588
1600
 
1589
1601
class SearchResult(AbstractSearchResult):
1705
1717
 
1706
1718
    def __repr__(self):
1707
1719
        if len(self.heads) > 5:
1708
 
            heads_repr = repr(list(self.heads)[:5] + ', ...]')
 
1720
            heads_repr = repr(list(self.heads)[:5])[:-1]
 
1721
            heads_repr += ', <%d more>...]' % (len(self.heads) - 5,)
1709
1722
        else:
1710
1723
            heads_repr = repr(self.heads)
1711
1724
        return '<%s heads:%s repo:%r>' % (
1813
1826
        self.from_repo = from_repo
1814
1827
        self.find_ghosts = find_ghosts
1815
1828
 
1816
 
    def get_search_result(self):
 
1829
    def execute(self):
1817
1830
        return self.to_repo.search_missing_revision_ids(
1818
1831
            self.from_repo, find_ghosts=self.find_ghosts)
1819
1832
 
1853
1866
            self.__class__.__name__, self.from_repo, self.to_repo,
1854
1867
            self.find_ghosts, reqd_revs_repr, ifp_revs_repr)
1855
1868
 
1856
 
    def get_search_result(self):
 
1869
    def execute(self):
1857
1870
        return self.to_repo.search_missing_revision_ids(
1858
1871
            self.from_repo, revision_ids=self.required_ids,
1859
1872
            if_present_ids=self.if_present_ids, find_ghosts=self.find_ghosts)