~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Martin Pool
  • Date: 2005-08-22 17:52:11 UTC
  • Revision ID: mbp@sourcefrog.net-20050822175211-90caf03af7d0cf07
- fix bug where bzr upgrade aborts when trying to fix trees that mention revisions
  which are not locally present

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
 
 
 
18
import bzrlib.errors
19
19
 
20
20
 
21
21
def upgrade(branch):
71
71
                mutter("  set inventory_sha1 on {%s}" % rev_id)
72
72
 
73
73
            for prr in rev.parents:
74
 
                actual_sha1 = branch.get_revision_sha1(prr.revision_id)
75
 
                if (updated_previous_revision
76
 
                    or prr.revision_sha1 is None):
77
 
                    if prr.revision_sha1 != actual_sha1:
78
 
                        prr.revision_sha1 = actual_sha1
79
 
                        updated = True
80
 
                elif actual_sha1 != prr.revision_sha1:
81
 
                    raise BzrCheckError("parent {%s} of {%s} sha1 mismatch: "
82
 
                                        "%s vs %s"
83
 
                                        % (prr.revision_id, rev_id,
84
 
                                           actual_sha1, prr.revision_sha1))
 
74
                try:
 
75
                    actual_sha1 = branch.get_revision_sha1(prr.revision_id)
 
76
                except bzrlib.errors.NoSuchRevision:
 
77
                    mutter("parent {%s} of {%s} not present in branch; skipped"
 
78
                           % (prr.revision_id, rev_id))
 
79
                    continue
 
80
                    
 
81
                if actual_sha1 != prr.revision_sha1:
 
82
                    mutter("parent {%s} of {%s} sha1 mismatch: "
 
83
                           "%s vs %s; fixed"
 
84
                           % (prr.revision_id, rev_id,
 
85
                              actual_sha1, prr.revision_sha1))
 
86
                    prr.revision_sha1 = actual_sha1
 
87
                    updated = True
85
88
 
86
89
            if updated:
87
90
                updated_previous_revision = True