Compare and synchronize repositories during Svn to Git migrationBy neokrates, written on July 6, 2010 |
howto |
- neokrates
- Email: uwarov@yahoo.com
- Website: http://www.thinkplexx.com
- Join date: 05-31-09
- Posts: 20
Which frameworks do you use to test your web frontend?
- We use no test automation (92%, 12 Votes)
- Selenium (8%, 1 Votes)
- Windmill (0%, 0 Votes)
- FITnesse (0%, 0 Votes)
- WebDriver (0%, 0 Votes)
- Watir (0%, 0 Votes)
- Canoo Webtest (0%, 0 Votes)
- Sahi (0%, 0 Votes)
- Other framework (0%, 0 Votes)
Total Voters: 13
Loading ...
There are good migration tools, but nothing is flawless. During Subversion to Git migration, complete data and history consistency must be ensured.
Here is simple bash script which uses diff to do that.
Works for:
Ubuntu 9.10
Git
Eclipse ganymede or Helios
Svn
diff
xxdiff
Should also work for:
most Linux distos
any eclipse with compare capability
| 1 |
How it works
Script checks the Svn path and Git paths which correspond to it. Just run it and then see the resulting “diff” file. Script may take time, lots of it for big code lines.
Four parameters need to be configured manually. They define Svn and Git repository locations.
SVN_REMOTE=https://svn.server/path/to/your/project
SVN_REV=12123 # Subversion revision
GIT_REMOTE=[email protected]:copy-project-name/copy-repo-name.git
GIT_REV=6020a2r # Unique sha-1 hash
Remark:
GIT_REV defines git repository state for the specific repository. Many repository browsers give the shortest possible form of that string for each commit.
(Like Gitorious)
| 2 |
Script
Both git and svn clients must be installed, configured and capable to read from repos.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #!/bin/bash TIMESTAMP=$(date +"%m-%d-%y_%H-%M-%S") SVN_REMOTE=https://svn.server/path/to/your/project SVN_REV=12123 SVN_LOCAL=svn_$TIMESTAMP GIT_REMOTE=git@git.server:copy-project-name/copy-repo-name.git GIT_REV=6020a2r GIT_LOCAL=git_$TIMESTAMP DIFFERENT=different_$TIMESTAMP.diff echo ################ CHECKOUT SVN ##################### echo checkout $SVN_REMOTE in revision $SVN_REV into $SVN_LOCAL svn co $SVN_REMOTE $SVN_LOCAL -r $SVN_REV echo ################ CHECKOUT GIT ##################### echo checkout $GIT_REMOTE in revision $GIT_REV into $GIT_LOCAL git clone $GIT_REMOTE $GIT_LOCAL cd $GIT_LOCAL git checkout $GIT_REV echo ################ GENERATING DIFF ##################### cd .. diff $GIT_LOCAL $SVN_LOCAL -q -s -r -x .svn -x .git |grep -v " are identical">$DIFFERENT echo "Diff $GIT_LOCAL $SVN_LOCAL" echo "View diff results: less $DIFFERENT " |
| 3 |
Ideas
After script execution, you get output like:
checkout https://svn.server/path/to/your/project in revision 12123 into svn_07-06-10_13-08-05 ... checkout https://svn.server/path/to/your/project in revision 6040b2e into git_07-06-10_13-08-05 .... HEAD is now at 6040b2e... Blah Blah Diff git_07-06-10_13-08-05 svn_07-06-10_13-08-05 View diff results: less different_07-06-10_13-08-05.diff
The directories git_07-06-10_13-08-05 and svn_07-06-10_13-08-05 can be used to visualize the diff.
| 3.1 |
Visualize with xxdiff
sudo apt-get install xxdiff xxdiff git_07-06-10_13-08-05 svn_07-06-10_13-08-05
Remark
In xxdiff Go [ View -> Options -> Directory diff ] and add -x .svn -x .git for both Shallow command: and Recursive command:. Then check “recursive”. That will filter out both Git and Subversion sub-directories in diff command output.
| 3.2 |
Visualize with eclipse compare
Add both checked out projects as simple eclipse projects and the choose both and “compare with -> each other”.
That’s it, have fun
|
LEARN MORE (amazon bookstore)
|
|
TAGS
|
|
SOCIAL
|
|
INCOMING SEARCH TERMS
|


















