Index: cmd/Client.g
===================================================================
RCS file: /home/cvspublic/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Client.g,v
retrieving revision 1.7
diff -u -r1.7 Client.g
--- cmd/Client.g	11 Aug 2002 16:00:33 -0000	1.7
+++ cmd/Client.g	26 Sep 2002 10:03:59 -0000
@@ -243,6 +243,7 @@
     |   checkin
     |   checkout
     |   uncheckout
+    |   update
     ;
 
 help
@@ -804,6 +805,25 @@
         printUsage("versioncontrol");
     }
 
+
+update
+    :   UPDATE
+        path:STRING
+        target:STRING
+        EOL
+        {
+		client.update(text(path), text(target));
+        }
+    ;
+    exception
+    catch [RecognitionException ex]
+    {
+        printUsage("update <path> <historyURL>");
+    }
+
+
+
+
 checkin
     :   CHECKIN
         path:STRING
@@ -1030,6 +1050,7 @@
     |   CHECKIN
     |   CHECKOUT
     |   UNCHECKOUT
+    |   UPDATE
     ;
 
 // ----------------------------------------- lexical analyzer class definitions
@@ -1117,6 +1138,7 @@
     CHECKIN                 = "checkin";
     CHECKOUT                = "checkout";
     UNCHECKOUT              = "uncheckout";
+    UPDATE                  = "update";
 }
 
 // ---------------------------------------------------------------- lexer rules
Index: cmd/Client.java
===================================================================
RCS file: /home/cvspublic/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Client.java,v
retrieving revision 1.7
diff -u -r1.7 Client.java
--- cmd/Client.java	17 Jul 2002 21:02:52 -0000	1.7
+++ cmd/Client.java	26 Sep 2002 10:03:59 -0000
@@ -1324,6 +1324,24 @@
         }
     }
 
+
+    void update(String path,String version){
+	try{
+	    path = checkUri(path);
+	    out.print("Updateing resource "+path+": ");
+	    if (webdavResource.updateMethod(path,version)){
+		out.println("succeeded.");
+	    }
+	    else {
+		out.println("failed!");
+		out.println(webdavResource.getStatusMessage());
+	    }
+	}
+        catch (Exception ex) {
+            handleException(ex);
+        }
+    }
+
     
     ///////////////////////////////////////////////////////////////////
     // Support methods
@@ -1563,8 +1581,7 @@
         out.println("  versioncontrol path           "+
             "set a versionable resource under versioncontrol");
         out.println("  versioncontrol URL path       "+
-            "creating a versioncontrol path ...        "+
-            "set a versionable resource under versioncontrol");
+		    "create a new versioncontrolled resource at path based on history URL");
         out.println("  checkout path                 "+
             "checkout of a checkedin resource");
         out.println("  checkin path                  "+
@@ -1579,6 +1596,8 @@
             "getting report (locate-by-history)");
         out.println("  mkws path ...                 " +
             "Make new workspace");
+        out.println("  update path target                 " +
+            "Update a resource identified by path to version identified by target");
         out.println
             ("Aliases: help=?, open=connect, ls=dir, pwc=pwd, cc=cd, " +
              "lls=ldir, copy=cp,\n move=mv, delete=del=rm, mkcol=mkdir, " +
Index: lib/WebdavResource.java
===================================================================
RCS file: /home/cvspublic/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java,v
retrieving revision 1.49
diff -u -r1.49 WebdavResource.java
--- lib/WebdavResource.java	18 Sep 2002 05:45:06 -0000	1.49
+++ lib/WebdavResource.java	26 Sep 2002 10:04:00 -0000
@@ -3775,6 +3775,39 @@
         return state;
     }
 
+
+    /**
+     * update this resource to the specified target
+     * @param target the path of the history element to update this resource to
+     **/
+    public boolean updateMethod(String target) throws HttpException, IOException {
+	return unlockMethod(httpURL.getPath(), target);
+    }
+
+
+
+    /**
+     * update the specified resource to the specified target
+     * @param path the path of the resource to update
+     * @param target the target to update from (history resource)
+     * @author Richard UNger - runger@camino.at
+     **/
+    public boolean updateMethod(String path,String target) throws HttpException, IOException {
+	setClient();
+	path = HttpURL.getPath(path);
+	UpdateMethod method = new UpdateMethod(path,target);
+	generateIfHeader(method);
+        method.setDebug(debug);
+        client.executeMethod(method);
+
+        int statusCode = method.getStatusCode();
+        setStatusCode(statusCode);
+
+        return (statusCode >= 200 && statusCode < 300) ? true : false;	
+    }
+
+
+
     
     public boolean versionControlMethod(String path)
         throws HttpException, IOException {
Index: lib/methods/UpdateMethod.java
===================================================================
RCS file: /home/cvspublic/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UpdateMethod.java,v
retrieving revision 1.3
diff -u -r1.3 UpdateMethod.java
--- lib/methods/UpdateMethod.java	14 Aug 2002 15:22:24 -0000	1.3
+++ lib/methods/UpdateMethod.java	26 Sep 2002 10:04:00 -0000
@@ -69,28 +69,17 @@
 import org.apache.commons.httpclient.State;
 import org.apache.commons.httpclient.HttpException;
 
+import org.apache.util.XMLPrinter;
+
 import org.apache.util.WebdavStatus;
 
 
 /**
- * The Checkout method can be applied to a checked-in version-controlled
- * resource.
- *
- *
- *
- * <h3>Example Request</h3>
- * <pre>
- * Checkout /foo.html HTTP/1.1
- * Host: www.server.org
- * Content-Length: xx
- * </pre>
+ * The Update method updates a version-controlled resource to a new version.
+ * Two parameters are required, the path of the resource, and a URI identifying
+ * the version from the history to which to update.
  *
- * <h3>Example Response</h3>
- * <pre>
- * HTTP/1.1 200 OK
- * </pre>
- *
- * @author <a href="mailto:Mathias.Luber@softwareag.com">Mathias Luber</a>
+ * @author <a href="mailto:runger@camino.at">Richard Unger</a>
  */
 public class UpdateMethod
     extends XMLResponseMethodBase {
@@ -102,7 +91,10 @@
 
     // ----------------------------------------------------- Instance Variables
       
-        
+    private String sComment, sCreatorDisplayName;
+    
+    private String sTarget = null;
+       
 
     // ----------------------------------------------------------- Constructors
 
@@ -112,11 +104,12 @@
      */
     public UpdateMethod() {
         name = "UPDATE";
-      
+        sComment ="none";
+        sCreatorDisplayName ="unknown";	
     }
 
 
-    /**
+   /**
      * Method constructor.
      */
     public UpdateMethod(String path) {
@@ -126,6 +119,20 @@
 
 
 
+    /**
+     * Method constructor.
+     */
+    public UpdateMethod(String path,String sTarget) {
+        super(path);
+        name = "UPDATE";
+	this.sTarget = sTarget;
+    }
+
+
+
+
+
+
 
 
 
@@ -135,11 +142,28 @@
      * @return String query
      */
     public String generateQuery() {
-
+        
         if (query != null) {
             return query;
+        } else if (sTarget != null){
+            XMLPrinter printer = new XMLPrinter();
+            printer.writeXMLHeader();
+            
+            printer.writeElement("D", "DAV:", "update", XMLPrinter.OPENING);
+            printer.writeElement("D", "version", XMLPrinter.OPENING);
+            
+            printer.writeElement("D", "href", XMLPrinter.OPENING);
+            printer.writeText(sTarget);
+            printer.writeElement("D", "href", XMLPrinter.CLOSING);
+            printer.writeElement("D", "version", XMLPrinter.CLOSING);
+            printer.writeElement("D", "update", XMLPrinter.CLOSING);
+            
+            return printer.toString();
         } else return "";
+
     }
+
+
 
     /**
      * Parse response.

