1 | |
package org.apache.maven.scm.provider; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.scm.CommandParameter; |
23 | |
import org.apache.maven.scm.CommandParameters; |
24 | |
import org.apache.maven.scm.NoSuchCommandScmException; |
25 | |
import org.apache.maven.scm.ScmBranch; |
26 | |
import org.apache.maven.scm.ScmBranchParameters; |
27 | |
import org.apache.maven.scm.ScmException; |
28 | |
import org.apache.maven.scm.ScmFileSet; |
29 | |
import org.apache.maven.scm.ScmRevision; |
30 | |
import org.apache.maven.scm.ScmTagParameters; |
31 | |
import org.apache.maven.scm.ScmVersion; |
32 | |
import org.apache.maven.scm.command.add.AddScmResult; |
33 | |
import org.apache.maven.scm.command.blame.BlameScmResult; |
34 | |
import org.apache.maven.scm.command.branch.BranchScmResult; |
35 | |
import org.apache.maven.scm.command.changelog.ChangeLogScmResult; |
36 | |
import org.apache.maven.scm.command.checkin.CheckInScmResult; |
37 | |
import org.apache.maven.scm.command.checkout.CheckOutScmResult; |
38 | |
import org.apache.maven.scm.command.diff.DiffScmResult; |
39 | |
import org.apache.maven.scm.command.edit.EditScmResult; |
40 | |
import org.apache.maven.scm.command.export.ExportScmResult; |
41 | |
import org.apache.maven.scm.command.info.InfoScmResult; |
42 | |
import org.apache.maven.scm.command.list.ListScmResult; |
43 | |
import org.apache.maven.scm.command.login.LoginScmResult; |
44 | |
import org.apache.maven.scm.command.mkdir.MkdirScmResult; |
45 | |
import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult; |
46 | |
import org.apache.maven.scm.command.remove.RemoveScmResult; |
47 | |
import org.apache.maven.scm.command.status.StatusScmResult; |
48 | |
import org.apache.maven.scm.command.tag.TagScmResult; |
49 | |
import org.apache.maven.scm.command.unedit.UnEditScmResult; |
50 | |
import org.apache.maven.scm.command.update.UpdateScmResult; |
51 | |
import org.apache.maven.scm.log.ScmLogDispatcher; |
52 | |
import org.apache.maven.scm.log.ScmLogger; |
53 | |
import org.apache.maven.scm.repository.ScmRepository; |
54 | |
import org.apache.maven.scm.repository.ScmRepositoryException; |
55 | |
import org.apache.maven.scm.repository.UnknownRepositoryStructure; |
56 | |
import org.codehaus.plexus.util.StringUtils; |
57 | |
|
58 | |
import java.io.File; |
59 | |
import java.util.ArrayList; |
60 | |
import java.util.Date; |
61 | |
import java.util.List; |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | 0 | public abstract class AbstractScmProvider |
70 | |
implements ScmProvider |
71 | |
{ |
72 | 0 | private ScmLogDispatcher logDispatcher = new ScmLogDispatcher(); |
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
public String getScmSpecificFilename() |
82 | |
{ |
83 | 0 | return null; |
84 | |
} |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
public String sanitizeTagName( String tag ) |
90 | |
{ |
91 | |
|
92 | 0 | return tag; |
93 | |
} |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
public boolean validateTagName( String tag ) |
99 | |
{ |
100 | |
|
101 | 0 | return true; |
102 | |
} |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
public List<String> validateScmUrl( String scmSpecificUrl, char delimiter ) |
108 | |
{ |
109 | 0 | List<String> messages = new ArrayList<String>(); |
110 | |
|
111 | |
try |
112 | |
{ |
113 | 0 | makeProviderScmRepository( scmSpecificUrl, delimiter ); |
114 | |
} |
115 | 0 | catch ( ScmRepositoryException e ) |
116 | |
{ |
117 | 0 | messages.add( e.getMessage() ); |
118 | 0 | } |
119 | |
|
120 | 0 | return messages; |
121 | |
} |
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
public boolean requiresEditMode() |
127 | |
{ |
128 | 0 | return false; |
129 | |
} |
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
public AddScmResult add( ScmRepository repository, ScmFileSet fileSet ) |
139 | |
throws ScmException |
140 | |
{ |
141 | 0 | return add( repository, fileSet, (String) null ); |
142 | |
} |
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, String message ) |
148 | |
throws ScmException |
149 | |
{ |
150 | 0 | login( repository, fileSet ); |
151 | |
|
152 | 0 | CommandParameters parameters = new CommandParameters(); |
153 | |
|
154 | 0 | parameters.setString( CommandParameter.MESSAGE, message == null ? "" : message ); |
155 | |
|
156 | |
|
157 | |
|
158 | 0 | parameters.setString( CommandParameter.BINARY, "false" ); |
159 | |
|
160 | 0 | return add( repository.getProviderRepository(), fileSet, parameters ); |
161 | |
} |
162 | |
|
163 | |
public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
164 | |
throws ScmException |
165 | |
{ |
166 | 0 | login( repository, fileSet ); |
167 | |
|
168 | |
|
169 | |
|
170 | 0 | parameters.setString( CommandParameter.BINARY, "false" ); |
171 | |
|
172 | 0 | return add( repository.getProviderRepository(), fileSet, parameters ); |
173 | |
} |
174 | |
|
175 | |
public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
176 | |
throws ScmException |
177 | |
{ |
178 | 0 | throw new NoSuchCommandScmException( "add" ); |
179 | |
} |
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName ) |
185 | |
throws ScmException |
186 | |
{ |
187 | 0 | return branch( repository, fileSet, branchName, new ScmBranchParameters() ); |
188 | |
} |
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, String message ) |
194 | |
throws ScmException |
195 | |
{ |
196 | 0 | ScmBranchParameters scmBranchParameters = new ScmBranchParameters(); |
197 | |
|
198 | 0 | if ( StringUtils.isNotEmpty( message ) ) |
199 | |
{ |
200 | 0 | scmBranchParameters.setMessage( message ); |
201 | |
} |
202 | |
|
203 | 0 | return branch( repository, fileSet, branchName, scmBranchParameters ); |
204 | |
} |
205 | |
|
206 | |
public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, |
207 | |
ScmBranchParameters scmBranchParameters ) |
208 | |
throws ScmException |
209 | |
{ |
210 | 0 | login( repository, fileSet ); |
211 | |
|
212 | 0 | CommandParameters parameters = new CommandParameters(); |
213 | |
|
214 | 0 | parameters.setString( CommandParameter.BRANCH_NAME, branchName ); |
215 | |
|
216 | 0 | parameters.setScmBranchParameters( CommandParameter.SCM_BRANCH_PARAMETERS, scmBranchParameters ); |
217 | |
|
218 | 0 | return branch( repository.getProviderRepository(), fileSet, parameters ); |
219 | |
} |
220 | |
|
221 | |
protected BranchScmResult branch( ScmProviderRepository repository, ScmFileSet fileSet, |
222 | |
CommandParameters parameters ) |
223 | |
throws ScmException |
224 | |
{ |
225 | 0 | throw new NoSuchCommandScmException( "branch" ); |
226 | |
} |
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, |
234 | |
int numDays, String branch ) |
235 | |
throws ScmException |
236 | |
{ |
237 | 0 | return changeLog( repository, fileSet, startDate, endDate, numDays, branch, null ); |
238 | |
} |
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, |
246 | |
int numDays, String branch, String datePattern ) |
247 | |
throws ScmException |
248 | |
{ |
249 | 0 | ScmBranch scmBranch = null; |
250 | |
|
251 | 0 | if ( StringUtils.isNotEmpty( branch ) ) |
252 | |
{ |
253 | 0 | scmBranch = new ScmBranch( branch ); |
254 | |
} |
255 | 0 | return changeLog( repository, fileSet, startDate, endDate, numDays, scmBranch, null ); |
256 | |
|
257 | |
} |
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, |
263 | |
int numDays, ScmBranch branch ) |
264 | |
throws ScmException |
265 | |
{ |
266 | 0 | return changeLog( repository, fileSet, startDate, endDate, numDays, branch, null ); |
267 | |
} |
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, |
273 | |
int numDays, ScmBranch branch, String datePattern ) |
274 | |
throws ScmException |
275 | |
{ |
276 | 0 | login( repository, fileSet ); |
277 | |
|
278 | 0 | CommandParameters parameters = new CommandParameters(); |
279 | |
|
280 | 0 | parameters.setDate( CommandParameter.START_DATE, startDate ); |
281 | |
|
282 | 0 | parameters.setDate( CommandParameter.END_DATE, endDate ); |
283 | |
|
284 | 0 | parameters.setInt( CommandParameter.NUM_DAYS, numDays ); |
285 | |
|
286 | 0 | parameters.setScmVersion( CommandParameter.BRANCH, branch ); |
287 | |
|
288 | 0 | parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); |
289 | |
|
290 | 0 | return changelog( repository.getProviderRepository(), fileSet, parameters ); |
291 | |
} |
292 | |
|
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag ) |
300 | |
throws ScmException |
301 | |
{ |
302 | 0 | return changeLog( repository, fileSet, startTag, endTag, null ); |
303 | |
} |
304 | |
|
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
|
310 | |
public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag, |
311 | |
String datePattern ) |
312 | |
throws ScmException |
313 | |
{ |
314 | 0 | ScmVersion startRevision = null; |
315 | 0 | ScmVersion endRevision = null; |
316 | |
|
317 | 0 | if ( StringUtils.isNotEmpty( startTag ) ) |
318 | |
{ |
319 | 0 | startRevision = new ScmRevision( startTag ); |
320 | |
} |
321 | |
|
322 | 0 | if ( StringUtils.isNotEmpty( endTag ) ) |
323 | |
{ |
324 | 0 | endRevision = new ScmRevision( endTag ); |
325 | |
} |
326 | |
|
327 | 0 | return changeLog( repository, fileSet, startRevision, endRevision, null ); |
328 | |
} |
329 | |
|
330 | |
|
331 | |
|
332 | |
|
333 | |
public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, |
334 | |
ScmVersion endVersion ) |
335 | |
throws ScmException |
336 | |
{ |
337 | 0 | return changeLog( repository, fileSet, startVersion, endVersion, null ); |
338 | |
} |
339 | |
|
340 | |
|
341 | |
|
342 | |
|
343 | |
public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, |
344 | |
ScmVersion endVersion, String datePattern ) |
345 | |
throws ScmException |
346 | |
{ |
347 | 0 | login( repository, fileSet ); |
348 | |
|
349 | 0 | CommandParameters parameters = new CommandParameters(); |
350 | |
|
351 | 0 | parameters.setScmVersion( CommandParameter.START_SCM_VERSION, startVersion ); |
352 | |
|
353 | 0 | parameters.setScmVersion( CommandParameter.END_SCM_VERSION, endVersion ); |
354 | |
|
355 | 0 | parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); |
356 | |
|
357 | 0 | return changelog( repository.getProviderRepository(), fileSet, parameters ); |
358 | |
} |
359 | |
|
360 | |
protected ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet, |
361 | |
CommandParameters parameters ) |
362 | |
throws ScmException |
363 | |
{ |
364 | 0 | throw new NoSuchCommandScmException( "changelog" ); |
365 | |
} |
366 | |
|
367 | |
|
368 | |
|
369 | |
|
370 | |
|
371 | |
|
372 | |
|
373 | |
public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String tag, String message ) |
374 | |
throws ScmException |
375 | |
{ |
376 | 0 | ScmVersion scmVersion = null; |
377 | |
|
378 | 0 | if ( StringUtils.isNotEmpty( tag ) ) |
379 | |
{ |
380 | 0 | scmVersion = new ScmBranch( tag ); |
381 | |
} |
382 | |
|
383 | 0 | return checkIn( repository, fileSet, scmVersion, message ); |
384 | |
} |
385 | |
|
386 | |
|
387 | |
|
388 | |
|
389 | |
public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String message ) |
390 | |
throws ScmException |
391 | |
{ |
392 | 0 | return checkIn( repository, fileSet, (ScmVersion) null, message ); |
393 | |
} |
394 | |
|
395 | |
|
396 | |
|
397 | |
|
398 | |
public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, |
399 | |
String message ) |
400 | |
throws ScmException |
401 | |
{ |
402 | 0 | login( repository, fileSet ); |
403 | |
|
404 | 0 | CommandParameters parameters = new CommandParameters(); |
405 | |
|
406 | 0 | parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); |
407 | |
|
408 | 0 | parameters.setString( CommandParameter.MESSAGE, message ); |
409 | |
|
410 | 0 | return checkin( repository.getProviderRepository(), fileSet, parameters ); |
411 | |
} |
412 | |
|
413 | |
protected CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet, |
414 | |
CommandParameters parameters ) |
415 | |
throws ScmException |
416 | |
{ |
417 | 0 | throw new NoSuchCommandScmException( "checkin" ); |
418 | |
} |
419 | |
|
420 | |
|
421 | |
|
422 | |
|
423 | |
|
424 | |
|
425 | |
|
426 | |
public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, String tag ) |
427 | |
throws ScmException |
428 | |
{ |
429 | 0 | return checkOut( repository, fileSet, tag, true ); |
430 | |
} |
431 | |
|
432 | |
|
433 | |
|
434 | |
|
435 | |
|
436 | |
|
437 | |
public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, String tag, boolean recursive ) |
438 | |
throws ScmException |
439 | |
{ |
440 | 0 | ScmVersion scmVersion = null; |
441 | |
|
442 | 0 | if ( StringUtils.isNotEmpty( tag ) ) |
443 | |
{ |
444 | 0 | scmVersion = new ScmBranch( tag ); |
445 | |
} |
446 | |
|
447 | 0 | return checkOut( repository, fileSet, scmVersion, recursive ); |
448 | |
} |
449 | |
|
450 | |
|
451 | |
|
452 | |
|
453 | |
public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet ) |
454 | |
throws ScmException |
455 | |
{ |
456 | 0 | return checkOut( repository, fileSet, (ScmVersion) null, true ); |
457 | |
} |
458 | |
|
459 | |
|
460 | |
|
461 | |
|
462 | |
public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion ) |
463 | |
throws ScmException |
464 | |
{ |
465 | 0 | return checkOut( repository, fileSet, scmVersion, true ); |
466 | |
} |
467 | |
|
468 | |
|
469 | |
|
470 | |
|
471 | |
public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, boolean recursive ) |
472 | |
throws ScmException |
473 | |
{ |
474 | 0 | return checkOut( repository, fileSet, (ScmVersion) null, recursive ); |
475 | |
} |
476 | |
|
477 | |
|
478 | |
|
479 | |
|
480 | |
public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, |
481 | |
boolean recursive ) |
482 | |
throws ScmException |
483 | |
{ |
484 | 0 | login( repository, fileSet ); |
485 | |
|
486 | 0 | CommandParameters parameters = new CommandParameters(); |
487 | |
|
488 | 0 | parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); |
489 | |
|
490 | 0 | parameters.setString( CommandParameter.RECURSIVE, recursive + "" ); |
491 | |
|
492 | 0 | return checkout( repository.getProviderRepository(), fileSet, parameters ); |
493 | |
} |
494 | |
|
495 | |
protected CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet, |
496 | |
CommandParameters parameters ) |
497 | |
throws ScmException |
498 | |
{ |
499 | 0 | throw new NoSuchCommandScmException( "checkout" ); |
500 | |
} |
501 | |
|
502 | |
|
503 | |
|
504 | |
|
505 | |
|
506 | |
|
507 | |
public DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, String startRevision, String endRevision ) |
508 | |
throws ScmException |
509 | |
{ |
510 | 0 | ScmVersion startVersion = null; |
511 | 0 | ScmVersion endVersion = null; |
512 | |
|
513 | 0 | if ( StringUtils.isNotEmpty( startRevision ) ) |
514 | |
{ |
515 | 0 | startVersion = new ScmRevision( startRevision ); |
516 | |
} |
517 | |
|
518 | 0 | if ( StringUtils.isNotEmpty( endRevision ) ) |
519 | |
{ |
520 | 0 | endVersion = new ScmRevision( endRevision ); |
521 | |
} |
522 | |
|
523 | 0 | return diff( repository, fileSet, startVersion, endVersion ); |
524 | |
} |
525 | |
|
526 | |
|
527 | |
|
528 | |
|
529 | |
public DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, |
530 | |
ScmVersion endVersion ) |
531 | |
throws ScmException |
532 | |
{ |
533 | 0 | login( repository, fileSet ); |
534 | |
|
535 | 0 | CommandParameters parameters = new CommandParameters(); |
536 | |
|
537 | 0 | parameters.setScmVersion( CommandParameter.START_SCM_VERSION, startVersion ); |
538 | |
|
539 | 0 | parameters.setScmVersion( CommandParameter.END_SCM_VERSION, endVersion ); |
540 | |
|
541 | 0 | return diff( repository.getProviderRepository(), fileSet, parameters ); |
542 | |
} |
543 | |
|
544 | |
protected DiffScmResult diff( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
545 | |
throws ScmException |
546 | |
{ |
547 | 0 | throw new NoSuchCommandScmException( "diff" ); |
548 | |
} |
549 | |
|
550 | |
|
551 | |
|
552 | |
|
553 | |
public EditScmResult edit( ScmRepository repository, ScmFileSet fileSet ) |
554 | |
throws ScmException |
555 | |
{ |
556 | 0 | login( repository, fileSet ); |
557 | |
|
558 | 0 | CommandParameters parameters = new CommandParameters(); |
559 | |
|
560 | 0 | return edit( repository.getProviderRepository(), fileSet, parameters ); |
561 | |
} |
562 | |
|
563 | |
protected EditScmResult edit( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
564 | |
throws ScmException |
565 | |
{ |
566 | 0 | if ( getLogger().isWarnEnabled() ) |
567 | |
{ |
568 | 0 | getLogger().warn( "Provider " + this.getScmType() + " does not support edit operation." ); |
569 | |
} |
570 | |
|
571 | 0 | return new EditScmResult( "", null, null, true ); |
572 | |
} |
573 | |
|
574 | |
|
575 | |
|
576 | |
|
577 | |
|
578 | |
|
579 | |
public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag ) |
580 | |
throws ScmException |
581 | |
{ |
582 | 0 | return export( repository, fileSet, tag, null ); |
583 | |
} |
584 | |
|
585 | |
|
586 | |
|
587 | |
|
588 | |
|
589 | |
|
590 | |
public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag, String outputDirectory ) |
591 | |
throws ScmException |
592 | |
{ |
593 | 0 | ScmVersion scmVersion = null; |
594 | |
|
595 | 0 | if ( StringUtils.isNotEmpty( tag ) ) |
596 | |
{ |
597 | 0 | scmVersion = new ScmRevision( tag ); |
598 | |
} |
599 | |
|
600 | 0 | return export( repository, fileSet, scmVersion, outputDirectory ); |
601 | |
} |
602 | |
|
603 | |
|
604 | |
|
605 | |
|
606 | |
public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet ) |
607 | |
throws ScmException |
608 | |
{ |
609 | 0 | return export( repository, fileSet, (ScmVersion) null, null ); |
610 | |
} |
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion ) |
616 | |
throws ScmException |
617 | |
{ |
618 | 0 | return export( repository, fileSet, scmVersion, null ); |
619 | |
} |
620 | |
|
621 | |
|
622 | |
|
623 | |
|
624 | |
public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, |
625 | |
String outputDirectory ) |
626 | |
throws ScmException |
627 | |
{ |
628 | 0 | login( repository, fileSet ); |
629 | |
|
630 | 0 | CommandParameters parameters = new CommandParameters(); |
631 | |
|
632 | 0 | parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); |
633 | |
|
634 | 0 | parameters.setString( CommandParameter.OUTPUT_DIRECTORY, outputDirectory ); |
635 | |
|
636 | 0 | return export( repository.getProviderRepository(), fileSet, parameters ); |
637 | |
} |
638 | |
|
639 | |
protected ExportScmResult export( ScmProviderRepository repository, ScmFileSet fileSet, |
640 | |
CommandParameters parameters ) |
641 | |
throws ScmException |
642 | |
{ |
643 | 0 | throw new NoSuchCommandScmException( "export" ); |
644 | |
} |
645 | |
|
646 | |
|
647 | |
|
648 | |
|
649 | |
public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, String tag ) |
650 | |
throws ScmException |
651 | |
{ |
652 | 0 | ScmVersion scmVersion = null; |
653 | |
|
654 | 0 | if ( StringUtils.isNotEmpty( tag ) ) |
655 | |
{ |
656 | 0 | scmVersion = new ScmRevision( tag ); |
657 | |
} |
658 | |
|
659 | 0 | return list( repository, fileSet, recursive, scmVersion ); |
660 | |
} |
661 | |
|
662 | |
|
663 | |
|
664 | |
|
665 | |
public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion ) |
666 | |
throws ScmException |
667 | |
{ |
668 | 0 | login( repository, fileSet ); |
669 | |
|
670 | 0 | CommandParameters parameters = new CommandParameters(); |
671 | |
|
672 | 0 | parameters.setString( CommandParameter.RECURSIVE, Boolean.toString( recursive ) ); |
673 | |
|
674 | 0 | if ( scmVersion != null ) |
675 | |
{ |
676 | 0 | parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); |
677 | |
} |
678 | |
|
679 | 0 | return list( repository.getProviderRepository(), fileSet, parameters ); |
680 | |
} |
681 | |
|
682 | |
|
683 | |
|
684 | |
|
685 | |
|
686 | |
|
687 | |
|
688 | |
|
689 | |
|
690 | |
|
691 | |
|
692 | |
protected ListScmResult list( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
693 | |
throws ScmException |
694 | |
{ |
695 | 0 | throw new NoSuchCommandScmException( "list" ); |
696 | |
} |
697 | |
|
698 | |
|
699 | |
|
700 | |
|
701 | |
public MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal ) |
702 | |
throws ScmException |
703 | |
{ |
704 | 0 | login( repository, fileSet ); |
705 | |
|
706 | 0 | CommandParameters parameters = new CommandParameters(); |
707 | |
|
708 | 0 | if ( message == null ) |
709 | |
{ |
710 | 0 | message = ""; |
711 | 0 | if ( !createInLocal ) |
712 | |
{ |
713 | 0 | getLogger().warn( "Commit message is empty!" ); |
714 | |
} |
715 | |
} |
716 | |
|
717 | 0 | parameters.setString( CommandParameter.MESSAGE, message ); |
718 | |
|
719 | 0 | parameters.setString( CommandParameter.SCM_MKDIR_CREATE_IN_LOCAL, Boolean.toString( createInLocal ) ); |
720 | |
|
721 | 0 | return mkdir( repository.getProviderRepository(), fileSet, parameters ); |
722 | |
} |
723 | |
|
724 | |
|
725 | |
|
726 | |
|
727 | |
|
728 | |
|
729 | |
|
730 | |
|
731 | |
|
732 | |
|
733 | |
protected MkdirScmResult mkdir( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
734 | |
throws ScmException |
735 | |
{ |
736 | 0 | throw new NoSuchCommandScmException( "mkdir" ); |
737 | |
} |
738 | |
|
739 | |
private void login( ScmRepository repository, ScmFileSet fileSet ) |
740 | |
throws ScmException |
741 | |
{ |
742 | 0 | LoginScmResult result = login( repository.getProviderRepository(), fileSet, new CommandParameters() ); |
743 | |
|
744 | 0 | if ( !result.isSuccess() ) |
745 | |
{ |
746 | 0 | throw new ScmException( "Can't login.\n" + result.getCommandOutput() ); |
747 | |
} |
748 | 0 | } |
749 | |
|
750 | |
protected LoginScmResult login( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
751 | |
throws ScmException |
752 | |
{ |
753 | 0 | return new LoginScmResult( null, null, null, true ); |
754 | |
} |
755 | |
|
756 | |
|
757 | |
|
758 | |
|
759 | |
public RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, String message ) |
760 | |
throws ScmException |
761 | |
{ |
762 | 0 | login( repository, fileSet ); |
763 | |
|
764 | 0 | CommandParameters parameters = new CommandParameters(); |
765 | |
|
766 | 0 | parameters.setString( CommandParameter.MESSAGE, message == null ? "" : message ); |
767 | |
|
768 | 0 | return remove( repository.getProviderRepository(), fileSet, parameters ); |
769 | |
} |
770 | |
|
771 | |
protected RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, |
772 | |
CommandParameters parameters ) |
773 | |
throws ScmException |
774 | |
{ |
775 | 0 | throw new NoSuchCommandScmException( "remove" ); |
776 | |
} |
777 | |
|
778 | |
|
779 | |
|
780 | |
|
781 | |
public StatusScmResult status( ScmRepository repository, ScmFileSet fileSet ) |
782 | |
throws ScmException |
783 | |
{ |
784 | 0 | login( repository, fileSet ); |
785 | |
|
786 | 0 | CommandParameters parameters = new CommandParameters(); |
787 | |
|
788 | 0 | return status( repository.getProviderRepository(), fileSet, parameters ); |
789 | |
} |
790 | |
|
791 | |
protected StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, |
792 | |
CommandParameters parameters ) |
793 | |
throws ScmException |
794 | |
{ |
795 | 0 | throw new NoSuchCommandScmException( "status" ); |
796 | |
} |
797 | |
|
798 | |
|
799 | |
|
800 | |
|
801 | |
public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName ) |
802 | |
throws ScmException |
803 | |
{ |
804 | 0 | return tag( repository, fileSet, tagName, new ScmTagParameters() ); |
805 | |
} |
806 | |
|
807 | |
|
808 | |
|
809 | |
|
810 | |
public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, String message ) |
811 | |
throws ScmException |
812 | |
{ |
813 | 0 | login( repository, fileSet ); |
814 | |
|
815 | 0 | CommandParameters parameters = new CommandParameters(); |
816 | |
|
817 | 0 | parameters.setString( CommandParameter.TAG_NAME, tagName ); |
818 | |
|
819 | 0 | if ( StringUtils.isNotEmpty( message ) ) |
820 | |
{ |
821 | 0 | parameters.setString( CommandParameter.MESSAGE, message ); |
822 | |
} |
823 | |
|
824 | 0 | ScmTagParameters scmTagParameters = new ScmTagParameters( message ); |
825 | |
|
826 | 0 | parameters.setScmTagParameters( CommandParameter.SCM_TAG_PARAMETERS, scmTagParameters ); |
827 | |
|
828 | 0 | return tag( repository.getProviderRepository(), fileSet, parameters ); |
829 | |
} |
830 | |
|
831 | |
|
832 | |
|
833 | |
|
834 | |
public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, |
835 | |
ScmTagParameters scmTagParameters ) |
836 | |
throws ScmException |
837 | |
{ |
838 | 0 | login( repository, fileSet ); |
839 | |
|
840 | 0 | CommandParameters parameters = new CommandParameters(); |
841 | |
|
842 | 0 | parameters.setString( CommandParameter.TAG_NAME, tagName ); |
843 | |
|
844 | 0 | parameters.setScmTagParameters( CommandParameter.SCM_TAG_PARAMETERS, scmTagParameters ); |
845 | |
|
846 | 0 | return tag( repository.getProviderRepository(), fileSet, parameters ); |
847 | |
} |
848 | |
|
849 | |
protected TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
850 | |
throws ScmException |
851 | |
{ |
852 | 0 | throw new NoSuchCommandScmException( "tag" ); |
853 | |
} |
854 | |
|
855 | |
|
856 | |
|
857 | |
|
858 | |
public UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet ) |
859 | |
throws ScmException |
860 | |
{ |
861 | 0 | login( repository, fileSet ); |
862 | |
|
863 | 0 | CommandParameters parameters = new CommandParameters(); |
864 | |
|
865 | 0 | return unedit( repository.getProviderRepository(), fileSet, parameters ); |
866 | |
} |
867 | |
|
868 | |
protected UnEditScmResult unedit( ScmProviderRepository repository, ScmFileSet fileSet, |
869 | |
CommandParameters parameters ) |
870 | |
throws ScmException |
871 | |
{ |
872 | 0 | if ( getLogger().isWarnEnabled() ) |
873 | |
{ |
874 | 0 | getLogger().warn( "Provider " + this.getScmType() + " does not support unedit operation." ); |
875 | |
} |
876 | |
|
877 | 0 | return new UnEditScmResult( "", null, null, true ); |
878 | |
} |
879 | |
|
880 | |
|
881 | |
|
882 | |
|
883 | |
|
884 | |
|
885 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag ) |
886 | |
throws ScmException |
887 | |
{ |
888 | 0 | return update( repository, fileSet, tag, true ); |
889 | |
} |
890 | |
|
891 | |
|
892 | |
|
893 | |
|
894 | |
|
895 | |
|
896 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, boolean runChangelog ) |
897 | |
throws ScmException |
898 | |
{ |
899 | 0 | return update( repository, fileSet, tag, "", runChangelog ); |
900 | |
} |
901 | |
|
902 | |
|
903 | |
|
904 | |
|
905 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet ) |
906 | |
throws ScmException |
907 | |
{ |
908 | 0 | return update( repository, fileSet, (ScmVersion) null, true ); |
909 | |
} |
910 | |
|
911 | |
|
912 | |
|
913 | |
|
914 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion ) |
915 | |
throws ScmException |
916 | |
{ |
917 | 0 | return update( repository, fileSet, scmVersion, true ); |
918 | |
} |
919 | |
|
920 | |
|
921 | |
|
922 | |
|
923 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, boolean runChangelog ) |
924 | |
throws ScmException |
925 | |
{ |
926 | 0 | return update( repository, fileSet, (ScmVersion) null, "", runChangelog ); |
927 | |
} |
928 | |
|
929 | |
|
930 | |
|
931 | |
|
932 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, |
933 | |
boolean runChangelog ) |
934 | |
throws ScmException |
935 | |
{ |
936 | 0 | return update( repository, fileSet, scmVersion, "", runChangelog ); |
937 | |
} |
938 | |
|
939 | |
|
940 | |
|
941 | |
|
942 | |
|
943 | |
|
944 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern ) |
945 | |
throws ScmException |
946 | |
{ |
947 | 0 | return update( repository, fileSet, tag, datePattern, true ); |
948 | |
} |
949 | |
|
950 | |
|
951 | |
|
952 | |
|
953 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, |
954 | |
String datePattern ) |
955 | |
throws ScmException |
956 | |
{ |
957 | 0 | return update( repository, fileSet, scmVersion, datePattern, true ); |
958 | |
} |
959 | |
|
960 | |
|
961 | |
|
962 | |
|
963 | |
private UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern, |
964 | |
boolean runChangelog ) |
965 | |
throws ScmException |
966 | |
{ |
967 | 0 | ScmBranch scmBranch = null; |
968 | |
|
969 | 0 | if ( StringUtils.isNotEmpty( tag ) ) |
970 | |
{ |
971 | 0 | scmBranch = new ScmBranch( tag ); |
972 | |
} |
973 | |
|
974 | 0 | return update( repository, fileSet, scmBranch, datePattern, runChangelog ); |
975 | |
} |
976 | |
|
977 | |
private UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, |
978 | |
String datePattern, boolean runChangelog ) |
979 | |
throws ScmException |
980 | |
{ |
981 | 0 | login( repository, fileSet ); |
982 | |
|
983 | 0 | CommandParameters parameters = new CommandParameters(); |
984 | |
|
985 | 0 | parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); |
986 | |
|
987 | 0 | parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); |
988 | |
|
989 | 0 | parameters.setString( CommandParameter.RUN_CHANGELOG_WITH_UPDATE, String.valueOf( runChangelog ) ); |
990 | |
|
991 | 0 | return update( repository.getProviderRepository(), fileSet, parameters ); |
992 | |
} |
993 | |
|
994 | |
|
995 | |
|
996 | |
|
997 | |
|
998 | |
|
999 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate ) |
1000 | |
throws ScmException |
1001 | |
{ |
1002 | 0 | return update( repository, fileSet, tag, lastUpdate, null ); |
1003 | |
} |
1004 | |
|
1005 | |
|
1006 | |
|
1007 | |
|
1008 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, |
1009 | |
Date lastUpdate ) |
1010 | |
throws ScmException |
1011 | |
{ |
1012 | 0 | return update( repository, fileSet, scmVersion, lastUpdate, null ); |
1013 | |
} |
1014 | |
|
1015 | |
|
1016 | |
|
1017 | |
|
1018 | |
|
1019 | |
|
1020 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate, |
1021 | |
String datePattern ) |
1022 | |
throws ScmException |
1023 | |
{ |
1024 | 0 | ScmBranch scmBranch = null; |
1025 | |
|
1026 | 0 | if ( StringUtils.isNotEmpty( tag ) ) |
1027 | |
{ |
1028 | 0 | scmBranch = new ScmBranch( tag ); |
1029 | |
} |
1030 | |
|
1031 | 0 | return update( repository, fileSet, scmBranch, lastUpdate, datePattern ); |
1032 | |
} |
1033 | |
|
1034 | |
|
1035 | |
|
1036 | |
|
1037 | |
public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, Date lastUpdate, |
1038 | |
String datePattern ) |
1039 | |
throws ScmException |
1040 | |
{ |
1041 | 0 | login( repository, fileSet ); |
1042 | |
|
1043 | 0 | CommandParameters parameters = new CommandParameters(); |
1044 | |
|
1045 | 0 | parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); |
1046 | |
|
1047 | 0 | if ( lastUpdate != null ) |
1048 | |
{ |
1049 | 0 | parameters.setDate( CommandParameter.START_DATE, lastUpdate ); |
1050 | |
} |
1051 | |
|
1052 | 0 | parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); |
1053 | |
|
1054 | 0 | parameters.setString( CommandParameter.RUN_CHANGELOG_WITH_UPDATE, "true" ); |
1055 | |
|
1056 | 0 | return update( repository.getProviderRepository(), fileSet, parameters ); |
1057 | |
} |
1058 | |
|
1059 | |
protected UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, |
1060 | |
CommandParameters parameters ) |
1061 | |
throws ScmException |
1062 | |
{ |
1063 | 0 | throw new NoSuchCommandScmException( "update" ); |
1064 | |
} |
1065 | |
|
1066 | |
|
1067 | |
|
1068 | |
|
1069 | |
public BlameScmResult blame( ScmRepository repository, ScmFileSet fileSet, String filename ) |
1070 | |
throws ScmException |
1071 | |
{ |
1072 | 0 | login( repository, fileSet ); |
1073 | |
|
1074 | 0 | CommandParameters parameters = new CommandParameters(); |
1075 | |
|
1076 | 0 | parameters.setString( CommandParameter.FILE, filename ); |
1077 | |
|
1078 | 0 | return blame( repository.getProviderRepository(), fileSet, parameters ); |
1079 | |
} |
1080 | |
|
1081 | |
protected BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
1082 | |
throws ScmException |
1083 | |
{ |
1084 | 0 | throw new NoSuchCommandScmException( "blame" ); |
1085 | |
} |
1086 | |
|
1087 | |
public InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) |
1088 | |
throws ScmException |
1089 | |
{ |
1090 | 0 | return null; |
1091 | |
} |
1092 | |
|
1093 | |
public RemoteInfoScmResult remoteInfo( ScmProviderRepository repository, ScmFileSet fileSet, |
1094 | |
CommandParameters parameters ) |
1095 | |
throws ScmException |
1096 | |
{ |
1097 | 0 | return null; |
1098 | |
} |
1099 | |
|
1100 | |
|
1101 | |
|
1102 | |
|
1103 | |
|
1104 | |
|
1105 | |
|
1106 | |
|
1107 | |
public void addListener( ScmLogger logger ) |
1108 | |
{ |
1109 | 0 | logDispatcher.addListener( logger ); |
1110 | 0 | } |
1111 | |
|
1112 | |
public ScmLogger getLogger() |
1113 | |
{ |
1114 | 0 | return logDispatcher; |
1115 | |
} |
1116 | |
|
1117 | |
|
1118 | |
|
1119 | |
|
1120 | |
public ScmProviderRepository makeProviderScmRepository( File path ) |
1121 | |
throws ScmRepositoryException, UnknownRepositoryStructure |
1122 | |
{ |
1123 | 0 | throw new UnknownRepositoryStructure(); |
1124 | |
} |
1125 | |
} |