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