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

Re: [PATCH]: Change sort order for 'svn diff'

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2005-11-20 12:34:29 CET

Kean Johnston wrote:
>> I'm worried that this patch introduces sorting for diff output, but
>> ignores other commands. If we start sorting the output we produce,
>> then it should be sorted for all commands -- checkout, update, status,
>> list, merge, switch, ...
> Maybe it might already. I didnt look at every single
> command but I made the change in the place Dan Berlin suggested,
> in libsvn_repos/reporter.c, and that seemed to affect checkout
> at the very least.
> However, I will say, that the order in which things are checked
> out or status reported is considerably less important than the
> order in which files are diff'ed.

Yes, in general: diff is quite important for the reasons you stated. But
actually I find unsorted "status" output to be quite obnoxious too.

>> IIRC, the last time we discussed this, there was a fairly good
>> proposal as to where such a change should be made.
> Ok I wasn't aware of previous discussions as I only recently started
> reading this list again. However, when I originally posted about
> this no-one other than Julian Foad mentioned any earlier work, and
> he mentioned that there was only mild enthusiasm for making everything
> sorted. Perhaps Julian and I should work together to see if we can
> extend his earlier work to take node type (file vs dir) into account?
> Julian?

Choosing the sort order is the easy bit. The difficulties I had were in trying
to make the wc-and-repos combined operations sorted. However, you might learn
something useful by looking at what I did for getting wc-only and repos-only
things sorted.

Here's the log message from the last version of my patch, so you can see in
which functions I put the sorting. I'll try to update the patch so that it
applies to trunk, and then post it, later today. The table of which commands
are sorted is out of date because the project source code has changed since I
last updated it over a year ago. Some parts of the patch will be broken as a

Perform multi-file operations in the sorted order of the file names.

This makes the output of operations like "svn diff" and "svn status"
predictable, repeatable, easy to read, etc., for the user's benefit, and
also provides a better foundation for machine processing of Subversion
output and even internal operations.

This patch addresses the following operations (+=yes, .=n/a, -=no, ?=was sorted
by this patch in the past, but needs re-checking):

- add
. blame
. cat
- checkout
. cleanup
? commit
. copy
? delete [1]
? diff (locally) [1]
- diff (contacting repository) [1]
? export
. help
? import
? info
? list
. log
? merge [1]
. mkdir
? move
. propedit
? propget,proplist
? propset,propdel
? resolved
? revert
? status (locally)
- status (contacting repository)
? switch,update [1]

[1] Sorted except that directories can be reported after their children.

File and directory names are sorted in the numerical order of their Unicode
representations. This order is fixed (because it is implemented on the server
as well as the client) and is not affected by locale or case-insensitive file

This patch sorts sequences of path names that are generated within Subversion.
It does not, for instance, sort a list of targets specified by the user.

Tweak a regression test so that it does not depend on "svn status" reporting
unversioned files before ".".

* subversion/clients/cmdline/propget-cmd.c (svn_cl__propget)
   Sort the properties by filename before printing them.

* subversion/libsvn_client/commit.c (import_dir)
   Call svn_io_get_dirents instead of doing the hard work manually.
   Sort the dir entries before processing and recursing.

* subversion/libsvn_client/export.c (copy_versioned_files)
   Sort the dir entries before processing and recursing.

* subversion/libsvn_client/prop_commands.c (remote_propget, remote_proplist)
   Sort the dir entries before processing and recursing.

* subversion/libsvn_repos/delta.c (delta_dirs)
   Bring together all additions, changes and deletions rather than leaving
     deletions until afterwards.
   Sort the FS dir entries before processing and recursing, so as to
     emit the editing operations in sorted order.

* subversion/libsvn_wc/adm_crawler.c (report_revisions)
* subversion/libsvn_wc/adm_ops.c (svn_wc_revert, mark_tree)
* subversion/libsvn_wc/diff.c (directory_elements_diff)
* subversion/libsvn_wc/entries.c (walker_helper)
   Sort the WC entries before processing and recursing.

* subversion/libsvn_wc/status.c
   (get_dir_status): Bring together all versioned and unversioned items from
     a single directory, instead of handling all the unversioned items first.
     Sort them before recursing and reporting.
   (handle_statii): Sort the entries before recursing and reporting.
   (close_directory): Report "." before its children, not after them.

* subversion/tests/clients/cmdline/stat_tests.py
   (status_for_unignored_file): Commit the property change so that no status is
     reported for "this dir", to avoid depending on the reporting order.

- Julian

To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Nov 20 12:35:18 2005

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