0

Suppose I have the follow patches in my mercurial queue:

$ hg qser -v
 0 A p1
 1 A p2
 2 A p3-StupidPatch
 3 A p4
 5 A p6
 ...
15 A p15

Now suppose that I want to do is reorder the patches so that p3-Stupid patch is the last patch. IE:

$ hg qser -v
 0 A p1
 1 A p2
 2 A p4
 3 A p6
 ...
14 A p15
15 A p3-StupidPatch

I know that I could do it like this:

$ # Pop patches until p2
$ hg qpop p2
$
$ hg qser -v
 0 A p1
 1 A p2
 2 U p3-StupidPatch
 3 U p4
 5 U p6
 ...
15 U p15
$
$ # Push patches one by one
$ hg qpush --move  p4
$ hg qpush --move p5
$ hg qpush --move p6
$ hg qpush --move p7
$ hg qpush --move p8
$ hg qpush --move p9
$ hg qpush --move p10
$ hg qpush --move p11
$ hg qpush --move p12
$ hg qpush --move p13
$ hg qpush --move p14
$ hg qpush --move p15
$ hg qpush --move p3-StupidPatch

Is there a better way to do this?

sixtyfootersdude
  • 25,859
  • 43
  • 145
  • 213
  • 1
    You might consider switching to `hg ci --secret`, `hg rebase`, and `hg histedit` instead of MQ. The core developers [don't like MQ](http://gregoryszorc.com/blog/2014/06/23/please-stop-using-mq/) and are at least *thinking* about [deprecating it](http://mercurial.selenic.com/wiki/MqDeprecationPlan). – Kevin Feb 27 '15 at 16:23
  • I fully agree. However, I'd make an additional suggestion to use 'Mercurial evolution', as it means you'll be able to use these commands without any risk (the old un-rebased changesets will still exist, just hidden). – Mathiasdm Feb 27 '15 at 16:34
  • Sadly, `hg evolve` is not stable enough for me to recommend it for production use. I'd wait until it gets moved into core. – Kevin Feb 27 '15 at 16:51

2 Answers2

2

You could unapply all the patches and change the order in the file .hg/patches/series. That's where the order is really stored.

Mathiasdm
  • 1,791
  • 14
  • 26
  • This is definitely the easiest way. Make sure you pay close attention when applying them the first time after rearranging in case some hunks fail. – Edward Feb 27 '15 at 16:13
0

You can use hgtk log to reorder patches like this:

enter image description here

sixtyfootersdude
  • 25,859
  • 43
  • 145
  • 213