post-review in git with svn remote

357 views
Skip to first unread message

Rusty Burchfield

unread,
Sep 5, 2008, 6:30:23 PM9/5/08
to reviewboard

We use svn as our main repository, but a number of developers use git-
svn locally. Is there any recommended way to use post-review in this
scenario.

For now I have created a simple ruby script to convert the git diff
style to svn diff style (see below). However, I am not sure how to
send the resulting diff through post-review.

Any suggestions are appreciated.

Thank you,
Rusty Burchfield

>>>
#!/usr/bin/ruby -w

diff = `unset GIT_EXTERNAL_DIFF; git diff`;
svn_rev = `git svn info | awk '/^Revision: /{print$2}'`.chomp

diff.gsub!(/^diff --git (.*\n)+?--- .*\n\+\+\+ .*\n/) do |matched|
file = matched.match(/--- a\/.*$/).to_s.sub(/^--- a\//, '')
"Index: #{file}\n#{'='*66}\n" +
"--- #{file}\t(revision #{svn_rev})\n" +
"+++ #{file}\t(working copy)\n"
end

puts diff
<<<

David Trowbridge

unread,
Sep 5, 2008, 6:36:51 PM9/5/08
to revie...@googlegroups.com
post-review actually supports this use case natively, since both
Christian and I use git-svn for reviewboard development.

If you add something like this to your .git/config, when you run
post-review it'll take a diff of your current HEAD up to the remote
branch and post it.
[reviewboard]
url = http://reviews.review-board.org/

-David

Rusty Burchfield

unread,
Sep 5, 2008, 9:11:02 PM9/5/08
to reviewboard
On Sep 5, 3:36 pm, "David Trowbridge" <trowb...@gmail.com> wrote:
> post-review actually supports this use case natively, since both
> Christian and I use git-svn for reviewboard development.
>
> If you add something like this to your .git/config, when you run
> post-review it'll take a diff of your current HEAD up to the remote
> branch and post it.
> [reviewboard]
> url =http://reviews.review-board.org/

Wow. Definitely glad to see that this use case is supported. ;-)

For the benefit of others, one issue I resolved was that the
repository was configured as svn://repo.example.com/. I had to
reconfigure it to svn://repo.example.com (no trailing slash).

The actual error message was: "Error creating review request: The
repository path specified is not in the list of known repositories
(code 206)"

Now I am stuck on the following error (sanitized).

$ post-review -d
>>> Repository info 'Path: svn://repo.example.com, Base path: /repo/trunk, Supports changesets: False'
>>> git diff --no-color --no-prefix -r -u master..
>>> git-svn find-rev master
>>> Looking for 'review.example.com /reviewboard/' cookie in /home/rusty/.post-review-cookies.txt
>>> Loaded valid cookie -- no login required
>>> Attempting to create review request for None
>>> Submitting the review request as rusty
>>> HTTP POSTing to http://review.example.com/reviewboard/api/json/reviewrequests/new/: {'repository_path': 'svn://repo.example.com', 'submit_as': 'rusty'}
>>> Review request created
>>> Attempting to set field 'target_groups' to 'rails' for review request '17'
>>> HTTP POSTing to http://review.example.com/reviewboard/api/json/reviewrequests/17/draft/set/: {'target_groups': 'rails'}
>>> HTTP POSTing to http://review.example.com/reviewboard/api/json/reviewrequests/17/draft/save/: {}
>>> Review request draft saved
Traceback (most recent call last):
File "/home/rusty/scripts/post-review", line 1589, in <module>
main(sys.argv[1:])
File "/home/rusty/scripts/post-review", line 1571, in main
submit_as=options.submit_as)
File "/home/rusty/scripts/post-review", line 1396, in tempt_fate
parent_diff_content)
File "/home/rusty/scripts/post-review", line 291, in upload_diff
debug("Uploading diff, size: %d" % len(diff_content))
TypeError: object of type 'NoneType' has no len()


Any thoughts on what I am missing here?

~Rusty

Rusty Burchfield

unread,
Sep 5, 2008, 9:32:23 PM9/5/08
to reviewboard
On Sep 5, 6:11 pm, Rusty Burchfield <gic...@gmail.com> wrote:
> Any thoughts on what I am missing here?

Ah. It is because I don't have any changes.

$ post-review --output-diff
None

~Rusty

Rusty Burchfield

unread,
Sep 8, 2008, 5:14:46 PM9/8/08
to reviewboard
OK, I have tried committing changes on a local branch without a
dcommit, and that still produces a "None" diff.
$ post-review -o
Traceback (most recent call last):
File "/home/rusty/scripts/post-review", line 1589, in <module>
main(sys.argv[1:])
File "/home/rusty/scripts/post-review", line 1571, in main
submit_as=options.submit_as)
File "/home/rusty/scripts/post-review", line 1396, in tempt_fate
parent_diff_content)
File "/home/rusty/scripts/post-review", line 291, in upload_diff
debug("Uploading diff, size: %d" % len(diff_content))

If I don't unset GIT_EXTERNAL_DIFF the above will pop the diff in my
external viewer.

Are there any other settings I need to change?

~Rusty

Rusty Burchfield

unread,
Sep 24, 2008, 6:40:18 PM9/24/08
to reviewboard
On Sep 8, 2:14 pm, Rusty Burchfield <gic...@gmail.com> wrote:
> Are there any other settings I need to change?

Ah ha! I was testing on master, but you apparently have to be on a
branch for it to work.

I guess it is doing a diff against master. This seems to cause some
issues when the branch has been rebased to a version different from
master. Is this expected behavior?

~Rusty

Christian Hammond

unread,
Sep 24, 2008, 8:17:40 PM9/24/08
to revie...@googlegroups.com
It uses master by default, but you can do a diff against any other parent branch using the --parent= parameter.

Christian

--
Christian Hammond - chi...@chipx86.com
VMware, Inc.
Reply all
Reply to author
Forward
0 new messages