001    package org.apache.maven.scm.provider.accurev;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *    http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import java.io.File;
023    import java.text.DateFormat;
024    import java.util.Collection;
025    import java.util.List;
026    import java.util.Map;
027    
028    import org.apache.maven.scm.command.blame.BlameLine;
029    import org.apache.maven.scm.util.ThreadSafeDateFormat;
030    
031    /**
032     * Represents the AccuRev CLI interface
033     * 
034     * @author ggardner
035     */
036    public interface AccuRev
037    {
038    
039        public static final String DEFAULT_ACCUREV_EXECUTABLE = "accurev";
040    
041        public static final int DEFAULT_PORT = 5050;
042    
043        public static final String ACCUREV_TIME_FORMAT_STRING = "yyyy/MM/dd HH:mm:ss";
044    
045        public static final DateFormat ACCUREV_TIME_SPEC = new ThreadSafeDateFormat( ACCUREV_TIME_FORMAT_STRING );
046    
047        public static final String DEFAULT_REMOVE_MESSAGE = "removed (maven-scm)";
048    
049        public static final String DEFAULT_ADD_MESSAGE = "initial version (maven-scm)";
050    
051        public static final String DEFAULT_PROMOTE_MESSAGE = "promote (maven-scm)";
052    
053        /**
054         * Reset command process, clear command output accumulators
055         */
056        void reset();
057    
058        /**
059         * Populate external to a workspace a (stream) and transactionId/time, to a specific location.
060         * 
061         * <p>
062         * You must check {@link AccuRevCapability#POPULATE_TO_TRANSACTION} before passing a tranid/time
063         * to this method. If not supported should pass "now","highest" or null for tranSpec
064         * 
065         * @param basedir
066         * @param stream stream to update to
067         * @param tranSpec transaction to update to or "now" if not supported.
068         * @param elements (must be depot relative. if null "/./" root is used)
069         * @return
070         * @throws AccuRevException
071         */
072        List<File> popExternal( File basedir, String stream, String tranSpec, Collection<File> elements )
073            throws AccuRevException;
074    
075        /**
076         * Re populate missing files to existing workspace.
077         * 
078         * @param basedir
079         * @param elements
080         * @return
081         * @throws AccuRevException
082         */
083        List<File> pop( File basedir, Collection<File> elements )
084            throws AccuRevException;
085    
086        /**
087         * Make workspace
088         * 
089         * @param basisStream
090         * @param workspaceName
091         * @param basedir
092         * @return
093         * @throws AccuRevException
094         */
095        boolean mkws( String basisStream, String workspaceName, File basedir )
096            throws AccuRevException;
097    
098        /**
099         * Update a workspace or reftree, to a particular transaction id
100         * 
101         * @param basedir
102         * @param transactionId
103         * @return
104         * @throws AccuRevException
105         */
106        List<File> update( File basedir, String transactionId )
107            throws AccuRevException;
108    
109        /**
110         * Get info about the current logged in user for the current workspace.
111         * 
112         * @param basedir
113         * @return
114         */
115        AccuRevInfo info( File basedir )
116            throws AccuRevException;
117    
118        /**
119         * Deactivate a workspace
120         * 
121         * @param workSpaceName full name of the workspace, including the user suffix
122         * @return
123         */
124        boolean rmws( String workSpaceName )
125            throws AccuRevException;
126    
127        /**
128         * Reactivate a workspace
129         * 
130         * @param workSpaceName full name of the workspace, including the user suffix
131         * @return
132         */
133        boolean reactivate( String workSpaceName )
134            throws AccuRevException;
135    
136        /**
137         * The accurev command line strings since last reset(), separated by ";"
138         * 
139         * @return
140         */
141        String getCommandLines();
142    
143        /**
144         * Full output of accurev command line invocations since reset
145         * 
146         * @return
147         */
148        String getErrorOutput();
149    
150        /**
151         * Add the file to the repository. File must be within a workspace
152         * 
153         * @param basedir base directory of the workspace
154         * @param files to add (relative to basedir, or absolute)
155         * @param message the commit message
156         */
157        List<File> add( File basedir, List<File> files, String message )
158            throws AccuRevException;
159    
160        /**
161         * Remove the file from the repository. Files must be within a workspace
162         * 
163         * @param basedir
164         * @param files
165         * @param message
166         * @return
167         * @throws AccuRevException
168         */
169        List<File> defunct( File basedir, List<File> files, String message )
170            throws AccuRevException;
171    
172        /**
173         * Any elements that have been kept previously or are currently modified will be promoted.
174         * 
175         * @param basedir - location of the workspace to act on
176         * @param message
177         * @return
178         * @throws AccuRevException
179         */
180        List<File> promoteAll( File basedir, String message )
181            throws AccuRevException;
182    
183        List<File> promote( File basedir, List<File> files, String message )
184            throws AccuRevException;
185    
186        /**
187         * Relocate/reparent a workspace
188         * 
189         * @param basedir
190         * @param workSpaceName (full workspacename including user)
191         * @param newBasisStream
192         * @return
193         * @throws AccuRevException
194         */
195        boolean chws( File basedir, String workSpaceName, String newBasisStream )
196            throws AccuRevException;
197    
198        boolean mksnap( String snapShotName, String basisStream )
199            throws AccuRevException;
200    
201        List<File> statTag( String streamName )
202            throws AccuRevException;
203    
204        /**
205         * Sorts list of elements by whether they exist in the backing stream or not.
206         * 
207         * @param basedir
208         * @param elements
209         * @return
210         * @throws AccuRevException
211         */
212        CategorisedElements statBackingStream( File basedir, Collection<File> elements )
213            throws AccuRevException;
214    
215        /**
216         * @param basedir
217         * @param elements list of elements to stat, relative to basedir
218         * @param statType
219         * @return
220         * @throws AccuRevException
221         */
222        List<File> stat( File basedir, Collection<File> elements, AccuRevStat statType )
223            throws AccuRevException;
224    
225        /**
226         * Accurev status of an element
227         * 
228         * @param element
229         * @return null if ignored or not in workspace
230         */
231        String stat( File element )
232            throws AccuRevException;
233    
234        List<Transaction> history( String baseStream, String fromTimeSpec, String toTimeSpec, int count,
235                                   boolean depotHistory, boolean transactionsOnly )
236            throws AccuRevException;
237    
238        /**
239         * AccuRev differences of a stream between to timespecs
240         * 
241         * @param baseStream
242         * @param fromTimeSpec
243         * @param toTimeSpec
244         * @return
245         * @throws AccuRevException
246         */
247        List<FileDifference> diff( String baseStream, String fromTimeSpec, String toTimeSpec )
248            throws AccuRevException;
249    
250        /**
251         * AccuRev annotate an element
252         * 
253         * @param file
254         * @return
255         * @throws AccuRevException
256         */
257        List<BlameLine> annotate( File baseDir, File file )
258            throws AccuRevException;
259    
260        /**
261         * Logins in as the given user, retains authtoken for use with subsequent commands.
262         * 
263         * @param user
264         * @param password
265         * @return
266         * @throws AccuRevException
267         */
268        boolean login( String user, String password )
269            throws AccuRevException;
270    
271        Map<String, WorkSpace> showWorkSpaces()
272            throws AccuRevException;
273    
274        Map<String, WorkSpace> showRefTrees()
275            throws AccuRevException;
276    
277        Stream showStream( String stream )
278            throws AccuRevException;
279    
280        String getExecutable();
281    
282        String getClientVersion()
283            throws AccuRevException;
284    
285        boolean  syncReplica()
286            throws AccuRevException;
287    
288    }