[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

svn diff cleanup

From: Ben Collins-Sussman <sussman_at_collab.net>
Date: 2002-04-16 00:21:02 CEST

OK, so maybe I misunderstood the 'svn diff' problem. This morning I
pronounced (with great hubris) that I could make 'svn diff' compare
two arbitrary URLs in just half an hour's work. After all, 'svn
merge' does so, and the two functions share a whole lot of code.

Indeed, making 'svn diff' call RA->do_switch (which uses 2 URLs)
instead of RA->do_update, was a trivial thing. But then I discovered
the tangled morass all of code leading *up* to that call. It's really
complicated and full of outdated assumptions. :-)

Karl giggled at me, and I made the analogy: 'svn merge' is a very
clean, simple thing, because it's not used very often. Much like rare
verbs in a spoken language -- they're easy to conjugate. But 'svn
diff' is full of shortcuts and complex use-cases. It's like an
irregular verb, because it's used so often. People need the shortcuts.

After diddling on the whiteboard for a while, I think we came up with
a clear, unambiguous syntax. Here's the interface description that
would be printed by 'svn help diff':

------------------------------------------------------------
diff (di): display the differences between two paths.
usage: 1. svn diff [-r N[:M]] [PATH1 [PATH2 [PATH3 ...]]]
       2. svn diff URL1[@N] URL2[@M]

  1. each PATH can be either a working-copy path or URL.
     If no PATHs are specified, a value of '.' is assumed.

      + if PATH is a URL, then revisions N and M must be specified via -r.

      + if PATH is a working-copy path, then -r switch has these effects:
          -r N:M : server compares revisions N and M of PATH,
          -r N : client compares revision N of PATH against working copy
          (no -r) : client compares base and working copies of PATH

  2. if the alternate syntax is used, the server compares URL1 and URL2
     at revisions N and M respectively. If either N or M are ommitted, a
     value of HEAD is assumed.
------------------------------------------------------------

I thought I'd throw this out for people to oggle. I'm pretty sure
that it covers all the many use-cases:

   svn diff
   svn diff foo.c
   svn diff -r N foo.c bar.c baz.h
   svn diff -r N:M foo.c bar.c http://blah qux.h
   svn diff http://bloo@N http://glorb@M

The interface to svn_client_diff(), of course, is going to remain
squeaky-clean and simple: it will continue to take two paths and two
revisions. All of the complex commandline-parsing logic will go into
clients/cmdline/diff-cmd.c, as that seems like the appropriate place.

Anyway, that's what I'm doing. Running head-first with a
vaccuum-cleaner into the code.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Apr 16 00:23:19 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.