Edgewall Software
Modify

Opened 21 years ago

Closed 19 years ago

#199 closed enhancement (fixed)

Ability to diff between any 2 revisions of a file or directory

Reported by: anonymous Owned by: Christian Boos
Priority: high Milestone: 0.10
Component: version control/changeset view Version: devel
Severity: major Keywords: tracdiff
Cc: Branch:
Release Notes:
API Changes:
Internal 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 (7)

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

Download all attachments as: .zip

Change History (39)

comment:1 by rocky, 21 years ago

Owner: changed from Jonas Borgström to rocky
Status: newassigned

comment:2 by rocky, 21 years ago

Owner: changed from rocky to Jonas Borgström

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.

comment:3 by daniel, 21 years ago

Milestone: 0.8
Priority: normalhigh

comment:4 by anonymous, 20 years ago

Milestone: 0.81.0

comment:5 by anonymous, 20 years ago

Priority: highhighest

comment:6 by daniel, 20 years ago

Priority: highestnormal

comment:7 by agr30@…, 20 years ago

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.

by agr30@…, 20 years ago

Attachment: python.patch added

New "anydiff" module

by agr30@…, 20 years ago

Attachment: templates.patch added

Templates for anydiff

comment:8 by Christopher Lenz, 20 years ago

Summary: Ability to diff between any 2 revs of a fileAbility to diff between any 2 revisions of a file or directory

Should work for directories too.

comment:9 by Christian Boos, 20 years ago

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 by anonymous, 20 years ago

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 by Christian Boos, 19 years ago

Owner: changed from Jonas Borgström to Christian Boos
Status: assignednew

I'll have a try on this one, with a simple web interface in the log view, to begin with.

by Christian Boos, 19 years ago

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 by Christian Boos, 19 years ago

Priority: normalhigh
Status: newassigned

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.

comment:13 by anonymous, 19 years ago

Summary: Ability to diff between any 2 revisions of a file or directoryrecommended 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 by anonymous, 19 years ago

Summary: recommended UI examplesAbility to diff between any 2 revisions of a file or directory

comment:15 by Christian Boos, 19 years ago

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…

by Christian Boos, 19 years ago

Attachment: diff_module_alpha2.diff added

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

comment:16 by Christian Boos, 19 years ago

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…

by Christian Boos, 19 years ago

Attachment: .2 added

Third iteration, added the UI for arbitrary diff

by Christian Boos, 19 years ago

Attachment: diff_module_alpha3.diff added

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

comment:17 by anonymous, 19 years ago

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

by Christian Boos, 19 years ago

Attachment: diff_module_beta1.diff added

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

comment:18 by anonymous, 19 years ago

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 by anonymous, 19 years ago

$ 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 by Christian Boos, 19 years ago

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 by chris@…, 19 years ago

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 by Christian Boos, 19 years ago

Milestone: 1.00.9
Priority: highhighest

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 by chris@…, 19 years ago

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 by anonymous, 19 years ago

Component: browsersearch system
Resolution: worksforme
Status: assignedclosed

comment:25 by anonymous, 19 years ago

Component: search systembrowser
Resolution: worksforme
Status: closedreopened

comment:26 by Christian Boos, 19 years ago

Component: browserchangeset view
Milestone: 0.91.0
Priority: highestnormal
Severity: normalmajor
Version: nonedevel

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.

comment:27 by Christian Boos, 19 years ago

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

comment:28 by jcarlson@…, 19 years ago

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 by Matthew Good, 19 years ago

jcarlson: the annotation support is requested in #629

comment:30 by Christian Boos, 19 years ago

Keywords: tracdiff added
Priority: normalhigh

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

comment:31 by Christopher Lenz, 19 years ago

Milestone: 1.00.10

comment:32 by Christian Boos, 19 years ago

Resolution: fixed
Status: reopenedclosed

Feature now available for Trac 0.10 (since r2808).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.