Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to import an MKS Integrity repository into git?

I need only the source tree and its history. I don't care for the requirements/issues stuff for now. I played a bit with the command line to figure out if I could get a list of change packages for the trunk and some of the dev paths. I thought it should be possible to extract a diff for every change package and use that to replay all the changes since the first commit in git. Something like this:

  1. get first commit and add it to git
  2. get next CP
  3. get diff for CP
  4. apply diff to git working dir
  5. add and commit changes to git
  6. repeat with (2.) until last CP

You could also replace change package with checkpoint (would be good enough for me).

A simpler way would be to just checkout a CP and add/commit to git. But then you would loose track of add, remove, move and rename operations.

Does anyone know how to get a unified diff from "si diff"? That would already help alot.

Any ideas?

Edit2:
Added an answer that shows how I actually did the migration...

like image 707
EricSchaefer Avatar asked Aug 21 '09 21:08

EricSchaefer


1 Answers

I cannot post the actual program I wrote, because I did not do it on my own time. However, I can post how I did it. It should be easy to redo it with any scripting language. The tool I wrote migrated only one branch at a time. I would tell it which branch I want (e.g. 1.21.1) and the starting and ending revision in the branch (e.g. 4 and 78 would migrate all revisions starting from 1.21.1.4 up to 1.21.1.78). To have all branches in one repo I would provide the .git directory to use for importing into.

  • begin loop from starting revision to ending revision
    • CURRENTREV=BRANCH.loopcounter
    • create the repo directory
    • move the .git dir into the repo directory
    • move the .gitignore file into the repo directory
    • chdir into the repo directory
    • create mks sandbox inside the repo dir via "si createsandbox -P MKS_PROJECT_PATH --yes --projectRevision=CURRENTREV
    • fetch revision description via "si viewprojecthistory --rfilter=range:CURRENTREV-CURRENTREV", capture output!
    • extract user, date, label(s), comments from previous output
    • "git add ."
    • pipe extracted info from above into "git commit -qF -" (cannot do -m if you want multiple lines like the checkpoint comment)
    • drop sandbox via "si dropsandbox --yes index.pj"
    • move .git and .gitignore to a save place (for next iteration)
    • delete all remaining files in the sandbox directory
    • move to parent dir (..)
    • delete sandbox/repo dir
  • create final git dir
  • move .git and .gitignore into final git dir
  • "git reset --hard HEAD"

Done.

MKS uses some kind of ASCII encoding for its string and git usually uses UTF-8 so watch out for problem when importing meta data into git (user names, comments, tags etc.).

For more branches do this:

  • in the git directory checkout the revision where the branch should start and create a branch ("git checkout -b NEWBRANCHNAME")
  • now move .git and .gitignore to the save place and delete the whole dir
  • now do the same thing as above

One more thing: "si" is the MKS command line tool. So you either need to specify its complete path or put its path into the search path.

like image 107
EricSchaefer Avatar answered Sep 18 '22 21:09

EricSchaefer