> -----Original Message-----
> From: julianf...@apache.org [mailto:julianf...@apache.org]
> Sent: vrijdag 14 juli 2017 16:22
> To: comm...@subversion.apache.org
> Subject: svn commit: r1801970 - in /subversion/branches/shelve-
> checkpoint/subversion: libsvn_client/shelve.c svn/shelve-cmd.c
> 
> Author: julianfoad
> Date: Fri Jul 14 14:21:35 2017
> New Revision: 1801970
> 
> URL: http://svn.apache.org/viewvc?rev=1801970&view=rev
> Log:
> On the 'shelve-checkpoint' branch: make 'svn shelve --list' more verbose.
> 
> Print the patch file age and size, and (unless '-q') also a diffstat.
> 
> * subversion/libsvn_client/shelve.c
>   (svn_client_shelves_list): Retrieve more stats including file size and
>     mtime.
> 
> * subversion/svn/shelve-cmd.c
>   (shelves_list): Print each patch's age and size, and run 'diffstat' if
>     found in the path.
>   (svn_cl__shelves,
>    svn_cl__shelves): Update callers.
> 
> Modified:
>     subversion/branches/shelve-checkpoint/subversion/libsvn_client/shelve.c
>     subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c
> 
> Modified: subversion/branches/shelve-
> checkpoint/subversion/libsvn_client/shelve.c
> URL: http://svn.apache.org/viewvc/subversion/branches/shelve-
> checkpoint/subversion/libsvn_client/shelve.c?rev=1801970&r1=1801969&r2
> =1801970&view=diff
> ==========================================================
> ====================
> --- subversion/branches/shelve-
> checkpoint/subversion/libsvn_client/shelve.c (original)
> +++ subversion/branches/shelve-
> checkpoint/subversion/libsvn_client/shelve.c Fri Jul 14 14:21:35 2017
> @@ -314,7 +314,7 @@ svn_client_shelves_list(apr_hash_t **dir
> 
>    SVN_ERR(svn_wc__get_shelves_dir(&shelves_dir, ctx->wc_ctx,
> local_abspath,
>                                    scratch_pool, scratch_pool));
> -  SVN_ERR(svn_io_get_dirents3(dirents, shelves_dir, TRUE
> /*only_check_type*/,
> +  SVN_ERR(svn_io_get_dirents3(dirents, shelves_dir, FALSE
> /*only_check_type*/,
>                                result_pool, scratch_pool));
> 
>    /* Remove non-shelves */
> 
> Modified: subversion/branches/shelve-checkpoint/subversion/svn/shelve-
> cmd.c
> URL: http://svn.apache.org/viewvc/subversion/branches/shelve-
> checkpoint/subversion/svn/shelve-
> cmd.c?rev=1801970&r1=1801969&r2=1801970&view=diff
> ==========================================================
> ====================
> --- subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c
> (original)
> +++ subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c
> Fri Jul 14 14:21:35 2017
> @@ -51,21 +51,36 @@ get_shelf_name(const char **shelf_name,
>  /* Display a list of shelves */
>  static svn_error_t *
>  shelves_list(const char *local_abspath,
> +             svn_boolean_t diffstat,
>               svn_client_ctx_t *ctx,
> -             apr_pool_t *pool)
> +             apr_pool_t *scratch_pool)
>  {
>    apr_hash_t *dirents;
>    apr_hash_index_t *hi;
> 
> -  SVN_ERR(svn_client_shelves_list(&dirents, local_abspath, ctx, pool, pool));
> +  SVN_ERR(svn_client_shelves_list(&dirents, local_abspath,
> +                                  ctx, scratch_pool, scratch_pool));
> 
> -  for (hi = apr_hash_first(pool, dirents); hi; hi = apr_hash_next(hi))
> +  for (hi = apr_hash_first(scratch_pool, dirents); hi; hi = 
> apr_hash_next(hi))
>      {

I know it is just a prototype, but some stable sorting would be nice.


>        const char *name = apr_hash_this_key(hi);
> +      svn_io_dirent2_t *dirent = apr_hash_this_val(hi);
> +      int age = (apr_time_now() - dirent->mtime) / 1000000 / 60;
> 
> -      if (strstr(name, ".patch"))
> +      if (! strstr(name, ".patch"))
> +        continue;
> +
> +      printf("%-30s %6d mins old %10ld bytes\n",
> +             name, age, (long)dirent->filesize);

And in general we try to avoid the standard print functions as these might not 
be as compatible as expected. (UTF-8 support, buffering, etc.)
> +
> +      if (diffstat)
>          {
> -          printf("%s\n", name);
> +          char *path = svn_path_join_many(scratch_pool,
> +                                          local_abspath, ".svn/shelves", 
> name,
> +                                          SVN_VA_NULL);
> +
> +          system(apr_psprintf(scratch_pool, "diffstat %s 2> /dev/null", 
> path));
> +          printf("\n");

And this will certainly fail on Windows (but the error is ignored anyway). I 
would recommend flushing stdout before calling system() on other platforms.

        Bert
>          }
>      }
> 
> @@ -94,7 +109,9 @@ svn_cl__shelve(apr_getopt_t *os,
>        if (os->ind < os->argc)
>          return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, 0, NULL);
> 
> -      SVN_ERR(shelves_list(local_abspath, ctx, pool));
> +      SVN_ERR(shelves_list(local_abspath,
> +                           ! opt_state->quiet /*diffstat*/,
> +                           ctx, pool));
>        return SVN_NO_ERROR;
>      }
> 
> @@ -192,7 +209,7 @@ svn_cl__shelves(apr_getopt_t *os,
>      return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, 0, NULL);
> 
>    SVN_ERR(svn_dirent_get_absolute(&local_abspath, "", pool));
> -  SVN_ERR(shelves_list(local_abspath, ctx, pool));
> +  SVN_ERR(shelves_list(local_abspath, TRUE /*diffstat*/, ctx, pool));
> 
>    return SVN_NO_ERROR;
>  }
> 


Reply via email to