Import history from renamed files and folders to version control

孤街醉人 提交于 2019-12-12 04:53:15

问题


I have a client that hired me to implement version control using Mercurial, for his fifteen year old application. But also wants to have the whole history loaded to Mercurial server, but there is no version control software currently, only renamed files with the date they were changed, like program1.c to program1_20060917.c and program1 copy (1).c, and old folders with all the files (another version), like folder_20080419.

I thought of importing file by file as a change, but the count goes over 2K commits, and he doesn't want it like that.

He agrees to reconcile to group the files in changes but I couldn't find something to do it.

Maybe if I could loaded into SVN, Git or CVS, then I could convert it to Mercurial.

Does anyone knows what could be used or done? Thanks in advance.


回答1:


He agrees to reconcile to group the files in changes but I couldn't find something to do it

In any case preliminary stage of this task is only pure handwork: with only (for example) three states S1, S2, S3 without additional information it is not possible to create correct DAG - it is S1 -> S2 -> S3 or S1 -> S3 -> S2 or ...

You have to have ordered (chronologically) list of changes. Each change can be the whole folder or only file(s).

Oldest set will be first changeset in repository.

For every next changeset you have: in case or individual file(s) copy into repository, be careful with renamed separate files (when you add renamed file alongside the already existing original you'll get bad days for restoring), slices of folders are more manageable in this aspect; in case of the whole folder remove all old content of working dir (all the except .hg directory) and add new from changeset-folder

After replacement (both types) hg status -A will show you the sate of working directory with your changes (pure M will not require additional tricks, M+A probably also - consult with author, mix of A+D may be result of renames and must be handled with accuracy)

hg addremove --dry-run will try to collect (and show) changes at this changeset, compared to previous (add new, forget deleted). In case of renaming of some versioned files you have to repair this information using -s option of addremove, for simultaneous editing and renaming: picking similarity percentage (parameter of -s option) by hand for getting correct results

As result of set for hg addremove (real operations, without without --dry-run) you'll get working dir, ready to hg commit and repeating process with next changeset untill to their complete fixation

PS: SVN will not help you with renames at all (renames still are weak point of Subversion), Git is a lot worse choice, than Mercurial - in Mercurial you can handle and fix logic in case of errors for addremove -s, Git perform all blindly behind the scene (and at commit time, in case of error you'll have to fix history)



来源:https://stackoverflow.com/questions/25128363/import-history-from-renamed-files-and-folders-to-version-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!