# HG changeset patch # User FUJIWARA Katsunori # Date 2014-04-17 00:36:09 # Node ID 92fab48dfec16c9ad085e2ca50dbaa18359e661a # Parent 50981ce3623672f4644248d7a16497f0063cae44 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 @@ def comparison(web, req, tmpl): 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 @@ diff modified file 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 @@ comparison new file -1:000000000000 - 0:b789fdd96dc2 + 0:0cd96de13884 @@ -697,6 +701,12 @@ comparison existing file 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 @@ comparison existing file - - + + @@ -820,6 +830,12 @@ comparison removed file $ 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 @@ comparison removed file
0:b789fdd96dc21:a80d06849b331:559edbd9ed202:d73db4d812ff
- - + + @@ -947,13 +963,13 @@ comparison not-modified file $ 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 @@ comparison not-modified file
1:a80d06849b33-1:0000000000002:d73db4d812ff3:20e80271eb7a
- - + +
0:6b67ccefd5ce0:6b67ccefd5ce4:402bea3b09765:41d9fc4a6ae1