Mercurial > hg
comparison mercurial/hgweb/webutil.py @ 21122:50981ce36236
hgweb: show as same parents as "hg parents -r REV FILE" in pages for file
Before this patch, "parents" in pages for file doesn't show as same
parents as "hg parents -r REV FILE", when the specified file is not
modified in the specified revision.
For example, it is assumed that revision A, B and D change file "f".
changelog (A) ---> (B) ---> (C) ---> (D)
filelog "f" (x) ---> (y) ------------> (z)
"/file/D/f" invokes "webutil.parents()" with filectx(z) gotten from
changectx(D), and it returns changectx(B). This is as same result as
"hg parents -r D f".
In the other hand, "/file/C/f" invokes "webutil.parents()" with
filectx(y') gotten from changectx(C), and it returns changectx(A),
because filectx(y') is linked to changectx(B), and works like
filectx(y) in some cases.
In this case, revision B is hidden from users browsing file "f" in
revision C.
This patch shows as same parents as "hg parents -r REV FILE" in pages
for file, by making "webutil.parents()" return:
- "linkrev()"-ed revision only, if:
- specified context instance is "filectx" (because
"webutil.parents()" is invoked with changectx, too), and
- (1) the revision from which filectx is gotten and (2) the one to
which filectx is linked are different from each other
- revision gotten from "ctx.parents()", otherwise
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Thu, 17 Apr 2014 09:36:08 +0900 |
parents | 52e5aca15f0c |
children | 513d47905114 |
comparison
equal
deleted
inserted
replaced
21121:8c9e84b44221 | 21122:50981ce36236 |
---|---|
5 # | 5 # |
6 # This software may be used and distributed according to the terms of the | 6 # This software may be used and distributed according to the terms of the |
7 # GNU General Public License version 2 or any later version. | 7 # GNU General Public License version 2 or any later version. |
8 | 8 |
9 import os, copy | 9 import os, copy |
10 from mercurial import match, patch, error, ui, util, pathutil | 10 from mercurial import match, patch, error, ui, util, pathutil, context |
11 from mercurial.i18n import _ | 11 from mercurial.i18n import _ |
12 from mercurial.node import hex, nullid | 12 from mercurial.node import hex, nullid |
13 from common import ErrorResponse | 13 from common import ErrorResponse |
14 from common import HTTP_NOT_FOUND | 14 from common import HTTP_NOT_FOUND |
15 import difflib | 15 import difflib |
136 if util.safehasattr(s, 'path'): | 136 if util.safehasattr(s, 'path'): |
137 d['file'] = s.path() | 137 d['file'] = s.path() |
138 yield d | 138 yield d |
139 | 139 |
140 def parents(ctx, hide=None): | 140 def parents(ctx, hide=None): |
141 if (isinstance(ctx, context.basefilectx) and | |
142 ctx.changectx().rev() != ctx.linkrev()): | |
143 return _siblings([ctx._repo[ctx.linkrev()]], hide) | |
141 return _siblings(ctx.parents(), hide) | 144 return _siblings(ctx.parents(), hide) |
142 | 145 |
143 def children(ctx, hide=None): | 146 def children(ctx, hide=None): |
144 return _siblings(ctx.children(), hide) | 147 return _siblings(ctx.children(), hide) |
145 | 148 |