mercurialでコミットを並べ替える方法

昨日histeditを使って、コミットの圧縮をやってみたので、他にもやってみる。

今日はコミットを並べ替える方法を試した。あまりそういうことをしたいと思ったことないけど。


リポジトリの状態

$ hg glog --style=compact
@  1[tip]   e581cb4d1a5c   2013-08-20 17:33 +0900   brainstorm
|    add .hgignore
|
o  0   941c6df61fd2   2013-08-20 17:33 +0900   brainstorm
     add README.txt


hg histedit 0でエディタが開く

pick 941c6df61fd2 0 add README.txt
pick e581cb4d1a5c 1 add .hgignore

# Edit history between 941c6df61fd2 and e581cb4d1a5c
#
# Commands:
#  p, pick = use commit
#  e, edit = use commit, but stop for amending
#  f, fold = use commit, but fold into previous commit (combines N and N-1)
#  d, drop = remove commit from history
#  m, mess = edit message without changing commit content
#


エディタでコミットを並び替えて保存

pick e581cb4d1a5c 1 add .hgignore
pick 941c6df61fd2 0 add README.txt

# Edit history between 941c6df61fd2 and e581cb4d1a5c
#
# Commands:
#  p, pick = use commit
#  e, edit = use commit, but stop for amending
#  f, fold = use commit, but fold into previous commit (combines N and N-1)
#  d, drop = remove commit from history
#  m, mess = edit message without changing commit content
#


結果。並べ変わった。

$ hg glog --style=compact
@  1[tip]   434347dbb452   2013-08-20 17:33 +0900   brainstorm
|    add README.txt
|
o  0   dee75f45d9a6   2013-08-20 17:33 +0900   brainstorm
     add .hgignore

簡単ですね。

HisteditExtension - Mercurial