I've been trying to sort out how to use git-svn to push changes back to the 
Trac SVN repository from a Git clone of the mirror. We briefly discussed 
this in (1) some time back. When the Git repository is cloned the SVN 
metadata is not cloned (2), so some additional work is necessary.

I've been hoping to setup git-svn without pulling all of the history from 
SVN into a set of branches with a different prefix (e.g. svn/trunk, 
svn/1.0-stable, ...) since that is a time-consuming operation. I'd like to 
just recreate the SVN metadata in the existing "mirror" branches if 
possible (mirror/trunk, mirror/1.0-stable, ...).

The following seems to correctly initialize the repository,
git svn init --prefix=mirror/ -s 
--rewrite-root="http://trac.edgewall.org/intertrac/log:"; 
https://svn.edgewall.org/repos/trac

However, running `git svn fetch` will start to clone revisions from SVN. If 
instead, we only try to fetch the last few hundred revisions, then it 
appears to rebuild the SVN metadata for the revisions that were cloned from 
the Git repository. This is a fast operation.

The following demonstrates:

$ git branch
  0.12-stable
* 1.0-stable
  trunk

$ git remote show mirror
* remote mirror
  Fetch URL: http://svn.edgewall.org/git/trac/mirror
  Push  URL: http://svn.edgewall.org/git/trac/mirror
  HEAD branch: trunk
  Remote branches:
    0.12-stable tracked
    1.0-stable  tracked
    master      tracked
    trunk       tracked
  Local branches configured for 'git pull':
    0.12-stable merges with remote 0.12-stable
    1.0-stable  merges with remote 1.0-stable
    trunk       merges with remote trunk
  Local refs configured for 'git push':
    0.12-stable pushes to 0.12-stable (up to date)
    1.0-stable  pushes to 1.0-stable  (up to date)
    trunk       pushes to trunk       (up to date)

$ git log -n 5 --oneline
1927b4e 1.0.2dev: use `fnmatchcase` in order to to match case-sensitive in 
authz
bc3eb58 1.0.2dev: improved `trac.util.get_pkginfo()` for non-toplevel 
module and
65db46a 1.0.2dev: follow-ups to [12815], fixed for the case that allows 
specific
5777252 1.0.2dev: Disable wikitoolbar on `disabled` and `readonly` 
elements. Ref
fe498bb 1.0.2dev: improved resource description of default repository which 
the 

git svn fetch -r 12700:HEAD
Rebuilding 
.git/svn/refs/remotes/mirror/trunk/.rev_map.af82e41b-90c4-0310-8c96-b1721e28e2e2
 
...
r1 = c08bf199cd81f681f6fbd45c9ee8602791759c2e
r2 = f5617dd4bc0363402a48935fd309ace01f34fb29
r3 = d2cea1bd7f26c84aeaa3ce5989fcd8e50e8fb8d2
r4 = 8e55bfe859605f4074deccdb3da19d3c0442c3df
r5 = ca4a8390fcf541a2f2d97a5e9377ffaddf22bf84
...
r12725 = 2a2d63f4033f77e5808d06c7522d4926b09e82bf
r12726 = ad80866e51293cf3ed5af0bfcfc230c1fe433592
r12735 = f9785c652890ecfd88eb0ef876f4f08c38c33ff8
r12759 = 493e7f5b98c8319c7d3825626a2b6da9c8d3ad0c
r12766 = e517b258017d2fee8fc125bb60212eb5568b26ec
r12769 = af22c0b4273be81653c80652fc628e846a26f730
r12806 = 94aae7dbc636baeff1068a9c65cf2f6a5197b7c7
r12809 = bf5e5ca59f4bffdafcd1816bd860d33bc3280d89
r12817 = e6f915422cdd2a58ba051f7abd21e2ce52767bc0
Done rebuilding 
.git/svn/refs/remotes/mirror/0.12-stable/.rev_map.af82e41b-90c4-0310-8c96-b1721e28e2e2
    M    trac/resource.py
r12851 = b908d9fda703a4ed0f2a059347fa70f0011d8dd8 
(refs/remotes/mirror/trunk)
    M    trac/cache.py
r12852 = f8fbf5603ec1838274f52051c0b96615ed7a432c 
(refs/remotes/mirror/trunk)

$ git log -n 5 --oneline
1927b4e 1.0.2dev: use `fnmatchcase` in order to to match case-sensitive in 
authz
bc3eb58 1.0.2dev: improved `trac.util.get_pkginfo()` for non-toplevel 
module and
65db46a 1.0.2dev: follow-ups to [12815], fixed for the case that allows 
specific
5777252 1.0.2dev: Disable wikitoolbar on `disabled` and `readonly` 
elements. Ref
fe498bb 1.0.2dev: improved resource description of default repository which 
the 

$ git svn rebase
Current branch 1.0-stable is up to date.

The hashes are unchanged by the operation, which means we can pull from the 
git mirror and push to svn.

[12851] and [12852] were committed using `git svn dcommit`
http://trac.edgewall.org/changeset/12851
http://trac.edgewall.org/changeset/12852

The workflow for committing changes to SVN appears to be:

 * Rebase local tracking branch (trunk, 1.0-stable or 0.12-stable) against 
the mirror.
 * Rebase feature branch against the local tracking branch.
 * Merge changes from the feature branch into local tracking branch.
 * Push local tracking branch to the SVN.

git checkout trunk
git pull mirror trunk
git checkout feature-branch
git rebase trunk
git checkout trunk
git merge --ff-only feature-branch
git svn dcommit

I plan to add some notes to (3). I'm just posting here first in case anyone 
has feedback or a chance to try this out.

(1) http://trac.edgewall.org/ticket/11189#comment:12
(2) http://blog.tfnico.com/2010/11/git-svn-mirror-for-multiple-branches.html
(3) http://trac.edgewall.org/wiki/TracTeam/Repositories

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-dev+unsubscr...@googlegroups.com.
To post to this group, send email to trac-dev@googlegroups.com.
Visit this group at http://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.

Reply via email to