git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-svn: teach find-rev to find near matches
@ 2013-01-17 22:19 John Keeping
  2013-01-18  0:49 ` Eric Wong
  0 siblings, 1 reply; 3+ messages in thread
From: John Keeping @ 2013-01-17 22:19 UTC (permalink / raw)
  To: git; +Cc: Eric Wong

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>
---
 Documentation/git-svn.txt | 10 ++++++++++
 git-svn.perl              | 12 ++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 69decb1..34d438b 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -346,6 +346,16 @@ Any other arguments are passed directly to 'git log'
 	corresponding git commit hash (this can optionally be followed by a
 	tree-ish to specify which branch should be searched).  When given a
 	tree-ish, returns the corresponding SVN revision number.
++
+--before;;
+	Don't require an exact match if given an SVN revision, instead find
+	the commit corresponding to the state of the SVN repository (on the
+	current branch) at the specified revision.
++
+--after;;
+	Don't require an exact match if given an SVN revision; if there is
+	not an exact match return the closest match searching forward in the
+	history.
 
 'set-tree'::
 	You should consider using 'dcommit' instead of this command.
diff --git a/git-svn.perl b/git-svn.perl
index bd5266c..d086694 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -114,6 +114,7 @@ my ($_stdin, $_help, $_edit,
 	$_message, $_file, $_branch_dest,
 	$_template, $_shared,
 	$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
+	$_before, $_after,
 	$_merge, $_strategy, $_preserve_merges, $_dry_run, $_local,
 	$_prefix, $_no_checkout, $_url, $_verbose,
 	$_commit_url, $_tag, $_merge_info, $_interactive);
@@ -258,7 +259,8 @@ my %cmd = (
 			} ],
 	'find-rev' => [ \&cmd_find_rev,
 	                "Translate between SVN revision numbers and tree-ish",
-			{} ],
+			{ 'before' => \$_before,
+			  'after' => \$_after } ],
 	'rebase' => [ \&cmd_rebase, "Fetch and rebase your working directory",
 			{ 'merge|m|M' => \$_merge,
 			  'verbose|v' => \$_verbose,
@@ -1191,7 +1193,13 @@ sub cmd_find_rev {
 			    "$head history\n";
 		}
 		my $desired_revision = substr($revision_or_hash, 1);
-		$result = $gs->rev_map_get($desired_revision, $uuid);
+		if ($_before) {
+			$result = $gs->find_rev_before($desired_revision, 1);
+		} elsif ($_after) {
+			$result = $gs->find_rev_after($desired_revision, 1);
+		} else {
+			$result = $gs->rev_map_get($desired_revision, $uuid);
+		}
 	} else {
 		my (undef, $rev, undef) = cmt_metadata($revision_or_hash);
 		$result = $rev;
-- 
1.8.1.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-svn: teach find-rev to find near matches
  2013-01-17 22:19 [PATCH] git-svn: teach find-rev to find near matches John Keeping
@ 2013-01-18  0:49 ` Eric Wong
  2013-01-18 23:14   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2013-01-18  0:49 UTC (permalink / raw)
  To: John Keeping; +Cc: git

John Keeping <john@keeping.me.uk> wrote:
> 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>

Thanks.
Signed-off-by: Eric Wong <normalperson@yhbt.net>

I've pushed this out to git://bogomips.org/git-svn along with a few
other things I seem to have forgotten about :x

John Keeping (1):
      git-svn: teach find-rev to find near matches

Jonathan Nieder (2):
      Git::SVN::Editor::T: pass $deletions to ->A and ->D
      git svn: do not overescape URLs (fallback case)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-svn: teach find-rev to find near matches
  2013-01-18  0:49 ` Eric Wong
@ 2013-01-18 23:14   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2013-01-18 23:14 UTC (permalink / raw)
  To: Eric Wong; +Cc: John Keeping, git

Eric Wong <normalperson@yhbt.net> writes:

> I've pushed this out to git://bogomips.org/git-svn along with a few
> other things I seem to have forgotten about :x
>
> John Keeping (1):
>       git-svn: teach find-rev to find near matches
>
> Jonathan Nieder (2):
>       Git::SVN::Editor::T: pass $deletions to ->A and ->D
>       git svn: do not overescape URLs (fallback case)

Thanks; pulled and pushed out.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-18 23:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-17 22:19 [PATCH] git-svn: teach find-rev to find near matches John Keeping
2013-01-18  0:49 ` Eric Wong
2013-01-18 23:14   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).