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

Re: [PATCH] Re: [Issue 816] - Silent failure in svn log -r

From: Kieran <kieran_at_esperi.demon.co.uk>
Date: 2002-07-26 22:15:42 CEST

On Fri, 26 Jul 2002, Kieran wrote:

> On 25 Jul 2002 issues@subversion.tigris.org wrote:
>
> > http://subversion.tigris.org/issues/show_bug.cgi?id=816
> >
> >
> >
> >
> >
> > ------- Additional Comments From kfogel@tigris.org 2002-07-25 12:45 PDT -------
> > Should not do silent success. If the user explicitly requests a
> > non-existent revision, there ought to be _some_ signal that they have
> > done so :-).
> >
> > Maybe print the logs for the existent revisions, then insert a special
> > error log msg or something, dunno. Lots of ways to do it, just please
> > not silently...
> >
> The following patch is a partial fix: it addresses the case where one of
> revision number is greater than the current head.
>
> Unfortunately, I don't know enough to write the error log bit yet, so
> you may want to reject this and let someone who knows what they're
> doing tackle it.
>
> Incidentally, it might be worth pointing out in the usage messages that
> "head" is a valid revision number.
>
> Regards
>
> Kieran
>

There was no response on the list to the earlier patch. This is
probably good, because it wasn't so great.

Second cut on the patch. This deals with commands of the form:

svn log x:y

where either x or y > head.

Behaviour:
(as I write, head is 2738)

Case 1: If x == y and x <= head:
> $ svn log -r 2000:2000
>
> subversion/libsvn_client/log.c:195
> svn_error: #21019 : <Bogus revision number>
> Revision numbers cannot match: 2737, 2737. Exitting
> $
I've left it like this so that there can be a discussion of what should
happen in the case of a bogus range. Currently, it exits silently.

Case 2: If only one is greater than head (two cases):
If other value is less than head
   $ svn log -r 2737:3000 gives same output as svn log -r 2737:head
except:
  <snip normal message>
>
> ------------------------------------------------------------------------
>
> subversion/libsvn_client/log.c:177
> svn_error: #21019 : <Bogus revision number>
> Revision number too high: 3000. Using head (2738)
> $
Should I "prettify" this? If so, I'd like to add an error code to
./subversion/include/svn_error_codes.h named
SVN_ERR_REVISION_ARG_TOO_HIGH, so that I can tell the difference between
the fatal and non-fatal cases. Is this braindead, or will it fly?

IF other value is head: degrades to case 1 above

Case 3:
If both values are greater than head:
> $ ./svn log -r 2900:3000
>
> subversion/libsvn_client/log.c:184
> svn_error: #21019 : <Bogus revision number>
> Revision numbers too high: 2900, 3000. Head is 2738. Exitting
> You have mail in /home/kieran/.Mailbox
> $

Regards

Kieran

Index: subversion/libsvn_client/log.c
===================================================================
--- subversion/libsvn_client/log.c
+++ subversion/libsvn_client/log.c Fri Jul 26 20:38:16 2002
@@ -62,9 +62,11 @@
   const char *URL;
   const char *base_name = NULL;
   apr_array_header_t *condensed_targets;
- svn_revnum_t start_revnum, end_revnum;
- svn_error_t *err;
+ svn_revnum_t start_revnum, end_revnum, head_revnum;
+ svn_error_t *err, *nonfatal_err;
+ svn_client_revision_t head;

+ head.kind = svn_client_revision_head;
   if ((start->kind == svn_client_revision_unspecified)
       || (end->kind == svn_client_revision_unspecified))
     {
@@ -73,7 +75,7 @@
          "svn_client_log: caller failed to supply revision");
     }

- start_revnum = end_revnum = SVN_INVALID_REVNUM;
+ start_revnum = end_revnum = head_revnum = SVN_INVALID_REVNUM;

   path = (APR_ARRAY_IDX(targets, 0, const char *));

@@ -151,7 +153,47 @@
            (&start_revnum, ra_lib, session, start, base_name, pool));
   SVN_ERR (svn_client__get_revision_number
            (&end_revnum, ra_lib, session, end, base_name, pool));
+ SVN_ERR (svn_client__get_revision_number
+ (&head_revnum, ra_lib, session, &head, base_name, pool));

+ /* To deal with the case where one of the revision numbers provided
+ is greater than the current head, we calculate the head revision
+ number in the line above, and use that value instead of the
+ problem value. */
+ if (start_revnum > head_revnum && end_revnum <= head_revnum)
+ {
+ nonfatal_err = svn_error_createf(SVN_ERR_BAD_REVISION, 0, NULL,
pool,
+ "Revision number too high: %d. Using head
(%d)",
+ (int)start_revnum, (int)head_revnum);
+ printf("DEBUG: Revision number too high: %d. Using head (%d)\n",
+ (int)start_revnum, (int)head_revnum);
+ start_revnum = head_revnum;
+ }
+ if (start_revnum <= head_revnum && end_revnum > head_revnum)
+ {
+ nonfatal_err = svn_error_createf(SVN_ERR_BAD_REVISION, 0, NULL,
pool,
+ "Revision number too high: %d. Using head
(%d)",
+ (int)end_revnum, (int)head_revnum);
+ end_revnum = head_revnum;
+ }
+ if (start_revnum > head_revnum && end_revnum > head_revnum)
+ {
+ err = svn_error_createf(SVN_ERR_BAD_REVISION, 0, NULL, pool,
+ "Revision numbers too high: %d, %d. Head
is %d. Exitting",
+ (int)start_revnum, (int)end_revnum,
(int)head_revnum);
+ return err;
+ }
+
+ /* Previous to this change, "svn log -r x:x" exitted silently. It
will now give
+ diagnostic, although it's not clear to me that an error is better
than simply
+ providing the log message for that particular revision */
+ if (start_revnum == end_revnum)
+ {
+ err = svn_error_createf(SVN_ERR_BAD_REVISION, 0, NULL, pool,
+ "Revision numbers cannot match: %d, %d.
Exitting",
+ (int)start_revnum, (int)end_revnum);
+ return err;
+ }
   err = ra_lib->get_log (session,
                          condensed_targets,
                          start_revnum,
@@ -196,8 +238,8 @@

   /* We're done with the RA session. */
   SVN_ERR (ra_lib->close (session));
-
- return err;
+ if (err) return err;
+ return nonfatal_err;
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Jul 26 22:17:35 2002

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.