Skip to content

Commit

Permalink
add --auth to sendchange; deprecate --username in favor of --who
Browse files Browse the repository at this point in the history
Refs #1708
  • Loading branch information
djmitche committed Dec 9, 2010
1 parent b25c9bd commit 9bb38de
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 17 deletions.
3 changes: 3 additions & 0 deletions master/NEWS
Expand Up @@ -30,6 +30,9 @@ non-functional, and has been removed. (#1059)

*** contrib/hg_buildbot.py was removed in favor of buildbot.changes.hgbuildbot.

*** The misnamed sendchange option 'username' has been renamed to 'who'; the old
option continues to work, but is deprecated and will be removed. (#1711)

* Buildbot 0.8.2

** Upgrading
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/changes/hgbuildbot.py
Expand Up @@ -95,7 +95,7 @@ def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
if branchtype == 'inrepo':
branch = workingctx(repo).branch()

s = sendchange.Sender(master, None)
s = sendchange.Sender(master)
d = defer.Deferred()
reactor.callLater(0, d.callback, None)
# process changesets
Expand Down
12 changes: 5 additions & 7 deletions master/buildbot/clients/sendchange.py
Expand Up @@ -4,24 +4,22 @@
from twisted.internet import reactor

class Sender:
def __init__(self, master, user=None):
self.user = user
def __init__(self, master, auth=('change','changepw')):
self.username, self.password = auth
self.host, self.port = master.split(":")
self.port = int(self.port)
self.num_changes = 0

def send(self, branch, revision, comments, files, user=None, category=None,
def send(self, branch, revision, comments, files, who=None, category=None,
when=None, properties={}, repository='', project='', revlink=''):
if user is None:
user = self.user
change = {'project': project, 'repository': repository, 'who': user,
change = {'project': project, 'repository': repository, 'who': who,
'files': files, 'comments': comments, 'branch': branch,
'revision': revision, 'category': category, 'when': when,
'properties': properties, 'revlink': revlink}
self.num_changes += 1

f = pb.PBClientFactory()
d = f.login(credentials.UsernamePassword("change", "changepw"))
d = f.login(credentials.UsernamePassword(self.username, self.password))
reactor.connectTCP(self.host, self.port, f)
d.addCallback(self.addChange, change)
return d
Expand Down
27 changes: 22 additions & 5 deletions master/buildbot/scripts/runner.py
Expand Up @@ -771,7 +771,10 @@ def __init__(self):
optParameters = [
("master", "m", None,
"Location of the buildmaster's PBListener (host:port)"),
("username", "u", None, "Username performing the commit"),
# deprecated in 0.8.3; remove in 0.8.5 (bug #1711)
("username", "u", None, "deprecated name for --who"),
("auth", "a", None, "Authentication token - username:password, or prompt for password"),
("who", "W", None, "Author of the commit"),
("repository", "R", '', "Repository specifier"),
("project", "P", '', "Project specifier"),
("branch", "b", None, "Branch specifier"),
Expand All @@ -789,6 +792,7 @@ def __init__(self):

buildbotOptions = [
[ 'master', 'master' ],
[ 'who', 'who' ],
[ 'username', 'username' ],
[ 'branch', 'branch' ],
[ 'category', 'category' ],
Expand All @@ -808,7 +812,11 @@ def sendchange(config, runReactor=False):
connection will be drpoped as soon as the Change has been sent."""
from buildbot.clients.sendchange import Sender

user = config.get('username')
who = config.get('who')
if not who and config.get('username'):
print "NOTE: --username/-u is deprecated: use --who/-W'"
who = config.get('username')
auth = config.get('auth')
master = config.get('master')
branch = config.get('branch')
category = config.get('category')
Expand Down Expand Up @@ -836,11 +844,20 @@ def sendchange(config, runReactor=False):

files = config.get('files', [])

assert user, "you must provide a username"
# fix up the auth with a password if none was given
if not auth:
auth = 'change:changepw'
if ':' not in auth:
import getpass
pw = getpass.getpass("Enter password for '%s': " % auth)
auth = "%s:%s" % (auth, pw)
auth = auth.split(':', 1)

assert who, "you must provide a committer (--who)"
assert master, "you must provide the master location"

s = Sender(master, user)
d = s.send(branch, revision, comments, files, category=category, when=when,
s = Sender(master, auth)
d = s.send(branch, revision, comments, files, who=who, category=category, when=when,
properties=properties, repository=repository, project=project,
revlink=revlink)
if runReactor:
Expand Down
2 changes: 1 addition & 1 deletion master/contrib/darcs_buildbot.py
Expand Up @@ -137,7 +137,7 @@ def findNewChanges():

def sendChanges(master):
changes = findNewChanges()
s = sendchange.Sender(master, None)
s = sendchange.Sender(master)

d = defer.Deferred()
reactor.callLater(0, d.callback, None)
Expand Down
12 changes: 9 additions & 3 deletions master/docs/cmdline.texinfo
Expand Up @@ -458,12 +458,18 @@ VC server. It requires that you have a PBChangeSource
(@pxref{PBChangeSource}) running in the buildmaster (by being set in
@code{c['change_source']}).


@example
buildbot sendchange --master @var{MASTERHOST}:@var{PORT} --username @var{USER} @var{FILENAMES..}
buildbot sendchange --master @var{MASTERHOST}:@var{PORT} --auth @var{USER}:@var{PASS} \
--who @var{COMMITTER} @var{FILENAMES..}
@end example

The @code{master} and @code{username} arguments can also be given in the
The @code{auth} option specifies the credentials to use to connect to the
master, in the form @code{user:pass}. If the password is omitted, then
sendchange will prompt for it. If both are omitted, the old default (username
"change" and password "changepw") will be used. Note that this password is
well-known, and should not be used on an internet-accessible port.

The @code{master} and @code{who} arguments can also be given in the
options file (@pxref{.buildbot config directory}). There are other (optional)
arguments which can influence the @code{Change} that gets submitted:

Expand Down

0 comments on commit 9bb38de

Please sign in to comment.