git-svn: teach find-rev to find near matches
When a single SVN repository is split into multiple Git repositories many SVN revisions will exist in only one of the Git repositories created. For some projects the only way to build a working artifact is to check out corresponding versions of various repositories, with no indication of what those are in the Git world - in the SVN world the revision numbers are sufficient. By adding "--before" to "git-svn find-rev" we can say "tell me what this repository looked like when that other repository looked like this": git svn find-rev --before \ r$(git --git-dir=/over/there.git svn find-rev HEAD) Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Eric Wong <normalperson@yhbt.net>
John Keeping committed
Jan 17, 2013 at 22:19 UTC
2934a484fdaf9ceea4da2e9402a2f54dcaf59fb1
2 files changed
+20
-2
Documentation/git-svn.txt
+10
@@ -346,6 +346,16 @@ Any other arguments are passed directly to 'git log'
346
corresponding git commit hash (this can optionally be followed by a
347
tree-ish to specify which branch should be searched). When given a
348
tree-ish, returns the corresponding SVN revision number.
349
++
350
+--before;;
351
+ Don't require an exact match if given an SVN revision, instead find
352
+ the commit corresponding to the state of the SVN repository (on the
353
+ current branch) at the specified revision.
354
++
355
+--after;;
356
+ Don't require an exact match if given an SVN revision; if there is
357
+ not an exact match return the closest match searching forward in the
358
+ history.
359
360
'set-tree'::
361
You should consider using 'dcommit' instead of this command.
git-svn.perl
+10
-2
@@ -114,6 +114,7 @@ my ($_stdin, $_help, $_edit,
114
$_message, $_file, $_branch_dest,
115
$_template, $_shared,
116
$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
117
+ $_before, $_after,
118
$_merge, $_strategy, $_preserve_merges, $_dry_run, $_local,
119
$_prefix, $_no_checkout, $_url, $_verbose,
120
$_commit_url, $_tag, $_merge_info, $_interactive);
@@ -258,7 +259,8 @@ my %cmd = (
259
} ],
260
'find-rev' => [ \&cmd_find_rev,
261
"Translate between SVN revision numbers and tree-ish",
261
- {} ],
262
+ { 'before' => \$_before,
263
+ 'after' => \$_after } ],
264
'rebase' => [ \&cmd_rebase, "Fetch and rebase your working directory",
265
{ 'merge|m|M' => \$_merge,
266
'verbose|v' => \$_verbose,
@@ -1191,7 +1193,13 @@ sub cmd_find_rev {
1193
"$head history\n";
1194
}
1195
my $desired_revision = substr($revision_or_hash, 1);
1194
- $result = $gs->rev_map_get($desired_revision, $uuid);
1196
+ if ($_before) {
1197
+ $result = $gs->find_rev_before($desired_revision, 1);
1198
+ } elsif ($_after) {
1199
+ $result = $gs->find_rev_after($desired_revision, 1);
1200
+ } else {
1201
+ $result = $gs->rev_map_get($desired_revision, $uuid);
1202
+ }
1203
} else {
1204
my (undef, $rev, undef) = cmt_metadata($revision_or_hash);
1205
$result = $rev;