move changes to branch retroactively?

Neal Becker ndbecker2 at gmail.com
Thu Jan 8 20:04:11 UTC 2015


Harvey Chapman wrote:

>> On Jan 8, 2015, at 1:20 PM, Neal Becker <ndbecker2 at gmail.com> wrote:
>> 
>> It's gotten a little more complicated.
>> 
>> Here's what I have:
>> 
>> 1115 - 1116 - 1117 - 1118 - 1119
>> where 1119 is the new branch commit
>> 
>> 1118 is a couple of changes I forgot to commit, but should be independent of
>> other changes (1118 only changes files not touched by 1116+1117)
>> 
>> So 1116+1117 are the changes I want to get off the default, and put on their
>> own branch.
>> 
>> Here's what I want:
>> 
>> 1115 - 1118 < default
>>     - 1119 - 1116 - 1117 < new branch
>> 
>> or even better:
>> 
>> 1115 - 1118 < default
>>     - 1119 - 1116 - 1117 - 1118 < new branch
>> 
>> Now as I understand, graft _copies_ changes, not moves them, correct?
> 
> I created the following repo to mimic yours:
> 
> hg init neal
> cd neal
> for i in `seq 0 18`; do echo $i; touch $i; hg commit -Am $i; done
> hg branch new_branch
> hg commit -m "new_branch"
> 
> hg log --limit 5 --graph --template '{rev}: \"{desc}\" {branch} {tags}'
> 
> @  19: "new_branch" new_branch tip
> |
> o  18: "18" default
> |
> o  17: "17" default
> |
> o  16: "16" default
> |
> o  15: "15" default
> |
> 
> Here are some commands to end up with the graph below:
> 
> hg update 15
> hg strip 19
> hg rebase -s 18 -d .
> hg branch new_branch
> hg commit -m "new_branch"
> hg rebase -s 16
> 
> hg log --limit 5 --graph --template '{rev}: \"{desc}\" {branch} {tags}'
> 
> o  19: "17" new_branch tip
> |
> o  18: "16" new_branch
> |
> @  17: "new_branch" new_branch
> |
> | o  16: "18" default
> |/
> o  15: "15" default
> |
> 
> If you really want “18” at the tip of new_branch, just graft it:
> 
> hg update new_branch
> hg graft 16		# <<< NOTE! After rebasing above, “18” is now 16. Use 
hashes or
> be careful.
> 
> hg log --limit 6 --graph --template '{rev}: \"{desc}\" {branch} {tags}'
> 
> @  20: "18" new_branch tip
> |
> o  19: "17" new_branch
> |
> o  18: "16" new_branch
> |
> o  17: "new_branch" new_branch
> |
> | o  16: "18" default
> |/
> o  15: "15" default
> |
> 
> Although, if 18 really is independent of both 16 and 17, why not branch from
> there? So, starting over from the beginning:
> 
> hg update 15
> hg strip 19
> hg rebase -s 18 -d .
> hg update 18               # <<< Branch from 18
> hg branch new_branch
> hg commit -m "new_branch"
> hg rebase -s 16
> 
> hg log --limit 5 --graph --template '{rev}: \"{desc}\" {branch} {tags}'
> 
> o  19: "17" new_branch tip
> |
> o  18: "16" new_branch
> |
> @  17: "new_branch" new_branch
> |
> o  16: "18" default
> |
> o  15: "15" default
> |

Thanks!  Perfect.




More information about the Mercurial mailing list