upload.py Usage
upload.py is a tool for uploading diffs from a version control system to the codereview app.
Usage summary:
upload.py [options] [-- diff_options]
Diff options are passed to the diff command of the underlying system.
Supported version control systems:
- Git
- Mercurial
- Subversion
- Perforce
It is important for Git/Mercurial users to specify a tree/node/branch to diff against by using the '--rev' option.
Options
- -h, --help
- Show this help message and exit.
- -y, --assume_yes
- Assume that the answer to yes/no questions is 'yes'.
Logging options
- -q, --quiet
- Print errors only.
- -v, --verbose
- Print info level logs.
- --noisy
- Print all logs.
- --print_diffs
- Print full diffs.
Review server options
- -s SERVER, --server=SERVER
- The server to upload to. The format is host[:port]. Defaults to '%default'.
- -e EMAIL, --email=EMAIL
- The username to use. Will prompt if omitted.
- -H HOST, --host=HOST
- Overrides the Host header sent with all RPCs.
- --no_cookies
- Do not save authentication cookies to local disk.
- --account_type=TYPE
- Override the default account type (defaults to '%default', valid choices are 'GOOGLE' and 'HOSTED').
Issue options
- -t TITLE, --title=TITLE
- New issue subject or new patch set title
- -m MESSAGE, --message=MESSAGE
- New issue description or new patch set message
- -F FILE, --file=FILE
- Read the message above from file.
- -r REVIEWERS, --reviewers=REVIEWERS
- Add reviewers (comma separated email addresses).
- --cc=CC
- Add CC (comma separated email addresses).
- --private
- Make the issue restricted to reviewers and those CCed
Patch options
- -i ISSUE, --issue=ISSUE
- Issue number to which to add. Defaults to new issue.
- --base_url=BASE_URL
- Base URL path for files (listed as "Base URL" when viewing issue). If omitted, will be guessed automatically for SVN repos and left blank for others.
- --download_base
- Base files will be downloaded by the server (side-by-side diffs may not work on files with CRs).
- --rev=REV
- Base revision/branch/tree to diff against. Use rev1:rev2 range to review already committed changeset.
- --send_mail
- Send notification email to reviewers.
- -p, --send_patch
- Same as --send_mail, but include diff as an attachment, and prepend email subject with 'PATCH:'.
- --vcs=VCS
- Version control system (optional, usually upload.py already guesses the right VCS).
- --emulate_svn_auto_props
- Emulate Subversion's auto properties feature.
Perforce-specific options (overrides P4 environment variables)
- --p4_port=P4_PORT
- Perforce server and port (optional)
- --p4_changelist=P4_CHANGELIST
- Perforce changelist id
- --p4_client=P4_CLIENT
- Perforce client/workspace
- --p4_user=P4_USER
- Perforce user
Running upload.py from perforce GUIs
You can right click on a perforce changelist and create a new Rietveld code review by adding a custom tool with the following settings:
Application: python Arguments: /PATH/TO/upload.py -s MY_SERVER --p4_changelist %p --p4_port $p --p4_user $u --p4_client $c Start In: empty. Check "Add to applicable context menus", "Run tool in terminal window" (or system equivalent), and "Ignore P4CONFIG files".
Replace /PATH/TO/ with the location of upload.py, and MY_SERVER with the rietveld code review server. See screenshot here.
I use hg <blush>I think too I misunderstood</blush> I found this http://fwierzbicki.blogspot.com/2008/08/code-review-with-rietveld.html that pointed me on the right path. Now I wonder how I could misunderstand it at all. But you know, newbyiness and yes, I think that an example that cover the full code review process could have saved me some time. Thanks a lot BTW
upload.py -s codereview.example.com -e me@example.com --rev=1
That uploads a diff between the current code and revision 1.
so, I'm using git. Does the tool automatically assume you want to diff from the tip of the current code? For example, how do I tell upload.py to generate the issue from files between two commits?
Just add the two revisions as an argument, e.g. upload.py -m "test" firstrev..secondrev
If you use Rietveld/Codereview installed with Google Apps, you must download the upload.py script from the installed instance (click on Create Issue to see a download link). You will still have to use the -s parameter to point it to your Rietveld instance, but it correctly selects the login type for Google Apps, and you must use an account in your domain.
Here's an example: I've got a project in SVN and my working copy is different (doing svn diff produces output; or, if you're using Tortoise, you can see that there are modifications).
First, I installed the client version of SVN so that I would have the svn app from the command line. Then, I placed upload.py in my system32 folder so that I could call it from anywhere (because system32 is in the PATH environment variable). You can test both of these conditions by opening a shell and cd'ing to your working directory, then try svn and upload.py - both should produce output.
Open up cmd and cd to your working directory (e.g. C:\Projects\Example). Run upload.py with arguments for your apps server (or the default Google Rietveld server). Should look a lot like this:
C:\Projects\Example>upload.py --server=http://codereview.advanced.pro/
Upload server: http://codereview.advanced.pro/ (change with -s/--server)
New issue subject: Testing Rietveld
Email (login for uploading to http://codereview.advanced.pro/): myemail@advanced.pro
Password for myemail@advanced.pro:
Saving authentication cookies to C:\Users\me/.codereview_upload_cookies
Issue created. URL: http://codereview.advanced.pro/2392001
Uploading base file for ...
Now navigate to the URL and play around.
I have absolutely no clue how to use this. I'm a new hg user and I've got an hg named branch with several commits. I can get the patch set by doing 'hg diff -r pyk3' (py3k being the other head in my repository that I branched from to do my work). I've tried everything I could think of to pass to --rev, but no matter what I try I get 'No valid patches found in output from hg diff'.
I think the docs for this tool need some examples, or at least an explanation of how what you pass to --rev gets passed to the underlying diff command.
@xjbase: Passing in "--rev pyk3" should do it. Can you run upload.py with "-v" flag set? That should print the actual hg commands.
I try to use Rietveld for some days,but I really don't know how to use upload.py,I'm a new learner,who can give me some help?Thanks a lot.
Thanks for pckujawa,I use upload.py correctly now.But I can't checkout Rietveld through http://rietveld.googlecode.com/svn/trunk/,anybody who can tell me the reasons?Thanks a lot!
Hi everybody, Rietveld is great - thanks Guido! I'm trying to figure out how to use upload.py with Google Apps and am hoping for some help. I downloaded upload.py using the link from within our Google Apps account. I've tried everything. Here is the command when run from the root of the local SVN project which is checked out: [oracle@cpu2 myproject]$ pwd /home/oracle/Desktop/svn-test/myproject /home/oracle/Desktop/Python-2.7.1/python ../upload.py --server=http://codereview.happyphonoodles.com --email=andy@happyphonoodles.com --rev=2 --noisy 2011-01-25 17:49:36 INFO upload.py:688 Running ['hg', 'root'] 2011-01-25 17:49:36 INFO upload.py:1784 Guessed VCS = Subversion 2011-01-25 17:49:36 INFO upload.py:688 Running ['svn', 'info'] Traceback (most recent call last):
OSError: 2? No such file or directoryThank you very much and best regards,
Andy (414) 212-5372
Thanks to Andi Albrecht in another forum, I realized the cause and fixed the first error. Now it appears upload.py does not support SVN repos over https? It appears that even though I set --base_url= to the http repo (which I verified works properly) rather than the https repo, and upload.py confirmed this (as shown in the log below), it later defaults back to the https URL, which appears may be causing the error given the message "AttributeError??: 'module' object has no attribute 'HTTPSHandler'". Humph. Here is the log:
myproject?$ /home/oracle/Desktop/Python-2.7.1/python ../upload.py --server=http://codereview.happyphonoodles.com --email=andy@happyphonoodles.com --base_url=http://mysvn.svn.cvsdude.com/myproject/ --rev=2 --noisy 2011-01-26 11:06:58 INFO upload.py:688 Running 'root'? 2011-01-26 11:06:58 INFO upload.py:1784 Guessed VCS = Subversion 2011-01-26 11:06:58 INFO upload.py:688 Running 'info'? 2011-01-26 11:06:58 INFO upload.py:922 Guessed base = https://mysvn.svn.cvsdude.com/myproject/ Using base URL "http://mysvn.svn.cvsdude.com/myproject/" from --base_url instead of "https://mysvn.svn.cvsdude.com/myproject/" 2011-01-26 11:06:58 INFO upload.py:688 Running ['svn', 'status', '--ignore-externals'] 2011-01-26 11:06:59 INFO upload.py:688 Running 'diff', '-r', '2'? 2011-01-26 11:07:11 INFO upload.py:938 Index: trunk/helloworld.txt 2011-01-26 11:07:11 INFO upload.py:688 Running ['svn', 'list', '-r', '2', 'trunk'] 2011-01-26 11:07:13 INFO upload.py:688 Running 'list', 'trunk'? 2011-01-26 11:07:14 INFO upload.py:688 Running ['svn', 'propget', 'svn:mime-type', 'https://mysvn.svn.cvsdude.com/myproject//trunk/helloworld.txt@2']
2011-01-26 11:07:18 INFO upload.py:688 Running ['svn', 'cat', 'https://mysvn.svn.cvsdude.com/myproject//trunk/helloworld.txt@2'] 2011-01-26 11:07:30 INFO upload.py:688 Running ['svn', 'propget', 'svn:keywords', 'https://mysvn.svn.cvsdude.com/myproject//trunk/helloworld.txt@2'] Upload server: http://codereview.happyphonoodles.com (change with -s/--server) New issue subject: test code review Traceback (most recent call last):
AttributeError??: 'module' object has no attribute 'HTTPSHandler'
I searched the rietveld wiki and issues though found no discussion of https.
Thanks very much and best regards,
Andy
Thanks again to Andi Albrecht in another forum, after installing openssl-devel and recompiling python, update.pl worked without issue! Also, I'll make sure to use the codereview-discuss group in the future. Best regards, Andy
Hey, sometimes I notice that the "Delta from patch set" does not work as what I expected.
For example, after I upload patch #1 and work on code review feedbacks, when I upload #2, the diff between #2 and #1 actually shows the diff between base and my latest change, instead of the delta of #2 and #1. When this happens, the upload.py outputs "Uploading base file for xxx".
Anyone knows why this could happen? Is there any option flag to avoid this?
I am using svn and upload command I used was "upload.py -s xxx -i yyyy".
Thanks!
If you can you reproduce this 100% with open source repository, then it will be better if you open an issue http://code.google.com/p/rietveld/issues/list - or else it may take a while.
Hi guys.
As a ruby shop we have created a tool for ourselves to automate the original upload tool installation/configuration and changeset generation with description/title/reviewers etc...
https://github.com/railsware/plunger
@yaroslav: Good work. I realize that there is a need in more appropriate tool for certain workflows, because I maintain a copy of official upload.py script as http://pypi.python.org/pypi/review which can be installed with any Python packaging software like pip - pip install review.
You need to be aware that upload.py downloaded from other domains than http://codereview.appspot.com or from PyPI is different. See customized_upload_py() - http://code.google.com/p/rietveld/source/browse/codereview/views.py#3742
Can you be more specific, what is the use case of your tool? Chromium project also uses wrapper for upload.py With your help we can merge repeated functionality right inside upload.py. Thanks for working on this.