comparison mercurial/localrepo.py @ 8646:60f9e574b6eb

localrepo: use lock.release for single lock
author Simon Heimberg <simohe@besonet.ch>
date Wed, 27 May 2009 14:16:13 +0200
parents 1323dddf8078
children cb74433f9b41
comparison
equal deleted inserted replaced
8645:27638a233577 8646:60f9e574b6eb
969 if listclean: 969 if listclean:
970 clean += fixup 970 clean += fixup
971 971
972 # update dirstate for files that are actually clean 972 # update dirstate for files that are actually clean
973 if fixup: 973 if fixup:
974 wlock = None
975 try: 974 try:
975 wlock = self.wlock(False)
976 try: 976 try:
977 # updating the dirstate is optional 977 # updating the dirstate is optional
978 # so we don't wait on the lock 978 # so we don't wait on the lock
979 wlock = self.wlock(False)
980 for f in fixup: 979 for f in fixup:
981 self.dirstate.normal(f) 980 self.dirstate.normal(f)
982 except error.LockError: 981 finally:
983 pass 982 wlock.release()
984 finally: 983 except error.LockError:
985 release(wlock) 984 pass
986 985
987 if not parentworking: 986 if not parentworking:
988 mf1 = mfmatches(ctx1) 987 mf1 = mfmatches(ctx1)
989 if working: 988 if working:
990 # we are comparing working dir against non-parent 989 # we are comparing working dir against non-parent
1060 self.dirstate.forget(f) 1059 self.dirstate.forget(f)
1061 finally: 1060 finally:
1062 wlock.release() 1061 wlock.release()
1063 1062
1064 def remove(self, list, unlink=False): 1063 def remove(self, list, unlink=False):
1065 wlock = None 1064 if unlink:
1066 try: 1065 for f in list:
1067 if unlink: 1066 try:
1068 for f in list: 1067 util.unlink(self.wjoin(f))
1069 try: 1068 except OSError, inst:
1070 util.unlink(self.wjoin(f)) 1069 if inst.errno != errno.ENOENT:
1071 except OSError, inst: 1070 raise
1072 if inst.errno != errno.ENOENT: 1071 wlock = self.wlock()
1073 raise 1072 try:
1074 wlock = self.wlock()
1075 for f in list: 1073 for f in list:
1076 if unlink and os.path.exists(self.wjoin(f)): 1074 if unlink and os.path.exists(self.wjoin(f)):
1077 self.ui.warn(_("%s still exists!\n") % f) 1075 self.ui.warn(_("%s still exists!\n") % f)
1078 elif self.dirstate[f] == 'a': 1076 elif self.dirstate[f] == 'a':
1079 self.dirstate.forget(f) 1077 self.dirstate.forget(f)
1080 elif f not in self.dirstate: 1078 elif f not in self.dirstate:
1081 self.ui.warn(_("%s not tracked!\n") % f) 1079 self.ui.warn(_("%s not tracked!\n") % f)
1082 else: 1080 else:
1083 self.dirstate.remove(f) 1081 self.dirstate.remove(f)
1084 finally: 1082 finally:
1085 release(wlock) 1083 wlock.release()
1086 1084
1087 def undelete(self, list): 1085 def undelete(self, list):
1088 manifests = [self.manifest.read(self.changelog.read(p)[0]) 1086 manifests = [self.manifest.read(self.changelog.read(p)[0])
1089 for p in self.dirstate.parents() if p != nullid] 1087 for p in self.dirstate.parents() if p != nullid]
1090 wlock = self.wlock() 1088 wlock = self.wlock()