summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-02-18 09:50:58 +0100
committerOndřej Surý <ondrej@sury.org>2011-02-18 09:50:58 +0100
commitc072558b90f1bbedc2022b0f30c8b1ac4712538e (patch)
tree67767591619e4bd8111fb05fac185cde94fb7378 /lib
parent5859517b767c99749a45651c15d4bae5520ebae8 (diff)
downloadgolang-c072558b90f1bbedc2022b0f30c8b1ac4712538e.tar.gz
Imported Upstream version 2011.02.15upstream/2011.02.15
Diffstat (limited to 'lib')
-rw-r--r--lib/codereview/codereview.py49
-rw-r--r--lib/godoc/package.html21
2 files changed, 42 insertions, 28 deletions
diff --git a/lib/codereview/codereview.py b/lib/codereview/codereview.py
index 095270577..96efc855b 100644
--- a/lib/codereview/codereview.py
+++ b/lib/codereview/codereview.py
@@ -253,7 +253,7 @@ class CL(object):
def Flush(self, ui, repo):
if self.name == "new":
- self.Upload(ui, repo, gofmt_just_warn=True)
+ self.Upload(ui, repo, gofmt_just_warn=True, creating=True)
dir = CodeReviewDir(ui, repo)
path = dir + '/cl.' + self.name
f = open(path+'!', "w")
@@ -279,8 +279,8 @@ class CL(object):
typecheck(s, str)
return s
- def Upload(self, ui, repo, send_mail=False, gofmt=True, gofmt_just_warn=False):
- if not self.files:
+ def Upload(self, ui, repo, send_mail=False, gofmt=True, gofmt_just_warn=False, creating=False, quiet=False):
+ if not self.files and not creating:
ui.warn("no files in change list\n")
if ui.configbool("codereview", "force_gofmt", True) and gofmt:
CheckFormat(ui, repo, self.files, just_warn=gofmt_just_warn)
@@ -292,15 +292,20 @@ class CL(object):
("cc", JoinComma(self.cc)),
("description", self.desc),
("base_hashes", ""),
- # Would prefer not to change the subject
- # on reupload, but /upload requires it.
- ("subject", self.Subject()),
]
if self.name != "new":
form_fields.append(("issue", self.name))
vcs = None
- if self.files:
+ # We do not include files when creating the issue,
+ # because we want the patch sets to record the repository
+ # and base revision they are diffs against. We use the patch
+ # set message for that purpose, but there is no message with
+ # the first patch set. Instead the message gets used as the
+ # new CL's overall subject. So omit the diffs when creating
+ # and then we'll run an immediate upload.
+ # This has the effect that every CL begins with an empty "Patch set 1".
+ if self.files and not creating:
vcs = MercurialVCS(upload_options, ui, repo)
data = vcs.GenerateDiff(self.files)
files = vcs.GetBaseFiles(data)
@@ -311,6 +316,12 @@ class CL(object):
uploaded_diff_file = [("data", "data.diff", data)]
else:
uploaded_diff_file = [("data", "data.diff", emptydiff)]
+
+ if vcs and self.name != "new":
+ form_fields.append(("subject", "diff -r " + vcs.base_rev + " " + getremote(ui, repo, {}).path))
+ else:
+ # First upload sets the subject for the CL itself.
+ form_fields.append(("subject", self.Subject()))
ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file)
response_body = MySend("/upload", body, content_type=ctype)
patchset = None
@@ -320,7 +331,10 @@ class CL(object):
msg = lines[0]
patchset = lines[1].strip()
patches = [x.split(" ", 1) for x in lines[2:]]
- ui.status(msg + "\n")
+ if response_body.startswith("Issue updated.") and quiet:
+ pass
+ else:
+ ui.status(msg + "\n")
set_status("uploaded CL metadata + diffs")
if not response_body.startswith("Issue created.") and not response_body.startswith("Issue updated."):
raise util.Abort("failed to update issue: " + response_body)
@@ -342,14 +356,15 @@ class CL(object):
self.Flush(ui, repo)
return
- def Mail(self, ui,repo):
+ def Mail(self, ui, repo):
pmsg = "Hello " + JoinComma(self.reviewer)
if self.cc:
pmsg += " (cc: %s)" % (', '.join(self.cc),)
pmsg += ",\n"
pmsg += "\n"
+ repourl = getremote(ui, repo, {}).path
if not self.mailed:
- pmsg += "I'd like you to review this change.\n"
+ pmsg += "I'd like you to review this change to\n" + repourl + "\n"
else:
pmsg += "Please take another look.\n"
typecheck(pmsg, str)
@@ -1082,7 +1097,10 @@ def change(ui, repo, *pats, **opts):
dirty[cl] = True
for d, _ in dirty.items():
+ name = d.name
d.Flush(ui, repo)
+ if name == "new":
+ d.Upload(ui, repo, quiet=True)
if opts["stdout"]:
ui.write(cl.EditorText())
@@ -1124,15 +1142,12 @@ def clpatch(ui, repo, clname, **opts):
if err != "":
return err
try:
- cmd = subprocess.Popen(argv, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None, close_fds=True)
+ cmd = subprocess.Popen(argv, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None, close_fds=sys.platform != "win32")
except:
return "hgpatch: " + ExceptionDetail()
- if os.fork() == 0:
- cmd.stdin.write(patch)
- os._exit(0)
- cmd.stdin.close()
- out = cmd.stdout.read()
- if cmd.wait() != 0 and not opts["ignore_hgpatch_failure"]:
+
+ out, err = cmd.communicate(patch)
+ if cmd.returncode != 0 and not opts["ignore_hgpatch_failure"]:
return "hgpatch failed"
cl.local = True
cl.files = out.strip().split()
diff --git a/lib/godoc/package.html b/lib/godoc/package.html
index 570ae4016..4205f9315 100644
--- a/lib/godoc/package.html
+++ b/lib/godoc/package.html
@@ -5,7 +5,7 @@
-->
{.section PAst}
- <pre>{@ FSet|html}</pre>
+ <pre>{@ FSet|html-esc}</pre>
{.end}
{.section PDoc}
<!-- PackageName is printed as title by the top-level template -->
@@ -31,46 +31,45 @@
<h2 id="Constants">Constants</h2>
{.repeated section @}
{Doc|html-comment}
- <pre>{Decl FSet|html}</pre>
+ <pre>{Decl FSet|html-esc}</pre>
{.end}
{.end}
{.section Vars}
<h2 id="Variables">Variables</h2>
{.repeated section @}
{Doc|html-comment}
- <pre>{Decl FSet|html}</pre>
+ <pre>{Decl FSet|html-esc}</pre>
{.end}
{.end}
{.section Funcs}
{.repeated section @}
{# Name is a string - no need for FSet}
<h2 id="{Name|html-esc}">func <a href="/{Decl FSet|url-pos}">{Name|html-esc}</a></h2>
- <p><code>{Decl FSet|html}</code></p>
+ <p><code>{Decl FSet|html-esc}</code></p>
{Doc|html-comment}
{.end}
{.end}
{.section Types}
{.repeated section @}
- {# Type.Name is a string - no need for FSet}
<h2 id="{Type.Name FSet|html-esc}">type <a href="/{Decl FSet|url-pos}">{Type.Name FSet|html-esc}</a></h2>
{Doc|html-comment}
- <p><pre>{Decl FSet|html}</pre></p>
+ <p><pre>{Decl FSet|html-esc}</pre></p>
{.repeated section Consts}
{Doc|html-comment}
- <pre>{Decl FSet|html}</pre>
+ <pre>{Decl FSet|html-esc}</pre>
{.end}
{.repeated section Vars}
{Doc|html-comment}
- <pre>{Decl FSet|html}</pre>
+ <pre>{Decl FSet|html-esc}</pre>
{.end}
{.repeated section Factories}
<h3 id="{Type.Name FSet|html-esc}.{Name|html-esc}">func <a href="/{Decl FSet|url-pos}">{Name|html-esc}</a></h3>
- <p><code>{Decl FSet|html}</code></p>
+ <p><code>{Decl FSet|html-esc}</code></p>
{Doc|html-comment}
{.end}
{.repeated section Methods}
- <h3 id="{Type.Name FSet|html-esc}.{Name|html-esc}">func ({Recv FSet|html}) <a href="/{Decl FSet|url-pos}">{Name|html-esc}</a></h3>
- <p><code>{Decl FSet|html}</code></p>
+ <h3 id="{Type.Name FSet|html-esc}.{Name|html-esc}">func ({Recv FSet|html-esc}) <a href="/{Decl FSet|url-pos}">{Name|html-esc}</a></h3>
+ <p><code>{Decl FSet|html-esc}</code></p>
{Doc|html-comment}
{.end}
{.end}