Opened 14 years ago
Closed 14 years ago
#610 closed defect (fixed)
Use repos.display_rev for revision numbers that are displayed in templates
Reported by: | trbs <trbs@…> | Owned by: | osimons |
---|---|---|---|
Priority: | major | Milestone: | 0.6 |
Component: | General | Version: | dev |
Keywords: | Cc: | felix.schwarz@… | |
Operating System: | BSD |
Description
When using version control systems that are based on hashes of changesets, like Mercurial or GIT the revision numbers are often shorted or alternatively formatted so that the user doesn't have to see the large hex.
Therefor I've added display_rev on several places in Bitten so that templates always display the formatted revision number.
For example in Mercurial the revision number now looks like:
386:b9d1f6a7318b
Instead of:
b9d1f6a7318b3300150d951a478448a3d03fb9df
Please look at the code and commit in: http://bitbucket.org/trbs/bitten/changeset/338389921ce0
The patch is also attached :)
Attachments (4)
Change History (21)
Changed 14 years ago by trbs <trbs@…>
comment:1 Changed 14 years ago by hodgestar
- Owner set to hodgestar
- Status changed from new to assigned
comment:2 Changed 14 years ago by trbs <trbs@…>
There is one addition for the timeline at: http://bitbucket.org/trbs/bitten/changeset/0a0bce41190a
comment:3 Changed 14 years ago by Felix Schwarz <felix.schwarz@…>
- Cc felix.schwarz@… added
comment:4 Changed 14 years ago by osimons
- Milestone changed from 0.6.1 to 0.6
Makes sense and looks good. A complete refreshed patch for a final "test & apply" will see that we can get this committed now before 0.6.
comment:5 Changed 14 years ago by Felix Schwarz <felix.schwarz@…>
When porting the patch to the latest 0.6 branch, I found some problems – The biggest one is that it causes 4 unit test errors because the Mock request does not have an attribute 'display_rev'. I verified that I ported the patch correctly by running the test suite from a clone of trbs' repository and I see even more failures there.
The problem should be relatively simple to fix but the patch can't go in as it is right now.
Changed 14 years ago by Felix Schwarz <felix.schwarz@…>
Updated patch (latest 0.6), still causes some test failures
comment:6 Changed 14 years ago by osimons
- Owner changed from hodgestar to osimons
- Status changed from assigned to new
Thanks Felix!
Looking at 0.11 and 0.12 tagged versions of trac.versioncontrol.api, I see that display_rev is a newer attribute available in 0.12. For 0.11 there is something called short_rev. However, both just do return self.normalize_rev(rev), so that is perhaps also what we should call directly - normalize_rev(rev) instead of repos.display_rev(rev).
Attached is a patch that uses this new call + updates the fake Mock repository implementations in tests to support the new method where needed.
Testing needed.
Changed 14 years ago by Felix Schwarz <felix.schwarz@…>
fix invalid method name - obviously the tests are not covering all of the code…
comment:7 Changed 14 years ago by Felix Schwarz <felix.schwarz@…>
So checked the patch against latest Trac 0.11 and I don't see any problems besides the one mentioned in comment 7.
However I'm also not seeing any change with the Mercurial plugin. I'm just assuming that it makes a difference for some people. I always saw the short hashes with trbs showed in the description. This is with hg 1.2 on CentOS 4 and 1.6 on Fedora 13. Maybe this also depends on the Mercurial Plugin? for trac?
comment:8 follow-up: ↓ 9 Changed 14 years ago by osimons
No, the tests don't really have 100% coverage... The timeline provider is not currently tested at all, and I don't think I hit 'Timeline' on my site while testing the patch visually. Anyway, thanks for discovering. I've updated the full patch.
As for what is displayed, I see the Trac project repository browser now also displays some Mercurial development repositories. They use revision numbers like 7132:d441086e653b everywhere. Is that what you get from Bitten now?
/me really needs to get a Mercurial development project running...
comment:9 in reply to: ↑ 8 Changed 14 years ago by Felix Schwarz <felix.schwarz@…>
Replying to osimons:
As for what is displayed, I see the Trac project repository browser now also displays some Mercurial development repositories. They use revision numbers like 7132:d441086e653b everywhere. Is that what you get from Bitten now?
Exactly – however I saw exactly the same format also before…
/me really needs to get a Mercurial development project running...
If you need some nice features for motivation: easy hunk-level commits (hg record), move your stuff aside to fix a small issue (hg shelve) and keep patches for an open source project where you can't commit yourself (hg patch queue). :-)
comment:10 Changed 14 years ago by osimons
- Milestone changed from 0.6 to 0.6.1
If the patch doesn't make any difference to the user experience, I don't really see the value of applying it. Anyway, suggesting we push this issue to a bit later.
comment:11 follow-up: ↓ 12 Changed 14 years ago by trbs <bitten@…>
Sorry I've been on vacation last view weeks.
So it does show normalized_rev numbers on Trac 0.11 ?
I've been using Trac 0.12 (with several patches / quickfixes to bitten to make that work) and in my environment the user experience was greatly enhanced by using normalized revision numbers instead of the full hashes.
If I remember correctly the only place where otherwise normalized version numbers where shown is in the timeline..
comment:12 in reply to: ↑ 11 Changed 14 years ago by Felix Schwarz <felix.schwarz@…>
Replying to trbs <bitten@…>:
So it does show normalized_rev numbers on Trac 0.11 ?
Yes I think so. Just have a look at the build page of pycerberus. My trac does not contain any of the patches mentioned in this ticket. This is with 0.11 though, I could check if 0.12 is different.
Which DVCS are you using? With version exactly?
comment:13 Changed 14 years ago by trbs <bitten@…>
That looks fine indeed, interestingly links are also in normalized format as well as the link urls.
I'm using Trac 0.12 with Trac Mercurial? 0.12.0.23dev-r9946
comment:14 Changed 14 years ago by trbs <bitten@…>
Running hg --version Mercurial Distributed SCM (version 1.6.3+2-b10b07a821c3)
comment:15 Changed 14 years ago by osimons
- Milestone changed from 0.6.1 to 0.6
Oh. Seems I misunderstood. This is now the conclusions it seems:
- Trac 0.11 users will not see the change, all things as before
- Trac 0.12 users will see simplified revisions for those back-ends that support it, it is nice, it is useful, and everyone cheers
Back on track then.
comment:16 Changed 14 years ago by trbs <bitten@…>
Hopefully somebody can confirm my findings with Trac 0.12 :)
I've taken a quick look at Trac Mercurial? plugin this afternoon and could not find why it would make a difference between 0.11 and 0.12.
Originally I had chosen display_rev because of the comments on the API
Return a representation of a revision in the repos for displaying to the user.
vs
Return a (unique) canonical representation of a revision.
Thinking that it might be better because other back-ends could have differences between normalize_rev and display_rev.
Lastly should bitten/web_ui.py: "display_rev = repos.normalize_revv(rev)" not be surrounded by a try-catch ? just in case ?
I had problems because I migrated from SVN to Mercurial. Thus having svn revision id's which it wants to lookup in mercurial raising a Change Set Not Found? exception.
comment:17 Changed 14 years ago by osimons
- Resolution set to fixed
- Status changed from new to closed
Committed in [912]. Thanks both for work on this issue.
Looks good.