summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/codereview/codereview.py33
-rw-r--r--lib/godoc/example.html4
-rw-r--r--lib/godoc/godoc.html14
-rw-r--r--lib/godoc/package.html18
-rw-r--r--lib/godoc/search.html10
5 files changed, 56 insertions, 23 deletions
diff --git a/lib/codereview/codereview.py b/lib/codereview/codereview.py
index 1f4952f17..61e2fd772 100644
--- a/lib/codereview/codereview.py
+++ b/lib/codereview/codereview.py
@@ -1247,9 +1247,28 @@ def MatchAt(ctx, pats=None, opts=None, globbed=False, default='relpath'):
#######################################################################
# Commands added by code review extension.
+# As of Mercurial 2.1 the commands are all required to return integer
+# exit codes, whereas earlier versions allowed returning arbitrary strings
+# to be printed as errors. We wrap the old functions to make sure we
+# always return integer exit codes now. Otherwise Mercurial dies
+# with a TypeError traceback (unsupported operand type(s) for &: 'str' and 'int').
+# Introduce a Python decorator to convert old functions to the new
+# stricter convention.
+
+def hgcommand(f):
+ def wrapped(ui, repo, *pats, **opts):
+ err = f(ui, repo, *pats, **opts)
+ if type(err) is int:
+ return err
+ if not err:
+ return 0
+ raise hg_util.Abort(err)
+ return wrapped
+
#######################################################################
# hg change
+@hgcommand
def change(ui, repo, *pats, **opts):
"""create, edit or delete a change list
@@ -1363,6 +1382,7 @@ def change(ui, repo, *pats, **opts):
#######################################################################
# hg code-login (broken?)
+@hgcommand
def code_login(ui, repo, **opts):
"""log in to code review server
@@ -1378,6 +1398,7 @@ def code_login(ui, repo, **opts):
# hg clpatch / undo / release-apply / download
# All concerned with applying or unapplying patches to the repository.
+@hgcommand
def clpatch(ui, repo, clname, **opts):
"""import a patch from the code review server
@@ -1392,6 +1413,7 @@ def clpatch(ui, repo, clname, **opts):
return "cannot run hg clpatch outside default branch"
return clpatch_or_undo(ui, repo, clname, opts, mode="clpatch")
+@hgcommand
def undo(ui, repo, clname, **opts):
"""undo the effect of a CL
@@ -1403,6 +1425,7 @@ def undo(ui, repo, clname, **opts):
return "cannot run hg undo outside default branch"
return clpatch_or_undo(ui, repo, clname, opts, mode="undo")
+@hgcommand
def release_apply(ui, repo, clname, **opts):
"""apply a CL to the release branch
@@ -1655,6 +1678,7 @@ def lineDelta(deltas, n, len):
d = newdelta
return d, ""
+@hgcommand
def download(ui, repo, clname, **opts):
"""download a change from the code review server
@@ -1674,6 +1698,7 @@ def download(ui, repo, clname, **opts):
#######################################################################
# hg file
+@hgcommand
def file(ui, repo, clname, pat, *pats, **opts):
"""assign files to or remove files from a change list
@@ -1739,6 +1764,7 @@ def file(ui, repo, clname, pat, *pats, **opts):
#######################################################################
# hg gofmt
+@hgcommand
def gofmt(ui, repo, *pats, **opts):
"""apply gofmt to modified files
@@ -1772,6 +1798,7 @@ def gofmt_required(files):
#######################################################################
# hg mail
+@hgcommand
def mail(ui, repo, *pats, **opts):
"""mail a change for review
@@ -1804,18 +1831,21 @@ def mail(ui, repo, *pats, **opts):
#######################################################################
# hg p / hg pq / hg ps / hg pending
+@hgcommand
def ps(ui, repo, *pats, **opts):
"""alias for hg p --short
"""
opts['short'] = True
return pending(ui, repo, *pats, **opts)
+@hgcommand
def pq(ui, repo, *pats, **opts):
"""alias for hg p --quick
"""
opts['quick'] = True
return pending(ui, repo, *pats, **opts)
+@hgcommand
def pending(ui, repo, *pats, **opts):
"""show pending changes
@@ -1851,6 +1881,7 @@ def pending(ui, repo, *pats, **opts):
def need_sync():
raise hg_util.Abort("local repository out of date; must sync before submit")
+@hgcommand
def submit(ui, repo, *pats, **opts):
"""submit change to remote repository
@@ -1983,6 +2014,7 @@ def submit(ui, repo, *pats, **opts):
#######################################################################
# hg sync
+@hgcommand
def sync(ui, repo, **opts):
"""synchronize with remote repository
@@ -2036,6 +2068,7 @@ def sync_changes(ui, repo):
#######################################################################
# hg upload
+@hgcommand
def upload(ui, repo, name, **opts):
"""upload diffs to the code review server
diff --git a/lib/godoc/example.html b/lib/godoc/example.html
index d7b219371..43ee4bddc 100644
--- a/lib/godoc/example.html
+++ b/lib/godoc/example.html
@@ -1,9 +1,9 @@
<div id="example_{{.Name}}" class="example">
<div class="collapsed">
- <p class="exampleHeading">▹ Example{{example_suffix .Name}}</p>
+ <p class="exampleHeading">▹ <span class="text">Example{{example_suffix .Name}}</span></p>
</div>
<div class="expanded">
- <p class="exampleHeading">▾ Example{{example_suffix .Name}}</p>
+ <p class="exampleHeading">▾ <span class="text">Example{{example_suffix .Name}}</span></p>
{{with .Doc}}<p>{{html .}}</p>{{end}}
<p>Code:</p>
<pre class="code">{{.Code}}</pre>
diff --git a/lib/godoc/godoc.html b/lib/godoc/godoc.html
index 09a2cc4c2..feb96e50f 100644
--- a/lib/godoc/godoc.html
+++ b/lib/godoc/godoc.html
@@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-{{with .Title}}
+{{with .Tabtitle}}
<title>{{html .}} - The Go Programming Language</title>
{{else}}
<title>The Go Programming Language</title>
@@ -15,10 +15,9 @@
</head>
<body>
-<div id="topbar"><div class="container">
+<div id="topbar"><div class="container{{if .Title}} wide{{end}}">
<form method="GET" action="/search">
-<div id="heading"><a href="/">The Go Programming Language</a></div>
<div id="menu">
<a href="/doc/">Documents</a>
<a href="/ref/">References</a>
@@ -27,13 +26,12 @@
<a href="/help/">Help</a>
<input type="text" id="search" name="q" class="inactive" value="Search">
</div>
+<div id="heading"><a href="/">The Go Programming Language</a></div>
</form>
</div></div>
-<div id="page">
-
-<div id="content">
+<div id="page"{{if .Title}} class="wide"{{end}}>
{{with .Title}}
<div id="plusone"><g:plusone size="small" annotation="none"></g:plusone></div>
@@ -52,8 +50,6 @@
</div>
-</div>
-
<div id="copyright">
Build version {{html .Version}}.
Except as noted, this content is licensed under a
@@ -61,7 +57,6 @@ Creative Commons Attribution 3.0 License.
</div>
</body>
-<!--
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
@@ -69,6 +64,5 @@ Creative Commons Attribution 3.0 License.
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
--->
</html>
diff --git a/lib/godoc/package.html b/lib/godoc/package.html
index fdebbf5d9..848e68df7 100644
--- a/lib/godoc/package.html
+++ b/lib/godoc/package.html
@@ -70,7 +70,7 @@
<p>
<span style="font-size:90%">
{{range .}}
- <a href="/{{.|srcLink}}">{{.|filename|html}}</a>
+ <a href="{{.|srcLink|html}}">{{.|filename|html}}</a>
{{end}}
</span>
</p>
@@ -93,7 +93,7 @@
{{range .Funcs}}
{{/* Name is a string - no need for FSet */}}
{{$name_html := html .Name}}
- <h2 id="{{$name_html}}">func <a href="/{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h2>
+ <h2 id="{{$name_html}}">func <a href="{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h2>
<pre>{{node_html .Decl $.FSet}}</pre>
{{comment_html .Doc}}
{{example_html .Name $.Examples $.FSet}}
@@ -101,7 +101,7 @@
{{range .Types}}
{{$tname := .Name}}
{{$tname_html := html .Name}}
- <h2 id="{{$tname_html}}">type <a href="/{{posLink_url .Decl $.FSet}}">{{$tname_html}}</a></h2>
+ <h2 id="{{$tname_html}}">type <a href="{{posLink_url .Decl $.FSet}}">{{$tname_html}}</a></h2>
<pre>{{node_html .Decl $.FSet}}</pre>
{{comment_html .Doc}}
@@ -119,7 +119,7 @@
{{range .Funcs}}
{{$name_html := html .Name}}
- <h3 id="{{$name_html}}">func <a href="/{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h3>
+ <h3 id="{{$name_html}}">func <a href="{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h3>
<pre>{{node_html .Decl $.FSet}}</pre>
{{comment_html .Doc}}
{{example_html .Name $.Examples $.FSet}}
@@ -127,7 +127,7 @@
{{range .Methods}}
{{$name_html := html .Name}}
- <h3 id="{{$tname_html}}.{{$name_html}}">func ({{html .Recv}}) <a href="/{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h3>
+ <h3 id="{{$tname_html}}.{{$name_html}}">func ({{html .Recv}}) <a href="{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h3>
<pre>{{node_html .Decl $.FSet}}</pre>
{{comment_html .Doc}}
{{$name := printf "%s_%s" $tname .Name}}
@@ -163,7 +163,13 @@
{{with .Dirs}}
{{/* DirList entries are numbers and strings - no need for FSet */}}
- {{if $.PDoc}}<h2 id="subdirectories">Subdirectories</h2>{{end}}
+ {{if $.PDoc}}
+ <h2 id="subdirectories">Subdirectories</h2>
+ {{else}}
+ <div class="pkgGopher">
+ <img class="gopher" src="/doc/gopher/pkg.png"/>
+ </div>
+ {{end}}
<table class="dir">
<tr>
<th>Name</th>
diff --git a/lib/godoc/search.html b/lib/godoc/search.html
index db90935d8..5b54d7126 100644
--- a/lib/godoc/search.html
+++ b/lib/godoc/search.html
@@ -38,7 +38,7 @@
{{$src_html := srcLink .File.Path | html}}
{{range .Groups}}
{{range .}}
- <a href="/{{$src_html}}?h={{$query_url}}#L{{infoLine .}}">{{$src_html}}:{{infoLine .}}</a>
+ <a href="{{$src_html}}?h={{$query_url}}#L{{infoLine .}}">{{$src_html}}:{{infoLine .}}</a>
{{infoSnippet_html .}}
{{end}}
{{end}}
@@ -52,7 +52,7 @@
<h3 id="Local_{{$pkg_html}}">package <a href="/{{$pkg_html}}">{{html .Pak.Name}}</a></h3>
{{range .Files}}
{{$src_html := srcLink .File.Path | html}}
- <a href="/{{$src_html}}?h={{$query_url}}">{{$src_html}}</a>
+ <a href="{{$src_html}}?h={{$query_url}}">{{$src_html}}</a>
<table class="layout">
{{range .Groups}}
<tr>
@@ -61,7 +61,7 @@
<td align="left" width="4"></td>
<td>
{{range .}}
- <a href="/{{$src_html}}?h={{$query_url}}#L{{infoLine .}}">{{infoLine .}}</a>
+ <a href="{{$src_html}}?h={{$query_url}}#L{{infoLine .}}">{{infoLine .}}</a>
{{end}}
</td>
</tr>
@@ -86,14 +86,14 @@
{{$src_html := srcLink .Filename | html}}
<tr>
<td align="left" valign="top">
- <a href="/{{$src_html}}?h={{$query_url}}">{{$src_html}}</a>:
+ <a href="{{$src_html}}?h={{$query_url}}">{{$src_html}}</a>:
</td>
<td align="left" width="4"></td>
<th align="left" valign="top">{{len .Lines}}</th>
<td align="left" width="4"></td>
<td align="left">
{{range .Lines}}
- <a href="/{{$src_html}}?h={{$query_url}}#L{{html .}}">{{html .}}</a>
+ <a href="{{$src_html}}?h={{$query_url}}#L{{html .}}">{{html .}}</a>
{{end}}
{{if not $.Complete}}
...