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

Re: [PATCH] Issue #692: Handle "svn log" with empty repos

From: Michael W Thelen <thelenm_at_cs.utah.edu>
Date: 2004-07-05 05:38:20 CEST

* Greg Hudson <ghudson@MIT.EDU> [2004-07-03 23:03]:
> I'm not sure how I feel about changing the behavior of "svn log -r
> 5:0". Also, I think (though I'm not sure) that your candidate patch
> might produce slightly different behavior for new servers vs. old
> servers when a new client is used, since the old server wouldn't filter
> out rev 0.

Whooops... you're right, it does. Thanks for pointing that out.

> What might conceivably make sense is to ask for HEAD:0 when no revs are
> specified, and then filter out the rev 0 log before passing it to the
> caller in that case. A tiny bit of wasted data in the common case, but
> no wasted round trip.

Maybe... that seems nicer, but not too much nicer, than issuing a bad
HEAD:1 request and then catching the error. Here's another thought: the
check for 0 at one endpoint of a revision range can happen in the client
library instead of the repos library. We can still change the default
end revision from 1 to 0, but detect the edge cases immediately -before-
issuing the log request rather than catching the error afterward. We
still have to handle the special cases, but the code to do so is much
smaller and more straightforward. Here's a rough idea of what I mean.
What do you think of this idea?

Index: subversion/libsvn_client/log.c
===================================================================
--- subversion/libsvn_client/log.c (revision 10137)
+++ subversion/libsvn_client/log.c (working copy)
@@ -248,6 +248,11 @@
               SVN_ERR (svn_client__get_revision_number
                        (&end_revnum, ra_lib, session, end, target, pool));
 
+ if ((start_revnum == 0) && (end_revnum > 0))
+ start_revnum = 1;
+ else if ((start_revnum > 0) && (end_revnum == 0))
+ end_revnum = 1;
+
             err = ra_lib->get_log (session,
                                    condensed_targets,
                                    start_revnum,
@@ -263,6 +268,11 @@
       }
     else /* both revisions are static, so no loop needed */
       {
+ if ((start_revnum == 0) && (end_revnum > 0))
+ start_revnum = 1;
+ else if ((start_revnum > 0) && (end_revnum == 0))
+ end_revnum = 1;
+
         err = ra_lib->get_log (session,
                                condensed_targets,
                                start_revnum,
@@ -273,39 +283,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;
Index: subversion/clients/cmdline/log-cmd.c
===================================================================
--- subversion/clients/cmdline/log-cmd.c (revision 10137)
+++ subversion/clients/cmdline/log-cmd.c (working copy)
@@ -515,7 +515,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; /* oldest commit */
         }
     }
 

-- Mike

-- 
Michael W. Thelen
Ninety percent of the politicians give the other ten percent a bad reputation.
                -- Henry Kissinger

Received on Mon Jul 5 05:39:57 2004

This is an archived mail posted to the Subversion Dev mailing list.