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

[PATCH] Make svn ls -v display dates when appropriate

From: Peter S. Housel <housel_at_acm.org>
Date: 2003-09-05 23:42:32 CEST

Sussman wished aloud for this on IRC. It was so simple I couln't
resist making the change.

The patch below makes the date/time display behavior of "svn ls
-v" match that of "ls" on most Un*x variants.

Log message:
* ls-cmd.c
  (print_dirents) Include the date (instead of the time) in the verbose
  list output if the entry's date is more than half a year in the past
  or future.

Index: subversion/clients/cmdline/ls-cmd.c
===================================================================
--- subversion/clients/cmdline/ls-cmd.c (revision 6985)
+++ subversion/clients/cmdline/ls-cmd.c (working copy)
@@ -68,6 +68,7 @@
                                           utf8_entryname, pool));
       if (verbose)
         {
+ apr_time_t now = apr_time_now();
           apr_time_exp_t exp_time;
           apr_status_t apr_err;
           apr_size_t size;
@@ -78,10 +79,20 @@
                                                 dirent->last_author, pool));
 
           /* svn_time_to_human_cstring gives us something *way* to long
- to use for this, so we have to roll our own. */
+ to use for this, so we have to roll our own. We include
+ the year if the entry's time is not within half a year. */
           apr_time_exp_lt (&exp_time, dirent->time);
- apr_err = apr_strftime (timestr, &size, sizeof (timestr),
- "%b %d %H:%M", &exp_time);
+ if (apr_time_sec(now - dirent->time) < (365 * 86400 / 2)
+ && apr_time_sec(dirent->time - now) < (365 * 86400 / 2))
+ {
+ apr_err = apr_strftime (timestr, &size, sizeof (timestr),
+ "%b %d %H:%M", &exp_time);
+ }
+ else
+ {
+ apr_err = apr_strftime (timestr, &size, sizeof (timestr),
+ "%b %d %Y", &exp_time);
+ }
 
           /* if that failed, just zero out the string and print nothing */
           if (apr_err)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Sep 5 23:43:22 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.