~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-05-07 01:50:29 UTC
  • mfrom: (4332.2.3 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090507015029-ymynxbonvgo1qcqi
(robertc) Do not trigger NoSuchRevision pulling from a stacked branch
        when the client needs content from it and the stacked-on
        branch. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
        # is expected)
72
72
        return None
73
73
 
74
 
    def recreate_search(self, repository, search_bytes):
 
74
    def recreate_search(self, repository, search_bytes, discard_excess=False):
 
75
        """Recreate a search from its serialised form.
 
76
 
 
77
        :param discard_excess: If True, and the search refers to data we don't
 
78
            have, just silently accept that fact - the verb calling
 
79
            recreate_search trusts that clients will look for missing things
 
80
            they expected and get it from elsewhere.
 
81
        """
75
82
        lines = search_bytes.split('\n')
76
83
        if lines[0] == 'ancestry-of':
77
84
            heads = lines[1:]
78
85
            search_result = graph.PendingAncestryResult(heads, repository)
79
86
            return search_result, None
80
87
        elif lines[0] == 'search':
81
 
            return self.recreate_search_from_recipe(repository, lines[1:])
 
88
            return self.recreate_search_from_recipe(repository, lines[1:],
 
89
                discard_excess=discard_excess)
82
90
        else:
83
91
            return (None, FailedSmartServerResponse(('BadSearch',)))
84
92
 
85
 
    def recreate_search_from_recipe(self, repository, lines):
 
93
    def recreate_search_from_recipe(self, repository, lines,
 
94
        discard_excess=False):
 
95
        """Recreate a specific revision search (vs a from-tip search).
 
96
 
 
97
        :param discard_excess: If True, and the search refers to data we don't
 
98
            have, just silently accept that fact - the verb calling
 
99
            recreate_search trusts that clients will look for missing things
 
100
            they expected and get it from elsewhere.
 
101
        """
86
102
        start_keys = set(lines[0].split(' '))
87
103
        exclude_keys = set(lines[1].split(' '))
88
104
        revision_count = int(lines[2])
97
113
                    break
98
114
                search.stop_searching_any(exclude_keys.intersection(next_revs))
99
115
            search_result = search.get_result()
100
 
            if search_result.get_recipe()[3] != revision_count:
 
116
            if (not discard_excess and
 
117
                search_result.get_recipe()[3] != revision_count):
101
118
                # we got back a different amount of data than expected, this
102
119
                # gets reported as NoSuchRevision, because less revisions
103
120
                # indicates missing revisions, and more should never happen as
379
396
        repository = self._repository
380
397
        repository.lock_read()
381
398
        try:
382
 
            search_result, error = self.recreate_search(repository, body_bytes)
 
399
            search_result, error = self.recreate_search(repository, body_bytes,
 
400
                discard_excess=True)
383
401
            if error is not None:
384
402
                repository.unlock()
385
403
                return error