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

Re: PATCH: column alignment in 'svn list -v' and 'svn status -v'

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2003-10-25 01:12:27 CEST

Sander Roobol wrote:
> On Mon, Sep 29, 2003 at 02:07:02PM -0500, Sander Roobol wrote:
>
>>On Fri, Sep 19, 2003 at 07:48:32PM +0100, Julian Foad wrote:
>>
>>>[From thread "minor bug in 'svn list -v'" on the "users" list.]
>>>
>>>Martin Maurer requested a wider "file size" field in "svn list" output.
>>>
>>>I suggested left-aligning the author field there and in "svn status"
>>>output, and other related column-alignment changes. Here is a patch for
>>>review.
>>
>>Just a reminder: you didn't commit this patch yet.
>
> Ping again. Will file an issue if there's no response in a few days.

Thanks for keeping an eye on this.

I have already committed the wider "file size" field. The other changes I am still not sure about. I think the left-aligning the "author" fields is good (somebody said yes, and nobody said no), and eliminating redundant white space, and some of the other stuff...

My current version of the patch is attached, but it is NOT fit for applying. The log message does not even match the content and the content may be inconsistent. But for the record, this is what I have at the moment.

The next move is really for me to make: I should split this into separate, coherent ideas and ask for review on each one. I'm not sure whether it is appropriate to file a "patch" issue, which might imply that the next move is for someone to review and apply the patch.

- Julian

Improve the alignment of columns in "svn list" and "svn status" output.

* subversion/clients/cmdline/ls-cmd.c
  (print_dirents)
    Left-align the author field: it makes more sense.
    Remove redundant padding from constants: they will be padded by "printf".

* subversion/clients/cmdline/status.c
  (print_status)
    Allow the author field to extend an extra two characters into existing
      white space before breaking alignment of subsequent fields.
    Align the "?" for no-working-revision in the same way as others "?"s.
    Left-align the author field: it makes more sense.
    Remove redundant padding from constants: they will be padded by "printf".

TODO: fix example output in help and in book.
TODO: use "-" instead of "_" or "?" for unknown info, inc. size of dirs.

Index: subversion/clients/cmdline/ls-cmd.c
===================================================================
--- subversion/clients/cmdline/ls-cmd.c (revision 7429)
+++ subversion/clients/cmdline/ls-cmd.c (working copy)
@@ -56,7 +56,6 @@
       const char *utf8_entryname, *stdout_entryname;
       svn_dirent_t *dirent;
       svn_item_t *item;
- char timestr[20];
      
       item = &APR_ARRAY_IDX (array, i, svn_item_t);
 
@@ -73,6 +72,8 @@
           apr_status_t apr_err;
           apr_size_t size;
           const char *stdout_author = NULL;
+ char timestr[20];
+ char size_buf[21]; /* Enough for 2^64 in base 10 plus '\0' */
           
           if (dirent->last_author)
             SVN_ERR (svn_cmdline_cstring_from_utf8 (&stdout_author,
@@ -99,11 +100,12 @@
           if (apr_err)
             timestr[0] = '\0';
 
- printf ("%7"SVN_REVNUM_T_FMT" %8.8s "
- "%10"SVN_FILESIZE_T_FMT" %12s %s%s\n",
+ sprintf (size_buf, "%" SVN_FILESIZE_T_FMT, dirent->size);
+
+ printf ("%7"SVN_REVNUM_T_FMT" %-8.8s %10s %12s %s%s\n",
                   dirent->created_rev,
- stdout_author ? stdout_author : " ? ",
- dirent->size,
+ stdout_author ? stdout_author : "",
+ (dirent->kind == svn_node_file) ? size_buf : "";
                   timestr,
                   stdout_entryname,
                   (dirent->kind == svn_node_dir) ? "/" : "");
Index: subversion/clients/cmdline/status.c
===================================================================
--- subversion/clients/cmdline/status.c (revision 7429)
+++ subversion/clients/cmdline/status.c (working copy)
@@ -73,13 +73,13 @@
   if (detailed)
     {
       if (! status->entry)
- working_rev = " ";
+ working_rev = "";
       else if (! SVN_IS_VALID_REVNUM (status->entry->revision))
- working_rev = " ? "; /* ### Why the odd alignment? */
+ working_rev = " ? ";
       else if (status->copied)
- working_rev = " -";
+ working_rev = "-";
       else
- sprintf (working_rev_buf, "%6" SVN_REVNUM_T_FMT,
+ sprintf (working_rev_buf, "%" SVN_REVNUM_T_FMT,
                  status->entry->revision);
 
       if (status->repos_text_status != svn_wc_status_none
@@ -91,12 +91,12 @@
       if (show_last_committed)
         {
           if (status->entry && SVN_IS_VALID_REVNUM (status->entry->cmt_rev))
- sprintf(commit_rev_buf, "%6" SVN_REVNUM_T_FMT,
+ sprintf(commit_rev_buf, "%" SVN_REVNUM_T_FMT,
                     status->entry->cmt_rev);
           else if (status->entry)
- commit_rev = " ? ";
+ commit_rev = " ? ";
           else
- commit_rev = " ";
+ commit_rev = "";
 
           if (status->entry && status->entry->cmt_author)
             {
@@ -112,14 +112,14 @@
                 }
             }
           else if (status->entry)
- commit_author = " ? ";
+ commit_author = "-";
           else
- commit_author = " ";
+ commit_author = "";
         }
     }
 
   if (detailed && show_last_committed)
- printf ("%c%c%c%c%c %c %6s %6s %8s %s\n",
+ printf ("%c%c%c%c%c %c %6s %6s %-10s %s\n",
             generate_status_code (status->text_status),
             generate_status_code (status->prop_status),
             status->locked ? 'L' : ' ',

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 25 01:11:21 2003

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.