Return-Path: Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 74724 invoked from network); 6 Nov 2000 20:18:04 -0000 Received: from mail.enteract.com (207.229.143.33) by locus.apache.org with SMTP; 6 Nov 2000 20:18:04 -0000 Received: from christchurch (28.nummus.enterconnect.net [207.229.144.124]) by mail.enteract.com (8.9.3/8.9.3) with SMTP id OAA48490 for ; Mon, 6 Nov 2000 14:18:01 -0600 (CST) (envelope-from slistopad@intercapsystems.com) Reply-To: From: "Samuel R Listopad II" To: Subject: Revised: [PATCH] Starteam Checkout Date: Mon, 6 Nov 2000 14:18:50 -0600 Message-ID: <004c01c0482e$c87a5610$5b0da8c0@nummus.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_004D_01C047FC.7DDFE610" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 In-Reply-To: Importance: Normal X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------=_NextPart_000_004D_01C047FC.7DDFE610 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit > could you please rewrite your patch in a way that it compiles on JDK > 1.1 (no HashMap please). Done. > And then I'd suggest to make > setAppendViewName take a boolean argument. And Done. > any Starteam users apart from Samuel here that could check that it > works in their environment as well? Yeah if someone could do some testing of this patch I would be greatly appreciative. Any questions, bugs or concerns should be sent to the list and me if possible. Sam ------=_NextPart_000_004D_01C047FC.7DDFE610 Content-Type: application/octet-stream; name="AntStarTeamCheckOut.java.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="AntStarTeamCheckOut.java.diff" Index: AntStarTeamCheckOut.java=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: = /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/option= al/scm/AntStarTeamCheckOut.java,v=0A= retrieving revision 1.2=0A= diff -w -b -B -d -u -r1.2 AntStarTeamCheckOut.java=0A= --- AntStarTeamCheckOut.java 2000/08/22 15:54:16 1.2=0A= +++ AntStarTeamCheckOut.java 2000/11/06 20:03:58=0A= @@ -73,16 +73,15 @@=0A= * out only if appropriate.=0A= *

=0A= * Checked out files go to a directory you specify under the subfolder=0A= - * named for the default StarTeam path to the view. That is, if you=0A= - * entered /home/cpovirk/work as the target folder, your project was = named=0A= - * "OurProject," the given view was named "TestView," and that view is=0A= - * stored by default at "C:\projects\Test," your files would be checked=0A= - * out to /home/cpovirk/work/Test." I avoided using the project name in=0A= + * named for the the view. That is, if you entered /home/cpovirk/work=0A= + * as the target folder, your project was named "OurProject," the given=0A= + * view was named "TestView," your files would be checked out to=0A= + * /home/cpovirk/work/TestView." I avoided using the project name in=0A= * the path because you may want to keep several versions of the same=0A= - * project on your computer, and I didn't want to use the view name, as=0A= - * there may be many "Test" or "Version 1.0" views, for example. This=0A= - * system's success, of course, depends on what you set the default path=0A= - * to in StarTeam.=0A= + * project on your computer. The view name does not have to be appended=0A= + * by setting the appendViewName attribute to false. This = is=0A= + * in case you have many "Test" or "Version 1.0" views that you need to=0A= + * checkout.=0A= *

=0A= * You can set AntStarTeamCheckOut to verbose or quiet mode. Also, it = has=0A= * a safeguard against overwriting the files on your computer: If the=0A= @@ -249,6 +248,12 @@=0A= * and not in its subfolders.=0A= */=0A= private String recursion =3D DEFAULT_RECURSIONSETTING;=0A= + /**=0A= + * Set appendViewName to false to check out files without adding=0A= + * a directory for view name between targetFolder and path to=0A= + * file in Starteam. (Under view)=0A= + */=0A= + private boolean appendViewName =3D true;=0A= =0A= // These fields deal with includes and excludes=0A= =0A= @@ -268,6 +273,26 @@=0A= private String delim =3D Platform.getFilePathDelim();=0A= =0A= /**=0A= + * The allowed Statuses to check out.=0A= + */=0A= + private String statusFilter =3D null;=0A= + private Vector statusToCheckout =3D null;=0A= +=0A= + private static Hashtable statusMap =3D null;=0A= +=0A= + static=0A= + {=0A= + statusMap =3D new Hashtable(10);=0A= + statusMap.put("c", new Integer(0)); //Current=0A= + statusMap.put("g", new Integer(1)); //Merge=0A= + statusMap.put("i", new Integer(2)); //Missing=0A= + statusMap.put("m", new Integer(3)); //Modified=0A= + statusMap.put("o", new Integer(4)); //out-of-date=0A= + statusMap.put("n", new Integer(5)); //Not in view=0A= + statusMap.put("u", new Integer(6)); //Unknown=0A= + }=0A= +=0A= + /**=0A= * Do the execution.=0A= * =0A= * @exception BuildException=0A= @@ -443,6 +468,21 @@=0A= =0A= // This is ugly; checking for the root folder.=0A= Folder f =3D v.getRootFolder();=0A= +=0A= + try=0A= + {=0A= + if(!getAppendViewName())=0A= + {=0A= + f.setAlternatePathFragment( (new = java.io.File(getTargetFolder())).getCanonicalPath() );=0A= + }=0A= + else=0A= + {=0A= + f.setAlternatePathFragment( (new = java.io.File(getTargetFolder()+delim+viewName)).getCanonicalPath() );=0A= + }=0A= + }catch(Exception e)=0A= + {=0A= + //pass=0A= + }=0A= if (!(getFolderName()=3D=3Dnull))=0A= {=0A= if (getFolderName().equals("\\") || getFolderName().equals("/"))=0A= @@ -584,7 +624,14 @@=0A= {=0A= return;=0A= }=0A= -=0A= + // Change the item to be checked out to a StarTeam File.=0A= + com.starbase.starteam.File remote =3D = (com.starbase.starteam.File)item;=0A= + int stat =3D 6;=0A= + try{=0A= + stat =3D remote.getStatus();=0A= + }catch(Exception e){=0A= + //pass=0A= + }=0A= // VERBOSE MODE ONLY=0A= if (getVerboseAsBoolean())=0A= {=0A= @@ -613,13 +660,14 @@=0A= if (bShowHeader)=0A= {=0A= System.out.print(" Item");=0A= - System.out.print(",\t" + p1.getDisplayName());=0A= - if (p2 !=3D null)=0A= + System.out.print(", " + p1.getDisplayName());=0A= + if (p2 !=3D null && !p2.equals(""))=0A= {=0A= - System.out.print(",\t" + p2.getDisplayName());=0A= + System.out.print(", " + p2.getDisplayName());=0A= }=0A= System.out.println("");=0A= }=0A= + System.out.println("\n Abs Path is " + = remote.getFullName());=0A= =0A= // Finally, show the Item properties ...=0A= =0A= @@ -628,74 +676,49 @@=0A= =0A= // Show the primary descriptor.=0A= // There should always be one.=0A= - System.out.print(",\t" + formatForDisplay(p1, = item.get(p1.getName())));=0A= + System.out.print(", " + formatForDisplay(p1, = item.get(p1.getName())));=0A= =0A= // Show the secondary descriptor, if there is one.=0A= // Some item types have one, some don't.=0A= - if (p2 !=3D null)=0A= + if (p2 !=3D null && !p2.equals(""))=0A= {=0A= - System.out.print(",\t" + formatForDisplay(p2, = item.get(p2.getName())));=0A= + System.out.print(", " + formatForDisplay(p2, = item.get(p2.getName())));=0A= }=0A= =0A= // Show if the file is locked.=0A= int locker =3D item.getLocker();=0A= if (locker>-1)=0A= {=0A= - System.out.println(",\tLocked by " + locker);=0A= + System.out.print(", Locked by " + locker);=0A= }=0A= else=0A= {=0A= - System.out.println(",\tNot locked");=0A= + System.out.print(", Not locked");=0A= }=0A= + try{=0A= + System.out.println(", " + = com.starbase.starteam.Status.name(stat));=0A= + }catch(Exception e){=0A= + System.out.println("Failed to get status");=0A= + }=0A= }=0A= // END VERBOSE ONLY=0A= =0A= // Check it out; also ugly.=0A= =0A= - // Change the item to be checked out to a StarTeam File.=0A= - com.starbase.starteam.File remote =3D = (com.starbase.starteam.File)item;=0A= =0A= - // Create a variable dirName that contains the name of the StarTeam = folder that is the root folder in this view.=0A= - // Get the default path to the current view.=0A= - String dirName =3D v.getDefaultPath();=0A= - // Settle on "/" as the default path separator for this purpose only.=0A= - dirName =3D dirName.replace('\\', '/');=0A= - // Take the StarTeam folder name furthest down in the = hierarchy.=0A= - int endDirIndex =3D dirName.length();=0A= - // If it ends with separator then strip it off=0A= - if (dirName.endsWith("/"))=0A= - {=0A= - // This should be the SunOS and Linux case=0A= - endDirIndex--;=0A= - }=0A= - dirName =3D dirName.substring(dirName.lastIndexOf("/", = dirName.length() - 2) + 1, endDirIndex);=0A= =0A= - // Replace the projectName in the file's absolute path to the = viewName.=0A= - // This eventually makes the target of a checkout operation equal to:=0A= - // targetFolder + dirName + [subfolders] + itemName=0A= - StringTokenizer pathTokenizer =3D new = StringTokenizer(item.getParentFolder().getFolderHierarchy(), delim);=0A= - String localName =3D delim;=0A= - String currentToken =3D null;=0A= - while (pathTokenizer.hasMoreTokens())=0A= - {=0A= - currentToken =3D pathTokenizer.nextToken();=0A= - if (currentToken.equals(getProjectName()))=0A= - {=0A= - currentToken =3D dirName;=0A= - }=0A= - localName +=3D currentToken + delim;=0A= - }=0A= - // Create a reference to the local target file using the format = listed above.=0A= - java.io.File local =3D new java.io.File(getTargetFolder() + localName = + item.get(p1.getName()));=0A= try=0A= {=0A= - remote.checkoutTo(local, Item.LockType.UNCHANGED, false, true, true);=0A= + if(statusToCheckout =3D=3D null || statusToCheckout.indexOf(new = Integer(stat)) !=3D -1){=0A= + project.log("Checking file " + remote.getName() + " out to = " + remote.getFullName(), project.MSG_VERBOSE);=0A= + remote.checkout(Item.LockType.UNCHANGED, false, true, true);=0A= + checkedOut++;=0A= + }=0A= }=0A= catch (Throwable e)=0A= {=0A= project.log(" " + e.getMessage());=0A= }=0A= - checkedOut++;=0A= }=0A= =0A= /**=0A= @@ -1286,6 +1309,39 @@=0A= {=0A= return project.toBoolean(verbose);=0A= }=0A= + /**=0A= + * Sets the appendViewName attribute to the given value.=0A= + *=0A= + * @param append A boolean containing telling AntStarTeamCheckOut=0A= + * whether to add the view name to=0A= + * the checkout directory. By default it is=0A= + * true, so the program adds the extra directory which=0A= + * is named the same as the View.=0A= + * @see #getAppendViewName()=0A= + */=0A= +=0A= + public void setAppendViewName(boolean append)=0A= + {=0A= + this.appendViewName =3D append;=0A= + }=0A= +=0A= + public void setAppendViewName(String append)=0A= + {=0A= + this.appendViewName =3D project.toBoolean(append);=0A= + }=0A= +=0A= + /**=0A= + * Gets the appendViewName attribute.=0A= + *=0A= + * @return A boolean telling the application=0A= + * to add the view name to the checkout path or not.=0A= + * @see #setAppendViewName(String appendViewName)=0A= + */=0A= +=0A= + public boolean getAppendViewName()=0A= + {=0A= + return appendViewName;=0A= + }=0A= =0A= // Begin filter getters and setters=0A= =0A= @@ -1407,5 +1463,52 @@=0A= {=0A= return excludes;=0A= }=0A= + /**=0A= + * Sets the statusFilter attribute.=0A= + *=0A= + * Sets the Filter of what statuses are acceptable to checkout. It = is a=0A= + * String which gets parsed. An example of a Status filter is = "MUGI"=0A= + * without spaces and other delimiters. This example would = check out=0A= + * files only if thier status was Modified, Unknown, Merge, or = Missing.=0A= + * Any other status and the file would not be checked out.=0A= + *=0A= + * Values can be any combination of the following:=0A= + *
=0A=
+        * 		'C':  Current=0A=
+        * 		'G':  Merge=0A=
+        * 		'I':  Missing=0A=
+        * 		'M':  Modified=0A=
+        * 		'O':  Out-of-Date=0A=
+        * 		'N':  Not-in-View=0A=
+        * 		'U':  Unknown=0A=
+        * 
=0A= + *=0A= + * These statuses are defined in the Starteam documentation.=0A= + * @param stats A String defining the statuses acceptable to be = checked out.=0A= + *=0A= + */=0A= + public void setStatusFilter(String stats)=0A= + {=0A= + this.statusFilter =3D stats;=0A= + statusToCheckout =3D new Vector();=0A= + char letters[] =3D stats.toCharArray();=0A= + for(int i=3D0; i