Opened 11 years ago
Closed 11 years ago
#11438 closed defect (fixed)
Wikilink to Git `log:[reponame]@[branch]` resolves branch to its tip in href
Reported by: | Owned by: | Jun Omae | |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.2 |
Component: | version control/log view | Version: | 1.0-stable |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
|
||
API Changes: | |||
Internal Changes: |
Description
Using the wiki syntax log:rjollos.git@t10138 to link to a named branch log in a git repository results in a rendered link with an href like /log/rjollos.git/?rev=cd20d667b7b19e3ddba88bb2406472b71de797c2
: the branch name "t10138" has been replaced with a reference to its current tip.
Using the unresolved branch name in the log reference would be preferable:
- It would allow users to bookmark the resulting link. Currently if a user bookmarks the resulting link, it will become "stale" as soon as the branch tip changes, and will no longer meet the user's expectation that it shows an up-to-date log of the t10138 branch.
- It would prevent "race conditions" which can cause the link to become stale. If a user visits a wiki page that contains the
log:
link, and then leaves that page open in a browser window, while another user commits and pushes changes to the t10138 branch, then the link will no longer point to the current branch tip without a page reload. If the user is very unlucky, the branch tip could even change during the lifecycle of the request to the wiki page, which means the link might even be stale right away.
This behavior is also inconsistent with browser:rjollos.git@t10138, which does result in a link to /browser/rjollos.git?rev=t10138
and therefore always points at the branch tip.
Attachments (0)
Change History (7)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Milestone: | → next-stable-1.0.x |
---|---|
Owner: | set to |
Status: | new → assigned |
Version: | → 1.0-stable |
Indeed. That is inconsistent between browser:
and log:
link.
-
trac/versioncontrol/web_ui/log.py
diff --git a/trac/versioncontrol/web_ui/log.py b/trac/versioncontrol/web_ui/log.py index 8898919..cb37fb0 100644
a b class LogModule(Component): 400 400 path or '/', 401 401 revs=str(revranges)) 402 402 else: 403 re v = repos.normalize_rev(revs)403 repos.normalize_rev(revs) # verify revision 404 404 href = formatter.href.log(repos.reponame or None, 405 path or '/', rev=rev )405 path or '/', rev=revs) 406 406 if query and '?' in href: 407 407 query = '&' + query[1:] 408 408 return tag.a(label, class_='source',
I try to add unit tests later.
follow-up: 4 comment:3 by , 11 years ago
Looks like the MercurialPlugin has the same inconsistency: log:jomae.hg@t10313-hashed-path (href has resolved SHA) vs browser:jomae.hg@t10313-hashed-path (⇒ ?rev=10313-hashed-path
) — I'll file that separately since it lives in its own repository.
follow-up: 5 comment:4 by , 11 years ago
Looks like the MercurialPlugin has the same inconsistency: log:jomae.hg@t10313-hashed-path (href has resolved SHA) vs browser:jomae.hg@t10313-hashed-path (⇒
?rev=10313-hashed-path
)
I know. It doesn't depend on repository type. e.g. log:@0000001 and log:@head vs browser:@0000001 and browser:@head on svn. Therefore, we shouldn't change git or mercurial components.
comment:5 by , 11 years ago
Replying to jomae:
Looks like the MercurialPlugin has the same inconsistency: log:jomae.hg@t10313-hashed-path (href has resolved SHA) vs browser:jomae.hg@t10313-hashed-path (⇒
?rev=10313-hashed-path
)I know. It doesn't depend on repository type. e.g. log:@0000001 and log:@head vs browser:@0000001 and browser:@head on svn. Therefore, we shouldn't change git or mercurial components.
Oh — right — whoops, sorry about that.
comment:6 by , 11 years ago
Milestone: | next-stable-1.0.x → 1.0.2 |
---|
Also the log page doesn't work with named revision ranges, e.g. /log/?revs=12445-head which currently revs
parameter is ignored and shows latest 100 revisions.
Proposed changes can be found in log:jomae.git:t11438.
comment:7 by , 11 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
This could be fixed by removing the call to
normalize_rev
in browser:trunk/trac/versioncontrol/web_ui/log.py#L403 (no similar call is made in thebrowser.py
's IWikiSyntaxProvider link resolving method)Or possibly the git plugin's
normalize_rev
function at browser:trunk/tracopt/versioncontrol/git/git_fs.py#L412 should be adjusted so that a providedrev
is considered already normalized if it refers uniquely to a named branch or tag? The docstring for normalize_rev in trac.versioncontrol.api suggests this is allowed:But I'm not sure if that would have negative consequences elsewhere.