~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/info.py

Test cases exposed a bug in missing revisions count of working tree. It
had an off-by-one error when comparing length of a list with its index
(which starts from 0). Fix is to use branch for the lookup of the revno
of working tree's last revision and substract that. This keeps revno
calculation behind branch API and makes the exception check redundant.

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
                len(remote_extra), plural(len(remote_extra)))
151
151
            print
152
152
 
153
 
    if len(history) and working.last_revision() != history[-1]:
154
 
        try:
155
 
            missing_count = len(history) - history.index(working.last_revision())
156
 
        except ValueError:
157
 
            # consider it all out of date
158
 
            missing_count = len(history)
 
153
    tree_last_id = working.last_revision()
 
154
    if len(history) and tree_last_id != history[-1]:
 
155
        tree_last_revno = branch.revision_id_to_revno(tree_last_id)
 
156
        missing_count = len(history) - tree_last_revno
159
157
        print 'Working tree is out of date: missing %d revision%s.' % (
160
158
            missing_count, plural(missing_count))
161
159
        print