/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 bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2007-08-20 05:48:40 UTC
  • mfrom: (2727 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2737.
  • Revision ID: mbp@sourcefrog.net-20070820054840-x2ugmd9dc4yodw9o
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
                                      DEPRECATED_PARAMETER,
60
60
                                      deprecated_passed,
61
61
                                      zero_eight, zero_nine, zero_sixteen,
 
62
                                      zero_ninetyone,
62
63
                                      )
63
64
from bzrlib.trace import mutter, note
64
65
 
351
352
        """Print `file` to stdout."""
352
353
        raise NotImplementedError(self.print_file)
353
354
 
354
 
    def append_revision(self, *revision_ids):
355
 
        raise NotImplementedError(self.append_revision)
356
 
 
357
355
    def set_revision_history(self, rev_history):
358
356
        raise NotImplementedError(self.set_revision_history)
359
357
 
1114
1112
 
1115
1113
 
1116
1114
class BzrBranchFormat6(BzrBranchFormat5):
1117
 
    """Branch format with last-revision
 
1115
    """Branch format with last-revision and tags.
1118
1116
 
1119
1117
    Unlike previous formats, this has no explicit revision history. Instead,
1120
1118
    this just stores the last-revision, and the left-hand history leading
1121
1119
    up to there is the history.
1122
1120
 
1123
1121
    This format was introduced in bzr 0.15
 
1122
    and became the default in 0.91.
1124
1123
    """
1125
1124
 
1126
1125
    def get_format_string(self):
1239
1238
 
1240
1239
# formats which have no format string are not discoverable
1241
1240
# and not independently creatable, so are not registered.
1242
 
__default_format = BzrBranchFormat5()
1243
 
BranchFormat.register_format(__default_format)
 
1241
__format5 = BzrBranchFormat5()
 
1242
__format6 = BzrBranchFormat6()
 
1243
BranchFormat.register_format(__format5)
1244
1244
BranchFormat.register_format(BranchReferenceFormat())
1245
 
BranchFormat.register_format(BzrBranchFormat6())
1246
 
BranchFormat.set_default_format(__default_format)
 
1245
BranchFormat.register_format(__format6)
 
1246
BranchFormat.set_default_format(__format6)
1247
1247
_legacy_formats = [BzrBranchFormat4(),
1248
1248
                   ]
1249
1249
 
1341
1341
        """See Branch.print_file."""
1342
1342
        return self.repository.print_file(file, revision_id)
1343
1343
 
1344
 
    @needs_write_lock
1345
 
    def append_revision(self, *revision_ids):
1346
 
        """See Branch.append_revision."""
1347
 
        revision_ids = [osutils.safe_revision_id(r) for r in revision_ids]
1348
 
        for revision_id in revision_ids:
1349
 
            _mod_revision.check_not_reserved_id(revision_id)
1350
 
            mutter("add {%s} to revision-history" % revision_id)
1351
 
        rev_history = self.revision_history()
1352
 
        rev_history.extend(revision_ids)
1353
 
        self.set_revision_history(rev_history)
1354
 
 
1355
1344
    def _write_revision_history(self, history):
1356
1345
        """Factored out of set_revision_history.
1357
1346
 
1372
1361
 
1373
1362
    @needs_write_lock
1374
1363
    def set_last_revision_info(self, revno, revision_id):
 
1364
        """Set the last revision of this branch.
 
1365
 
 
1366
        The caller is responsible for checking that the revno is correct
 
1367
        for this revision id.
 
1368
 
 
1369
        It may be possible to set the branch last revision to an id not
 
1370
        present in the repository.  However, branches can also be 
 
1371
        configured to check constraints on history, in which case this may not
 
1372
        be permitted.
 
1373
        """
1375
1374
        revision_id = osutils.safe_revision_id(revision_id)
1376
1375
        history = self._lefthand_history(revision_id)
1377
1376
        assert len(history) == revno, '%d != %d' % (len(history), revno)
1959
1958
        self._write_last_revision_info(len(history), last_revision)
1960
1959
 
1961
1960
    @needs_write_lock
1962
 
    def append_revision(self, *revision_ids):
1963
 
        revision_ids = [osutils.safe_revision_id(r) for r in revision_ids]
1964
 
        if len(revision_ids) == 0:
1965
 
            return
1966
 
        prev_revno, prev_revision = self.last_revision_info()
1967
 
        for revision in self.repository.get_revisions(revision_ids):
1968
 
            if prev_revision == _mod_revision.NULL_REVISION:
1969
 
                if revision.parent_ids != []:
1970
 
                    raise errors.NotLeftParentDescendant(self, prev_revision,
1971
 
                                                         revision.revision_id)
1972
 
            else:
1973
 
                if revision.parent_ids[0] != prev_revision:
1974
 
                    raise errors.NotLeftParentDescendant(self, prev_revision,
1975
 
                                                         revision.revision_id)
1976
 
            prev_revision = revision.revision_id
1977
 
        self.set_last_revision_info(prev_revno + len(revision_ids),
1978
 
                                    revision_ids[-1])
1979
 
 
1980
 
    @needs_write_lock
1981
1961
    def _set_parent_location(self, url):
1982
1962
        """Set the parent branch"""
1983
1963
        self._set_config_location('parent_location', url, make_relative=True)
2049
2029
        :param revision_id: The revision-id to truncate history at.  May
2050
2030
          be None to copy complete history.
2051
2031
        """
 
2032
        source_revno, source_revision_id = self.last_revision_info()
2052
2033
        if revision_id is None:
2053
 
            revno, revision_id = self.last_revision_info()
 
2034
            revno, revision_id = source_revno, source_revision_id
 
2035
        elif source_revision_id == revision_id:
 
2036
            # we know the revno without needing to walk all of history
 
2037
            revno = source_revno
2054
2038
        else:
2055
2039
            # To figure out the revno for a random revision, we need to build
2056
2040
            # the revision history, and count its length.