2009-02-25 75 views

回答

11

你可以用MQ(水銀隊列)輕鬆地做到這一點:

設置了錯誤的日期回購

+ hg init 
+ echo line 
+ hg commit -A -d 12/1 -m first 
adding file 
+ echo line 
+ hg commit -A -d 12/2 -m second 
+ echo line 
+ hg commit -A -d 12/3 -m third 
+ hg log 
changeset: 2:81c88de729a8 
tag:   tip 
user:  Ry4an Brase <[email protected]> 
date:  Thu Dec 03 00:00:00 2009 -0600 
summary:  third 

changeset: 1:c1fe70008824 
user:  Ry4an Brase <[email protected]> 
date:  Wed Dec 02 00:00:00 2009 -0600 
summary:  second 

changeset: 0:abb97adaa541 
user:  Ry4an Brase <[email protected]> 
date:  Tue Dec 01 00:00:00 2009 -0600 
summary:  first 

打開的變更到補丁隊列

+ hg qimport -r 2 
+ hg qimport -r 1 
+ hg qimport -r 0 

使每個依次修補qtip並修復日期

+ hg qrefresh -D 
+ hg qpop 
Now at: 1.diff 
+ hg qrefresh -D 
+ hg qpop 
Now at: 0.diff 
+ hg qrefresh -D 

重新應用補丁

+ hg qpush 
applying 1.diff 
Now at: 1.diff 
+ hg qpush 
applying 2.diff 
Now at: 2.diff 

打開每個補丁回到現實的變更

+ hg qdel -r 0 
+ hg qdel -r 1 
+ hg qdel -r 2 

要好:

+ hg log 
changeset: 2:6b51e14aadfc 
tag:   tip 
user:  Ry4an Brase <[email protected]> 
date:  Wed Feb 25 22:29:01 2009 -0600 
summary:  third 

changeset: 1:5cbb9fc51bcc 
user:  Ry4an Brase <[email protected]> 
date:  Wed Feb 25 22:29:02 2009 -0600 
summary:  second 

changeset: 0:ec58d1f24278 
user:  Ry4an Brase <[email protected]> 
date:  Wed Feb 25 22:29:02 2009 -0600 
summary:  first 
10

還有​​標誌爲hg commit,這是你如何覆蓋提交時間。問題在於如何在沒有工具太多痛苦的情況下重新承諾早期的更改

讓我們假設你得到本地提交下列病史:

dir1> hg commit # r100, OK 
dir1> hg commit # r101, need to fix time 
dir1> hg commit # r102, need to fix time 

這裏是我的解決方案:

hg diff -r100:101 > 101.diff 
hg diff -r101:102 > 102.diff 
cd .. 
hg clone -r100 dir1 dir2 # create a copy just before changesets than needs to be fixed 
cd dir2 
patch -i ../dir1/101.diff 
hg commit -m "Same commit message" --date="required date" 
patch -i ../dir1/102.diff 
hg commit -m "Same commit message" --date="required date" 
cd .. 
rm -rf dir1 && mv dir2 dir1 # replace working copy 

您可以自動與hg patch補丁的應用程序,我沒有在我的實踐中使用且。

+0

一個簡單而乾淨的方式。謝謝! – 2009-02-26 12:09:56

+3

您可以使用「hg strip」刪除有問題的修訂而不是克隆。 – skypher 2009-03-01 13:25:10

8

如果它只是一個單一的承諾,這承諾是最近一個(無論你在哪一個分支上),這樣做的快速單線是:

hg commit --amend -d now