~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2007-02-09 23:39:24 UTC
  • mto: This revision was merged to the branch mainline in revision 2294.
  • Revision ID: john@arbash-meinel.com-20070209233924-k7qbjpta67k3ry2h
Audit Branch to ensure utf8 revision ids.
Requires a small update to lockable_files to allow us to directly
write byte strings, without needing to wrap in a StringIO

Show diffs side-by-side

added added

removed removed

Lines of Context:
360
360
        """Given a revision id, return its revno"""
361
361
        if revision_id is None:
362
362
            return 0
 
363
        revision_id = osutils.safe_revision_id(revision_id)
363
364
        history = self.revision_history()
364
365
        try:
365
366
            return history.index(revision_id) + 1
545
546
        """
546
547
        new_history = self.revision_history()
547
548
        if revision_id is not None:
 
549
            revision_id = osutils.safe_revision_id(revision_id)
548
550
            try:
549
551
                new_history = new_history[:new_history.index(revision_id) + 1]
550
552
            except ValueError:
1127
1129
    @needs_write_lock
1128
1130
    def set_revision_history(self, rev_history):
1129
1131
        """See Branch.set_revision_history."""
1130
 
        self.control_files.put_utf8(
 
1132
        rev_history = [osutils.safe_revision_id(r) for r in rev_history]
 
1133
        self.control_files.put_bytes(
1131
1134
            'revision-history', '\n'.join(rev_history))
1132
1135
        transaction = self.get_transaction()
1133
1136
        history = transaction.map.find_revision_history()
1173
1176
        :param other_branch: The other branch that DivergedBranches should
1174
1177
            raise with respect to.
1175
1178
        """
 
1179
        revision_id = osutils.safe_revision_id(revision_id)
1176
1180
        # stop_revision must be a descendant of last_revision
1177
1181
        stop_graph = self.repository.get_revision_graph(revision_id)
1178
1182
        if last_rev is not None and last_rev not in stop_graph:
1201
1205
                if stop_revision is None:
1202
1206
                    # if there are no commits, we're done.
1203
1207
                    return
 
1208
            else:
 
1209
                stop_revision = osutils.safe_revision_id(stop_revision)
1204
1210
            # whats the current last revision, before we fetch [and change it
1205
1211
            # possibly]
1206
1212
            last_rev = self.last_revision()
1299
1305
                        "use bzrlib.urlutils.escape")
1300
1306
                    
1301
1307
            url = urlutils.relative_url(self.base, url)
1302
 
            self.control_files.put('parent', StringIO(url + '\n'))
 
1308
            self.control_files.put_bytes('parent', url + '\n')
1303
1309
 
1304
1310
    @deprecated_function(zero_nine)
1305
1311
    def tree_config(self):