This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 202417
Collapse All | Expand All

(-)lib.cvsclient/src/org/netbeans/lib/cvsclient/command/GlobalOptions.java (-1 / +2 lines)
Lines 49-54 Link Here
49
import java.io.File;
49
import java.io.File;
50
import java.util.*;
50
import java.util.*;
51
51
52
import org.netbeans.lib.cvsclient.CVSRoot;
52
import org.netbeans.lib.cvsclient.request.*;
53
import org.netbeans.lib.cvsclient.request.*;
53
54
54
/**
55
/**
Lines 462-468 Link Here
462
     * @param cvsRoot CVS root to use
463
     * @param cvsRoot CVS root to use
463
     */
464
     */
464
    public void setCVSRoot(String cvsRoot) {
465
    public void setCVSRoot(String cvsRoot) {
465
        this.cvsRoot = cvsRoot;
466
        this.cvsRoot = CVSRoot.parse(cvsRoot).toString();
466
    }
467
    }
467
468
468
    /**
469
    /**
(-)lib.cvsclient/src/org/netbeans/lib/cvsclient/CVSRoot.java (-6 / +7 lines)
Lines 50-55 Link Here
50
import java.util.*;
50
import java.util.*;
51
import org.netbeans.lib.cvsclient.connection.Connection;
51
import org.netbeans.lib.cvsclient.connection.Connection;
52
import org.netbeans.lib.cvsclient.connection.ConnectionFactory;
52
import org.netbeans.lib.cvsclient.connection.ConnectionFactory;
53
import org.netbeans.lib.cvsclient.util.PathUtils;
53
54
54
/**
55
/**
55
    <p>
56
    <p>
Lines 207-213 Link Here
207
        if (r == null)
208
        if (r == null)
208
            throw new IllegalArgumentException("Repository is obligatory.");
209
            throw new IllegalArgumentException("Repository is obligatory.");
209
        else
210
        else
210
            this.repository = r;
211
            setRepository(r);
211
    }
212
    }
212
	
213
	
213
    /**
214
    /**
Lines 242-248 Link Here
242
                if (cvsroot.indexOf(':') == 1 && cvsroot.indexOf('\\') == 2) {
243
                if (cvsroot.indexOf(':') == 1 && cvsroot.indexOf('\\') == 2) {
243
                    //#67504 it looks like windows drive  => local
244
                    //#67504 it looks like windows drive  => local
244
                    method = METHOD_LOCAL;
245
                    method = METHOD_LOCAL;
245
                    repository = cvsroot;
246
                    setRepository(cvsroot);
246
                    return;
247
                    return;
247
                }                
248
                }                
248
                colonPosition = cvsroot.indexOf(':');
249
                colonPosition = cvsroot.indexOf(':');
Lines 313-319 Link Here
313
        
314
        
314
        if (localFormat) {
315
        if (localFormat) {
315
            // everything after method is repository in local format
316
            // everything after method is repository in local format
316
            this.repository = cvsroot.substring(colonPosition);
317
            setRepository(cvsroot.substring(colonPosition));
317
        } else {
318
        } else {
318
            /* So now we parse SERVER_FORMAT
319
            /* So now we parse SERVER_FORMAT
319
            :method:[[user][:password]@]hostname[:[port]]/reposi/tory
320
            :method:[[user][:password]@]hostname[:[port]]/reposi/tory
Lines 403-412 Link Here
403
                if (pr.startsWith(":")) {  // NOI18N
404
                if (pr.startsWith(":")) {  // NOI18N
404
                    pr = pr.substring(1);
405
                    pr = pr.substring(1);
405
                }
406
                }
406
                this.repository = pr;
407
                setRepository(pr);
407
            } else {
408
            } else {
408
                this.port = 0;
409
                this.port = 0;
409
                this.repository = cvsroot.substring(pathBegin);
410
                setRepository(cvsroot.substring(pathBegin));
410
            }
411
            }
411
        }
412
        }
412
    }
413
    }
Lines 729-735 Link Here
729
        if (repository == null) {
730
        if (repository == null) {
730
            throw new IllegalArgumentException("The repository must not be null.");
731
            throw new IllegalArgumentException("The repository must not be null.");
731
        }
732
        }
732
        this.repository = repository;
733
        this.repository = PathUtils.normalizePath(repository);
733
    }
734
    }
734
735
735
}
736
}
(-)lib.cvsclient/src/org/netbeans/lib/cvsclient/util/PathUtils.java (+59 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.lib.cvsclient.util;
43
44
/**
45
 *
46
 * @author Vladimir Sitnikov <w.sitnikov@gmail.com>
47
 */
48
public class PathUtils {
49
50
    public static String normalizePath(String path) {
51
        // toss out unix or windows separator repetitions as well as trailing separator 
52
53
        if (path.endsWith("/") || path.endsWith("\\")) {
54
            return normalizePath(path.substring(0, path.length() - 1));
55
        } else {
56
            return path.replaceAll("/+", "/").replaceAll("\\\\+", "\\\\");
57
        }
58
    }
59
}
(-)lib.cvsclient/test/unit/src/org/netbeans/lib/cvsclient/CVSRootTest.java (+10 lines)
Lines 147-152 Link Here
147
        
147
        
148
    }
148
    }
149
    
149
    
150
    public void testRepositoryPathNormalizing() {
151
        // pass some cvsroots with path separator repetitions and trailing path separator char
152
        CVSRoot root = CVSRoot.parse(":pserver:mike@javadev.zappmobile.ro:2401:/home//cvsroot/");
153
        compareRoot(root, CVSRoot.METHOD_PSERVER, "mike", null, "javadev.zappmobile.ro", 2401, "/home/cvsroot");
154
        root = CVSRoot.parse(":ssh;ver=2:username@cvs.sf.net:/cvsroot//xoops/");
155
        compareRoot(root, CVSRoot.METHOD_EXT, "username", null, "cvs.sf.net", 0, "/cvsroot/xoops");
156
        root = CVSRoot.parse("c:\\CVSROOT\\\\Module1\\");
157
        compareRoot(root, CVSRoot.METHOD_LOCAL, null, null, null, 0, "c:\\CVSROOT\\Module1");
158
    }
159
    
150
    /**
160
    /**
151
     * Test of CVSRoot.parse() method.
161
     * Test of CVSRoot.parse() method.
152
     * It should not parse the CVSROOT String if not of the form
162
     * It should not parse the CVSROOT String if not of the form

Return to bug 202417