001package org.apache.maven.scm.provider; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.maven.scm.CommandParameter; 023import org.apache.maven.scm.CommandParameters; 024import org.apache.maven.scm.NoSuchCommandScmException; 025import org.apache.maven.scm.ScmBranch; 026import org.apache.maven.scm.ScmBranchParameters; 027import org.apache.maven.scm.ScmException; 028import org.apache.maven.scm.ScmFileSet; 029import org.apache.maven.scm.ScmRevision; 030import org.apache.maven.scm.ScmTagParameters; 031import org.apache.maven.scm.ScmVersion; 032import org.apache.maven.scm.command.add.AddScmResult; 033import org.apache.maven.scm.command.blame.BlameScmRequest; 034import org.apache.maven.scm.command.blame.BlameScmResult; 035import org.apache.maven.scm.command.branch.BranchScmResult; 036import org.apache.maven.scm.command.changelog.ChangeLogScmRequest; 037import org.apache.maven.scm.command.changelog.ChangeLogScmResult; 038import org.apache.maven.scm.command.checkin.CheckInScmResult; 039import org.apache.maven.scm.command.checkout.CheckOutScmResult; 040import org.apache.maven.scm.command.diff.DiffScmResult; 041import org.apache.maven.scm.command.edit.EditScmResult; 042import org.apache.maven.scm.command.export.ExportScmResult; 043import org.apache.maven.scm.command.info.InfoScmResult; 044import org.apache.maven.scm.command.list.ListScmResult; 045import org.apache.maven.scm.command.login.LoginScmResult; 046import org.apache.maven.scm.command.mkdir.MkdirScmResult; 047import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult; 048import org.apache.maven.scm.command.remove.RemoveScmResult; 049import org.apache.maven.scm.command.status.StatusScmResult; 050import org.apache.maven.scm.command.tag.TagScmResult; 051import org.apache.maven.scm.command.unedit.UnEditScmResult; 052import org.apache.maven.scm.command.update.UpdateScmResult; 053import org.apache.maven.scm.log.ScmLogDispatcher; 054import org.apache.maven.scm.log.ScmLogger; 055import org.apache.maven.scm.repository.ScmRepository; 056import org.apache.maven.scm.repository.ScmRepositoryException; 057import org.apache.maven.scm.repository.UnknownRepositoryStructure; 058import org.codehaus.plexus.util.StringUtils; 059 060import java.io.File; 061import java.util.ArrayList; 062import java.util.Date; 063import java.util.List; 064 065/** 066 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> 067 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> 068 * @author Olivier Lamy 069 * 070 */ 071public abstract class AbstractScmProvider 072 implements ScmProvider 073{ 074 private ScmLogDispatcher logDispatcher = new ScmLogDispatcher(); 075 076 // ---------------------------------------------------------------------- 077 // 078 // ---------------------------------------------------------------------- 079 080 /** 081 * {@inheritDoc} 082 */ 083 public String getScmSpecificFilename() 084 { 085 return null; 086 } 087 088 /** 089 * {@inheritDoc} 090 */ 091 public String sanitizeTagName( String tag ) 092 { 093 /* by default, we assume all tags are valid. */ 094 return tag; 095 } 096 097 /** 098 * {@inheritDoc} 099 */ 100 public boolean validateTagName( String tag ) 101 { 102 /* by default, we assume all tags are valid. */ 103 return true; 104 } 105 106 /** 107 * {@inheritDoc} 108 */ 109 public List<String> validateScmUrl( String scmSpecificUrl, char delimiter ) 110 { 111 List<String> messages = new ArrayList<String>(); 112 113 try 114 { 115 makeProviderScmRepository( scmSpecificUrl, delimiter ); 116 } 117 catch ( ScmRepositoryException e ) 118 { 119 messages.add( e.getMessage() ); 120 } 121 122 return messages; 123 } 124 125 /** 126 * {@inheritDoc} 127 */ 128 public boolean requiresEditMode() 129 { 130 return false; 131 } 132 133 // ---------------------------------------------------------------------- 134 // Scm Implementation 135 // ---------------------------------------------------------------------- 136 137 /** 138 * {@inheritDoc} 139 */ 140 public AddScmResult add( ScmRepository repository, ScmFileSet fileSet ) 141 throws ScmException 142 { 143 return add( repository, fileSet, (String) null ); 144 } 145 146 /** 147 * {@inheritDoc} 148 */ 149 public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, String message ) 150 throws ScmException 151 { 152 login( repository, fileSet ); 153 154 CommandParameters parameters = new CommandParameters(); 155 156 parameters.setString( CommandParameter.MESSAGE, message == null ? "" : message ); 157 158 // TODO: binary may be dependant on particular files though 159 // TODO: set boolean? 160 parameters.setString( CommandParameter.BINARY, "false" ); 161 162 return add( repository.getProviderRepository(), fileSet, parameters ); 163 } 164 165 public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters ) 166 throws ScmException 167 { 168 login( repository, fileSet ); 169 170 // TODO: binary may be dependant on particular files though 171 // TODO: set boolean? 172 parameters.setString( CommandParameter.BINARY, "false" ); 173 174 return add( repository.getProviderRepository(), fileSet, parameters ); 175 } 176 177 public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) 178 throws ScmException 179 { 180 throw new NoSuchCommandScmException( "add" ); 181 } 182 183 /** 184 * {@inheritDoc} 185 */ 186 public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName ) 187 throws ScmException 188 { 189 return branch( repository, fileSet, branchName, new ScmBranchParameters() ); 190 } 191 192 /** 193 * {@inheritDoc} 194 */ 195 public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, String message ) 196 throws ScmException 197 { 198 ScmBranchParameters scmBranchParameters = new ScmBranchParameters(); 199 200 if ( StringUtils.isNotEmpty( message ) ) 201 { 202 scmBranchParameters.setMessage( message ); 203 } 204 205 return branch( repository, fileSet, branchName, scmBranchParameters ); 206 } 207 208 public BranchScmResult branch( ScmRepository repository, ScmFileSet fileSet, String branchName, 209 ScmBranchParameters scmBranchParameters ) 210 throws ScmException 211 { 212 login( repository, fileSet ); 213 214 CommandParameters parameters = new CommandParameters(); 215 216 parameters.setString( CommandParameter.BRANCH_NAME, branchName ); 217 218 parameters.setScmBranchParameters( CommandParameter.SCM_BRANCH_PARAMETERS, scmBranchParameters ); 219 220 return branch( repository.getProviderRepository(), fileSet, parameters ); 221 } 222 223 protected BranchScmResult branch( ScmProviderRepository repository, ScmFileSet fileSet, 224 CommandParameters parameters ) 225 throws ScmException 226 { 227 throw new NoSuchCommandScmException( "branch" ); 228 } 229 230 /** 231 * {@inheritDoc} 232 * 233 * @deprecated 234 */ 235 public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, 236 int numDays, String branch ) 237 throws ScmException 238 { 239 return changeLog( repository, fileSet, startDate, endDate, numDays, branch, null ); 240 } 241 242 /** 243 * {@inheritDoc} 244 * 245 * @deprecated 246 */ 247 public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, 248 int numDays, String branch, String datePattern ) 249 throws ScmException 250 { 251 ScmBranch scmBranch = null; 252 253 if ( StringUtils.isNotEmpty( branch ) ) 254 { 255 scmBranch = new ScmBranch( branch ); 256 } 257 return changeLog( repository, fileSet, startDate, endDate, numDays, scmBranch, null ); 258 259 } 260 261 /** 262 * {@inheritDoc} 263 */ 264 public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, 265 int numDays, ScmBranch branch ) 266 throws ScmException 267 { 268 return changeLog( repository, fileSet, startDate, endDate, numDays, branch, null ); 269 } 270 271 /** 272 * {@inheritDoc} 273 */ 274 public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, 275 int numDays, ScmBranch branch, String datePattern ) 276 throws ScmException 277 { 278 final ChangeLogScmRequest request = new ChangeLogScmRequest( repository, fileSet ); 279 request.setDateRange( startDate, endDate ); 280 request.setNumDays( numDays ); 281 request.setScmBranch( branch ); 282 request.setDatePattern( datePattern ); 283 return changeLog( request ); 284 } 285 286 /** 287 * {@inheritDoc} 288 */ 289 public ChangeLogScmResult changeLog( ChangeLogScmRequest request ) 290 throws ScmException 291 { 292 final ScmRepository scmRepository = request.getScmRepository(); 293 final ScmFileSet scmFileSet = request.getScmFileSet(); 294 login( scmRepository, scmFileSet ); 295 return changelog( scmRepository.getProviderRepository(), scmFileSet, request.getCommandParameters() ); 296 } 297 298 299 /** 300 * {@inheritDoc} 301 * 302 * @deprecated 303 */ 304 public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag ) 305 throws ScmException 306 { 307 return changeLog( repository, fileSet, startTag, endTag, null ); 308 } 309 310 /** 311 * {@inheritDoc} 312 * 313 * @deprecated 314 */ 315 public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, String startTag, String endTag, 316 String datePattern ) 317 throws ScmException 318 { 319 ScmVersion startRevision = null; 320 ScmVersion endRevision = null; 321 322 if ( StringUtils.isNotEmpty( startTag ) ) 323 { 324 startRevision = new ScmRevision( startTag ); 325 } 326 327 if ( StringUtils.isNotEmpty( endTag ) ) 328 { 329 endRevision = new ScmRevision( endTag ); 330 } 331 332 return changeLog( repository, fileSet, startRevision, endRevision, null ); 333 } 334 335 /** 336 * {@inheritDoc} 337 */ 338 public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, 339 ScmVersion endVersion ) 340 throws ScmException 341 { 342 return changeLog( repository, fileSet, startVersion, endVersion, null ); 343 } 344 345 /** 346 * {@inheritDoc} 347 */ 348 public ChangeLogScmResult changeLog( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, 349 ScmVersion endVersion, String datePattern ) 350 throws ScmException 351 { 352 login( repository, fileSet ); 353 354 CommandParameters parameters = new CommandParameters(); 355 356 parameters.setScmVersion( CommandParameter.START_SCM_VERSION, startVersion ); 357 358 parameters.setScmVersion( CommandParameter.END_SCM_VERSION, endVersion ); 359 360 parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); 361 362 return changelog( repository.getProviderRepository(), fileSet, parameters ); 363 } 364 365 protected ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet, 366 CommandParameters parameters ) 367 throws ScmException 368 { 369 throw new NoSuchCommandScmException( "changelog" ); 370 } 371 372 373 /** 374 * {@inheritDoc} 375 * 376 * @deprecated 377 */ 378 public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String tag, String message ) 379 throws ScmException 380 { 381 ScmVersion scmVersion = null; 382 383 if ( StringUtils.isNotEmpty( tag ) ) 384 { 385 scmVersion = new ScmBranch( tag ); 386 } 387 388 return checkIn( repository, fileSet, scmVersion, message ); 389 } 390 391 /** 392 * {@inheritDoc} 393 */ 394 public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, String message ) 395 throws ScmException 396 { 397 return checkIn( repository, fileSet, (ScmVersion) null, message ); 398 } 399 400 /** 401 * {@inheritDoc} 402 */ 403 public CheckInScmResult checkIn( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, 404 String message ) 405 throws ScmException 406 { 407 login( repository, fileSet ); 408 409 CommandParameters parameters = new CommandParameters(); 410 411 parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); 412 413 parameters.setString( CommandParameter.MESSAGE, message ); 414 415 return checkin( repository.getProviderRepository(), fileSet, parameters ); 416 } 417 418 protected CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet, 419 CommandParameters parameters ) 420 throws ScmException 421 { 422 throw new NoSuchCommandScmException( "checkin" ); 423 } 424 425 426 /** 427 * {@inheritDoc} 428 * 429 * @deprecated 430 */ 431 public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, String tag ) 432 throws ScmException 433 { 434 return checkOut( repository, fileSet, tag, true ); 435 } 436 437 /** 438 * {@inheritDoc} 439 * 440 * @deprecated 441 */ 442 public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, String tag, boolean recursive ) 443 throws ScmException 444 { 445 ScmVersion scmVersion = null; 446 447 if ( StringUtils.isNotEmpty( tag ) ) 448 { 449 scmVersion = new ScmBranch( tag ); 450 } 451 452 return checkOut( repository, fileSet, scmVersion, recursive ); 453 } 454 455 /** 456 * {@inheritDoc} 457 */ 458 public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet ) 459 throws ScmException 460 { 461 return checkOut( repository, fileSet, (ScmVersion) null, true ); 462 } 463 464 /** 465 * {@inheritDoc} 466 */ 467 public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion ) 468 throws ScmException 469 { 470 return checkOut( repository, fileSet, scmVersion, true ); 471 } 472 473 /** 474 * {@inheritDoc} 475 */ 476 public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, boolean recursive ) 477 throws ScmException 478 { 479 return checkOut( repository, fileSet, (ScmVersion) null, recursive ); 480 } 481 482 /** 483 * {@inheritDoc} 484 */ 485 public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, 486 boolean recursive ) 487 throws ScmException 488 { 489 login( repository, fileSet ); 490 491 CommandParameters parameters = new CommandParameters(); 492 493 parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); 494 495 parameters.setString( CommandParameter.RECURSIVE, Boolean.toString( recursive ) ); 496 497 return checkout( repository.getProviderRepository(), fileSet, parameters ); 498 } 499 500 protected CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet, 501 CommandParameters parameters ) 502 throws ScmException 503 { 504 throw new NoSuchCommandScmException( "checkout" ); 505 } 506 507 /** 508 * {@inheritDoc} 509 * 510 * @deprecated 511 */ 512 public DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, String startRevision, String endRevision ) 513 throws ScmException 514 { 515 ScmVersion startVersion = null; 516 ScmVersion endVersion = null; 517 518 if ( StringUtils.isNotEmpty( startRevision ) ) 519 { 520 startVersion = new ScmRevision( startRevision ); 521 } 522 523 if ( StringUtils.isNotEmpty( endRevision ) ) 524 { 525 endVersion = new ScmRevision( endRevision ); 526 } 527 528 return diff( repository, fileSet, startVersion, endVersion ); 529 } 530 531 /** 532 * {@inheritDoc} 533 */ 534 public DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, ScmVersion startVersion, 535 ScmVersion endVersion ) 536 throws ScmException 537 { 538 login( repository, fileSet ); 539 540 CommandParameters parameters = new CommandParameters(); 541 542 parameters.setScmVersion( CommandParameter.START_SCM_VERSION, startVersion ); 543 544 parameters.setScmVersion( CommandParameter.END_SCM_VERSION, endVersion ); 545 546 return diff( repository.getProviderRepository(), fileSet, parameters ); 547 } 548 549 protected DiffScmResult diff( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) 550 throws ScmException 551 { 552 throw new NoSuchCommandScmException( "diff" ); 553 } 554 555 /** 556 * {@inheritDoc} 557 */ 558 public EditScmResult edit( ScmRepository repository, ScmFileSet fileSet ) 559 throws ScmException 560 { 561 login( repository, fileSet ); 562 563 CommandParameters parameters = new CommandParameters(); 564 565 return edit( repository.getProviderRepository(), fileSet, parameters ); 566 } 567 568 protected EditScmResult edit( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) 569 throws ScmException 570 { 571 if ( getLogger().isWarnEnabled() ) 572 { 573 getLogger().warn( "Provider " + this.getScmType() + " does not support edit operation." ); 574 } 575 576 return new EditScmResult( "", null, null, true ); 577 } 578 579 /** 580 * {@inheritDoc} 581 * 582 * @deprecated 583 */ 584 public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag ) 585 throws ScmException 586 { 587 return export( repository, fileSet, tag, null ); 588 } 589 590 /** 591 * {@inheritDoc} 592 * 593 * @deprecated 594 */ 595 public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, String tag, String outputDirectory ) 596 throws ScmException 597 { 598 ScmVersion scmVersion = null; 599 600 if ( StringUtils.isNotEmpty( tag ) ) 601 { 602 scmVersion = new ScmRevision( tag ); 603 } 604 605 return export( repository, fileSet, scmVersion, outputDirectory ); 606 } 607 608 /** 609 * {@inheritDoc} 610 */ 611 public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet ) 612 throws ScmException 613 { 614 return export( repository, fileSet, (ScmVersion) null, null ); 615 } 616 617 /** 618 * {@inheritDoc} 619 */ 620 public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion ) 621 throws ScmException 622 { 623 return export( repository, fileSet, scmVersion, null ); 624 } 625 626 /** 627 * {@inheritDoc} 628 */ 629 public ExportScmResult export( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, 630 String outputDirectory ) 631 throws ScmException 632 { 633 login( repository, fileSet ); 634 635 CommandParameters parameters = new CommandParameters(); 636 637 parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); 638 639 parameters.setString( CommandParameter.OUTPUT_DIRECTORY, outputDirectory ); 640 641 return export( repository.getProviderRepository(), fileSet, parameters ); 642 } 643 644 protected ExportScmResult export( ScmProviderRepository repository, ScmFileSet fileSet, 645 CommandParameters parameters ) 646 throws ScmException 647 { 648 throw new NoSuchCommandScmException( "export" ); 649 } 650 651 /** 652 * {@inheritDoc} 653 */ 654 public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, String tag ) 655 throws ScmException 656 { 657 ScmVersion scmVersion = null; 658 659 if ( StringUtils.isNotEmpty( tag ) ) 660 { 661 scmVersion = new ScmRevision( tag ); 662 } 663 664 return list( repository, fileSet, recursive, scmVersion ); 665 } 666 667 /** 668 * {@inheritDoc} 669 */ 670 public ListScmResult list( ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion ) 671 throws ScmException 672 { 673 login( repository, fileSet ); 674 675 CommandParameters parameters = new CommandParameters(); 676 677 parameters.setString( CommandParameter.RECURSIVE, Boolean.toString( recursive ) ); 678 679 if ( scmVersion != null ) 680 { 681 parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); 682 } 683 684 return list( repository.getProviderRepository(), fileSet, parameters ); 685 } 686 687 /** 688 * List each element (files and directories) of <B>fileSet</B> as they exist in the repository. 689 * 690 * @param repository the source control system 691 * @param fileSet the files to list 692 * @param parameters 693 * @return The list of files in the repository 694 * @throws NoSuchCommandScmException unless overriden by subclass 695 * @throws ScmException if any 696 */ 697 protected ListScmResult list( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) 698 throws ScmException 699 { 700 throw new NoSuchCommandScmException( "list" ); 701 } 702 703 /** 704 * {@inheritDoc} 705 */ 706 public MkdirScmResult mkdir( ScmRepository repository, ScmFileSet fileSet, String message, boolean createInLocal ) 707 throws ScmException 708 { 709 login( repository, fileSet ); 710 711 CommandParameters parameters = new CommandParameters(); 712 713 if ( message == null ) 714 { 715 message = ""; 716 if ( !createInLocal ) 717 { 718 getLogger().warn( "Commit message is empty!" ); 719 } 720 } 721 722 parameters.setString( CommandParameter.MESSAGE, message ); 723 724 parameters.setString( CommandParameter.SCM_MKDIR_CREATE_IN_LOCAL, Boolean.toString( createInLocal ) ); 725 726 return mkdir( repository.getProviderRepository(), fileSet, parameters ); 727 } 728 729 /** 730 * Create directory/directories in the repository. 731 * 732 * @param repository 733 * @param fileSet 734 * @param parameters 735 * @return 736 * @throws ScmException 737 */ 738 protected MkdirScmResult mkdir( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) 739 throws ScmException 740 { 741 throw new NoSuchCommandScmException( "mkdir" ); 742 } 743 744 private void login( ScmRepository repository, ScmFileSet fileSet ) 745 throws ScmException 746 { 747 LoginScmResult result = login( repository.getProviderRepository(), fileSet, new CommandParameters() ); 748 749 if ( !result.isSuccess() ) 750 { 751 throw new ScmException( "Can't login.\n" + result.getCommandOutput() ); 752 } 753 } 754 755 protected LoginScmResult login( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) 756 throws ScmException 757 { 758 return new LoginScmResult( null, null, null, true ); 759 } 760 761 /** 762 * {@inheritDoc} 763 */ 764 public RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, String message ) 765 throws ScmException 766 { 767 login( repository, fileSet ); 768 769 CommandParameters parameters = new CommandParameters(); 770 771 parameters.setString( CommandParameter.MESSAGE, message == null ? "" : message ); 772 773 return remove( repository.getProviderRepository(), fileSet, parameters ); 774 } 775 776 protected RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, 777 CommandParameters parameters ) 778 throws ScmException 779 { 780 throw new NoSuchCommandScmException( "remove" ); 781 } 782 783 /** 784 * {@inheritDoc} 785 */ 786 public StatusScmResult status( ScmRepository repository, ScmFileSet fileSet ) 787 throws ScmException 788 { 789 login( repository, fileSet ); 790 791 CommandParameters parameters = new CommandParameters(); 792 793 return status( repository.getProviderRepository(), fileSet, parameters ); 794 } 795 796 protected StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, 797 CommandParameters parameters ) 798 throws ScmException 799 { 800 throw new NoSuchCommandScmException( "status" ); 801 } 802 803 /** 804 * {@inheritDoc} 805 */ 806 public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName ) 807 throws ScmException 808 { 809 return tag( repository, fileSet, tagName, new ScmTagParameters() ); 810 } 811 812 /** 813 * {@inheritDoc} 814 */ 815 public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, String message ) 816 throws ScmException 817 { 818 login( repository, fileSet ); 819 820 CommandParameters parameters = new CommandParameters(); 821 822 parameters.setString( CommandParameter.TAG_NAME, tagName ); 823 824 if ( StringUtils.isNotEmpty( message ) ) 825 { 826 parameters.setString( CommandParameter.MESSAGE, message ); 827 } 828 829 ScmTagParameters scmTagParameters = new ScmTagParameters( message ); 830 831 parameters.setScmTagParameters( CommandParameter.SCM_TAG_PARAMETERS, scmTagParameters ); 832 833 return tag( repository.getProviderRepository(), fileSet, parameters ); 834 } 835 836 /** 837 * {@inheritDoc} 838 */ 839 public TagScmResult tag( ScmRepository repository, ScmFileSet fileSet, String tagName, 840 ScmTagParameters scmTagParameters ) 841 throws ScmException 842 { 843 login( repository, fileSet ); 844 845 CommandParameters parameters = new CommandParameters(); 846 847 parameters.setString( CommandParameter.TAG_NAME, tagName ); 848 849 parameters.setScmTagParameters( CommandParameter.SCM_TAG_PARAMETERS, scmTagParameters ); 850 851 return tag( repository.getProviderRepository(), fileSet, parameters ); 852 } 853 854 protected TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) 855 throws ScmException 856 { 857 throw new NoSuchCommandScmException( "tag" ); 858 } 859 860 /** 861 * {@inheritDoc} 862 */ 863 public UnEditScmResult unedit( ScmRepository repository, ScmFileSet fileSet ) 864 throws ScmException 865 { 866 login( repository, fileSet ); 867 868 CommandParameters parameters = new CommandParameters(); 869 870 return unedit( repository.getProviderRepository(), fileSet, parameters ); 871 } 872 873 protected UnEditScmResult unedit( ScmProviderRepository repository, ScmFileSet fileSet, 874 CommandParameters parameters ) 875 throws ScmException 876 { 877 if ( getLogger().isWarnEnabled() ) 878 { 879 getLogger().warn( "Provider " + this.getScmType() + " does not support unedit operation." ); 880 } 881 882 return new UnEditScmResult( "", null, null, true ); 883 } 884 885 /** 886 * {@inheritDoc} 887 * 888 * @deprecated 889 */ 890 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag ) 891 throws ScmException 892 { 893 return update( repository, fileSet, tag, true ); 894 } 895 896 /** 897 * {@inheritDoc} 898 * 899 * @deprecated 900 */ 901 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, boolean runChangelog ) 902 throws ScmException 903 { 904 return update( repository, fileSet, tag, "", runChangelog ); 905 } 906 907 /** 908 * {@inheritDoc} 909 */ 910 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet ) 911 throws ScmException 912 { 913 return update( repository, fileSet, (ScmVersion) null, true ); 914 } 915 916 /** 917 * {@inheritDoc} 918 */ 919 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion ) 920 throws ScmException 921 { 922 return update( repository, fileSet, scmVersion, true ); 923 } 924 925 /** 926 * {@inheritDoc} 927 */ 928 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, boolean runChangelog ) 929 throws ScmException 930 { 931 return update( repository, fileSet, (ScmVersion) null, "", runChangelog ); 932 } 933 934 /** 935 * {@inheritDoc} 936 */ 937 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, 938 boolean runChangelog ) 939 throws ScmException 940 { 941 return update( repository, fileSet, scmVersion, "", runChangelog ); 942 } 943 944 /** 945 * {@inheritDoc} 946 * 947 * @deprecated 948 */ 949 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern ) 950 throws ScmException 951 { 952 return update( repository, fileSet, tag, datePattern, true ); 953 } 954 955 /** 956 * {@inheritDoc} 957 */ 958 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, 959 String datePattern ) 960 throws ScmException 961 { 962 return update( repository, fileSet, scmVersion, datePattern, true ); 963 } 964 965 /** 966 * @deprecated 967 */ 968 private UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, String datePattern, 969 boolean runChangelog ) 970 throws ScmException 971 { 972 ScmBranch scmBranch = null; 973 974 if ( StringUtils.isNotEmpty( tag ) ) 975 { 976 scmBranch = new ScmBranch( tag ); 977 } 978 979 return update( repository, fileSet, scmBranch, datePattern, runChangelog ); 980 } 981 982 private UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, 983 String datePattern, boolean runChangelog ) 984 throws ScmException 985 { 986 login( repository, fileSet ); 987 988 CommandParameters parameters = new CommandParameters(); 989 990 parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); 991 992 parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); 993 994 parameters.setString( CommandParameter.RUN_CHANGELOG_WITH_UPDATE, String.valueOf( runChangelog ) ); 995 996 return update( repository.getProviderRepository(), fileSet, parameters ); 997 } 998 999 /** 1000 * {@inheritDoc} 1001 * 1002 * @deprecated 1003 */ 1004 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate ) 1005 throws ScmException 1006 { 1007 return update( repository, fileSet, tag, lastUpdate, null ); 1008 } 1009 1010 /** 1011 * {@inheritDoc} 1012 */ 1013 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, 1014 Date lastUpdate ) 1015 throws ScmException 1016 { 1017 return update( repository, fileSet, scmVersion, lastUpdate, null ); 1018 } 1019 1020 /** 1021 * {@inheritDoc} 1022 * 1023 * @deprecated 1024 */ 1025 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, String tag, Date lastUpdate, 1026 String datePattern ) 1027 throws ScmException 1028 { 1029 ScmBranch scmBranch = null; 1030 1031 if ( StringUtils.isNotEmpty( tag ) ) 1032 { 1033 scmBranch = new ScmBranch( tag ); 1034 } 1035 1036 return update( repository, fileSet, scmBranch, lastUpdate, datePattern ); 1037 } 1038 1039 /** 1040 * {@inheritDoc} 1041 */ 1042 public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, Date lastUpdate, 1043 String datePattern ) 1044 throws ScmException 1045 { 1046 login( repository, fileSet ); 1047 1048 CommandParameters parameters = new CommandParameters(); 1049 1050 parameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion ); 1051 1052 if ( lastUpdate != null ) 1053 { 1054 parameters.setDate( CommandParameter.START_DATE, lastUpdate ); 1055 } 1056 1057 parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); 1058 1059 parameters.setString( CommandParameter.RUN_CHANGELOG_WITH_UPDATE, "true" ); 1060 1061 return update( repository.getProviderRepository(), fileSet, parameters ); 1062 } 1063 1064 protected UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, 1065 CommandParameters parameters ) 1066 throws ScmException 1067 { 1068 throw new NoSuchCommandScmException( "update" ); 1069 } 1070 1071 /** 1072 * {@inheritDoc} 1073 */ 1074 public BlameScmResult blame( ScmRepository repository, ScmFileSet fileSet, String filename ) 1075 throws ScmException 1076 { 1077 login( repository, fileSet ); 1078 1079 CommandParameters parameters = new CommandParameters(); 1080 1081 parameters.setString( CommandParameter.FILE, filename ); 1082 1083 return blame( repository.getProviderRepository(), fileSet, parameters ); 1084 } 1085 1086 protected BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) 1087 throws ScmException 1088 { 1089 throw new NoSuchCommandScmException( "blame" ); 1090 } 1091 1092 public BlameScmResult blame( BlameScmRequest blameScmRequest ) 1093 throws ScmException 1094 { 1095 return blame( blameScmRequest.getScmRepository().getProviderRepository(), blameScmRequest.getScmFileSet(), 1096 blameScmRequest.getCommandParameters() ); 1097 } 1098 1099 public InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) 1100 throws ScmException 1101 { 1102 return null; 1103 } 1104 1105 public RemoteInfoScmResult remoteInfo( ScmProviderRepository repository, ScmFileSet fileSet, 1106 CommandParameters parameters ) 1107 throws ScmException 1108 { 1109 return null; 1110 } 1111 1112 // ---------------------------------------------------------------------- 1113 // 1114 // ---------------------------------------------------------------------- 1115 1116 /** 1117 * {@inheritDoc} 1118 */ 1119 public void addListener( ScmLogger logger ) 1120 { 1121 logDispatcher.addListener( logger ); 1122 } 1123 1124 public ScmLogger getLogger() 1125 { 1126 return logDispatcher; 1127 } 1128 1129 /** 1130 * {@inheritDoc} 1131 */ 1132 public ScmProviderRepository makeProviderScmRepository( File path ) 1133 throws ScmRepositoryException, UnknownRepositoryStructure 1134 { 1135 throw new UnknownRepositoryStructure(); 1136 } 1137}