1482 def refresh(self, repo, pats=None, **opts): |
1482 def refresh(self, repo, pats=None, **opts): |
1483 if not self.applied: |
1483 if not self.applied: |
1484 self.ui.write(_("no patches applied\n")) |
1484 self.ui.write(_("no patches applied\n")) |
1485 return 1 |
1485 return 1 |
1486 msg = opts.get('msg', '').rstrip() |
1486 msg = opts.get('msg', '').rstrip() |
|
1487 editor = opts.get('editor') |
1487 newuser = opts.get('user') |
1488 newuser = opts.get('user') |
1488 newdate = opts.get('date') |
1489 newdate = opts.get('date') |
1489 if newdate: |
1490 if newdate: |
1490 newdate = '%d %d' % util.parsedate(newdate) |
1491 newdate = '%d %d' % util.parsedate(newdate) |
1491 wlock = repo.wlock() |
1492 wlock = repo.wlock() |
1650 raise |
1651 raise |
1651 |
1652 |
1652 try: |
1653 try: |
1653 # might be nice to attempt to roll back strip after this |
1654 # might be nice to attempt to roll back strip after this |
1654 |
1655 |
1655 if not msg: |
1656 defaultmsg = "[mq]: %s" % patchfn |
|
1657 if editor: |
|
1658 origeditor = editor |
|
1659 def desceditor(repo, ctx, subs): |
|
1660 desc = origeditor(repo, ctx, subs) |
|
1661 if desc.rstrip(): |
|
1662 ph.setmessage(desc) |
|
1663 return desc |
|
1664 return defaultmsg |
|
1665 message = msg or "\n".join(ph.message) |
|
1666 editor = desceditor |
|
1667 elif not msg: |
1656 if not ph.message: |
1668 if not ph.message: |
1657 message = "[mq]: %s\n" % patchfn |
1669 message = defaultmsg |
1658 else: |
1670 else: |
1659 message = "\n".join(ph.message) |
1671 message = "\n".join(ph.message) |
1660 else: |
1672 else: |
1661 message = msg |
1673 message = msg |
1662 ph.setmessage(msg) |
1674 ph.setmessage(msg) |
1663 |
1675 |
1664 # Ensure we create a new changeset in the same phase than |
1676 # Ensure we create a new changeset in the same phase than |
1665 # the old one. |
1677 # the old one. |
1666 n = newcommit(repo, oldphase, message, user, ph.date, |
1678 n = newcommit(repo, oldphase, message, user, ph.date, |
1667 match=match, force=True) |
1679 match=match, force=True, editor=editor) |
1668 # only write patch after a successful commit |
1680 # only write patch after a successful commit |
1669 c = [list(x) for x in refreshchanges] |
1681 c = [list(x) for x in refreshchanges] |
1670 if inclsubs: |
1682 if inclsubs: |
1671 self.putsubstate2changes(substatestate, c) |
1683 self.putsubstate2changes(substatestate, c) |
1672 chunks = patchmod.diff(repo, patchparent, |
1684 chunks = patchmod.diff(repo, patchparent, |
2476 Returns 0 on success. |
2488 Returns 0 on success. |
2477 """ |
2489 """ |
2478 q = repo.mq |
2490 q = repo.mq |
2479 message = cmdutil.logmessage(ui, opts) |
2491 message = cmdutil.logmessage(ui, opts) |
2480 if opts.get('edit'): |
2492 if opts.get('edit'): |
2481 if not q.applied: |
|
2482 ui.write(_("no patches applied\n")) |
|
2483 return 1 |
|
2484 if message: |
2493 if message: |
2485 raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) |
2494 raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) |
2486 patch = q.applied[-1].name |
2495 def editor(repo, ctx, subs): |
2487 ph = patchheader(q.join(patch), q.plainmode) |
2496 return ui.edit(ctx.description() + "\n", ctx.user()) |
2488 message = ui.edit('\n'.join(ph.message), ph.user or ui.username()) |
2497 else: |
2489 # We don't want to lose the patch message if qrefresh fails (issue2062) |
2498 editor = False |
2490 repo.savecommitmessage(message) |
|
2491 setupheaderopts(ui, opts) |
2499 setupheaderopts(ui, opts) |
2492 wlock = repo.wlock() |
2500 wlock = repo.wlock() |
2493 try: |
2501 try: |
2494 ret = q.refresh(repo, pats, msg=message, **opts) |
2502 ret = q.refresh(repo, pats, msg=message, editor=editor, **opts) |
2495 q.savedirty() |
2503 q.savedirty() |
2496 return ret |
2504 return ret |
2497 finally: |
2505 finally: |
2498 wlock.release() |
2506 wlock.release() |
2499 |
2507 |
2580 message.append('* * *') |
2588 message.append('* * *') |
2581 message.extend(msg) |
2589 message.extend(msg) |
2582 message = '\n'.join(message) |
2590 message = '\n'.join(message) |
2583 |
2591 |
2584 if opts.get('edit'): |
2592 if opts.get('edit'): |
2585 message = ui.edit(message, user or ui.username()) |
2593 def editor(repo, ctx, subs): |
2586 repo.savecommitmessage(message) |
2594 return ui.edit(ctx.description() + "\n", ctx.user()) |
|
2595 else: |
|
2596 editor = False |
2587 |
2597 |
2588 diffopts = q.patchopts(q.diffopts(), *patches) |
2598 diffopts = q.patchopts(q.diffopts(), *patches) |
2589 wlock = repo.wlock() |
2599 wlock = repo.wlock() |
2590 try: |
2600 try: |
2591 q.refresh(repo, msg=message, git=diffopts.git) |
2601 q.refresh(repo, msg=message, git=diffopts.git, editor=editor) |
2592 q.delete(repo, patches, opts) |
2602 q.delete(repo, patches, opts) |
2593 q.savedirty() |
2603 q.savedirty() |
2594 finally: |
2604 finally: |
2595 wlock.release() |
2605 wlock.release() |
2596 |
2606 |