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

Re: svn commit: r930662 - in /subversion/branches/svn-patch-improvements/subversion: libsvn_client/patch.c tests/cmdline/patch_tests.py

From: Stefan Sperling <stsp_at_elego.de>
Date: Sun, 4 Apr 2010 13:20:09 +0200

On Sun, Apr 04, 2010 at 10:55:26AM -0000, dannas_at_apache.org wrote:
> Author: dannas
> Date: Sun Apr 4 10:55:25 2010
> New Revision: 930662
>
> URL: http://svn.apache.org/viewvc?rev=930662&view=rev
> Log:
> Make 'svn patch' able to remove dirs beeing empty after patching, taking
> into account both versioned and unversioned files and dirs.
>

> +
> +/* Compare A and B and return an integer greater than, equal to, or less
> + * than 0, according to whether A has less subdirs, just as many or more
> + * subdir than B. That means that the path with the most subdirs is placed
> + * first. */
> +static int
> +sort_compare_nr_of_path_elements(const svn_sort__item_t *a,
> + const svn_sort__item_t *b)
> +{
> + const char *astr, *bstr;
> + int n_a = 0, n_b = 0, i;
> +
> + astr = a->key;
> + bstr = b->key;
> +
> + for (i = 0; i < a->klen; i++)
> + if (astr[i] == '/')
> + n_a++;

Drive-by review (will look more closely later):

Maybe use svn_path_component_count() here?
And rename sort_compare_nr_of_path_elements() to
sort_compare_path_component_count()? (I tend to prefer function names
consisting of proper words...)

Stefan

> +
> + for (i = 0; i < b->klen; i++)
> + if (bstr[i] == '/')
> + n_b++;
> +
> + if (n_a > n_b)
> + return -1;
> + else if (n_a == n_b)
> + return 0;
> + else
> + return 1;
> +}
Received on 2010-04-04 13:20:45 CEST

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.