comparison mercurial/transaction.py @ 421:43b8da7420a9

[PATCH] rename under the other OS -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [PATCH] rename under the other OS From: K Thananchayan <thananck@yahoo.com> Rename fails under windows if dest file exists. This patch add a rename method to util module that removes the dest file and retries if initial attempt fails. manifest hash: 2744d9fd1717e15133b411a269df909fa8ec0faf -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCuNzDywK+sNU5EO8RAsPBAJ9NQN3bTuJvTem5x+utGnoMkhYc0QCbBFSJ PoMP69H1UnVE6drFlnlFE0s= =pePw -----END PGP SIGNATURE-----
author mpm@selenic.com
date Tue, 21 Jun 2005 19:36:35 -0800
parents 5dcbe4d9a30c
children 688d03d6997a
comparison
equal deleted inserted replaced
420:dbe86d465e09 421:43b8da7420a9
10 # 10 #
11 # This software may be used and distributed according to the terms 11 # This software may be used and distributed according to the terms
12 # of the GNU General Public License, incorporated herein by reference. 12 # of the GNU General Public License, incorporated herein by reference.
13 13
14 import os 14 import os
15 import util
15 16
16 class transaction: 17 class transaction:
17 def __init__(self, opener, journal, after = None): 18 def __init__(self, opener, journal, after = None):
18 self.journal = None 19 self.journal = None
19 20
44 45
45 def close(self): 46 def close(self):
46 self.file.close() 47 self.file.close()
47 self.entries = [] 48 self.entries = []
48 if self.after: 49 if self.after:
49 os.rename(self.journal, self.after) 50 util.rename(self.journal, self.after)
50 else: 51 else:
51 os.unlink(self.journal) 52 os.unlink(self.journal)
52 53
53 def abort(self): 54 def abort(self):
54 if not self.entries: return 55 if not self.entries: return