From patchwork Thu Apr 17 00:42:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4, of, 5, STABLE] hgweb: show revisions and hashes gotten from changelog in "comparison" page From: Katsunori FUJIWARA X-Patchwork-Id: 4390 Message-Id: <68c7dfb8906d8968ede7.1397695345@juju> To: mercurial-devel@selenic.com Date: Thu, 17 Apr 2014 09:42:25 +0900 # HG changeset patch # User FUJIWARA Katsunori # Date 1397694969 -32400 # Thu Apr 17 09:36:09 2014 +0900 # Branch stable # Node ID 68c7dfb8906d8968ede7bf7d1fda6282fa24a141 # Parent 9609e6d8302abb6e2108057d5204f249a4e5155d hgweb: show revisions and hashes gotten from changelog in "comparison" page Before this patch, revision numbers and hash values in "comparison" page are gotten from not changelog but filelog. Such filelog information is useful only for hgweb debugging, and may confuse users. This patch shows revision numbers and hash values gotten from changelog in "comparison" page. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -8,7 +8,7 @@ import os, mimetypes, re, cgi, copy import webutil from mercurial import error, encoding, archival, templater, templatefilters -from mercurial.node import short, hex, nullid +from mercurial.node import short, hex from mercurial import util from common import paritygen, staticfile, get_contact, ErrorResponse from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND @@ -712,28 +712,22 @@ return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))] return f.data().splitlines() + parent = ctx.p1() + leftrev = parent.rev() + leftnode = parent.node() + rightrev = ctx.rev() + rightnode = ctx.node() if path in ctx: fctx = ctx[path] - rightrev = fctx.filerev() - rightnode = fctx.filenode() rightlines = filelines(fctx) - parent = ctx.p1() if path not in parent: - leftrev = -1 - leftnode = nullid leftlines = () else: pfctx = parent[path] - leftrev = pfctx.filerev() - leftnode = pfctx.filenode() leftlines = filelines(pfctx) else: - rightrev = -1 - rightnode = nullid rightlines = () fctx = ctx.parents()[0][path] - leftrev = fctx.filerev() - leftnode = fctx.filenode() leftlines = filelines(fctx) comparison = webutil.compare(tmpl, context, leftlines, rightlines) diff --git a/tests/test-hgweb-diffs.t b/tests/test-hgweb-diffs.t --- a/tests/test-hgweb-diffs.t +++ b/tests/test-hgweb-diffs.t @@ -576,6 +576,10 @@ comparison new file + $ hg parents --template "{rev}:{node|short}\n" -r 0 + $ hg log --template "{rev}:{node|short}\n" -r 0 + 0:0cd96de13884 + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'comparison/0/a' 200 Script output follows @@ -667,7 +671,7 @@ -1:000000000000 - 0:b789fdd96dc2 + 0:0cd96de13884 @@ -697,6 +701,12 @@ 1 files updated, 0 files merged, 1 files removed, 0 files unresolved $ echo a >> a $ hg ci -mc + + $ hg parents --template "{rev}:{node|short}\n" -r tip + 1:559edbd9ed20 + $ hg log --template "{rev}:{node|short}\n" -r tip + 2:d73db4d812ff + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'comparison/tip/a' 200 Script output follows @@ -787,8 +797,8 @@ - - + + @@ -820,6 +830,12 @@ $ hg rm a $ hg ci -md + + $ hg parents --template "{rev}:{node|short}\n" -r tip + 2:d73db4d812ff + $ hg log --template "{rev}:{node|short}\n" -r tip + 3:20e80271eb7a + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'comparison/tip/a' 200 Script output follows @@ -910,8 +926,8 @@
0:b789fdd96dc21:a80d06849b331:559edbd9ed202:d73db4d812ff
- - + + @@ -947,13 +963,13 @@ $ echo f > f $ hg add f $ hg ci -m f - $ hg tip --template "{node|short}\n" - 41d9fc4a6ae1 + $ hg tip --template "{rev}:{node|short}\n" + 5:41d9fc4a6ae1 $ hg diff -c tip e - $ hg parents --template "{node|short}\n" -r tip - 402bea3b0976 - $ hg parents --template "{node|short}\n" -r tip e - 402bea3b0976 + $ hg parents --template "{rev}:{node|short}\n" -r tip + 4:402bea3b0976 + $ hg parents --template "{rev}:{node|short}\n" -r tip e + 4:402bea3b0976 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'comparison/tip/e' 200 Script output follows @@ -1045,8 +1061,8 @@
1:a80d06849b33-1:0000000000002:d73db4d812ff3:20e80271eb7a
- - + +
0:6b67ccefd5ce0:6b67ccefd5ce4:402bea3b09765:41d9fc4a6ae1