# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: C:\fonar101\Projects\NB_repo # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: lib.cvsclient/src/org/netbeans/lib/cvsclient/command/GlobalOptions.java --- lib.cvsclient/src/org/netbeans/lib/cvsclient/command/GlobalOptions.java Базовая редакция (BASE) +++ lib.cvsclient/src/org/netbeans/lib/cvsclient/command/GlobalOptions.java Локально измененный (на основе LOCAL) @@ -49,6 +49,7 @@ import java.io.File; import java.util.*; +import org.netbeans.lib.cvsclient.CVSRoot; import org.netbeans.lib.cvsclient.request.*; /** @@ -462,7 +463,7 @@ * @param cvsRoot CVS root to use */ public void setCVSRoot(String cvsRoot) { - this.cvsRoot = cvsRoot; + this.cvsRoot = CVSRoot.parse(cvsRoot).toString(); } /** Index: lib.cvsclient/src/org/netbeans/lib/cvsclient/CVSRoot.java --- lib.cvsclient/src/org/netbeans/lib/cvsclient/CVSRoot.java Базовая редакция (BASE) +++ lib.cvsclient/src/org/netbeans/lib/cvsclient/CVSRoot.java Локально измененный (на основе LOCAL) @@ -50,6 +50,7 @@ import java.util.*; import org.netbeans.lib.cvsclient.connection.Connection; import org.netbeans.lib.cvsclient.connection.ConnectionFactory; +import org.netbeans.lib.cvsclient.util.PathUtils; /**

@@ -207,7 +208,7 @@ if (r == null) throw new IllegalArgumentException("Repository is obligatory."); else - this.repository = r; + setRepository(r); } /** @@ -242,7 +243,7 @@ if (cvsroot.indexOf(':') == 1 && cvsroot.indexOf('\\') == 2) { //#67504 it looks like windows drive => local method = METHOD_LOCAL; - repository = cvsroot; + setRepository(cvsroot); return; } colonPosition = cvsroot.indexOf(':'); @@ -313,7 +314,7 @@ if (localFormat) { // everything after method is repository in local format - this.repository = cvsroot.substring(colonPosition); + setRepository(cvsroot.substring(colonPosition)); } else { /* So now we parse SERVER_FORMAT :method:[[user][:password]@]hostname[:[port]]/reposi/tory @@ -403,10 +404,10 @@ if (pr.startsWith(":")) { // NOI18N pr = pr.substring(1); } - this.repository = pr; + setRepository(pr); } else { this.port = 0; - this.repository = cvsroot.substring(pathBegin); + setRepository(cvsroot.substring(pathBegin)); } } } @@ -729,7 +730,7 @@ if (repository == null) { throw new IllegalArgumentException("The repository must not be null."); } - this.repository = repository; + this.repository = PathUtils.normalizePath(repository); } } Index: lib.cvsclient/src/org/netbeans/lib/cvsclient/util/PathUtils.java --- lib.cvsclient/src/org/netbeans/lib/cvsclient/util/PathUtils.java Базовая редакция (BASE) +++ lib.cvsclient/src/org/netbeans/lib/cvsclient/util/PathUtils.java Создан локально @@ -0,0 +1,59 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.lib.cvsclient.util; + +/** + * + * @author Vladimir Sitnikov + */ +public class PathUtils { + + public static String normalizePath(String path) { + // toss out unix or windows separator repetitions as well as trailing separator + + if (path.endsWith("/") || path.endsWith("\\")) { + return normalizePath(path.substring(0, path.length() - 1)); + } else { + return path.replaceAll("/+", "/").replaceAll("\\\\+", "\\\\"); + } + } +} Index: lib.cvsclient/test/unit/src/org/netbeans/lib/cvsclient/CVSRootTest.java --- lib.cvsclient/test/unit/src/org/netbeans/lib/cvsclient/CVSRootTest.java Базовая редакция (BASE) +++ lib.cvsclient/test/unit/src/org/netbeans/lib/cvsclient/CVSRootTest.java Локально измененный (на основе LOCAL) @@ -147,6 +147,16 @@ } + public void testRepositoryPathNormalizing() { + // pass some cvsroots with path separator repetitions and trailing path separator char + CVSRoot root = CVSRoot.parse(":pserver:mike@javadev.zappmobile.ro:2401:/home//cvsroot/"); + compareRoot(root, CVSRoot.METHOD_PSERVER, "mike", null, "javadev.zappmobile.ro", 2401, "/home/cvsroot"); + root = CVSRoot.parse(":ssh;ver=2:username@cvs.sf.net:/cvsroot//xoops/"); + compareRoot(root, CVSRoot.METHOD_EXT, "username", null, "cvs.sf.net", 0, "/cvsroot/xoops"); + root = CVSRoot.parse("c:\\CVSROOT\\\\Module1\\"); + compareRoot(root, CVSRoot.METHOD_LOCAL, null, null, null, 0, "c:\\CVSROOT\\Module1"); + } + /** * Test of CVSRoot.parse() method. * It should not parse the CVSROOT String if not of the form