git-svn: teach git-svn to populate svn:mergeinfo
PATCH v2 1/1 git-svn: teach git-svn to populate svn:mergeinfo
Allow git-svn to populate the svn:mergeinfo property automatically in a narrow range of circumstances. Specifically, when dcommitting a revision with multiple parents, all but (potentially) the first of which have been committed to SVN in the same repository as the target of the dcommit.
In this case, the merge info is the union of that given by each of the parents, plus all changes introduced to the first parent by the other parents.
In all other cases where a revision to be committed has multiple parents, cause "git svn dcommit" to raise an error rather than completing the commit and potentially losing history information in the upstream SVN repository.
This behavior is disabled by default, and can be enabled by setting the svn.pushmergeinfo config option.
---
This is the second revision of a patch I posted earlier. I believe this patch is now suitable for inclusion.
Significant changes from the last revision are:
- All revisions in the commit list are checked beforehand to ensure that all non-first-parents of merge commits have suitable SVN metadata attached.
- Cases where a merge commit is at the top of an uncommitted stack are tested and now work correctly.
- Cleanups as suggested by Eric Wong.
This code is still vulnerable to race conditions if the git repository is modified while a dcommit is in progress, but this is a fundamental problem with git-svn's continual-rebasing-series approach, as previously discussed.
I believe I have determined the source of the added+untracked files in the working copy. With this repository:
branch1: A - B
/
branch2: C
If a file is added in C, and you attempt to dcommit B (C must be dcommitted or the problem will be detected and the commit will abort), git-svn runs a reset --mixed. So because the files added in C were present in B, they remain present but are untracked when you reset --mixed to A. So you cannot apply B to the rebased state because it would "create" the file you already have (with, admittedly, identical contents).
I'm not clear on why git will not allow this to proceed - the file in the working copy is identical to the file that would be "created", so there's no loss of data. "file would be overwritten", yes, technically, but never altered, so no problem really... Might be a user-interface consistency issue to allow it, but I'd be inclined to say git's behavior should change.
Regardless, this could be solved by using a reset --hard to A before beginning. Since we already disallow dcommitting with a dirty WC, this should be safe (never thought I'd say that about a reset --hard). I'm not going to write that change, though.
Of course, users could also recover from even the worst disaster via the reflog.
Documentation/git-svn.txt | 8 + git-svn.perl | 255 +++++++++++++++++++++++++ t/t9160-git-svn-mergeinfo-push.sh | 104 ++++++++++ t/t9160/branches.dump | 374 +++++++++++++++++++++++++++++++++++++ 4 files changed, 741 insertions(+), 0 deletions(-) create mode 100755 t/t9160-git-svn-mergeinfo-push.sh create mode 100644 t/t9160/branches.dump
Documentation/git-svn.txt +8 -0
@@ -213,6 +213,14 @@ discouraged. store this information (as a property), and svn clients starting from version 1.5 can make use of it. 'git svn' currently does not use it and does not set it automatically. ++ +[verse] +config key: svn.pushmergeinfo ++ +This option will cause git-svn to attempt to automatically populate the +svn:mergeinfo property in the SVN repository when possible. Currently, this can +only be done when dcommitting non-fast-forward merges where all parents but the +first have already been pushed into SVN. 'branch':: Create a branch in the SVN repository.
git-svn.perl +255 -0
279 lines not on this page · raw message
t/t9160-git-svn-mergeinfo-push.sh new file +104 -0
104 lines not on this page · raw message
t/t9160/branches.dump new file +374 -0
374 lines not on this page · raw message
Signature · 1 line
1.7.6.1.5.g8ba83.dirty
Quoted 2 lines · Bryan Jacobs
This is the second revision of a patch I posted earlier. I believe this patch is now suitable for inclusion.
Some comments inline, but I can clean them up myself and push out in a bit.
Documentation/git-svn.txt discouraged. · line 215
Quoted 6 lines
Documentation/git-svn.txt +0
-0@@ -213,6 +213,14 @@ discouraged. store this information (as a property), and svn clients starting from version 1.5 can make use of it. 'git svn' currently does not use it and does not set it automatically.
I noticed this conflicts when applying due to the missing --mergeinfo= documentation. Did you intend to remove --mergeinfo entirely and replace it with this? I think some folks already depend on it (it's been around since last year).
Documentation/git-svn.txt discouraged. · line 219
Quoted 4 lines
Documentation/git-svn.txt +4
-0+ if (not defined($push_merge_info) + or $push_merge_info eq "false" + or $push_merge_info eq "no" + or $push_merge_info eq "never") {
I missed this the first time, but "||" and "!" are easier for C programmers to understand and higher in precedence (ref: perlop manpage)
Signature · 1 line
Eric Wong
Quoted 14 lines · On Fri, 9 Sep 2011 15:21:59 -0700 Eric Wong <[email protected]> wrote:
Some comments inline, but I can clean them up myself and push out in a bit.
Quoted 6 lines
Documentation/git-svn.txt +0
-0@@ -213,6 +213,14 @@ discouraged. store this information (as a property), and svn clientsstarting from version 1.5 can make use of it. 'git svn' currently does not use it and does not set it automatically.
I noticed this conflicts when applying due to the missing --mergeinfo= documentation. Did you intend to remove --mergeinfo entirely and replace it with this? I think some folks already depend on it (it's been around since last year).
No, that was me munging my patch base. Feel free to set the documentation for mergeinfo however you like, even documenting this feature if you wish. The functionality of --mergeinfo still should work with this patch, although obviously if it's provided the auto-population will be bypassed.
Quoted 9 lines
Documentation/git-svn.txt
Quoted 4 lines
Documentation/git-svn.txt +4
-0+ if (not defined($push_merge_info) + or $push_merge_info eq "false" + or $push_merge_info eq "no" + or $push_merge_info eq "never") {I missed this the first time, but "||" and "!" are easier for C programmers to understand and higher in precedence (ref: perlop manpage)
You're right, "||" and "!" are better here. TMTOWTDI is the Perl motto, no? A double-edged sword.
Thanks for the help and review. I'll let you do the cleanup and push the resulting patch when you feel it's ready (as you suggested), rather than iterating again for these small changes.
Bryan Jacobs
Quoted 3 lines · Bryan Jacobs
Thanks for the help and review. I'll let you do the cleanup and push the resulting patch when you feel it's ready (as you suggested), rather than iterating again for these small changes.
OK, it's pushed to "master" on git://bogomips.org/git-svn.git
as commit 1e5814f3def08452aef4caa703f074ba7d167867.
On a side note, if you have more changes you want to make (and have free time :) git-svn.perl would really benefit from being split into separate .pm files for ease-of-maintenance.