Mercurial > hg
comparison hgext/mq.py @ 16653:73b8c2554be8
mq: introduce qpop --check
qpop --check let you qpop with uncommitted files if they do not
intersect with files touched by the popped patches.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Sat, 12 May 2012 00:19:30 +0200 |
parents | 9d76320d8b99 |
children | 490ed8972f1b |
comparison
equal
deleted
inserted
replaced
16648:1388cc711ea7 | 16653:73b8c2554be8 |
---|---|
1297 | 1297 |
1298 finally: | 1298 finally: |
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: |
1306 # index, rev, patch | 1308 # index, rev, patch |
1307 info = self.isapplied(patch) | 1309 info = self.isapplied(patch) |
1344 break | 1346 break |
1345 update = needupdate | 1347 update = needupdate |
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) |
1355 rev = self.applied[start].node | 1360 rev = self.applied[start].node |
1356 if update: | 1361 if update: |
1377 ctx = repo[qp] | 1382 ctx = repo[qp] |
1378 m, a, r, d = repo.status(qp, top)[:4] | 1383 m, a, r, d = repo.status(qp, top)[:4] |
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: |
1387 util.unlinkpath(repo.wjoin(f)) | 1394 util.unlinkpath(repo.wjoin(f)) |
1388 except OSError, e: | 1395 except OSError, e: |
2670 | 2677 |
2671 @command("^qpop", | 2678 @command("^qpop", |
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 """ |
2687 localupdate = True | 2700 localupdate = True |
2688 if opts.get('name'): | 2701 if opts.get('name'): |
2690 ui.warn(_('using patch queue: %s\n') % q.path) | 2703 ui.warn(_('using patch queue: %s\n') % q.path) |
2691 localupdate = False | 2704 localupdate = False |
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 |
2699 @command("qrename|qmv", [], _('hg qrename PATCH1 [PATCH2]')) | 2713 @command("qrename|qmv", [], _('hg qrename PATCH1 [PATCH2]')) |
2700 def rename(ui, repo, patch, name=None, **opts): | 2714 def rename(ui, repo, patch, name=None, **opts): |