View Javadoc
1   package org.apache.maven.scm.provider.accurev;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *    http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.text.DateFormat;
24  import java.util.Collection;
25  import java.util.List;
26  import java.util.Map;
27  
28  import org.apache.maven.scm.command.blame.BlameLine;
29  import org.apache.maven.scm.util.ThreadSafeDateFormat;
30  
31  /**
32   * Represents the AccuRev CLI interface
33   * 
34   * @author ggardner
35   */
36  public interface AccuRev
37  {
38  
39      public static final String DEFAULT_ACCUREV_EXECUTABLE = "accurev";
40  
41      public static final int DEFAULT_PORT = 5050;
42  
43      public static final String ACCUREV_TIME_FORMAT_STRING = "yyyy/MM/dd HH:mm:ss";
44  
45      public static final DateFormat ACCUREV_TIME_SPEC = new ThreadSafeDateFormat( ACCUREV_TIME_FORMAT_STRING );
46  
47      public static final String DEFAULT_REMOVE_MESSAGE = "removed (maven-scm)";
48  
49      public static final String DEFAULT_ADD_MESSAGE = "initial version (maven-scm)";
50  
51      public static final String DEFAULT_PROMOTE_MESSAGE = "promote (maven-scm)";
52  
53      /**
54       * Reset command process, clear command output accumulators
55       */
56      void reset();
57  
58      /**
59       * Populate external to a workspace a (stream) and transactionId/time, to a specific location.
60       * 
61       * <p>
62       * You must check {@link AccuRevCapability#POPULATE_TO_TRANSACTION} before passing a tranid/time
63       * to this method. If not supported should pass "now","highest" or null for tranSpec
64       * 
65       * @param basedir
66       * @param stream stream to update to
67       * @param tranSpec transaction to update to or "now" if not supported.
68       * @param elements (must be depot relative. if null "/./" root is used)
69       * @return
70       * @throws AccuRevException
71       */
72      List<File> popExternal( File basedir, String stream, String tranSpec, Collection<File> elements )
73          throws AccuRevException;
74  
75      /**
76       * Re populate missing files to existing workspace.
77       * 
78       * @param basedir
79       * @param elements
80       * @return
81       * @throws AccuRevException
82       */
83      List<File> pop( File basedir, Collection<File> elements )
84          throws AccuRevException;
85  
86      /**
87       * Make workspace
88       * 
89       * @param basisStream
90       * @param workspaceName
91       * @param basedir
92       * @return
93       * @throws AccuRevException
94       */
95      boolean mkws( String basisStream, String workspaceName, File basedir )
96          throws AccuRevException;
97  
98      /**
99       * 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 }