Edgewall Software

Ticket #199 (closed enhancement: fixed)

Opened 4 years ago

Last modified 3 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:

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

python.patch (11.1 kB) - added by agr30@… 4 years ago.
New "anydiff" module
templates.patch (6.2 kB) - added by agr30@… 4 years ago.
Templates for anydiff
diff_module_alpha1.diff (28.9 kB) - added by cboos 3 years ago.
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)
diff_module_alpha2.diff (32.1 kB) - added by cboos 3 years ago.
Improved upon alpha1 -- test this one, ignore the previous one
.2 (0 bytes) - added by cboos 3 years ago.
Third iteration, added the UI for arbitrary diff
diff_module_alpha3.diff (34.6 kB) - added by cboos 3 years ago.
Third iteration, added the UI for arbitrary diff (attachment is there now)
diff_module_beta1.diff (38.5 kB) - added by cboos 3 years ago.
Things begin to look good (patch against [1756])

Change History

Changed 4 years ago by rocky

  • owner changed from jonas to rocky
  • status changed from new to assigned

Changed 4 years ago by rocky

  • owner changed from rocky to jonas

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.

Changed 4 years ago by daniel

  • priority changed from normal to high
  • milestone set to 0.8

Changed 4 years ago by anonymous

  • milestone changed from 0.8 to 1.0

Changed 4 years ago by anonymous

  • priority changed from high to highest

Changed 4 years ago by daniel

  • priority changed from highest to normal

Changed 4 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.

Changed 4 years ago by agr30@…

New "anydiff" module

Changed 4 years ago by agr30@…

Templates for anydiff

Changed 4 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.

Changed 3 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

Changed 3 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).

Changed 3 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 3 years ago by cboos

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)

Changed 3 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:

  1. 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).
  2. Diff between revisions: given a path, shows the changes occuring between two revisions
  3. 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.

Changed 3 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.

Changed 3 years ago by anonymous

  • summary changed from recommended UI examples to Ability to diff between any 2 revisions of a file or directory

Changed 3 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 3 years ago by cboos

Improved upon alpha1 -- test this one, ignore the previous one

Changed 3 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 3 years ago by cboos

  • attachment .2 added

Third iteration, added the UI for arbitrary diff

Changed 3 years ago by cboos

Third iteration, added the UI for arbitrary diff (attachment is there now)

Changed 3 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 3 years ago by cboos

Things begin to look good (patch against [1756])

Changed 3 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?

Changed 3 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

Changed 3 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.

Changed 3 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

Changed 3 years ago by cboos

  • priority changed from high to highest
  • milestone changed from 1.0 to 0.9

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).

Changed 3 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

Changed 3 years ago by anonymous

  • status changed from assigned to closed
  • resolution set to worksforme
  • component changed from browser to search system

Changed 3 years ago by anonymous

  • status changed from closed to reopened
  • resolution worksforme deleted
  • component changed from search system to browser

Changed 3 years ago by cboos

  • priority changed from highest to normal
  • version changed from none to devel
  • component changed from browser to changeset view
  • severity changed from normal to major
  • milestone changed from 0.9 to 1.0

This will be post-poned to 1.0.

The TracDiff branch will be actively maintained meanwhile, and a patch for each released 0.9 version will be uploaded here.

Changed 3 years ago by cboos

This ticket depends on #2028. Go there for the patches against 0.9.x.

Changed 3 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.

Changed 3 years ago by mgood

jcarlson: the annotation support is requested in #629

Changed 3 years ago by cboos

  • keywords tracdiff added
  • priority changed from normal to high

Please test and provide feedback for source:sandbox/trac-diff

Changed 3 years ago by cmlenz

  • milestone changed from 1.0 to 0.10

Changed 3 years ago by cboos

  • status changed from reopened to closed
  • resolution set to fixed

Feature now available for Trac 0.10 (since r2808).

Add/Change #199 (Ability to diff between any 2 revisions of a file or directory)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.