1155 if i + off < len(self.series): |
1155 if i + off < len(self.series): |
1156 return self.series[i + off] |
1156 return self.series[i + off] |
1157 raise util.Abort(_("patch %s not in series") % patch) |
1157 raise util.Abort(_("patch %s not in series") % patch) |
1158 |
1158 |
1159 def push(self, repo, patch=None, force=False, list=False, |
1159 def push(self, repo, patch=None, force=False, list=False, |
1160 mergeq=None, all=False, move=False, exact=False): |
1160 mergeq=None, all=False, move=False, exact=False, nobackup=False): |
1161 diffopts = self.diffopts() |
1161 diffopts = self.diffopts() |
1162 wlock = repo.wlock() |
1162 wlock = repo.wlock() |
1163 try: |
1163 try: |
1164 heads = [] |
1164 heads = [] |
1165 for b, ls in repo.branchmap().iteritems(): |
1165 for b, ls in repo.branchmap().iteritems(): |
1255 end = start + 1 |
1255 end = start + 1 |
1256 else: |
1256 else: |
1257 end = self.series.index(patch, start) + 1 |
1257 end = self.series.index(patch, start) + 1 |
1258 |
1258 |
1259 tobackup = set() |
1259 tobackup = set() |
1260 if force: |
1260 if not nobackup and force: |
1261 m, a, r, d = self.checklocalchanges(repo, force=True) |
1261 m, a, r, d = self.checklocalchanges(repo, force=True) |
1262 tobackup.update(m + a) |
1262 tobackup.update(m + a) |
1263 |
1263 |
1264 s = self.series[start:end] |
1264 s = self.series[start:end] |
1265 all_files = set() |
1265 all_files = set() |
1296 return ret[0] |
1296 return ret[0] |
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 wlock = repo.wlock() |
1303 wlock = repo.wlock() |
1303 try: |
1304 try: |
1304 if patch: |
1305 if patch: |
1305 # index, rev, patch |
1306 # index, rev, patch |
1306 info = self.isapplied(patch) |
1307 info = self.isapplied(patch) |
1344 update = needupdate |
1345 update = needupdate |
1345 |
1346 |
1346 tobackup = set() |
1347 tobackup = set() |
1347 if update: |
1348 if update: |
1348 m, a, r, d = self.checklocalchanges(repo, force=force) |
1349 m, a, r, d = self.checklocalchanges(repo, force=force) |
1349 tobackup.update(m + a) |
1350 if not nobackup and force: |
|
1351 tobackup.update(m + a) |
1350 |
1352 |
1351 self.applieddirty = True |
1353 self.applieddirty = True |
1352 end = len(self.applied) |
1354 end = len(self.applied) |
1353 rev = self.applied[start].node |
1355 rev = self.applied[start].node |
1354 if update: |
1356 if update: |
2494 q.savedirty() |
2496 q.savedirty() |
2495 finally: |
2497 finally: |
2496 wlock.release() |
2498 wlock.release() |
2497 |
2499 |
2498 @command("qgoto", |
2500 @command("qgoto", |
2499 [('f', 'force', None, _('overwrite any local changes'))], |
2501 [('f', 'force', None, _('overwrite any local changes')), |
|
2502 ('', 'no-backup', None, _('do not save backup copies of files'))], |
2500 _('hg qgoto [OPTION]... PATCH')) |
2503 _('hg qgoto [OPTION]... PATCH')) |
2501 def goto(ui, repo, patch, **opts): |
2504 def goto(ui, repo, patch, **opts): |
2502 '''push or pop patches until named patch is at top of stack |
2505 '''push or pop patches until named patch is at top of stack |
2503 |
2506 |
2504 Returns 0 on success.''' |
2507 Returns 0 on success.''' |
2505 q = repo.mq |
2508 q = repo.mq |
2506 patch = q.lookup(patch) |
2509 patch = q.lookup(patch) |
|
2510 nobackup = opts.get('no_backup') |
2507 if q.isapplied(patch): |
2511 if q.isapplied(patch): |
2508 ret = q.pop(repo, patch, force=opts.get('force')) |
2512 ret = q.pop(repo, patch, force=opts.get('force'), nobackup=nobackup) |
2509 else: |
2513 else: |
2510 ret = q.push(repo, patch, force=opts.get('force')) |
2514 ret = q.push(repo, patch, force=opts.get('force'), nobackup=nobackup) |
2511 q.savedirty() |
2515 q.savedirty() |
2512 return ret |
2516 return ret |
2513 |
2517 |
2514 @command("qguard", |
2518 @command("qguard", |
2515 [('l', 'list', None, _('list all patches and guards')), |
2519 [('l', 'list', None, _('list all patches and guards')), |
2632 ('l', 'list', None, _('list patch name in commit text')), |
2636 ('l', 'list', None, _('list patch name in commit text')), |
2633 ('a', 'all', None, _('apply all patches')), |
2637 ('a', 'all', None, _('apply all patches')), |
2634 ('m', 'merge', None, _('merge from another queue (DEPRECATED)')), |
2638 ('m', 'merge', None, _('merge from another queue (DEPRECATED)')), |
2635 ('n', 'name', '', |
2639 ('n', 'name', '', |
2636 _('merge queue name (DEPRECATED)'), _('NAME')), |
2640 _('merge queue name (DEPRECATED)'), _('NAME')), |
2637 ('', 'move', None, _('reorder patch series and apply only the patch'))], |
2641 ('', 'move', None, |
|
2642 _('reorder patch series and apply only the patch')), |
|
2643 ('', 'no-backup', None, _('do not save backup copies of files'))], |
2638 _('hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]')) |
2644 _('hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]')) |
2639 def push(ui, repo, patch=None, **opts): |
2645 def push(ui, repo, patch=None, **opts): |
2640 """push the next patch onto the stack |
2646 """push the next patch onto the stack |
2641 |
2647 |
2642 When -f/--force is applied, all local changes in patched files |
2648 When -f/--force is applied, all local changes in patched files |
2657 return 1 |
2663 return 1 |
2658 mergeq = queue(ui, repo.path, newpath) |
2664 mergeq = queue(ui, repo.path, newpath) |
2659 ui.warn(_("merging with queue at: %s\n") % mergeq.path) |
2665 ui.warn(_("merging with queue at: %s\n") % mergeq.path) |
2660 ret = q.push(repo, patch, force=opts.get('force'), list=opts.get('list'), |
2666 ret = q.push(repo, patch, force=opts.get('force'), list=opts.get('list'), |
2661 mergeq=mergeq, all=opts.get('all'), move=opts.get('move'), |
2667 mergeq=mergeq, all=opts.get('all'), move=opts.get('move'), |
2662 exact=opts.get('exact')) |
2668 exact=opts.get('exact'), nobackup=opts.get('no_backup')) |
2663 return ret |
2669 return ret |
2664 |
2670 |
2665 @command("^qpop", |
2671 @command("^qpop", |
2666 [('a', 'all', None, _('pop all patches')), |
2672 [('a', 'all', None, _('pop all patches')), |
2667 ('n', 'name', '', |
2673 ('n', 'name', '', |
2668 _('queue name to pop (DEPRECATED)'), _('NAME')), |
2674 _('queue name to pop (DEPRECATED)'), _('NAME')), |
2669 ('f', 'force', None, _('forget any local changes to patched files'))], |
2675 ('f', 'force', None, _('forget any local changes to patched files')), |
|
2676 ('', 'no-backup', None, _('do not save backup copies of files'))], |
2670 _('hg qpop [-a] [-f] [PATCH | INDEX]')) |
2677 _('hg qpop [-a] [-f] [PATCH | INDEX]')) |
2671 def pop(ui, repo, patch=None, **opts): |
2678 def pop(ui, repo, patch=None, **opts): |
2672 """pop the current patch off the stack |
2679 """pop the current patch off the stack |
2673 |
2680 |
2674 By default, pops off the top of the patch stack. If given a patch |
2681 By default, pops off the top of the patch stack. If given a patch |
2683 ui.warn(_('using patch queue: %s\n') % q.path) |
2690 ui.warn(_('using patch queue: %s\n') % q.path) |
2684 localupdate = False |
2691 localupdate = False |
2685 else: |
2692 else: |
2686 q = repo.mq |
2693 q = repo.mq |
2687 ret = q.pop(repo, patch, force=opts.get('force'), update=localupdate, |
2694 ret = q.pop(repo, patch, force=opts.get('force'), update=localupdate, |
2688 all=opts.get('all')) |
2695 all=opts.get('all'), nobackup=opts.get('no_backup')) |
2689 q.savedirty() |
2696 q.savedirty() |
2690 return ret |
2697 return ret |
2691 |
2698 |
2692 @command("qrename|qmv", [], _('hg qrename PATCH1 [PATCH2]')) |
2699 @command("qrename|qmv", [], _('hg qrename PATCH1 [PATCH2]')) |
2693 def rename(ui, repo, patch, name=None, **opts): |
2700 def rename(ui, repo, patch, name=None, **opts): |