Splitting files in Mercurial and retaining history on both sides
I need to split a number of files and I'm looking for options to retain the full file history in the split-off files.
Background...
I've inherited a project containing lots of Oracle PL/SQL packages with the packag开发者_如何学Goe spec and the package body all stored in a single ".sql" file. I'd prefer to have the package specification and package body in separate files.
i.e.
Starting with: myfile.sql
I'd like to split this file so that the first bit (package specification) goes in:
myfile.pks
and the last bit (package body) goes in:
myfile.pkb
I've no issues doing the separation itself, but I was wondering if anyone had any ideas how I could retain show the file history of myfile.sql
both in myfile.pks
and myfile.pkb
.
Splitting files can be modelled by hg rename
and hg copy
to retain the history:
hg copy myfile.sql myfile.pks
hg rename myfile.sql myfile.pkb
The edit the *.pks and *.pkb file to remove the half that doesn't belong there.
After the edit commit it all.
To see the copies and renames you have to use git format of diffs:
hg diff -g
Since this is very useful its often set as default in the .hgrc
file by adding:
[diff]
git=1
IDEs make it even simpler. E.g. in IntelliJ select the file and do Refactor
> Copy
.
精彩评论