eric6/Plugins/VcsPlugins/vcsGit/GitStatusDialog.py

changeset 7785
9978016560ec
parent 7779
757334671130
child 7923
91e843545d9a
equal deleted inserted replaced
7784:3257703e10c5 7785:9978016560ec
1146 else: 1146 else:
1147 patch = self.lDiffParser.createHunkPatch(startIndex) 1147 patch = self.lDiffParser.createHunkPatch(startIndex)
1148 if patch: 1148 if patch:
1149 patchFile = self.__tmpPatchFileName() 1149 patchFile = self.__tmpPatchFileName()
1150 try: 1150 try:
1151 f = open(patchFile, "w") 1151 with open(patchFile, "w") as f:
1152 f.write(patch) 1152 f.write(patch)
1153 f.close()
1154 self.vcs.gitApply(self.dname, patchFile, cached=True, 1153 self.vcs.gitApply(self.dname, patchFile, cached=True,
1155 noDialog=True) 1154 noDialog=True)
1156 self.on_refreshButton_clicked() 1155 self.on_refreshButton_clicked()
1157 finally: 1156 finally:
1158 os.remove(patchFile) 1157 os.remove(patchFile)
1169 else: 1168 else:
1170 patch = self.rDiffParser.createHunkPatch(startIndex) 1169 patch = self.rDiffParser.createHunkPatch(startIndex)
1171 if patch: 1170 if patch:
1172 patchFile = self.__tmpPatchFileName() 1171 patchFile = self.__tmpPatchFileName()
1173 try: 1172 try:
1174 f = open(patchFile, "w") 1173 with open(patchFile, "w") as f:
1175 f.write(patch) 1174 f.write(patch)
1176 f.close()
1177 self.vcs.gitApply(self.dname, patchFile, cached=True, 1175 self.vcs.gitApply(self.dname, patchFile, cached=True,
1178 reverse=True, noDialog=True) 1176 reverse=True, noDialog=True)
1179 self.on_refreshButton_clicked() 1177 self.on_refreshButton_clicked()
1180 finally: 1178 finally:
1181 os.remove(patchFile) 1179 os.remove(patchFile)
1202 else: 1200 else:
1203 patch = self.lDiffParser.createHunkPatch(startIndex) 1201 patch = self.lDiffParser.createHunkPatch(startIndex)
1204 if patch: 1202 if patch:
1205 patchFile = self.__tmpPatchFileName() 1203 patchFile = self.__tmpPatchFileName()
1206 try: 1204 try:
1207 f = open(patchFile, "w") 1205 with open(patchFile, "w") as f:
1208 f.write(patch) 1206 f.write(patch)
1209 f.close()
1210 self.vcs.gitApply(self.dname, patchFile, reverse=True, 1207 self.vcs.gitApply(self.dname, patchFile, reverse=True,
1211 noDialog=True) 1208 noDialog=True)
1212 self.on_refreshButton_clicked() 1209 self.on_refreshButton_clicked()
1213 finally: 1210 finally:
1214 os.remove(patchFile) 1211 os.remove(patchFile)

eric ide

mercurial