##// END OF EJS Templates
mq: allow to qpop/push with a dirty working copy (issue2780)...
Idan Kamara -
r14256:d04ba50e default
parent child Browse files
Show More
@@ -844,13 +844,16 b' class queue(object):'
844 inclsubs.append(s)
844 inclsubs.append(s)
845 return inclsubs
845 return inclsubs
846
846
847 def localchangesfound(self, refresh=True):
848 if refresh:
849 raise util.Abort(_("local changes found, refresh first"))
850 else:
851 raise util.Abort(_("local changes found"))
852
847 def check_localchanges(self, repo, force=False, refresh=True):
853 def check_localchanges(self, repo, force=False, refresh=True):
848 m, a, r, d = repo.status()[:4]
854 m, a, r, d = repo.status()[:4]
849 if (m or a or r or d) and not force:
855 if (m or a or r or d) and not force:
850 if refresh:
856 self.localchangesfound(refresh)
851 raise util.Abort(_("local changes found, refresh first"))
852 else:
853 raise util.Abort(_("local changes found"))
854 return m, a, r, d
857 return m, a, r, d
855
858
856 _reserved = ('series', 'status', 'guards', '.', '..')
859 _reserved = ('series', 'status', 'guards', '.', '..')
@@ -1127,8 +1130,6 b' class queue(object):'
1127 if start == len(self.series):
1130 if start == len(self.series):
1128 self.ui.warn(_('patch series already fully applied\n'))
1131 self.ui.warn(_('patch series already fully applied\n'))
1129 return 1
1132 return 1
1130 if not force:
1131 self.check_localchanges(repo, refresh=self.applied)
1132
1133
1133 if exact:
1134 if exact:
1134 if move:
1135 if move:
@@ -1167,6 +1168,19 b' class queue(object):'
1167 end = self.series.index(patch, start) + 1
1168 end = self.series.index(patch, start) + 1
1168
1169
1169 s = self.series[start:end]
1170 s = self.series[start:end]
1171
1172 if not force:
1173 mm, aa, rr, dd = repo.status()[:4]
1174 wcfiles = set(mm + aa + rr + dd)
1175 if wcfiles:
1176 for patchname in s:
1177 pf = os.path.join(self.path, patchname)
1178 patchfiles = patchmod.changedfiles(pf, strip=1)
1179 if not wcfiles.isdisjoint(patchfiles):
1180 self.localchangesfound(self.applied)
1181 elif mergeq:
1182 self.check_localchanges(refresh=self.applied)
1183
1170 all_files = set()
1184 all_files = set()
1171 try:
1185 try:
1172 if mergeq:
1186 if mergeq:
@@ -1247,9 +1261,6 b' class queue(object):'
1247 break
1261 break
1248 update = needupdate
1262 update = needupdate
1249
1263
1250 if not force and update:
1251 self.check_localchanges(repo)
1252
1253 self.applied_dirty = 1
1264 self.applied_dirty = 1
1254 end = len(self.applied)
1265 end = len(self.applied)
1255 rev = self.applied[start].node
1266 rev = self.applied[start].node
@@ -1272,6 +1283,12 b' class queue(object):'
1272 qp = self.qparents(repo, rev)
1283 qp = self.qparents(repo, rev)
1273 ctx = repo[qp]
1284 ctx = repo[qp]
1274 m, a, r, d = repo.status(qp, top)[:4]
1285 m, a, r, d = repo.status(qp, top)[:4]
1286 parentfiles = set(m + a + r + d)
1287 if not force and parentfiles:
1288 mm, aa, rr, dd = repo.status()[:4]
1289 wcfiles = set(mm + aa + rr + dd)
1290 if not wcfiles.isdisjoint(parentfiles):
1291 self.localchangesfound()
1275 if d:
1292 if d:
1276 raise util.Abort(_("deletions found between repo revs"))
1293 raise util.Abort(_("deletions found between repo revs"))
1277 for f in a:
1294 for f in a:
@@ -163,8 +163,12 b' qpush --exact --force with changes to an'
163 $ hg update 1 -q
163 $ hg update 1 -q
164 $ echo c0 >> f0
164 $ echo c0 >> f0
165 $ hg qpush -e
165 $ hg qpush -e
166 abort: local changes found
166 applying p0
167 [255]
167 now at: p0
168 $ cat f0
169 c0
170 $ hg qpop -aq
171 patch queue now empty
168 $ hg qpush -ef
172 $ hg qpush -ef
169 applying p0
173 applying p0
170 now at: p0
174 now at: p0
@@ -178,8 +182,13 b' qpush --exact --force with changes to an'
178 $ hg update 1 -q
182 $ hg update 1 -q
179 $ echo c0 >> f0
183 $ echo c0 >> f0
180 $ hg qpush -e p1
184 $ hg qpush -e p1
181 abort: local changes found
185 applying p0
182 [255]
186 applying p1
187 now at: p1
188 $ cat f0
189 c0
190 $ hg qpop -aq
191 patch queue now empty
183 $ hg qpush -e p1 -f
192 $ hg qpush -e p1 -f
184 applying p0
193 applying p0
185 applying p1
194 applying p1
@@ -1259,6 +1259,47 b' Issue1033: test applying on an empty fil'
1259 now at: changea
1259 now at: changea
1260 $ cd ..
1260 $ cd ..
1261
1261
1262 test qpop with local changes, issue2780
1263
1264 $ hg init forcepop
1265 $ cd forcepop
1266 $ echo 1 > 1
1267 $ hg ci -Am 1
1268 adding 1
1269 $ hg qnew foo
1270 $ echo 2 > 2
1271 $ hg add
1272 adding 2
1273
1274 unrelated changes
1275
1276 $ hg qpop
1277 popping foo
1278 patch queue now empty
1279
1280 related changes
1281
1282 $ hg forget 2
1283 $ rm 2
1284 $ hg qpush
1285 applying foo
1286 patch foo is empty
1287 now at: foo
1288 $ echo 2 >> 1
1289 $ hg qrefresh
1290 $ echo 2 >> 1
1291 $ hg qpop
1292 abort: local changes found, refresh first
1293 [255]
1294 $ hg st
1295 M 1
1296
1297 related changes with force
1298 $ hg qpop --force
1299 popping foo
1300 patch queue now empty
1301 $ hg st
1302 $ cd ..
1262
1303
1263 test qpush with --force, issue1087
1304 test qpush with --force, issue1087
1264
1305
@@ -1276,16 +1317,9 b' test qpush with --force, issue1087'
1276 $ echo world >> hello.txt
1317 $ echo world >> hello.txt
1277
1318
1278
1319
1279 qpush should fail, local changes
1320 apply, should not discard changes with empty patch
1280
1321
1281 $ hg qpush
1322 $ hg qpush
1282 abort: local changes found
1283 [255]
1284
1285
1286 apply force, should not discard changes with empty patch
1287
1288 $ hg qpush -f
1289 applying empty
1323 applying empty
1290 patch empty is empty
1324 patch empty is empty
1291 now at: empty
1325 now at: empty
General Comments 0
You need to be logged in to leave comments. Login now