comparison hgext/mq.py @ 14732:e9ed3506f066 stable

backout of d04ba50e104d: allow to qpop/push with a dirty working copy The new behavior was breaking existing tools that relied on a sequence such as this: 1) start with a dirty working copy 2) qimport some patch 3) try to qpush it 4) old behavior would fail at this point due to outstanding changes. (new behavior would only fail if the outstanding changes and the patches changes intersect) 5) innocent user qrefreshes, gets his local changes in the imported patch It's worth considering if we can move this behavior to -f in the future.
author Idan Kamara <idankk86@gmail.com>
date Fri, 24 Jun 2011 23:25:42 +0300
parents 35c2cc322ba8
children d3bb825ddae3
comparison
equal deleted inserted replaced
14730:f5765353d430 14732:e9ed3506f066
1132 # work as it detects an error when done 1132 # work as it detects an error when done
1133 start = self.seriesend() 1133 start = self.seriesend()
1134 if start == len(self.series): 1134 if start == len(self.series):
1135 self.ui.warn(_('patch series already fully applied\n')) 1135 self.ui.warn(_('patch series already fully applied\n'))
1136 return 1 1136 return 1
1137 if not force:
1138 self.checklocalchanges(repo, refresh=self.applied)
1137 1139
1138 if exact: 1140 if exact:
1139 if move: 1141 if move:
1140 raise util.Abort(_("cannot use --exact and --move together")) 1142 raise util.Abort(_("cannot use --exact and --move together"))
1141 if self.applied: 1143 if self.applied:
1170 end = start + 1 1172 end = start + 1
1171 else: 1173 else:
1172 end = self.series.index(patch, start) + 1 1174 end = self.series.index(patch, start) + 1
1173 1175
1174 s = self.series[start:end] 1176 s = self.series[start:end]
1175
1176 if not force:
1177 mm, aa, rr, dd = repo.status()[:4]
1178 wcfiles = set(mm + aa + rr + dd)
1179 if wcfiles:
1180 for patchname in s:
1181 pf = os.path.join(self.path, patchname)
1182 patchfiles = patchmod.changedfiles(self.ui, repo, pf)
1183 if wcfiles.intersection(patchfiles):
1184 self.localchangesfound(self.applied)
1185 elif mergeq:
1186 self.checklocalchanges(refresh=self.applied)
1187
1188 all_files = set() 1177 all_files = set()
1189 try: 1178 try:
1190 if mergeq: 1179 if mergeq:
1191 ret = self.mergepatch(repo, mergeq, s, diffopts) 1180 ret = self.mergepatch(repo, mergeq, s, diffopts)
1192 else: 1181 else:
1263 if entry.node in parents: 1252 if entry.node in parents:
1264 needupdate = True 1253 needupdate = True
1265 break 1254 break
1266 update = needupdate 1255 update = needupdate
1267 1256
1257 if not force and update:
1258 self.checklocalchanges(repo)
1259
1268 self.applieddirty = 1 1260 self.applieddirty = 1
1269 end = len(self.applied) 1261 end = len(self.applied)
1270 rev = self.applied[start].node 1262 rev = self.applied[start].node
1271 if update: 1263 if update:
1272 top = self.checktoppatch(repo)[0] 1264 top = self.checktoppatch(repo)[0]
1285 # form of hg.update. 1277 # form of hg.update.
1286 if update: 1278 if update:
1287 qp = self.qparents(repo, rev) 1279 qp = self.qparents(repo, rev)
1288 ctx = repo[qp] 1280 ctx = repo[qp]
1289 m, a, r, d = repo.status(qp, top)[:4] 1281 m, a, r, d = repo.status(qp, top)[:4]
1290 parentfiles = set(m + a + r + d)
1291 if not force and parentfiles:
1292 mm, aa, rr, dd = repo.status()[:4]
1293 wcfiles = set(mm + aa + rr + dd)
1294 if wcfiles.intersection(parentfiles):
1295 self.localchangesfound()
1296 if d: 1282 if d:
1297 raise util.Abort(_("deletions found between repo revs")) 1283 raise util.Abort(_("deletions found between repo revs"))
1298 for f in a: 1284 for f in a:
1299 try: 1285 try:
1300 util.unlinkpath(repo.wjoin(f)) 1286 util.unlinkpath(repo.wjoin(f))