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