Commits

Daniel Graña committed 8d4ed52 Merge

Comments (0)

Files changed (1)

         data['title'] = parameters['title']
     if parameters['user']:
         data['poster'] = parameters['user']
-    
+
     if len(data['poster']) > 30:
         data['poster'] = data['poster'][:30]
-    
+
     if parameters['keep']:
         data['hold'] = 'on'
     data = urlencode(data)
-    
+
     if parameters['url']:
         url = parameters['url']
     else:
         url = pastebins['dpaste']['url']
-    
+
     request = urllib2.Request(url, data)
     if parameters['httpauth']:
         request.add_header('Authorization', 'Basic %s' \
                     % base64.encodestring(parameters['httpauth'])[:-1])
-    elif parameters['usenetrc']:
+    elif parameters['netrc']:
         auth = _netrc_get_credentials(url)
         if auth:
-            request.add_header('Authorization', 'Basic %s' \
-                    % base64.encodestring('%s:%s' % (auth[0], auth[2]))[:-1])
+            b64str = base64.urlsafe_b64encode('%s:%s' % (auth[0], auth[2]))
+            request.add_header('Authorization', 'Basic %s' % b64str)
     response = urllib2.urlopen(request)
     return response.geturl()
 
         data['title'] = parameters['title']
     if parameters['user']:
         data['author'] = parameters['user']
-    
+
     if len(data['author']) > 30:
         data['author'] = data['author'][:30]
-    
+
     # Same values used in dpaste.org form for default (a month) and forever expires.
     data['expire_options'] = '3110400000' if parameters['keep'] else '2592000'
     data = urlencode(data)
-    
+
     if parameters['url']:
         url = parameters['url']
     else:
         url = pastebins['dpaste.org']['url']
-    
+
     request = urllib2.Request(url, data)
     if parameters['httpauth']:
         request.add_header('Authorization', 'Basic %s' \
                     % base64.encodestring(parameters['httpauth'])[:-1])
-    elif parameters['usenetrc']:
+    elif parameters['netrc']:
         auth = _netrc_get_credentials(url)
         if auth:
             request.add_header('Authorization', 'Basic %s' \
         dest = 'dpaste'
     if dest not in pastebins:
         raise util.Abort('unknown pastebin (see "hg help pastebins")!')
-    
+
     if not opts['user']:
         opts['user'] = ui.username().replace('<', '').replace('>', '')
-    
+
     if opts['rev'] and opts['stdin']:
         raise util.Abort('--rev and --stdin options are mutually exclusive')
 
         if opts['rev']:
             rev = opts.pop('rev')
             revs = cmdutil.revrange(repo, rev)
-            
+
             if len(revs) == 1:
                 opts['change'] = revs[0]
             else:
                 opts['rev'] = rev
-            
+
             commands.diff(ui, repo, *fnames, **opts)
         else:
             commands.diff(ui, repo, *fnames, **opts)
         content = ui.popbuffer()
-    
+
     if not content.strip():
         raise util.Abort('nothing to paste!')
-    
+
     if ui.verbose:
         ui.status('Pasting:\n%s\n' % content)
     
         ('',  'dry-run', False, 'do not paste to the pastebin'),
         ('',  'url', '', 'perform request against this url'),
         ('',  'httpauth', '', 'http authorization (user:pass)'),
-        ('',  'usenetrc', False, 'use ~/.netrc for http authorization'),
+        ('',  'netrc', False, 'use ~/.netrc for http authorization'),
         ('',  'stdin', False, 'read content from standard input'),
         ('',  'syntax', '', 'choose syntax'),
     ] + commands.diffopts + commands.walkopts,