Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 package 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.

like image 212
Nick Pierpoint Avatar asked Nov 11 '10 15:11

Nick Pierpoint


1 Answers

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 .hgrcfile by adding:

[diff]
    git=1
like image 56
Peer Stritzinger Avatar answered Nov 03 '22 10:11

Peer Stritzinger