~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Robert Collins
  • Date: 2005-09-28 05:25:54 UTC
  • mfrom: (1185.1.42)
  • mto: (1092.2.18)
  • mto: This revision was merged to the branch mainline in revision 1397.
  • Revision ID: robertc@robertcollins.net-20050928052554-beb985505f77ea6a
update symlink branch to integration

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
 
                
 
18
import errno
 
19
import os
 
20
import tempfile
 
21
 
20
22
import bzrlib.errors
21
23
import bzrlib.progress
22
24
from bzrlib.xml import serializer_v4
 
25
from bzrlib.osutils import rename
23
26
 
24
27
 
25
28
def upgrade(branch):
106
109
                tmpfd, tmp_path = tempfile.mkstemp(prefix=rev_id, suffix='.gz',
107
110
                    dir=branch.controlfilename('revision-store'))
108
111
                os.close(tmpfd)
109
 
                def special_rename(p1, p2):
110
 
                    if sys.platform == 'win32':
111
 
                        try:
112
 
                            os.remove(p2)
113
 
                        except OSError, e:
114
 
                            if e.errno != errno.ENOENT:
115
 
                                raise
116
 
                    os.rename(p1, p2)
117
112
 
118
113
                try:
119
114
                    # TODO: We may need to handle the case where the old revision
121
116
 
122
117
                    # Remove the old revision entry out of the way
123
118
                    rev_path = branch.controlfilename(['revision-store', rev_id+'.gz'])
124
 
                    special_rename(rev_path, tmp_path)
 
119
                    rename(rev_path, tmp_path)
125
120
                    branch.revision_store.add(rev_tmp, rev_id) # Add the new one
126
121
                    os.remove(tmp_path) # Remove the old name
127
122
                    mutter('    Updated revision entry {%s}' % rev_id)
128
123
                except:
129
124
                    # On any exception, restore the old entry
130
 
                    special_rename(tmp_path, rev_path)
 
125
                    rename(tmp_path, rev_path)
131
126
                    raise
132
127
                rev_tmp.close()
133
128
                updated_revisions.append(rev_id)