summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hammond <chipx86@chipx86.com>2010-01-31 01:08:39 -0800
committerChristian Hammond <chipx86@chipx86.com>2010-01-31 01:14:07 -0800
commita822ccf61e9ded0f5a8f76acf04c0f2deeec1c20 (patch)
tree7e4efaa95448c74ec7b01688791ae222d89be400
parent368f1f4e19d30a7fc3a8c9d36ca294258548d2f1 (diff)
Add support for --diff-filename=-
This adds support for passing diff content on STDIN when using --diff-filename=-. When specified, any input that is required (such as authentication information) will terminate and inform the user they must pass the appropriate information on the command line.
-rwxr-xr-xrbtools/postreview.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/rbtools/postreview.py b/rbtools/postreview.py
index c8c0300..effa801 100755
--- a/rbtools/postreview.py
+++ b/rbtools/postreview.py
@@ -250,6 +250,10 @@ class ReviewBoardHTTPPasswordMgr(urllib2.HTTPPasswordMgr):
def find_user_password(self, realm, uri):
if uri.startswith(self.rb_url):
if self.rb_user is None or self.rb_pass is None:
+ if options.diff_filename == '-':
+ die('HTTP authentication is required, but cannot be '
+ 'used with --diff-filename=-')
+
print "==> HTTP Authentication Required"
print 'Enter username and password for "%s" at %s' % \
(realm, urlparse(uri)[1])
@@ -296,6 +300,12 @@ class ReviewBoardServer(object):
if not force and self.has_valid_cookie():
return
+ if (options.diff_filename == '-' and
+ not options.username and not options.submit_as and
+ not options.password):
+ die('Authentication information needs to be provided on '
+ 'the command line when using --diff-filename=-')
+
print "==> Review Board Login Required"
print "Enter username and password for Review Board at %s" % self.url
if options.username:
@@ -2716,8 +2726,7 @@ def main():
parent_diff = None
if options.diff_filename == '-':
- raise NotImplemented('- for diff filename')
- #diff = sys.stdin.read()
+ diff = sys.stdin.read()
else:
try:
fp = open(os.path.join(origcwd, options.diff_filename), 'r')