comparison hggit/git_handler.py @ 1025:e7a8a5710257

wlock: use non-context-manager form to restore older hg support
author Kevin Bullock <kbullock@ringworld.org>
date Mon, 24 Jul 2017 15:07:44 -0500
parents 078c3912afce
children fa08148bc5fc
comparison
equal deleted inserted replaced
1024:078c3912afce 1025:e7a8a5710257
195 map_hg_real[hgsha] = gitsha 195 map_hg_real[hgsha] = gitsha
196 self._map_git_real = map_git_real 196 self._map_git_real = map_git_real
197 self._map_hg_real = map_hg_real 197 self._map_hg_real = map_hg_real
198 198
199 def save_map(self, map_file): 199 def save_map(self, map_file):
200 with self.repo.wlock(): 200 wlock = self.repo.wlock()
201 try:
201 file = self.repo.vfs(map_file, 'w+', atomictemp=True) 202 file = self.repo.vfs(map_file, 'w+', atomictemp=True)
202 map_hg = self._map_hg 203 map_hg = self._map_hg
203 buf = cStringIO.StringIO() 204 buf = cStringIO.StringIO()
204 bwrite = buf.write 205 bwrite = buf.write
205 for hgsha, gitsha in map_hg.iteritems(): 206 for hgsha, gitsha in map_hg.iteritems():
206 bwrite("%s %s\n" % (gitsha, hgsha)) 207 bwrite("%s %s\n" % (gitsha, hgsha))
207 file.write(buf.getvalue()) 208 file.write(buf.getvalue())
208 buf.close() 209 buf.close()
209 # If this complains, atomictempfile no longer has close 210 # If this complains, atomictempfile no longer has close
210 file.close() 211 file.close()
212 finally:
213 wlock.release()
211 214
212 def load_tags(self): 215 def load_tags(self):
213 self.tags = {} 216 self.tags = {}
214 if os.path.exists(self.repo.vfs.join(self.tags_file)): 217 if os.path.exists(self.repo.vfs.join(self.tags_file)):
215 for line in self.repo.vfs(self.tags_file): 218 for line in self.repo.vfs(self.tags_file):