1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. /*
  18. * Portions of this software are based upon public domain software
  19. * originally written at the National Center for Supercomputing Applications,
  20. * University of Illinois, Urbana-Champaign.
  21. */
  22. package org.apache.tools.ant.taskdefs.optional.perforce;
  23. import org.apache.tools.ant.BuildException;
  24. /**
  25. * Reopen Perforce checkout files between changelists.
  26. *
  27. *
  28. * @ant.task category="scm"
  29. */
  30. public class P4Reopen extends P4Base {
  31. private String toChange = "";
  32. /**
  33. * The changelist to move files to; required.
  34. * @param toChange new change list number
  35. * @throws BuildException if the change parameter is null or empty
  36. */
  37. public void setToChange(String toChange) throws BuildException {
  38. if (toChange == null && !toChange.equals("")) {
  39. throw new BuildException("P4Reopen: tochange cannot be null or empty");
  40. }
  41. this.toChange = toChange;
  42. }
  43. /**
  44. * do the work
  45. * @throws BuildException if P4View is null
  46. */
  47. public void execute() throws BuildException {
  48. if (P4View == null) {
  49. throw new BuildException("No view specified to reopen");
  50. }
  51. execP4Command("-s reopen -c " + toChange + " " + P4View, new SimpleP4OutputHandler(this));
  52. }
  53. }