38
38
SmartServerRequest,
39
39
SuccessfulSmartServerResponse,
41
from bzrlib.repository import _strip_NULL_ghosts, network_format_registry
41
from bzrlib.repository import (
43
network_format_registry,
42
46
from bzrlib import revision as _mod_revision
43
47
from bzrlib.versionedfile import NetworkRecordStream, record_to_fulltext_bytes
284
288
return SuccessfulSmartServerResponse(('ok', ), '\n'.join(lines))
291
class SmartServerRepositoryGetRevIdForRevno(SmartServerRepositoryReadLocked):
293
def do_readlocked_repository_request(self, repository, revno,
295
"""Find the revid for a given revno, given a known revno/revid pair.
299
known_revno, known_revid = known_pair
300
history = [known_revid]
301
distance_from_known = known_revno - revno
302
# XXX: handle distance_from_known < 0, etc
304
_iter_for_revno(repository, history, stop_index=revno)
305
except errors.RevisionNotPresent, err:
306
# A stacked repository, or a left-hand ghost. Either way, even
307
# though the named revision isn't in this repo, we know it's the
308
# next step in this left-hand history. The client can probably
309
# find this revision in a fallback repository.
310
if history[-1] == err.revision_id:
311
raise AssertionError(
312
'revision_id of RevisionNotPresent err already in history '
313
'from _iter_for_revno.')
314
history.append(err.revision_id)
315
if len(history) < distance_from_known:
316
earliest_revno = known_revno - len(history)
317
return SuccessfulSmartServerResponse(
318
('history-incomplete', earliest_revno, history[-1]))
319
return SuccessfulSmartServerResponse(('ok', history[-1],))
287
322
class SmartServerRequestHasRevision(SmartServerRepositoryRequest):
289
324
def do_repository_request(self, repository, revision_id):