~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Martin Pool
  • Date: 2005-07-04 12:26:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050704122602-69901910521e62c3
- check command checks that all inventory-ids are the same as in the revision.

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
 
import tempfile, os, errno
19
 
                
20
 
import bzrlib.errors
21
 
import bzrlib.progress
22
 
from bzrlib.xml import serializer_v4
 
18
 
23
19
 
24
20
 
25
21
def upgrade(branch):
38
34
 
39
35
    from bzrlib.trace import mutter
40
36
    from bzrlib.errors import BzrCheckError
41
 
    import bzrlib.ui
 
37
    from bzrlib.progress import ProgressBar
42
38
 
43
39
    branch.lock_write()
44
40
 
45
 
    pb = bzrlib.ui.ui_factory.progress_bar()
46
 
 
47
41
    try:
 
42
        pb = ProgressBar(show_spinner=True)
48
43
        last_rev_id = None
49
44
 
50
45
        history = branch.revision_history()
76
71
                mutter("  set inventory_sha1 on {%s}" % rev_id)
77
72
 
78
73
            for prr in rev.parents:
79
 
                try:
80
 
                    actual_sha1 = branch.get_revision_sha1(prr.revision_id)
81
 
                except bzrlib.errors.NoSuchRevision:
82
 
                    mutter("parent {%s} of {%s} not present in branch; skipped"
83
 
                           % (prr.revision_id, rev_id))
84
 
                    continue
85
 
                    
86
 
                if actual_sha1 != prr.revision_sha1:
87
 
                    mutter("parent {%s} of {%s} sha1 mismatch: "
88
 
                           "%s vs %s; fixed"
89
 
                           % (prr.revision_id, rev_id,
90
 
                              actual_sha1, prr.revision_sha1))
91
 
                    prr.revision_sha1 = actual_sha1
92
 
                    updated = True
 
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))
93
85
 
94
86
            if updated:
95
87
                updated_previous_revision = True
99
91
                # revision entry. I'm not supremely happy about it, but
100
92
                # there should be *some* way of making old entries have
101
93
                # the full meta information.
 
94
                import tempfile, os, errno
 
95
                from bzrlib.xml import pack_xml
 
96
                
102
97
                rev_tmp = tempfile.TemporaryFile()
103
 
                serializer_v4.write_revision(rev, rev_tmp)
 
98
                pack_xml(rev, rev_tmp)
104
99
                rev_tmp.seek(0)
105
100
 
106
101
                tmpfd, tmp_path = tempfile.mkstemp(prefix=rev_id, suffix='.gz',