Show More
@@ -2992,18 +2992,17 b' def select(ui, repo, *args, **opts):' | |||||
2992 |
|
2992 | |||
2993 | q = repo.mq |
|
2993 | q = repo.mq | |
2994 | guards = q.active() |
|
2994 | guards = q.active() | |
|
2995 | pushable = lambda i: q.pushable(q.applied[i].name)[0] | |||
2995 | if args or opts.get('none'): |
|
2996 | if args or opts.get('none'): | |
2996 | old_unapplied = q.unapplied(repo) |
|
2997 | old_unapplied = q.unapplied(repo) | |
2997 | old_guarded = [i for i in xrange(len(q.applied)) if |
|
2998 | old_guarded = [i for i in xrange(len(q.applied)) if not pushable(i)] | |
2998 | not q.pushable(i)[0]] |
|
|||
2999 | q.setactive(args) |
|
2999 | q.setactive(args) | |
3000 | q.savedirty() |
|
3000 | q.savedirty() | |
3001 | if not args: |
|
3001 | if not args: | |
3002 | ui.status(_('guards deactivated\n')) |
|
3002 | ui.status(_('guards deactivated\n')) | |
3003 | if not opts.get('pop') and not opts.get('reapply'): |
|
3003 | if not opts.get('pop') and not opts.get('reapply'): | |
3004 | unapplied = q.unapplied(repo) |
|
3004 | unapplied = q.unapplied(repo) | |
3005 | guarded = [i for i in xrange(len(q.applied)) |
|
3005 | guarded = [i for i in xrange(len(q.applied)) if not pushable(i)] | |
3006 | if not q.pushable(i)[0]] |
|
|||
3007 | if len(unapplied) != len(old_unapplied): |
|
3006 | if len(unapplied) != len(old_unapplied): | |
3008 | ui.status(_('number of unguarded, unapplied patches has ' |
|
3007 | ui.status(_('number of unguarded, unapplied patches has ' | |
3009 | 'changed from %d to %d\n') % |
|
3008 | 'changed from %d to %d\n') % | |
@@ -3039,18 +3038,17 b' def select(ui, repo, *args, **opts):' | |||||
3039 | ui.write(g, '\n') |
|
3038 | ui.write(g, '\n') | |
3040 | else: |
|
3039 | else: | |
3041 | ui.write(_('no active guards\n')) |
|
3040 | ui.write(_('no active guards\n')) | |
3042 |
reapply = opts.get('reapply') and q.applied and q.applied |
|
3041 | reapply = opts.get('reapply') and q.applied and q.applied[-1].name | |
3043 | popped = False |
|
3042 | popped = False | |
3044 | if opts.get('pop') or opts.get('reapply'): |
|
3043 | if opts.get('pop') or opts.get('reapply'): | |
3045 | for i in xrange(len(q.applied)): |
|
3044 | for i in xrange(len(q.applied)): | |
3046 |
|
|
3045 | if not pushable(i): | |
3047 | if not pushable: |
|
|||
3048 | ui.status(_('popping guarded patches\n')) |
|
3046 | ui.status(_('popping guarded patches\n')) | |
3049 | popped = True |
|
3047 | popped = True | |
3050 | if i == 0: |
|
3048 | if i == 0: | |
3051 | q.pop(repo, all=True) |
|
3049 | q.pop(repo, all=True) | |
3052 | else: |
|
3050 | else: | |
3053 |
q.pop(repo, |
|
3051 | q.pop(repo, q.applied[i - 1].name) | |
3054 | break |
|
3052 | break | |
3055 | if popped: |
|
3053 | if popped: | |
3056 | try: |
|
3054 | try: |
@@ -256,14 +256,21 b' should push b.patch' | |||||
256 | $ hg qpush -a |
|
256 | $ hg qpush -a | |
257 | applying c.patch |
|
257 | applying c.patch | |
258 | now at: c.patch |
|
258 | now at: c.patch | |
259 | $ hg qselect -n --reapply |
|
259 | $ hg qselect -n --reapply -v | |
260 | guards deactivated |
|
260 | guards deactivated | |
261 | popping guarded patches |
|
261 | popping guarded patches | |
262 | popping c.patch |
|
262 | popping c.patch | |
263 | popping b.patch |
|
263 | popping b.patch | |
264 | patch queue now empty |
|
264 | patch queue now empty | |
265 | reapplying unguarded patches |
|
265 | reapplying unguarded patches | |
|
266 | skipping a.patch - guarded by '+1' '+2' | |||
|
267 | skipping b.patch - guarded by '+2' | |||
|
268 | skipping a.patch - guarded by '+1' '+2' | |||
|
269 | skipping b.patch - guarded by '+2' | |||
266 | applying c.patch |
|
270 | applying c.patch | |
|
271 | patching file c | |||
|
272 | adding c | |||
|
273 | c | |||
267 | now at: c.patch |
|
274 | now at: c.patch | |
268 |
|
275 | |||
269 | guards in series file: +1 +2 -3 |
|
276 | guards in series file: +1 +2 -3 | |
@@ -388,7 +395,6 b' new.patch, b.patch: Guarded. c.patch: Ap' | |||||
388 | 3 G d.patch |
|
395 | 3 G d.patch | |
389 | $ hg qselect 2 |
|
396 | $ hg qselect 2 | |
390 | number of unguarded, unapplied patches has changed from 0 to 1 |
|
397 | number of unguarded, unapplied patches has changed from 0 to 1 | |
391 | number of guarded, applied patches has changed from 1 to 0 |
|
|||
392 | $ qappunappv |
|
398 | $ qappunappv | |
393 | % hg qapplied |
|
399 | % hg qapplied | |
394 | new.patch |
|
400 | new.patch | |
@@ -507,3 +513,78 b' excercise corner cases in "qselect --rea' | |||||
507 | 0 G new.patch |
|
513 | 0 G new.patch | |
508 | 1 A c.patch |
|
514 | 1 A c.patch | |
509 | 2 A d.patch |
|
515 | 2 A d.patch | |
|
516 | ||||
|
517 | test that qselect shows "number of guarded, applied patches" correctly | |||
|
518 | ||||
|
519 | $ hg qimport -q -e b.patch | |||
|
520 | adding b.patch to series file | |||
|
521 | $ hg qguard -- b.patch -not-b | |||
|
522 | $ hg qpop -a -q | |||
|
523 | patch queue now empty | |||
|
524 | $ hg qunapplied -v | |||
|
525 | 0 G new.patch | |||
|
526 | 1 U c.patch | |||
|
527 | 2 U d.patch | |||
|
528 | 3 U b.patch | |||
|
529 | $ hg qselect not-new not-c | |||
|
530 | number of unguarded, unapplied patches has changed from 3 to 2 | |||
|
531 | $ hg qpush -q -a | |||
|
532 | patch d.patch is empty | |||
|
533 | now at: b.patch | |||
|
534 | ||||
|
535 | $ hg qapplied -v | |||
|
536 | 0 G new.patch | |||
|
537 | 1 G c.patch | |||
|
538 | 2 A d.patch | |||
|
539 | 3 A b.patch | |||
|
540 | $ hg qselect --none | |||
|
541 | guards deactivated | |||
|
542 | $ hg qselect not-new not-c not-d | |||
|
543 | number of guarded, applied patches has changed from 0 to 1 | |||
|
544 | ||||
|
545 | test that "qselect --reapply" reapplies patches successfully when the | |||
|
546 | already applied patch becomes unguarded and it follows the already | |||
|
547 | guarded (= not yet applied) one. | |||
|
548 | ||||
|
549 | $ hg qpop -q -a | |||
|
550 | patch queue now empty | |||
|
551 | $ hg qselect not-new not-c | |||
|
552 | number of unguarded, unapplied patches has changed from 1 to 2 | |||
|
553 | $ hg qpush -q -a | |||
|
554 | patch d.patch is empty | |||
|
555 | now at: b.patch | |||
|
556 | $ hg qapplied -v | |||
|
557 | 0 G new.patch | |||
|
558 | 1 G c.patch | |||
|
559 | 2 A d.patch | |||
|
560 | 3 A b.patch | |||
|
561 | $ hg qselect -q --reapply not-c not-b | |||
|
562 | now at: d.patch | |||
|
563 | cannot push 'b.patch' - guarded by '-not-b' | |||
|
564 | $ hg qseries -v | |||
|
565 | 0 U new.patch | |||
|
566 | 1 G c.patch | |||
|
567 | 2 A d.patch | |||
|
568 | 3 G b.patch | |||
|
569 | ||||
|
570 | test that "qselect --reapply" checks applied patches correctly when no | |||
|
571 | applied patche becomes guarded but some of unapplied ones become | |||
|
572 | unguarded. | |||
|
573 | ||||
|
574 | $ hg qpop -q -a | |||
|
575 | patch queue now empty | |||
|
576 | $ hg qselect not-new not-c not-d | |||
|
577 | number of unguarded, unapplied patches has changed from 2 to 1 | |||
|
578 | $ hg qpush -q -a | |||
|
579 | now at: b.patch | |||
|
580 | $ hg qapplied -v | |||
|
581 | 0 G new.patch | |||
|
582 | 1 G c.patch | |||
|
583 | 2 G d.patch | |||
|
584 | 3 A b.patch | |||
|
585 | $ hg qselect -q --reapply not-new not-c | |||
|
586 | $ hg qseries -v | |||
|
587 | 0 G new.patch | |||
|
588 | 1 G c.patch | |||
|
589 | 2 U d.patch | |||
|
590 | 3 A b.patch |
@@ -131,8 +131,12 b' try to push and pop while a is guarded' | |||||
131 | now at: c |
|
131 | now at: c | |
132 |
|
132 | |||
133 | now try it when a is unguarded, and we're at the top of the queue |
|
133 | now try it when a is unguarded, and we're at the top of the queue | |
|
134 | ||||
|
135 | $ hg qapplied -v | |||
|
136 | 0 G a | |||
|
137 | 1 A b | |||
|
138 | 2 A c | |||
134 | $ hg qsel block |
|
139 | $ hg qsel block | |
135 | number of guarded, applied patches has changed from 1 to 0 |
|
|||
136 | $ hg qpush b |
|
140 | $ hg qpush b | |
137 | abort: cannot push to a previous patch: b |
|
141 | abort: cannot push to a previous patch: b | |
138 | [255] |
|
142 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now