Commit 82747423 authored by Russ Cox's avatar Russ Cox

codereview: add golang-dev@googlegroups.com

    automatically in "hg mail".
also, avoid "empty list means all modified files in client" bug

R=gri, cw
CC=golang-dev
https://golang.org/cl/174072
parent 55ca7a26
...@@ -90,6 +90,10 @@ if __name__ == "__main__": ...@@ -90,6 +90,10 @@ if __name__ == "__main__":
sys.exit(2) sys.exit(2)
server = "codereview.appspot.com"
server_url_base = None
defaultcc = [ "golang-dev@googlegroups.com" ]
####################################################################### #######################################################################
# Change list parsing. # Change list parsing.
# #
...@@ -101,6 +105,13 @@ if __name__ == "__main__": ...@@ -101,6 +105,13 @@ if __name__ == "__main__":
# Also, the existence of the cl.nnnnnn file marks this repository # Also, the existence of the cl.nnnnnn file marks this repository
# as the one where the change list lives. # as the one where the change list lives.
emptydiff = """Index: ~rietveld~placeholder~
===================================================================
diff --git a/~rietveld~placeholder~ b/~rietveld~placeholder~
new file mode 100644
"""
class CL(object): class CL(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
...@@ -191,6 +202,8 @@ class CL(object): ...@@ -191,6 +202,8 @@ class CL(object):
return s return s
def Upload(self, ui, repo, send_mail=False, gofmt=True, gofmt_just_warn=False): def Upload(self, ui, repo, send_mail=False, gofmt=True, gofmt_just_warn=False):
if not self.files:
ui.warn("no files in change list\n")
if ui.configbool("codereview", "force_gofmt", True) and gofmt: if ui.configbool("codereview", "force_gofmt", True) and gofmt:
CheckGofmt(ui, repo, self.files, just_warn=gofmt_just_warn) CheckGofmt(ui, repo, self.files, just_warn=gofmt_just_warn)
os.chdir(repo.root) os.chdir(repo.root)
...@@ -209,14 +222,18 @@ class CL(object): ...@@ -209,14 +222,18 @@ class CL(object):
# but RealMain doesn't have the most reusable interface. # but RealMain doesn't have the most reusable interface.
if self.name != "new": if self.name != "new":
form_fields.append(("issue", self.name)) form_fields.append(("issue", self.name))
vcs = GuessVCS(upload_options) vcs = None
data = vcs.GenerateDiff(self.files) if self.files:
files = vcs.GetBaseFiles(data) vcs = GuessVCS(upload_options)
if len(data) > MAX_UPLOAD_SIZE: data = vcs.GenerateDiff(self.files)
uploaded_diff_file = [] files = vcs.GetBaseFiles(data)
form_fields.append(("separate_patches", "1")) if len(data) > MAX_UPLOAD_SIZE:
uploaded_diff_file = []
form_fields.append(("separate_patches", "1"))
else:
uploaded_diff_file = [("data", "data.diff", data)]
else: else:
uploaded_diff_file = [("data", "data.diff", data)] uploaded_diff_file = [("data", "data.diff", emptydiff)]
ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file) ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file)
response_body = MySend("/upload", body, content_type=ctype) response_body = MySend("/upload", body, content_type=ctype)
patchset = None patchset = None
...@@ -235,7 +252,8 @@ class CL(object): ...@@ -235,7 +252,8 @@ class CL(object):
self.url = server_url_base + self.name self.url = server_url_base + self.name
if not uploaded_diff_file: if not uploaded_diff_file:
patches = UploadSeparatePatches(issue, rpc, patchset, data, upload_options) patches = UploadSeparatePatches(issue, rpc, patchset, data, upload_options)
vcs.UploadBaseFiles(issue, rpc, patches, patchset, upload_options, files) if vcs:
vcs.UploadBaseFiles(issue, rpc, patches, patchset, upload_options, files)
if send_mail: if send_mail:
MySend("/" + issue + "/mail", payload="") MySend("/" + issue + "/mail", payload="")
self.web = True self.web = True
...@@ -563,7 +581,7 @@ def EditCL(ui, repo, cl): ...@@ -563,7 +581,7 @@ def EditCL(ui, repo, cl):
# For use by submit, etc. (NOT by change) # For use by submit, etc. (NOT by change)
# Get change list number or list of files from command line. # Get change list number or list of files from command line.
# If files are given, make a new change list. # If files are given, make a new change list.
def CommandLineCL(ui, repo, pats, opts): def CommandLineCL(ui, repo, pats, opts, defaultcc=None):
if len(pats) > 0 and GoodCLName(pats[0]): if len(pats) > 0 and GoodCLName(pats[0]):
if len(pats) != 1: if len(pats) != 1:
return None, "cannot specify change number and file names" return None, "cannot specify change number and file names"
...@@ -582,6 +600,8 @@ def CommandLineCL(ui, repo, pats, opts): ...@@ -582,6 +600,8 @@ def CommandLineCL(ui, repo, pats, opts):
cl.reviewer = Add(cl.reviewer, SplitCommaSpace(opts.get('reviewer'))) cl.reviewer = Add(cl.reviewer, SplitCommaSpace(opts.get('reviewer')))
if opts.get('cc'): if opts.get('cc'):
cl.cc = Add(cl.cc, SplitCommaSpace(opts.get('cc'))) cl.cc = Add(cl.cc, SplitCommaSpace(opts.get('cc')))
if defaultcc:
cl.cc = Add(cl.cc, defaultcc)
if cl.name == "new": if cl.name == "new":
if opts.get('message'): if opts.get('message'):
cl.desc = opts.get('message') cl.desc = opts.get('message')
...@@ -607,6 +627,8 @@ def ReplacementForCmdutilMatch(repo, pats=[], opts={}, globbed=False, default='r ...@@ -607,6 +627,8 @@ def ReplacementForCmdutilMatch(repo, pats=[], opts={}, globbed=False, default='r
cl, err = LoadCL(repo.ui, repo, clname, web=False) cl, err = LoadCL(repo.ui, repo, clname, web=False)
if err != '': if err != '':
raise util.Abort("loading CL " + clname + ": " + err) raise util.Abort("loading CL " + clname + ": " + err)
if cl.files == None:
raise util.Abort("no files in CL " + clname)
files = Add(files, cl.files) files = Add(files, cl.files)
pats = Sub(pats, taken) + ['path:'+f for f in files] pats = Sub(pats, taken) + ['path:'+f for f in files]
return original_match(repo, pats=pats, opts=opts, globbed=globbed, default=default) return original_match(repo, pats=pats, opts=opts, globbed=globbed, default=default)
...@@ -647,10 +669,6 @@ def CheckGofmt(ui, repo, files, just_warn=False): ...@@ -647,10 +669,6 @@ def CheckGofmt(ui, repo, files, just_warn=False):
####################################################################### #######################################################################
# Mercurial commands # Mercurial commands
server = "codereview.appspot.com"
server_url_base = None
# every command must take a ui and and repo as arguments. # every command must take a ui and and repo as arguments.
# opts is a dict where you can find other command line flags # opts is a dict where you can find other command line flags
# #
...@@ -904,11 +922,11 @@ def mail(ui, repo, *pats, **opts): ...@@ -904,11 +922,11 @@ def mail(ui, repo, *pats, **opts):
Uploads a patch to the code review server and then sends mail Uploads a patch to the code review server and then sends mail
to the reviewer and CC list asking for a review. to the reviewer and CC list asking for a review.
""" """
cl, err = CommandLineCL(ui, repo, pats, opts) cl, err = CommandLineCL(ui, repo, pats, opts, defaultcc=defaultcc)
if err != "": if err != "":
return err return err
cl.Upload(ui, repo, gofmt_just_warn=True) cl.Upload(ui, repo, gofmt_just_warn=True)
if not cl.reviewer: if not cl.reviewer and not cl.cc:
return "no reviewers listed in CL" return "no reviewers listed in CL"
pmsg = "Hello " + JoinComma(cl.reviewer) pmsg = "Hello " + JoinComma(cl.reviewer)
if cl.cc: if cl.cc:
...@@ -1281,12 +1299,6 @@ cmdtable = { ...@@ -1281,12 +1299,6 @@ cmdtable = {
####################################################################### #######################################################################
# Wrappers around upload.py for interacting with Rietveld # Wrappers around upload.py for interacting with Rietveld
emptydiff = """Index: ~rietveld~placeholder~
===================================================================
diff --git a/~rietveld~placeholder~ b/~rietveld~placeholder~
new file mode 100644
"""
# HTML form parser # HTML form parser
class FormParser(HTMLParser): class FormParser(HTMLParser):
def __init__(self): def __init__(self):
...@@ -1515,25 +1527,6 @@ def GetSettings(issue): ...@@ -1515,25 +1527,6 @@ def GetSettings(issue):
f['description'] = MySend("/"+issue+"/description", force_auth=False) f['description'] = MySend("/"+issue+"/description", force_auth=False)
return f return f
def CreateIssue(subject, desc):
form_fields = [
("content_upload", "1"),
# ("user", upload_options.email),
("reviewers", ''),
("cc", ''),
("description", desc),
("base_hashes", ""),
("subject", subject),
]
uploaded_diff_file = [
("data", "data.diff", emptydiff),
]
ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file)
response = MySend("/upload", body, content_type=ctype)
if response != "":
print >>sys.stderr, "Error creating issue:\n" + response
sys.exit(2)
def EditDesc(issue, subject=None, desc=None, reviewers=None, cc=None, closed=None): def EditDesc(issue, subject=None, desc=None, reviewers=None, cc=None, closed=None):
form_fields = GetForm("/" + issue + "/edit") form_fields = GetForm("/" + issue + "/edit")
if subject is not None: if subject is not None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment