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

Fixing issue 1950

From: Max Bowsher <maxb_at_ukf.net>
Date: 2005-01-09 16:15:29 CET

I'd appreciate comments on the below proposed patch to fix issue 1950.

It contains a small API change and a small "svn log" output change regarding
revision 0, which want to give people a chance to comment on before I
commit.

Max.

Fix issue 1950: svn log in a r0 WC shows a r1 log message.
Also make a number of other changes:
- If a log message has been set on revision 0, then show it in svn log and
  svn log --xml output.
- Remove the "No commit for revision 0." message, which was being printed
  inside the seperator line of the previous revision. Print nothing unless
  a log message has been set.

* subversion/clients/cmdline/log-cmd.c
  (log_receiver, log_receiver_xml): Tweak r0 special case as outlined above.
  (svn_cl__log):
    Change the default log ranges from {HEAD,BASE}:1 to {HEAD,BASE}:0.

* subversion/libsvn_client/log.c (svn_client_log2): Remove a special case
from
    this not-yet-released API, moving it to ...
  (svn_client_log): ... this compatibility wrapper implementing the old API.
    The special case is no longer required, following the HEAD:1 to HEAD:0
    change above.
    Fix a rare error leak in the compatibility wrapper.

* subversion/include/svn_client.h
  (svn_client_log, svn_client_log2): Document the special case removal.

Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h (revision 12638)
+++ subversion/include/svn_client.h (working copy)
@@ -792,20 +792,12 @@
  *
  * Use @a pool for any temporary allocation.
  *
- * Special case for repositories at revision 0:
+ * IMPORTANT: A special case for the revision range HEAD:1, which was
present
+ * in svn_client_log(), has been removed from svn_client_log2(). Instead.
it
+ * is expected that callers will specify the range HEAD:0, to avoid a
+ * SVN_ERR_FS_NO_SUCH_REVISION error when invoked against an empty
repository
+ * (i.e. one not containing a revision 1).
  *
- * If @a start->kind is @c svn_opt_revision_head, and @a end->kind is
- * @c svn_opt_revision_number && @a end->number is @c 1, then handle an
- * empty (no revisions) repository specially: instead of erroring
- * because requested revision 1 when the highest revision is 0, just
- * invoke @a receiver on revision 0, passing @c NULL for changed paths and
- * empty strings for the author and date. This is because that
- * particular combination of @a start and @a end usually indicates the
- * common case of log invocation -- the user wants to see all log
- * messages from youngest to oldest, where the oldest commit is
- * revision 1. That works fine, except when there are no commits in
- * the repository, hence this special case.
- *
  * If @a ctx->notify_func is non-null, then call @a ctx->notify_func/baton
  * with a 'skip' signal on any unversioned targets.
  */
@@ -825,7 +817,22 @@
 /**
  * @deprecated Provided for backward compatibility with the 1.0 API.
  *
- * Similar to svn_client_log2, but with the @a limit parameter set to 0.
+ * Similar to svn_client_log2, but with the @a limit parameter set to 0,
+ * and the following special case:
+ *
+ * Special case for repositories at revision 0:
+ *
+ * If @a start->kind is @c svn_opt_revision_head, and @a end->kind is
+ * @c svn_opt_revision_number && @a end->number is @c 1, then handle an
+ * empty (no revisions) repository specially: instead of erroring
+ * because requested revision 1 when the highest revision is 0, just
+ * invoke @a receiver on revision 0, passing @c NULL for changed paths and
+ * empty strings for the author and date. This is because that
+ * particular combination of @a start and @a end usually indicates the
+ * common case of log invocation -- the user wants to see all log
+ * messages from youngest to oldest, where the oldest commit is
+ * revision 1. That works fine, except when there are no commits in
+ * the repository, hence this special case.
  */
 svn_error_t *
 svn_client_log (const apr_array_header_t *targets,
Index: subversion/libsvn_client/log.c
===================================================================
--- subversion/libsvn_client/log.c (revision 12638)
+++ subversion/libsvn_client/log.c (working copy)
@@ -268,39 +268,6 @@
                                 receiver_baton,
                                 pool);
       }
-
- /* Special case: If there have been no commits, we'll get an error
- * for requesting log of a revision higher than 0. But the
- * default behavior of "svn log" is to give revisions HEAD through
- * 1, on the assumption that HEAD >= 1.
- *
- * So if we got that error for that reason, and it looks like the
- * user was just depending on the defaults (rather than explicitly
- * requesting the log for revision 1), then we don't error. Instead
- * we just invoke the receiver manually on a hand-constructed log
- * message for revision 0.
- *
- * See also http://subversion.tigris.org/issues/show_bug.cgi?id=692.
- */
- if (err && (err->apr_err == SVN_ERR_FS_NO_SUCH_REVISION)
- && (start->kind == svn_opt_revision_head)
- && ((end->kind == svn_opt_revision_number)
- && (end->value.number == 1)))
- {
- svn_revnum_t youngest_rev;
-
- SVN_ERR (ra_lib->get_latest_revnum (session, &youngest_rev, pool));
- if (youngest_rev == 0)
- {
- err = SVN_NO_ERROR;
-
- /* Log receivers are free to handle revision 0 specially... But
- just in case some don't, we make up a message here. */
- SVN_ERR (receiver (receiver_baton,
- NULL, 0, "", "", _("No commits in
repository."),
- pool));
- }
- }
   }

   return err;
@@ -317,7 +284,45 @@
                 svn_client_ctx_t *ctx,
                 apr_pool_t *pool)
 {
- return svn_client_log2 (targets, start, end, 0, discover_changed_paths,
- strict_node_history, receiver, receiver_baton,
ctx,
- pool);
+ svn_error_t *err = SVN_NO_ERROR;
+
+ err = svn_client_log2 (targets, start, end, 0, discover_changed_paths,
+ strict_node_history, receiver, receiver_baton,
ctx,
+ pool);
+
+ /* Special case: If there have been no commits, we'll get an error
+ * for requesting log of a revision higher than 0. But the
+ * default behavior of "svn log" is to give revisions HEAD through
+ * 1, on the assumption that HEAD >= 1.
+ *
+ * So if we got that error for that reason, and it looks like the
+ * user was just depending on the defaults (rather than explicitly
+ * requesting the log for revision 1), then we don't error. Instead
+ * we just invoke the receiver manually on a hand-constructed log
+ * message for revision 0.
+ *
+ * See also http://subversion.tigris.org/issues/show_bug.cgi?id=692.
+ */
+ if (err && (err->apr_err == SVN_ERR_FS_NO_SUCH_REVISION)
+ && (start->kind == svn_opt_revision_head)
+ && ((end->kind == svn_opt_revision_number)
+ && (end->value.number == 1)))
+ {
+ svn_revnum_t youngest_rev;
+
+ SVN_ERR (ra_lib->get_latest_revnum (session, &youngest_rev, pool));
+ if (youngest_rev == 0)
+ {
+ svn_error_clear (err);
+ err = SVN_NO_ERROR;
+
+ /* Log receivers are free to handle revision 0 specially... But
+ just in case some don't, we make up a message here. */
+ SVN_ERR (receiver (receiver_baton,
+ NULL, 0, "", "", _("No commits in
repository."),
+ pool));
+ }
+ }
+
+ return err;
 }
Index: subversion/clients/cmdline/log-cmd.c
===================================================================
--- subversion/clients/cmdline/log-cmd.c (revision 12638)
+++ subversion/clients/cmdline/log-cmd.c (working copy)
@@ -207,8 +207,8 @@
   if (lb->cancel_func)
     SVN_ERR (lb->cancel_func (lb->cancel_baton));

- if (rev == 0)
- return svn_cmdline_printf (pool, _("No commit for revision 0.\n"));
+ if (rev == 0 && msg == NULL)
+ return SVN_NO_ERROR;

   /* ### See http://subversion.tigris.org/issues/show_bug.cgi?id=807
      for more on the fallback fuzzy conversions below. */
@@ -343,7 +343,7 @@
   if (lb->cancel_func)
     SVN_ERR (lb->cancel_func (lb->cancel_baton));

- if (rev == 0)
+ if (rev == 0 && msg == NULL)
     return SVN_NO_ERROR;

   revstr = apr_psprintf (pool, "%ld", rev);
@@ -479,8 +479,8 @@
     }
   else if (opt_state->start_revision.kind == svn_opt_revision_unspecified)
     {
- /* If the first target is a URL, then we default to HEAD:1.
- Otherwise, the default is BASE:1 since WC@HEAD may not exist. */
+ /* If the first target is a URL, then we default to HEAD:0.
+ Otherwise, the default is BASE:0 since WC@HEAD may not exist. */
       if (svn_path_is_url (target))
         opt_state->start_revision.kind = svn_opt_revision_head;
       else
@@ -489,7 +489,7 @@
       if (opt_state->end_revision.kind == svn_opt_revision_unspecified)
         {
           opt_state->end_revision.kind = svn_opt_revision_number;
- opt_state->end_revision.value.number = 1; /* oldest commit */
+ opt_state->end_revision.value.number = 0;
         }
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Jan 9 16:16:59 2005

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.