Skip to content

Commit

Permalink
hgserver: add test for fastannotate (bug 1504794); r=sheehan
Browse files Browse the repository at this point in the history
fastannotate has broken before. Let's add test coverage to ensure
it continues to work.

We already have a helper script in the test environment to set hgrc
options. However, it doesn't work with %include, which is a special
directive. Rather than complicate that script with %include
functionality, I wrote a simple, non-generic script to accomplish
what we need.

Differential Revision: https://phabricator.services.mozilla.com/D11131

--HG--
extra : moz-landing-system : lando
  • Loading branch information
indygreg committed Nov 6, 2018
1 parent 8088a06 commit affc558
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ansible/roles/docker-hg-web/files/enable-fastannotate
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python3.6
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os
import sys

repo = sys.argv[1]

with open(os.path.join(repo, '.hg', 'hgrc'), 'ab') as fh:
fh.write(b'\n%include /etc/mercurial/hgrc-fastannotate\n')
1 change: 1 addition & 0 deletions ansible/roles/docker-hg-web/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- name: install Docker support files
copy: src={{ item }} dest=/{{ item }} owner=root group=root mode=0755
with_items:
- enable-fastannotate
- entrypoint.py
- entrypoint-solo
- set-config-option
Expand Down
60 changes: 60 additions & 0 deletions hgserver/tests/test-fastannotate.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#require hgmodocker

$ . $TESTDIR/hgserver/tests/helpers.sh
$ hgmoenv
$ standarduser

$ hgmo create-repo mozilla-central scm_level_1
(recorded repository creation in replication log)
$ hgmo exec hgweb0 /var/hg/venv_replication/bin/vcsreplicator-consumer --wait-for-no-lag /etc/mercurial/vcsreplicator.ini
$ hgmo exec hgweb0 /enable-fastannotate /repo/hg/mozilla/mozilla-central

$ hg -q clone ssh://$SSH_SERVER:$HGPORT/mozilla-central
$ cd mozilla-central
$ cat > foo << EOF
> line0
> line1
> line2
> line3
> EOF
$ hg add foo
$ hg commit -m 'commit 1'
$ cat > foo << EOF
> line0
> line1 modified
> line2
> line3
> EOF
$ hg commit -m 'commit 2'
$ cat > foo << EOF
> line0
> line1 modified
> line2 modified
> line3
> EOF
$ hg commit -m 'commit 3'
$ hg -q push

$ hgmo exec hgweb0 /var/hg/venv_replication/bin/vcsreplicator-consumer --wait-for-no-lag /etc/mercurial/vcsreplicator.ini

$ http ${HGWEB_0_URL}mozilla-central/annotate/f01fe54ccaa1/foo | grep '<pre>'
<td class="followlines-btn-parent"><pre><a class="linenr" href="#l1"> 1</a></pre></td>
<td><pre>line0
<td class="followlines-btn-parent"><pre><a class="linenr" href="#l2"> 2</a></pre></td>
<td><pre>line1 modified
<td class="followlines-btn-parent"><pre><a class="linenr" href="#l3"> 3</a></pre></td>
<td><pre>line2
<td class="followlines-btn-parent"><pre><a class="linenr" href="#l4"> 4</a></pre></td>
<td><pre>line3

$ hgmo exec hgweb0 /var/hg/venv_hgweb/bin/hg --cwd /repo/hg/mozilla/mozilla-central --config fastannotate.modes=fastannotate fastannotate -r f01fe54ccaa1 foo
0: line0
1: line1 modified
0: line2
0: line3

$ hgmo exec hgweb0 ls /repo/hg/mozilla/mozilla-central/.hg/fastannotate/default
foo.l
foo.m

$ hgmo clean

0 comments on commit affc558

Please sign in to comment.