445: Add command-line apply-diff script

oras*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Aug. 7, 2013
482, 1319
What's the URL of the page containing the problem?

Internal


What steps will reproduce the problem?
1. Approve a change.
2. Desire to commit the change.

What is the expected output? What do you see instead?

I'd like to see a script like post-review, (perhaps "commit-review") that:

- checks to see the review is approved ("Ship it!")
- grabs the files from the review
- possibly checks to see that those files are the same as the ones in the
sandbox
- commits those files with the review id, summary, description, and
testing_done in reviewboard as the commit comment


What operating system are you using? What browser?

Linux, IceWeasel.


Please provide any additional information below.


I might even take a shot at a patch if the json APIs existed.  I don't want
to dig into the server side, though, as I didn't install Review Board and I
don't know where that lives.

Hitting http://demo.review-board.org/api/json/, I don't see an obvious
looking API to get:

a) Whether the change is marked "Ship it!" or not
b) The list of files associated with the change
c) The full file text of the list from b.

I can get the id, summary, description, and testing done, tho.

Let me know if a), b), and c) already exist.
#1 oras*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Whoops, this is not a "defect", it's an enhancement.  However, I can't see where to
change that now.
#2 oras*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Oh, of course such a script should also set submitted.
chipx86
#3 chipx86
Someone would have to write such a script for their internal setup. The behavior
described (checking a sandbox) is very specific to certain configurations. It's
unlikely we'll be writing one ourselves, but patches are very much welcome.

As for the API:

a) You should be able to get a list of reviews on a review request through the API
and then check if any of them have ship_it set.
b) I don't know if we have this yet. This should be in a separate bug.
c) We don't have API for this either.
  • -Type-Defect
    +Type-Enhancement
chipx86
#4 chipx86
  • +Component-Scripts
chipx86
#5 chipx86
See also bug 482
david
#6 david
Merging bug 482 into this one, since they're fundamentally the same.
  • +Add command-line apply-diff script
chipx86
#9 chipx86
  • +Confirmed
  • -Component-Scripts
    +Component-RBTools
#10 berna******@gmai***** (Google Code) (Is this you? Claim this profile.)
For SVN:

You can always try to download the diff file then run "patch" on a "matching" SVN
working-copy. But doing it manually or build a script to do it doesn't change a
problematic flaw in SVN: 

For SVN, it is impossible to _reliably_ commit changes from the information that was
uploaded by post-review since the "SVN diff" output misses a lot of information. (svn
move,copy,rename without content edits,binary files,explicit file delete).

SVN version 1.8 (1.7 is not out as of this writing) (stephan -- committer of SVN --
mentions that they might fix SVN diff file format -- adding the "git extensions"
possibly -- along with a proper SVN patch implementation).  With SVN 1.8, you would
simply download the patch, and apply it to a local WC.
#11 Jan.Ko*******@gmai***** (Google Code) (Is this you? Claim this profile.)
I can't find it now but I made hook in Subversion which based on commit comment (which contain informations like review request id) compare diffs and just commit code if the same or update diff if there was differences.
I have also another idea. I call that "rbshell". Running rbshell will switch a bash shell to mode like virtualenv where some additional function will be available.
Command "next" will fetch and apply patch from ReviewBoard to current view. After commiter resolve conflicts they can run "next" one more time and so on until submited patches end in ReviewBoard :)
#12 Jan.Ko*******@gmai***** (Google Code) (Is this you? Claim this profile.)
I attach pre-commit script. They use roundup issue tracker to get informations[http://roundup.sourceforge.net/] to get review request id based on issue number. There is also jsawk [http://github.com/micha/jsawk] and attached clean_diff (because you must clean data from unified diff before compare).
  • +
    +
    #!/usr/bin/python
    import re
    import sys
    output = []
    data = sys.stdin.readlines()
    filename = None
    delimiter = '=' * 67
    for line in data:
        line = line.strip()
        if line == delimiter:
            data = output.pop()
            filename = data.split(':')[1].strip()
            continue
        if filename and re.match(r'^--- ' + filename, line):
            line = line.split('(')[0].strip()
        if filename and re.match(r'^\+\+\+ ' + filename, line):
            line = line.split('(')[0].strip()
            filename = None
        output.append(line)
    print '\n'.join(output) 
david
#13 david
We now have "rbt patch" which does most of the hard work of fetching a diff and applying it to your local tree. I don't think we want to deal with committing it (at least until we have a clearer sense of how people use this script).
  • -Confirmed
    +Fixed