/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/repository.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
236
236
                                                      self.unlock)
237
237
 
238
238
 
 
239
class WriteGroup(object):
 
240
    """Context manager that manages a write group.
 
241
 
 
242
    Raising an exception will result in the write group being aborted.
 
243
    """
 
244
 
 
245
    def __init__(self, repository, suppress_errors=False):
 
246
        self.repository = repository
 
247
        self._suppress_errors = suppress_errors
 
248
 
 
249
    def __enter__(self):
 
250
        self.repository.start_write_group()
 
251
        return self
 
252
 
 
253
    def __exit__(self, exc_type, exc_val, exc_tb):
 
254
        if exc_type:
 
255
            self.repository.abort_write_group(self._suppress_errors)
 
256
            return False
 
257
        else:
 
258
            self.repository.commit_write_group()
 
259
 
 
260
 
239
261
######################################################################
240
262
# Repositories
241
263
 
923
945
        partial_history = [known_revid]
924
946
        distance_from_known = known_revno - revno
925
947
        if distance_from_known < 0:
926
 
            raise ValueError(
927
 
                'requested revno (%d) is later than given known revno (%d)'
928
 
                % (revno, known_revno))
 
948
            raise errors.RevnoOutOfBounds(revno, (0, known_revno))
929
949
        try:
930
950
            _iter_for_revno(
931
951
                self, partial_history, stop_index=distance_from_known)
932
952
        except errors.RevisionNotPresent as err:
933
953
            if err.revision_id == known_revid:
934
954
                # The start revision (known_revid) wasn't found.
935
 
                raise
 
955
                raise errors.NoSuchRevision(self, known_revid)
936
956
            # This is a stacked repository with no fallbacks, or a there's a
937
957
            # left-hand ghost.  Either way, even though the revision named in
938
958
            # the error isn't in this repo, we know it's the next step in this