* [PATCH] git-svn: Add 'find-rev' command
@ 2007-04-29 8:35 Adam Roben
2007-04-29 18:35 ` Eric Wong
0 siblings, 1 reply; 4+ messages in thread
From: Adam Roben @ 2007-04-29 8:35 UTC (permalink / raw)
To: Eric Wong; +Cc: git, Junio C Hamano, Adam Roben
This patch adds a new 'find-rev' command to git-svn that lets you easily
translate between SVN revision numbers and git tree-ish.
Signed-off-by: Adam Roben <aroben@apple.com>
---
This is an updated version of my previous patch that takes Eric and Junio's
comments into account.
Documentation/git-svn.txt | 6 ++++++
git-svn.perl | 23 +++++++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index a0d34e0..482c862 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -159,6 +159,12 @@ New features:
Any other arguments are passed directly to `git log'
--
+'find-rev'::
+ When given an SVN revision number of the form 'rN', returns the
+ 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.
+
'set-tree'::
You should consider using 'dcommit' instead of this command.
Commit specified commit or tree objects to SVN. This relies on
diff --git a/git-svn.perl b/git-svn.perl
index 7b5f8ab..30e4a41 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -141,6 +141,8 @@ my %cmd = (
'color' => \$Git::SVN::Log::color,
'pager=s' => \$Git::SVN::Log::pager,
} ],
+ 'find-rev' => [ \&cmd_find_rev, "Translate between SVN revision numbers and tree-ish",
+ { } ],
'rebase' => [ \&cmd_rebase, "Fetch and rebase your working directory",
{ 'merge|m|M' => \$_merge,
'verbose|v' => \$_verbose,
@@ -428,6 +430,27 @@ sub cmd_dcommit {
command_noisy(@finish, $gs->refname);
}
+sub cmd_find_rev {
+ my $revision_or_hash = shift;
+ my $result;
+ if ($revision_or_hash =~ /^r\d+$/) {
+ my $head = shift;
+ $head ||= 'HEAD';
+ my @refs;
+ my (undef, undef, undef, $gs) = working_head_info($head, \@refs);
+ unless ($gs) {
+ die "Unable to determine upstream SVN information from ",
+ "$head history\n";
+ }
+ my $desired_revision = substr($revision_or_hash, 1);
+ $result = $gs->rev_db_get($desired_revision);
+ } else {
+ my (undef, $rev, undef) = cmt_metadata($revision_or_hash);
+ $result = $rev;
+ }
+ print "$result\n" if $result;
+}
+
sub cmd_rebase {
command_noisy(qw/update-index --refresh/);
my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
--
1.5.2.rc0.75.g959b-dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] git-svn: Add 'find-rev' command
2007-04-29 8:35 [PATCH] git-svn: Add 'find-rev' command Adam Roben
@ 2007-04-29 18:35 ` Eric Wong
2007-04-29 20:31 ` Adam Roben
0 siblings, 1 reply; 4+ messages in thread
From: Eric Wong @ 2007-04-29 18:35 UTC (permalink / raw)
To: Adam Roben; +Cc: git, Junio C Hamano
Adam Roben <aroben@apple.com> wrote:
> This patch adds a new 'find-rev' command to git-svn that lets you easily
> translate between SVN revision numbers and git tree-ish.
Acked-by: Eric Wong <normalperson@yhbt.net>
Also, if you have time, can you get this (and 'log') to understand
revision numbers even if they're not from the working HEAD? Thanks.
> Signed-off-by: Adam Roben <aroben@apple.com>
> ---
> This is an updated version of my previous patch that takes Eric and Junio's
> comments into account.
>
> Documentation/git-svn.txt | 6 ++++++
> git-svn.perl | 23 +++++++++++++++++++++++
> 2 files changed, 29 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
> index a0d34e0..482c862 100644
> --- a/Documentation/git-svn.txt
> +++ b/Documentation/git-svn.txt
> @@ -159,6 +159,12 @@ New features:
> Any other arguments are passed directly to `git log'
>
> --
> +'find-rev'::
> + When given an SVN revision number of the form 'rN', returns the
> + 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.
> +
> 'set-tree'::
> You should consider using 'dcommit' instead of this command.
> Commit specified commit or tree objects to SVN. This relies on
> diff --git a/git-svn.perl b/git-svn.perl
> index 7b5f8ab..30e4a41 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -141,6 +141,8 @@ my %cmd = (
> 'color' => \$Git::SVN::Log::color,
> 'pager=s' => \$Git::SVN::Log::pager,
> } ],
> + 'find-rev' => [ \&cmd_find_rev, "Translate between SVN revision numbers and tree-ish",
> + { } ],
> 'rebase' => [ \&cmd_rebase, "Fetch and rebase your working directory",
> { 'merge|m|M' => \$_merge,
> 'verbose|v' => \$_verbose,
> @@ -428,6 +430,27 @@ sub cmd_dcommit {
> command_noisy(@finish, $gs->refname);
> }
>
> +sub cmd_find_rev {
> + my $revision_or_hash = shift;
> + my $result;
> + if ($revision_or_hash =~ /^r\d+$/) {
> + my $head = shift;
> + $head ||= 'HEAD';
> + my @refs;
> + my (undef, undef, undef, $gs) = working_head_info($head, \@refs);
> + unless ($gs) {
> + die "Unable to determine upstream SVN information from ",
> + "$head history\n";
> + }
> + my $desired_revision = substr($revision_or_hash, 1);
> + $result = $gs->rev_db_get($desired_revision);
> + } else {
> + my (undef, $rev, undef) = cmt_metadata($revision_or_hash);
> + $result = $rev;
> + }
> + print "$result\n" if $result;
> +}
> +
> sub cmd_rebase {
> command_noisy(qw/update-index --refresh/);
> my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
--
Eric Wong
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] git-svn: Add 'find-rev' command
2007-04-29 18:35 ` Eric Wong
@ 2007-04-29 20:31 ` Adam Roben
2007-04-29 22:25 ` Eric Wong
0 siblings, 1 reply; 4+ messages in thread
From: Adam Roben @ 2007-04-29 20:31 UTC (permalink / raw)
To: Eric Wong; +Cc: git, Junio C Hamano
On Apr 29, 2007, at 11:35 AM, Eric Wong wrote:
> Also, if you have time, can you get this (and 'log') to understand
> revision numbers even if they're not from the working HEAD? Thanks.
Won't the following code accomplish that for find-rev? Perhaps I
misunderstand you.
>
>> +sub cmd_find_rev {
>> + my $revision_or_hash = shift;
>> + my $result;
>> + if ($revision_or_hash =~ /^r\d+$/) {
>> + my $head = shift;
>> + $head ||= 'HEAD';
>> + my @refs;
>> + my (undef, undef, undef, $gs) = working_head_info($head, \@refs);
-Adam
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] git-svn: Add 'find-rev' command
2007-04-29 20:31 ` Adam Roben
@ 2007-04-29 22:25 ` Eric Wong
0 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2007-04-29 22:25 UTC (permalink / raw)
To: Adam Roben; +Cc: git, Junio C Hamano
Adam Roben <aroben@apple.com> wrote:
> On Apr 29, 2007, at 11:35 AM, Eric Wong wrote:
>
> >Also, if you have time, can you get this (and 'log') to understand
> >revision numbers even if they're not from the working HEAD? Thanks.
>
> Won't the following code accomplish that for find-rev? Perhaps I
> misunderstand you.
working_head_info() only calls rev-list for a given head.
You should probably iterate through (like fetch_all does)
each remote and do rev_db_get via the Git::SVN object.
> >>+sub cmd_find_rev {
> >>+ my $revision_or_hash = shift;
> >>+ my $result;
> >>+ if ($revision_or_hash =~ /^r\d+$/) {
> >>+ my $head = shift;
> >>+ $head ||= 'HEAD';
> >>+ my @refs;
> >>+ my (undef, undef, undef, $gs) = working_head_info($head,
> >>\@refs);
--
Eric Wong
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-04-29 22:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-29 8:35 [PATCH] git-svn: Add 'find-rev' command Adam Roben
2007-04-29 18:35 ` Eric Wong
2007-04-29 20:31 ` Adam Roben
2007-04-29 22:25 ` Eric Wong
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).