From a822ccf61e9ded0f5a8f76acf04c0f2deeec1c20 Mon Sep 17 00:00:00 2001 From: Christian Hammond Date: Sun, 31 Jan 2010 01:08:39 -0800 Subject: 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. --- rbtools/postreview.py | 13 +++++++++++-- 1 file 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') -- cgit v1.2.3