You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Ivan Zhakov <iv...@visualsvn.com> on 2013/04/25 00:58:05 UTC
Re: svn commit: r1471717 - /subversion/trunk/subversion/svnadmin/svnadmin.c
On Thu, Apr 25, 2013 at 2:01 AM, <da...@apache.org> wrote:
> URL: http://svn.apache.org/r1471717
> Log:
> Implement 'svnadmin info'.
>
See my review inline.
> Modified:
> subversion/trunk/subversion/svnadmin/svnadmin.c
>
> Modified: subversion/trunk/subversion/svnadmin/svnadmin.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/svnadmin.c?rev=1471717&r1=1471716&r2=1471717&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/svnadmin/svnadmin.c (original)
> +++ subversion/trunk/subversion/svnadmin/svnadmin.c Wed Apr 24 22:01:17 2013
[...]
> +svn_error_t *
> +subcommand_info(apr_getopt_t *os, void *baton, apr_pool_t *pool)
> +{
> + struct svnadmin_opt_state *opt_state = baton;
> + svn_repos_t *repos;
> + svn_fs_t *fs;
> +
> + /* Expect no more arguments. */
> + SVN_ERR(parse_args(NULL, os, 0, 0, pool));
> +
> + SVN_ERR(open_repos(&repos, opt_state->repository_path, pool));
> + fs = svn_repos_fs(repos);
> + SVN_ERR(svn_cmdline_printf(pool, _("Path: %s\n"),
> + svn_repos_path(repos, pool)));
Missing svn_dirent_local_style().
> +
> + {
> + apr_hash_t *capabilities_set;
> + apr_array_header_t *capabilities;
> + char *as_string;
> +
> + SVN_ERR(svn_repos_capabilities(&capabilities_set, repos, pool, pool));
> + SVN_ERR(svn_hash_keys(&capabilities, capabilities_set, pool));
> + as_string = svn_cstring_join(capabilities, ",", pool);
> +
> + /* Delete the trailing comma. */
> + as_string[strlen(as_string)-1] = '\0';
This will crash in case of empty string. Simple solution would be:
[[[
if (apr_hash_count(capabilities_set) > 0)
{
apr_array_header_t *capabilities;
char *as_string;
SVN_ERR(svn_hash_keys(&capabilities, capabilities_set, pool));
as_string = svn_cstring_join(capabilities, ",", pool);
as_string[strlen(as_string)-1] = '\0';
SVN_ERR(svn_cmdline_printf(pool, _("Repository capabilities: %s\n"),
as_string));
}
]]]
> +
> + if (capabilities->nelts)
> + SVN_ERR(svn_cmdline_printf(pool, _("Repository capabilities: %s\n"),
> + as_string));
> + }
> +
> + {
> + int repos_format, fs_format, minor;
One variable per line makes code much cleaner.
> + svn_version_t *repos_version, *fs_version;
> + SVN_ERR(svn_repos_info_format(&repos_format, &repos_version,
> + repos, pool, pool));
> + SVN_ERR(svn_cmdline_printf(pool, _("Repository format: %d\n"),
> + repos_format));
> +
> + SVN_ERR(svn_fs_info_format(&fs_format, &fs_version,
> + fs, pool, pool));
> + SVN_ERR(svn_cmdline_printf(pool, _("Filesystem format: %d\n"),
> + fs_format));
> +
> + SVN_ERR_ASSERT(repos_version->major == SVN_VER_MAJOR);
> + SVN_ERR_ASSERT(fs_version->major == SVN_VER_MAJOR);
> + SVN_ERR_ASSERT(repos_version->patch == 0);
> + SVN_ERR_ASSERT(fs_version->patch == 0);
> +
> + minor = (repos_version->minor > fs_version->minor)
> + ? repos_version->minor : fs_version->minor;
It would great to implement svn_ver_compare() and use it here. This
avoid hard-coding SVN_VER_MAJOR and make code easier to understand.
> + SVN_ERR(svn_cmdline_printf(pool, _("Compatible with version: %d.%d.0\n"),
> + SVN_VER_MAJOR, minor));
> + }
> +
> + {
> + apr_array_header_t *files;
> + int i;
> +
> + SVN_ERR(svn_fs_info_config_files(&files, fs, pool, pool));
> + for (i = 0; i < files->nelts; i++)
Loop without '{' and '}' is very dangerous :)
> + SVN_ERR(svn_cmdline_printf(pool, _("Config file: %s\n"),
> + APR_ARRAY_IDX(files, i, const char *)));
> + }
> +
> + {
> + const svn_fs_info_placeholder_t *info;
> +
> + SVN_ERR(svn_fs_info(&info, fs, pool, pool));
> + SVN_ERR(svn_cmdline_printf(pool, _("Filesystem type: %s\n"),
> + info->fs_type));
> + if (!strcmp(info->fs_type, SVN_FS_TYPE_FSFS))
> + {
> + const svn_fs_fsfs_info_t *fsfs_info = (const void *)info;
> + svn_revnum_t youngest;
> + SVN_ERR(svn_fs_youngest_rev(&youngest, fs, pool));
> +
> + if (fsfs_info->shard_size)
> + SVN_ERR(svn_cmdline_printf(pool, _("FSFS sharded: yes\n")));
> + else
> + SVN_ERR(svn_cmdline_printf(pool, _("FSFS sharded: no\n")));
> +
> + if (fsfs_info->shard_size)
> + SVN_ERR(svn_cmdline_printf(pool, _("FSFS shard size: %d\n"),
> + fsfs_info->shard_size));
> +
> + if (fsfs_info->min_unpacked_rev + fsfs_info->shard_size > youngest + 1)
> + SVN_ERR(svn_cmdline_printf(pool, _("FSFS packed: yes\n")));
> + else if (fsfs_info->min_unpacked_rev)
> + SVN_ERR(svn_cmdline_printf(pool, _("FSFS packed: partly\n")));
> + else
> + SVN_ERR(svn_cmdline_printf(pool, _("FSFS packed: no\n")));
> + }
> + }
> +
> + return SVN_NO_ERROR;
> +}
> +
> /* This implements `svn_opt_subcommand_t'. */
> static svn_error_t *
> subcommand_lock(apr_getopt_t *os, void *baton, apr_pool_t *pool)
>
>
--
Ivan Zhakov
CTO | VisualSVN | http://www.visualsvn.com
Re: svn commit: r1471717 -
/subversion/trunk/subversion/svnadmin/svnadmin.c
Posted by Daniel Shahaf <da...@elego.de>.
Ivan Zhakov wrote on Thu, Apr 25, 2013 at 13:29:05 +0400:
> On Thu, Apr 25, 2013 at 3:14 AM, Daniel Shahaf <d....@daniel.shahaf.name> wrote:
> > On IRC you also made a point about the "Config files" output (prints the
> > path to DB_CONFIG or to fsfs.conf). Do you think it should be removed
> > from 'svnadmin info'? From svn_fs.h (svn_fs_info_config_files)?
> My personal opinion that "Config files" are not useful in 'svnadmin
> info' and should be removed from output and API. In this case
> 'svnadmin info' output would be more regular.
>
Not sure what you mean by 'more regular'. We also don't print sharding
information for BDB filesystems, if that's what you mean...
I'd still like to hear what others think about possibly printing the
path to fsfs.conf / DB_CONFIG in the output, whether it should be kept
or axed or modified.
> Another problem is long repository path:
> [[[
> % $svnadmin create C:\ProgramData\Subversion\SuperRepo && $svnadmin
> info C:\ProgramData\Subversion\SuperRepo
> Path: C:\ProgramData\Subversion\SuperRepo
> Repository Format: 5
> Filesystem Format: 6
> Compatible With Version: 1.8.0
> Repository Capabilities: mergeinfo
> Filesystem Type: fsfs
> FSFS Sharded: yes
> FSFS Shard Size: 4
> FSFS Packed: yes
> Config File: C:\ProgramData\Subversion\SuperRepo\db\fsfs.conf
> ]]]
>
> 'Config File' is hard to scan visually IMHO.
Don't pass an abspath to svnadmin and you won't get an abspath in the
"Config File" field.
Re: svn commit: r1471717 - /subversion/trunk/subversion/svnadmin/svnadmin.c
Posted by Ivan Zhakov <iv...@visualsvn.com>.
On Thu, Apr 25, 2013 at 3:14 AM, Daniel Shahaf <d....@daniel.shahaf.name> wrote:
> Ivan Zhakov wrote on Thu, Apr 25, 2013 at 02:58:05 +0400:
>> On Thu, Apr 25, 2013 at 2:01 AM, <da...@apache.org> wrote:
[...]
>
> *nod*. Is that your preference or the project-agreed style?
>
It's not project agreed style, but I remember some discussions on the
list that one variable per line is better in general.
>> > + SVN_ERR_ASSERT(repos_version->major == SVN_VER_MAJOR);
>> > + SVN_ERR_ASSERT(fs_version->major == SVN_VER_MAJOR);
>> > +
>> > + minor = (repos_version->minor > fs_version->minor)
>> > + ? repos_version->minor : fs_version->minor;
>> It would great to implement svn_ver_compare() and use it here. This
>
> There is svn_ver__at_least() but I didn't want to use non-public
> functions.
svn_ver__at_least() has a little bit semantics: it compares using our
compatibility rules. Btw I don't see problem use our library private
function anyway.
>
> On IRC you also made a point about the "Config files" output (prints the
> path to DB_CONFIG or to fsfs.conf). Do you think it should be removed
> from 'svnadmin info'? From svn_fs.h (svn_fs_info_config_files)?
My personal opinion that "Config files" are not useful in 'svnadmin
info' and should be removed from output and API. In this case
'svnadmin info' output would be more regular.
Another problem is long repository path:
[[[
% $svnadmin create C:\ProgramData\Subversion\SuperRepo && $svnadmin
info C:\ProgramData\Subversion\SuperRepo
Path: C:\ProgramData\Subversion\SuperRepo
Repository Format: 5
Filesystem Format: 6
Compatible With Version: 1.8.0
Repository Capabilities: mergeinfo
Filesystem Type: fsfs
FSFS Sharded: yes
FSFS Shard Size: 4
FSFS Packed: yes
Config File: C:\ProgramData\Subversion\SuperRepo\db\fsfs.conf
]]]
'Config File' is hard to scan visually IMHO.
--
Ivan Zhakov
CTO | VisualSVN | http://www.visualsvn.com
Re: svn commit: r1471717 -
/subversion/trunk/subversion/svnadmin/svnadmin.c
Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Ivan Zhakov wrote on Thu, Apr 25, 2013 at 02:58:05 +0400:
> On Thu, Apr 25, 2013 at 2:01 AM, <da...@apache.org> wrote:
> > +svn_error_t *
> > +subcommand_info(apr_getopt_t *os, void *baton, apr_pool_t *pool)
> > +{
> > + SVN_ERR(svn_cmdline_printf(pool, _("Path: %s\n"),
> > + svn_repos_path(repos, pool)));
> Missing svn_dirent_local_style().
>
Fixed. (I actually wanted to do that before commit, but was distracted
and forgot about it.)
> > + /* Delete the trailing comma. */
> > + as_string[strlen(as_string)-1] = '\0';
> This will crash in case of empty string. Simple solution would be:
> [[[
> if (apr_hash_count(capabilities_set) > 0)
> ]]]
>
Fixed differently.
> > + {
> > + int repos_format, fs_format, minor;
> One variable per line makes code much cleaner.
>
*nod*. Is that your preference or the project-agreed style?
> > + SVN_ERR_ASSERT(repos_version->major == SVN_VER_MAJOR);
> > + SVN_ERR_ASSERT(fs_version->major == SVN_VER_MAJOR);
> > +
> > + minor = (repos_version->minor > fs_version->minor)
> > + ? repos_version->minor : fs_version->minor;
> It would great to implement svn_ver_compare() and use it here. This
There is svn_ver__at_least() but I didn't want to use non-public
functions.
> avoid hard-coding SVN_VER_MAJOR and make code easier to understand.
>
I hard-coded SVN_VER_MAJOR because of the assert a few lines above which
guarantees the repos/fs major versions are equal to it.
> > + SVN_ERR(svn_cmdline_printf(pool, _("Compatible with version: %d.%d.0\n"),
> > + SVN_VER_MAJOR, minor));
> > + }
> > +
Thanks for the review.
On IRC you also made a point about the "Config files" output (prints the
path to DB_CONFIG or to fsfs.conf). Do you think it should be removed
from 'svnadmin info'? From svn_fs.h (svn_fs_info_config_files)? What
do others think?
FWIW, example output:
[[[
% $svnadmin create r && $svnadmin info r
Path: r
Repository Format: 5
Filesystem Format: 6
Compatible With Version: 1.8.0
Repository Capabilities: mergeinfo
Filesystem Type: fsfs
FSFS Sharded: yes
FSFS Shard Size: 4
FSFS Packed: yes
Config File: r/db/fsfs.conf
% svnadmin create --fs-type=bdb --pre-1.4-compatible r2 && $svnadmin info r2
svnadmin: warning: The "bdb" repository back-end is deprecated, consider using "fsfs" instead.
Path: r2
Repository Format: 3
Filesystem Format: 1
Compatible With Version: 1.0.0
Filesystem Type: bdb
Config File: r2/db/DB_CONFIG
]]]