~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-02-02 10:16:52 UTC
  • mfrom: (2256.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070202101652-5367171684fe2eec
(robertc) Merge new Branch.last_revision_info method.

Show diffs side-by-side

added added

removed removed

Lines of Context:
225
225
        try:
226
226
            if last_revision is None:
227
227
                pb.update('get source history')
228
 
                from_history = from_branch.revision_history()
229
 
                if from_history:
230
 
                    last_revision = from_history[-1]
231
 
                else:
232
 
                    # no history in the source branch
233
 
                    last_revision = _mod_revision.NULL_REVISION
 
228
                last_revision = from_branch.last_revision_info()[1]
234
229
            return self.repository.fetch(from_branch.repository,
235
230
                                         revision_id=last_revision,
236
231
                                         pb=nested_pb)
324
319
        else:
325
320
            return None
326
321
 
 
322
    def last_revision_info(self):
 
323
        """Return information about the last revision.
 
324
 
 
325
        :return: A tuple (revno, last_revision_id).
 
326
        """
 
327
        rh = self.revision_history()
 
328
        revno = len(rh)
 
329
        if revno:
 
330
            return (revno, rh[-1])
 
331
        else:
 
332
            return (0, _mod_revision.NULL_REVISION)
 
333
 
327
334
    def missing_revisions(self, other, stop_revision=None):
328
335
        """Return a list of new revisions that would perfectly fit.
329
336
        
1246
1253
        """See Branch.pull."""
1247
1254
        source.lock_read()
1248
1255
        try:
1249
 
            old_count = len(self.revision_history())
 
1256
            old_count = self.last_revision_info()[0]
1250
1257
            try:
1251
1258
                self.update_revisions(source, stop_revision)
1252
1259
            except DivergedBranches:
1254
1261
                    raise
1255
1262
            if overwrite:
1256
1263
                self.set_revision_history(source.revision_history())
1257
 
            new_count = len(self.revision_history())
 
1264
            new_count = self.last_revision_info()[0]
1258
1265
            return new_count - old_count
1259
1266
        finally:
1260
1267
            source.unlock()