Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I export changesets from hg repository to svn repository

Tags:

git

svn

mercurial

I know there is hgsubversion extension for mercurial. But before I knew how it works, I maintain two separate repositories, one is SVN repo and one is Hg repo. I made most of my recent changes in the Hg repository and I need to "push" them to the svn repository.

The most straight forward way to do this is to get one revision from svn which is in sync with one revision from hg.

From there, I update to the next revision (from Hg), then commit it (to svn). Repeating these steps for many changesets is rather inconvenient. Are there more convenient ways to do this?

And if possible, solution that works in Windows OS.

Regards,

Afriza

like image 540
Afriza N. Arief Avatar asked Dec 05 '25 18:12

Afriza N. Arief


2 Answers

If you're talking about a linear series of changesets (no merges) you could employ a shell for loop

for therev in $(seq $(hg id -n -r .) $(hg id -n -r tip)) ; do
  hg update $therev
  svn commit -m "$(hg log --template '{desc}' -r .)"
done

That loops from the checkedout revision to the tip and commits each in turn preserving the commit message. You probably need to do something fancy arround added/removes files.

like image 131
Ry4an Brase Avatar answered Dec 08 '25 14:12

Ry4an Brase


No there are not.

You might have already seen this link. Currently interacting with svn repos is not officially supported yet. I would not write a shell script to automate this. This may yield unexpected results screw up the repos (however take a look at following workflow)

https://www.mercurial-scm.org/wiki/WorkingWithSubversion.

I currently do something similar to what you do.

  1. checkout from svn repos save it under $HOME/svnhgrepos/project1
  2. goto $HOME/svnhgrepos/project1, hg init, hg commit
  3. change $HOME/svnhgrepos/project1/.hg/hgrc to automatically update on push
  4. clone $HOME/svnhgrepos/project1 to $HOME/code/project1-clone.
  5. goto $HOME/code/project1-clone, hg qinit (mercurial queues)
  6. do all the development, commit it (just one changeset per feature/bugfix) and push it to $HOME/svnhgrepos/project1
  7. Goto $HOME/svnhgrepos/project1, and perform 'svn ci'
  8. I have not done this step in my setup. Now you may write a hg hook, to automatically peform a 'hg update' and a 'svn commit'
    
       e.g (i have not tested this)
       in $HOME/svnhgrepos/project1/.hg/hgrc   
       [hooks]
       changegroup.hg-update = hg update >&2
       changegroup.svn-commit = svn commit -m "hg log --template '{desc}' -r ."
       
    
like image 27
chinmaya Avatar answered Dec 08 '25 14:12

chinmaya