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 206061
Collapse All | Expand All

(-)a/nbbuild/cluster.properties (+1 lines)
Lines 394-399 Link Here
394
        usersguide,\
394
        usersguide,\
395
        utilities,\
395
        utilities,\
396
        utilities.project,\
396
        utilities.project,\
397
        vcs.ade.treestamp,\
397
        versioning,\
398
        versioning,\
398
        versioning.core,\
399
        versioning.core,\
399
        versioning.indexingbridge,\
400
        versioning.indexingbridge,\
(-)a/vcs.ade.treestamp/build.xml (+5 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project basedir="." default="netbeans" name="vcs.ade.treestamp">
3
    <description>Builds, tests, and runs the project org.netbeans.modules.vcs.ade.treestamp</description>
4
    <import file="../nbbuild/templates/projectized.xml"/>
5
</project>
(-)a/vcs.ade.treestamp/manifest.mf (+5 lines)
Line 0 Link Here
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.vcs.ade.treestamp
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/vcs/ade/treestamp/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.0
5
(-)a/vcs.ade.treestamp/nbproject/project.properties (+3 lines)
Line 0 Link Here
1
is.eager=true
2
javac.source=1.6
3
javac.compilerargs=-Xlint -Xlint:-serial
(-)a/vcs.ade.treestamp/nbproject/project.xml (+45 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://www.netbeans.org/ns/project/1">
3
    <type>org.netbeans.modules.apisupport.project</type>
4
    <configuration>
5
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
6
            <code-name-base>org.netbeans.modules.vcs.ade.treestamp</code-name-base>
7
            <module-dependencies>
8
                <dependency>
9
                    <code-name-base>org.netbeans.modules.versioning</code-name-base>
10
                    <build-prerequisite/>
11
                    <compile-dependency/>
12
                    <run-dependency>
13
                        <release-version>1</release-version>
14
                        <specification-version>1.29</specification-version>
15
                    </run-dependency>
16
                </dependency>
17
                <dependency>
18
                    <code-name-base>org.openide.filesystems</code-name-base>
19
                    <build-prerequisite/>
20
                    <compile-dependency/>
21
                    <run-dependency>
22
                        <specification-version>7.60</specification-version>
23
                    </run-dependency>
24
                </dependency>
25
                <dependency>
26
                    <code-name-base>org.openide.util</code-name-base>
27
                    <build-prerequisite/>
28
                    <compile-dependency/>
29
                    <run-dependency>
30
                        <specification-version>8.22</specification-version>
31
                    </run-dependency>
32
                </dependency>
33
                <dependency>
34
                    <code-name-base>org.openide.util.lookup</code-name-base>
35
                    <build-prerequisite/>
36
                    <compile-dependency/>
37
                    <run-dependency>
38
                        <specification-version>8.12</specification-version>
39
                    </run-dependency>
40
                </dependency>
41
            </module-dependencies>
42
            <public-packages/>
43
        </data>
44
    </configuration>
45
</project>
(-)a/vcs.ade.treestamp/src/org/netbeans/modules/vcs/ade/treestamp/ADEInterceptor.java (+63 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.vcs.ade.treestamp;
43
44
import java.io.File;
45
import org.netbeans.modules.versioning.spi.VCSInterceptor;
46
import org.openide.filesystems.TreeStamp;
47
48
/**
49
 *
50
 * @author Tomas Zezula
51
 */
52
public class ADEInterceptor extends VCSInterceptor {
53
54
    @Override
55
    public Object getAttribute(File file, String attrName) {
56
        if (TreeStamp.Provider.class.getName().equals(attrName)) {
57
            return ADETreeStampProvider.getInstance();
58
        } else {
59
            return super.getAttribute(file, attrName);
60
        }
61
    }
62
    
63
}
(-)a/vcs.ade.treestamp/src/org/netbeans/modules/vcs/ade/treestamp/ADETreeStampProvider.java (+232 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.vcs.ade.treestamp;
43
44
import java.io.BufferedReader;
45
import java.io.File;
46
import java.io.IOException;
47
import java.io.InputStreamReader;
48
import java.util.HashMap;
49
import java.util.HashSet;
50
import java.util.Map;
51
import java.util.Set;
52
import java.util.concurrent.atomic.AtomicReference;
53
import java.util.logging.Level;
54
import java.util.logging.Logger;
55
import java.util.regex.Matcher;
56
import java.util.regex.Pattern;
57
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileUtil;
59
import org.openide.filesystems.TreeStamp;
60
import org.openide.util.Exceptions;
61
62
/**
63
 *
64
 * @author Tomas Zezula
65
 */
66
public final class ADETreeStampProvider extends TreeStamp.Provider {
67
    
68
    private static final String LABEL = "BASE_LABEL:";                  //NOI18N
69
    private static final String CHANGED_FILES = "ALL AFFECTED FILES:";  //NOI18N
70
    private static final String NEW_FILES = "NEW FILES:";               //NOI18N
71
    private static final String REMOVED_FILES = "RMNAMED (REMOVED) FILES:"; //NOI18N
72
    private static final Pattern CHANGE = Pattern.compile("\\s*\\d+\\.\\s+(.*)"); //NOI18N
73
    
74
    private static final Logger LOG = Logger.getLogger(ADETreeStampProvider.class.getName());
75
    
76
    private final AtomicReference<File> adeRoot = new AtomicReference<File>();
77
    
78
    private ADETreeStampProvider() {}
79
80
    @Override
81
    protected Map<FileObject, TreeStamp> stamps(Map<FileObject, String> rootsAndBaseIds) {
82
        final Map<FileObject, TreeStamp> result = new HashMap<FileObject, TreeStamp>();
83
        Transaction tx = null;
84
        boolean described = false;
85
        for (Map.Entry<FileObject,String> entry : rootsAndBaseIds.entrySet()) {
86
            final FileObject root = entry.getKey();
87
            final String base = entry.getValue();
88
            final String adeRootPath = getADERootPath();
89
            final String rootDirPath = getPath(FileUtil.toFile(root));
90
            if (adeRootPath != null &&
91
                rootDirPath != null &&
92
                rootDirPath.startsWith(adeRootPath)) {  //NOI18N
93
                if (!described) {
94
                    described = true;
95
                    tx = describeTrans(getADERoot());
96
                }
97
                if (tx != null && (base == null || base.equals(tx.getLabel()))) {
98
                    final Set<String> paths = new HashSet<String>();
99
                    for (String cf : tx.getChanges()) {
100
                        if (cf.startsWith(rootDirPath)) {
101
                            paths.add(cf.substring(rootDirPath.length()));
102
                        }
103
                    }
104
                    result.put(root, create(tx.getLabel(), null, paths));
105
                    LOG.log(
106
                        Level.FINE,
107
                        "Root: {0}, Label: {1}, Changes: {2}",  //NOI18N
108
                        new Object[] {
109
                            rootDirPath,
110
                            tx.getLabel(),
111
                            paths
112
                        });
113
                }
114
            }
115
        }
116
        return result;
117
    }
118
    
119
    
120
    File getADERoot() {
121
        File adeRootDir = adeRoot.get();
122
        if (adeRootDir == null) {
123
            final String adeRootStr = System.getenv("ADE_VIEW_ROOT");  //NOI18N
124
            if (adeRootStr != null) {
125
                adeRootDir = FileUtil.normalizeFile(new File(adeRootStr));
126
                adeRoot.compareAndSet(null, adeRootDir);
127
            }
128
        }
129
        return adeRootDir;
130
    }
131
    
132
    String getADERootPath() {
133
        return getPath(getADERoot());
134
    }
135
    
136
    private static String getPath(final File file) {
137
        if (file == null) {
138
            return null;
139
        }
140
        String path = file.getAbsolutePath();
141
        if (!path.endsWith(File.separator)) {
142
            path = path + File.separatorChar;
143
        }
144
        return path;
145
    }
146
    
147
    
148
    private Transaction describeTrans(final File rootDir) {
149
        try {
150
            final Process process = new ProcessBuilder("ade","describetrans","-short").start();    //NOI18N
151
            final BufferedReader in = new BufferedReader( new InputStreamReader(process.getInputStream()));
152
            try {
153
                String label = null;
154
                Set<String> changedFiles = new HashSet<String>();
155
                int mode = 0;
156
                String line;
157
                while ((line=in.readLine())!=null) {
158
                    if (mode == 0) {
159
                        if (line.startsWith(LABEL)) {
160
                            String[] parts = line.split("\\s*:\\s*");   //NOI18N
161
                            if (parts.length == 2) {
162
                                label = parts[1];
163
                            }
164
                        } else if (line.startsWith(CHANGED_FILES)) {
165
                            mode = 1;
166
                        } else if (line.startsWith(NEW_FILES)) {
167
                            mode = 1;
168
                        } else if (line.startsWith(REMOVED_FILES)) {
169
                            mode = 1;
170
                        }
171
                    } else if (mode == 1) {
172
                        if (line.startsWith(CHANGED_FILES)) {
173
                            mode = 1;
174
                        } else if (line.startsWith(NEW_FILES)) {
175
                            mode = 1;
176
                        } else if (line.startsWith(REMOVED_FILES)) {
177
                            mode = 1;
178
                        } else {
179
                            final Matcher m = CHANGE.matcher(line);
180
                            if (m.matches()) {
181
                                String path = m.group(1);
182
                                changedFiles.add(
183
                                        FileUtil.normalizeFile(new File(rootDir,path.trim())).getAbsolutePath());
184
                            } else {
185
                                mode = 0;
186
                            }
187
                        }
188
                    }
189
                }
190
                if (label != null) {
191
                    return new Transaction(label, changedFiles);
192
                }
193
            } finally {
194
                in.close();
195
            }
196
        } catch (IOException ioe) {
197
            Exceptions.printStackTrace(ioe);
198
        }
199
        return null;
200
    }
201
    
202
    static ADETreeStampProvider getInstance() {
203
        return Holder.instance;
204
    }
205
    
206
    private static class Transaction {
207
        
208
        private final String label;
209
        private final Set<? extends String> changedFiles;
210
        
211
        private Transaction(
212
                final String label,
213
                final Set<? extends String> changedFiles) {
214
            this.label = label;
215
            this.changedFiles = changedFiles;
216
        }
217
        
218
        public String getLabel() {
219
            return label;
220
        }
221
        
222
        public Set<? extends String> getChanges() {
223
            return changedFiles;
224
        }
225
        
226
    }
227
    
228
    private static class Holder {
229
        private static final ADETreeStampProvider instance = new ADETreeStampProvider();
230
    }
231
    
232
}
(-)a/vcs.ade.treestamp/src/org/netbeans/modules/vcs/ade/treestamp/ADEVersioning.java (+73 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.vcs.ade.treestamp;
43
44
import java.io.File;
45
import org.netbeans.modules.versioning.spi.VCSInterceptor;
46
import org.netbeans.modules.versioning.spi.VersioningSystem;
47
import org.openide.util.lookup.ServiceProvider;
48
49
/**
50
 *
51
 * @author Tomas Zezula
52
 */
53
@ServiceProvider(service=VersioningSystem.class)
54
public class ADEVersioning extends VersioningSystem {
55
    
56
    private final VCSInterceptor interceptor = new ADEInterceptor();
57
    
58
    @Override
59
    public File getTopmostManagedAncestor(File file) {
60
        final File adeRootDir = ADETreeStampProvider.getInstance().getADERoot();
61
        if (adeRootDir != null && file.getAbsolutePath().startsWith(adeRootDir.getAbsolutePath())) {
62
            return adeRootDir;
63
        } else {
64
            return null;
65
        }
66
    }
67
68
    @Override
69
    public VCSInterceptor getVCSInterceptor() {
70
        return interceptor;
71
    }
72
    
73
}
(-)a/vcs.ade.treestamp/src/org/netbeans/modules/vcs/ade/treestamp/Bundle.properties (+1 lines)
Line 0 Link Here
1
OpenIDE-Module-Name=ADE TreeStamp Implementation

Return to bug 206061