[prev in list] [next in list] [prev in thread] [next in thread] 

List:       subversion-dev
Subject:    Issue #1213.
From:       Mark Grosberg <mark () nolab ! conman ! org>
Date:       2003-03-31 5:53:54
[Download RAW message or body]

Although I am still having problems with SWIG and Python, I thought I
would make a quick stab at issue #1213.

I'm not quite sure of the desired behavior. One option would be for PREV5,
for example, to walk back 5 _changes_ to a particular file (which could be
many more than 5 revisions to the repository).

The other approach would be for PREV5 to walk back 5 revisions from the
commited version of a particular WC entry. This is the approach I have
taken. The other approach is likely to be quite a bit harder.

For syntax, I chose something that I thought was tolerable yet extensible:

   prev    => Exactly 1 revision backwards from committed.
   prev/1  => Synonym for plain "prev"
   prev/2  => Two revisions backwards...
   prev/3  => Three revisions backwards...

if the previous commits changed the file or not). Searching back through
the nodes table would be a lot harder patch and probably outside the scope
of my current understanding of the code.

I was also unsure as to this routine:

  svn_boolean_t
  svn_client__revision_is_local (const svn_opt_revision_t *revision)
  {
    if ((revision->kind == svn_opt_revision_unspecified)
        || (revision->kind == svn_opt_revision_head)
        || (revision->kind == svn_opt_revision_number)
        || (revision->kind == svn_opt_revision_date))
      return FALSE;
    else
      return TRUE;
  }

Shouldn't PREV always be considered non-local. It's not like it's in the
text base, right? But my patch leaves the behavior for "PREV" as it was
previously (but says non-local for PREVX where X>1).

Comments welcome. I can't run "make check" yet, but its a start.

L8r,
Mark G.


["issue.1213" (TEXT/PLAIN)]

Index: libsvn_subr/opt.c
===================================================================
--- libsvn_subr/opt.c	(revision 5497)
+++ libsvn_subr/opt.c	(working copy)
@@ -284,6 +284,7 @@
   else if (strcasecmp (word, "prev") == 0)
     {
       revision->kind = svn_opt_revision_previous;
+      revision->value.number = 1;
     }
   else if (strcasecmp (word, "base") == 0)
     {
@@ -346,6 +347,18 @@
       *end = '\0';
       if (revision_from_word (revision, str) != 0)
         return NULL;
+      if ((revision->kind == svn_opt_revision_previous)
+          && (*end == '/'))
+      {
+        char *num;
+        *end++ = save;
+        num = end;
+        while (apr_isdigit (*end))
+           end++;
+        save = *end;
+        *end = '\0';
+        revision->value.number = SVN_STR_TO_REV (num);
+      }
       *end = save;
       return end;
     }
@@ -353,7 +366,6 @@
     return NULL;
 }
 
-
 int
 svn_opt_parse_revision (svn_opt_revision_t *start_revision,
                         svn_opt_revision_t *end_revision,
Index: libsvn_client/revisions.c
===================================================================
--- libsvn_client/revisions.c	(revision 5497)
+++ libsvn_client/revisions.c	(working copy)
@@ -52,7 +52,9 @@
   /* Sanity check. */
   if (((ra_lib == NULL) || (sess == NULL))
       && ((revision->kind == svn_opt_revision_date)
-          || (revision->kind == svn_opt_revision_head)))
+          || (revision->kind == svn_opt_revision_head)
+          || ((revision->kind == svn_opt_revision_previous)
+              && (revision->value.number > 1))))
     {
       return svn_error_create
         (SVN_ERR_CLIENT_RA_ACCESS_REQUIRED, NULL,
@@ -101,7 +103,12 @@
         {
           *revnum = ent->cmt_rev;
           if (revision->kind == svn_opt_revision_previous)
-            (*revnum)--;
+            {
+               if (*revnum > revision->value.number)
+                 (*revnum) -= revision->value.number;
+               else
+                 revnum = SVN_INVALID_REVNUM;
+            }
         }
     }
   else
@@ -133,10 +140,12 @@
 svn_boolean_t
 svn_client__revision_is_local (const svn_opt_revision_t *revision)
 {
-  if ((revision->kind == svn_opt_revision_unspecified)
-      || (revision->kind == svn_opt_revision_head)
-      || (revision->kind == svn_opt_revision_number)
-      || (revision->kind == svn_opt_revision_date))
+  if (revision->kind == svn_opt_revision_previous)
+    return (revision->value.number == 1);
+  else if ((revision->kind == svn_opt_revision_unspecified)
+           || (revision->kind == svn_opt_revision_head)
+           || (revision->kind == svn_opt_revision_number)
+           || (revision->kind == svn_opt_revision_date))
     return FALSE;
   else
     return TRUE;
Index: clients/cmdline/main.c
===================================================================
--- clients/cmdline/main.c	(revision 5497)
+++ clients/cmdline/main.c	(working copy)
@@ -71,7 +71,8 @@
      "                             \"HEAD\"      latest in repository\n"
      "                             \"BASE\"      base revision of item's working copy\n"
      "                             \"COMMITTED\" revision of item's last commit\n"
-     "                             \"PREV\"      revision before item's last commit"
+     "                             \"PREV\"      revision before item's last commit\n"
+     "                             \"PREV/x\"    'x' revisions before item's last commit\n"
      /* spacing corresponds to svn_opt_format_option */
     },
     {"file",          'F', 1, "read data from file ARG"},


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic