##// END OF EJS Templates
mq: introduce qpop --check...
Patrick Mezard -
r16653:73b8c255 default
parent child Browse files
Show More
@@ -1299,7 +1299,9 b' class queue(object):'
1299 wlock.release()
1299 wlock.release()
1300
1300
1301 def pop(self, repo, patch=None, force=False, update=True, all=False,
1301 def pop(self, repo, patch=None, force=False, update=True, all=False,
1302 nobackup=False):
1302 nobackup=False, check=False):
1303 if force and check:
1304 raise util.Abort(_('cannot use both --force and --check'))
1303 wlock = repo.wlock()
1305 wlock = repo.wlock()
1304 try:
1306 try:
1305 if patch:
1307 if patch:
@@ -1346,9 +1348,12 b' class queue(object):'
1346
1348
1347 tobackup = set()
1349 tobackup = set()
1348 if update:
1350 if update:
1349 m, a, r, d = self.checklocalchanges(repo, force=force)
1351 m, a, r, d = self.checklocalchanges(repo, force=force or check)
1350 if not nobackup and force:
1352 if force:
1351 tobackup.update(m + a)
1353 if not nobackup:
1354 tobackup.update(m + a)
1355 elif check:
1356 tobackup.update(m + a + r + d)
1352
1357
1353 self.applieddirty = True
1358 self.applieddirty = True
1354 end = len(self.applied)
1359 end = len(self.applied)
@@ -1379,8 +1384,10 b' class queue(object):'
1379 if d:
1384 if d:
1380 raise util.Abort(_("deletions found between repo revs"))
1385 raise util.Abort(_("deletions found between repo revs"))
1381
1386
1382 # backup local changes in --force case
1387 tobackup = set(a + m + r) & tobackup
1383 self.backup(repo, set(a + m + r) & tobackup)
1388 if check and tobackup:
1389 self.localchangesfound()
1390 self.backup(repo, tobackup)
1384
1391
1385 for f in a:
1392 for f in a:
1386 try:
1393 try:
@@ -2672,15 +2679,21 b' def push(ui, repo, patch=None, **opts):'
2672 [('a', 'all', None, _('pop all patches')),
2679 [('a', 'all', None, _('pop all patches')),
2673 ('n', 'name', '',
2680 ('n', 'name', '',
2674 _('queue name to pop (DEPRECATED)'), _('NAME')),
2681 _('queue name to pop (DEPRECATED)'), _('NAME')),
2682 ('c', 'check', None, _('tolerate non-conflicting local changes')),
2675 ('f', 'force', None, _('forget any local changes to patched files')),
2683 ('f', 'force', None, _('forget any local changes to patched files')),
2676 ('', 'no-backup', None, _('do not save backup copies of files'))],
2684 ('', 'no-backup', None, _('do not save backup copies of files'))],
2677 _('hg qpop [-a] [-f] [PATCH | INDEX]'))
2685 _('hg qpop [-a] [-f] [PATCH | INDEX]'))
2678 def pop(ui, repo, patch=None, **opts):
2686 def pop(ui, repo, patch=None, **opts):
2679 """pop the current patch off the stack
2687 """pop the current patch off the stack
2680
2688
2681 By default, pops off the top of the patch stack. If given a patch
2689 Without argument, pops off the top of the patch stack. If given a
2682 name, keeps popping off patches until the named patch is at the
2690 patch name, keeps popping off patches until the named patch is at
2683 top of the stack.
2691 the top of the stack.
2692
2693 By default, abort if the working directory contains uncommitted
2694 changes. With -c/--check, abort only if the uncommitted files
2695 overlap with patched files. With -f/--force, backup and discard
2696 changes made to such files.
2684
2697
2685 Return 0 on success.
2698 Return 0 on success.
2686 """
2699 """
@@ -2692,7 +2705,8 b' def pop(ui, repo, patch=None, **opts):'
2692 else:
2705 else:
2693 q = repo.mq
2706 q = repo.mq
2694 ret = q.pop(repo, patch, force=opts.get('force'), update=localupdate,
2707 ret = q.pop(repo, patch, force=opts.get('force'), update=localupdate,
2695 all=opts.get('all'), nobackup=opts.get('no_backup'))
2708 all=opts.get('all'), nobackup=opts.get('no_backup'),
2709 check=opts.get('check'))
2696 q.savedirty()
2710 q.savedirty()
2697 return ret
2711 return ret
2698
2712
@@ -202,6 +202,42 b' test qpop --force --no-backup'
202 $ test -f a.orig && echo 'error: backup with --no-backup'
202 $ test -f a.orig && echo 'error: backup with --no-backup'
203 [1]
203 [1]
204
204
205 test qpop --check
206
207 $ hg qpush
208 applying p1
209 now at: p1
210 $ hg qpop --check --force
211 abort: cannot use both --force and --check
212 [255]
213 $ echo a >> a
214 $ hg qpop --check
215 abort: local changes found, refresh first
216 [255]
217 $ hg revert -qa a
218 $ rm a
219 $ hg qpop --check
220 abort: local changes found, refresh first
221 [255]
222 $ hg rm -A a
223 $ hg qpop --check
224 abort: local changes found, refresh first
225 [255]
226 $ hg revert -qa a
227 $ echo b > b
228 $ hg add b
229 $ hg qpop --check
230 abort: local changes found, refresh first
231 [255]
232 $ hg forget b
233 $ echo d > d
234 $ hg add d
235 $ hg qpop --check
236 popping p1
237 patch queue now empty
238 $ hg forget d
239 $ rm d
240
205 test qpush --force and backup files
241 test qpush --force and backup files
206
242
207 $ echo a >> a
243 $ echo a >> a
General Comments 0
You need to be logged in to leave comments. Login now