Ticket #199 (closed enhancement: fixed)
Opened 8 years ago
Last modified 6 years ago
Ability to diff between any 2 revisions of a file or directory
| Reported by: | anonymous | Owned by: | cboos |
|---|---|---|---|
| Priority: | high | Milestone: | 0.10 |
| Component: | version control/changeset view | Version: | devel |
| Severity: | major | Keywords: | tracdiff |
| Cc: | |||
| Release Notes: | |||
| API Changes: | |||
Description
Would be a very nice feature to be able to diff between any 2 revs of a file, as opposed to just the immediate previous changes
Attachments
Change History
comment:1 Changed 8 years ago by rocky
- Owner changed from jonas to rocky
- Status changed from new to assigned
comment:2 Changed 8 years ago by rocky
- Owner changed from rocky to jonas
comment:3 Changed 8 years ago by daniel
- Milestone set to 0.8
- Priority changed from normal to high
comment:4 Changed 8 years ago by anonymous
- Milestone changed from 0.8 to 1.0
comment:5 Changed 7 years ago by anonymous
- Priority changed from high to highest
comment:6 Changed 7 years ago by daniel
- Priority changed from highest to normal
comment:7 Changed 7 years ago by agr30@…
Crude hack to make this work for now. It reuses the changeset code to get and show the diff. No checking of variables, so you should probably use it in a closed environment only.
Apply the patches and browse the revision log of a file. Select the "A" and "B" revisions to be compared and use the submit button.
comment:8 Changed 7 years ago by cmlenz
- Summary changed from Ability to diff between any 2 revs of a file to Ability to diff between any 2 revisions of a file or directory
Should work for directories too.
comment:9 Changed 7 years ago by cboos
TracLinks syntax proposal for generalized diffs:
- diff:trunk/trac#1550 : diff from revision 1550 to the head
- diff:trunk/trac#1550:1560 : diff from revision 1550 to revision 1560
- diff:branches/cboos-dev/intertrac-branch : diff from initial revision (add or copy) to the head (i.e. show the diffs accumulated on a branch since its creation)
- diff:branches/cboos-dev/intertrac-branch//trunk : diff from latest revision on the first path to the latest rev on the second path
- diff:branches/cboos-dev/intertrac-branch#1500//trunk : diff from revision 1500 on the first path to the latest rev on the second path
- diff:branches/cboos-dev/intertrac-branch#1500//trunk#1600 : diff from revision 1500 on the first path to the revision 1600 on the second path
comment:10 Changed 7 years ago by anonymous
The patches have a minor problem - the unified diff link at the bottom of the page does not work. The arguments 'a' and 'b' are not set for that call. Here's the python traceback:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/trac/ModPythonHandler.py", line 195, in handler
core.dispatch_request(mpr.path_info, args, mpr, env)
File "./core.py", line 442, in dispatch_request
File "/usr/lib/python2.3/site-packages/trac/Module.py", line 46, in run
disp()
File "/usr/lib/python2.3/site-packages/trac/Anydiff.py", line 229, in display_diff
self.render_diffs(UnifiedDiffEditor)
File "/usr/lib/python2.3/site-packages/trac/Anydiff.py", line 200, in render_diffs
old_root = svn.fs.revision_root(self.fs_ptr, int(self.args.get('a')), self.pool)
ValueError: invalid literal for int():
args contains nothing on the call to render_diffs in this case (but the HTML diffs call contains the correct arguments).
comment:11 Changed 7 years ago by cboos
- Owner changed from jonas to cboos
- Status changed from assigned to new
I'll have a try on this one, with a simple web interface in the log view,
to begin with.
Changed 7 years ago by cboos
- Attachment diff_module_alpha1.diff added
For your testing pleasure, this is my initial attempt. It's not 100% robust, but it does show the new interface and ideas (see follow-up comment)
comment:12 Changed 7 years ago by cboos
- Priority changed from normal to high
- Status changed from new to assigned
An initial version of the Diff module has been attached.
The Diff module
It is a derivative of the Changeset module, and it operates in 3 modes:
- Path history mode: same as the normal Changeset view, but focusing on a given path. Handy for "scrolling" on the changes for a given file (TODO: in order to work correctly, should take the sequence of revisions from the history of that path).
- Diff between revisions: given a path, shows the changes occuring between two revisions
- Arbitrary diff': given two (path,revision) pairs, shows the diffs occuring between them
As the last two modes deal with more than a changeset, no
changeset information is shown (except links to the old
and new changesets).
The Web UI
For the Path History Mode
There's a Diff to previous link in the Browser View.
Then, in the Diff View there are links for the Previous Diff
and the Next Diff, so that one can easily examine the sequence
of changes that happened on a given path.
For the Diff between Revisions
The Log View has a link Select for Diff, which
expands the current log view with selectors for the
old and new revisions.
Then, after selecting those revisions and clicking on Diff,
the Diff View opens.
For the Arbitrary Diff
No UI yet, but I intend to give the possibility to remember
the current path displayed in the Log View as a base for
diffing against it.
P.S.: This is work in progress, mainly for getting early feedback
I'm not sure if the patch will apply cleanly, because
I did a
svn copy trac/Changeset.py trac/Diff.py svn copy templates/changeset.cs templates/diff.cs
and those operations are apparently not marked as such in the .diff
(svn 1.1.1 bug?). If this is a problem, simply create the initial version
of the diff files by copying the changeset files.
comment:13 Changed 7 years ago by anonymous
- Summary changed from Ability to diff between any 2 revisions of a file or directory to recommended UI examples
This is a really essential feature in version control web browsers such as viewcvs and mediawiki.
For a UI, I would suggest the use of radio buttons like mediawiki. For example, Wikipedia Subversion History. All of the dynamic Javascript is not necessary--just the radio buttons and a "Diff" button.
I would not so much recommend the viewcvs UI. For example, Apache 1.3 README history. This is not as usable.
comment:14 Changed 7 years ago by anonymous
- Summary changed from recommended UI examples to Ability to diff between any 2 revisions of a file or directory
comment:15 Changed 7 years ago by cboos
Actually, what I did is closer to the Wikipedia model
(as the original patch did).
Here's the second iteration of the patch,
which handles better additions and changes...
Changed 7 years ago by cboos
- Attachment diff_module_alpha2.diff added
Improved upon alpha1 -- test this one, ignore the previous one
comment:16 Changed 7 years ago by cboos
diff_module: alpha3
I added an UI for the Arbitrary Diff:
There's now a possibility to select the current Path/Revision?
in the Log View and to keep that selection in the session.
Then, in the Log View for another Path/Revision?,
one can Diff against the currently selected base.
Maybe I should add that Diff panel in the Browser View too,
so that one is not forced to go to the Log View in order to
perform a diff between branches...
Changed 7 years ago by cboos
- Attachment diff_module_alpha3.diff added
Third iteration, added the UI for arbitrary diff (attachment is there now)
comment:17 Changed 7 years ago by anonymous
diff_module: beta1
Things begin to look good, functionality wise.
- Added support for diff and zip format
- Added the possibility to select the base for diff in the browser too. This is very convenient.
- + various fixes
Changed 7 years ago by cboos
- Attachment diff_module_beta1.diff added
Things begin to look good (patch against [1756])
comment:18 Changed 7 years ago by anonymous
ok, noob question: how I do apply the .patch or .diff file(s) to my own trac install? :) and which ones do I apply?
comment:19 Changed 7 years ago by anonymous
$ cd <somewhere>/trac-trunk $ ls htdocs/ templates/ trac/ README ... # # Applying the patch # $ cp trac/Changeset.py trac/Diff.py $ cp templates/changeset.cs templates/diff.cs $ patch -p0 < diff_module_beta1.diff # # To install and run (with tracd) # $ python setup.py install --prefix=/opt/trac-0.9pre-diff-module $ export PYTHONPATH=/opt/trac-0.9pre-diff-module/lib/site-packages $ /opt/trac-0.9pre-diff-module/scripts/tracd -p 8008 $TRAC_ENV
comment:20 Changed 7 years ago by cboos
Ok, work on this topic goes on there:
source:branches/cboos-dev/anydiff-branch
The last patch (diff_module_beta1.diff) is available in [1761] as well.
comment:21 Changed 7 years ago by chris@…
I cannot diff against the previous version using the link provided named "Diff to previous" it throws this error. The good news is that if I go to the revision history of a file I can diff between those revisions using the radio buttons.
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/trac/web/modpython_frontend.py", line 265, in handler
dispatch_request(mpr.path_info, mpr, env)
File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 419, in dispatch_request
dispatcher.dispatch(req)
File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 283, in dispatch
resp = chosen_handler.process_request(req)
File "/usr/lib/python2.3/site-packages/trac/Diff.py", line 90, in process_request
chgset = repos.get_changeset(rev)
File "/usr/lib/python2.3/site-packages/trac/versioncontrol/cache.py", line 49, in get_changeset
return CachedChangeset(rev, self.db, self.authz)
File "/usr/lib/python2.3/site-packages/trac/versioncontrol/cache.py", line 130, in __init__
date, author, message = cursor.fetchone()
TypeError: unpack non-sequence
comment:22 Changed 7 years ago by cboos
- Milestone changed from 1.0 to 0.9
- Priority changed from high to highest
That's an expected error for the diff_module_beta1.diff patch.
Since then, a lot of work has been done on the branch.
You should try against source:branches/cboos-dev/anydiff-branch
(since revision [1777]), everything should work
(see also the TracDiff page for the documentation).
comment:23 Changed 7 years ago by chris@…
I just installed from your anydiff-branch [1803] and everything seems to be working. I caught your post on the mailing list about the "set base for diff" button holding state in the web pages.
I'll have to use this for a while before I weigh in with my thoughts. I'll keep you informed on the mailing list.
Cheers,
Chris
comment:24 Changed 7 years ago by anonymous
- Component changed from browser to search system
- Resolution set to worksforme
- Status changed from assigned to closed
comment:25 Changed 7 years ago by anonymous
- Component changed from search system to browser
- Resolution worksforme deleted
- Status changed from closed to reopened
comment:26 Changed 6 years ago by cboos
- Component changed from browser to changeset view
- Milestone changed from 0.9 to 1.0
- Priority changed from highest to normal
- Severity changed from normal to major
- Version changed from none to devel
comment:27 Changed 6 years ago by cboos
This ticket depends on #2028. Go there for the patches against 0.9.x.
comment:28 Changed 6 years ago by jcarlson@…
Perhaps this has already been addressed, but with the ability to fetch an arbitrary diff between files, it doesn't seem out of line to list the the user/revision of the line changes for the diff (and/or entire original file, in the case of a ViewCVS annotate-like functionality), when such things are applicable.
comment:29 Changed 6 years ago by mgood
jcarlson: the annotation support is requested in #629
comment:30 Changed 6 years ago by cboos
- Keywords tracdiff added
- Priority changed from normal to high
Please test and provide feedback for source:sandbox/trac-diff
comment:31 Changed 6 years ago by cmlenz
- Milestone changed from 1.0 to 0.10
comment:32 Changed 6 years ago by cboos
- Resolution set to fixed
- Status changed from reopened to closed



Going to remove this from my plate for the time being. I may come back to this later on, but if not, its open for anyone else.