View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.scm.provider.svn.svnexe.command.checkin;
20  
21  import java.io.File;
22  import java.util.List;
23  
24  import org.apache.maven.scm.ScmFile;
25  import org.apache.maven.scm.ScmFileStatus;
26  import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer;
27  
28  /**
29   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
30   * @author Olivier Lamy
31   *
32   */
33  public class SvnCheckInConsumer extends AbstractFileCheckingConsumer {
34      private static final String SENDING_TOKEN = "Sending        ";
35  
36      private static final String ADDING_TOKEN = "Adding         ";
37  
38      private static final String ADDING_BIN_TOKEN = "Adding  (bin)  ";
39  
40      private static final String DELETING_TOKEN = "Deleting       ";
41  
42      private static final String TRANSMITTING_TOKEN = "Transmitting file data";
43  
44      private static final String COMMITTED_REVISION_TOKEN = "Committed revision";
45  
46      // ----------------------------------------------------------------------
47      //
48      // ----------------------------------------------------------------------
49  
50      public SvnCheckInConsumer(File workingDirectory) {
51          super(workingDirectory);
52      }
53  
54      // ----------------------------------------------------------------------
55      // StreamConsumer Implementation
56      // ----------------------------------------------------------------------
57  
58      /** {@inheritDoc} */
59      protected void parseLine(String line) {
60          String file;
61  
62          if (line.startsWith(COMMITTED_REVISION_TOKEN)) {
63              String revisionString = line.substring(COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1);
64  
65              revision = parseInt(revisionString);
66  
67              return;
68          } else if (line.startsWith(SENDING_TOKEN)) {
69              file = line.substring(SENDING_TOKEN.length());
70          } else if (line.startsWith(ADDING_TOKEN)) {
71              file = line.substring(ADDING_TOKEN.length());
72          } else if (line.startsWith(ADDING_BIN_TOKEN)) {
73              file = line.substring(ADDING_BIN_TOKEN.length());
74          } else if (line.startsWith(DELETING_TOKEN)) {
75              file = line.substring(DELETING_TOKEN.length());
76          } else if (line.startsWith(TRANSMITTING_TOKEN)) {
77              // ignore
78              return;
79          } else {
80              if (logger.isInfoEnabled()) {
81                  logger.info("Unknown line: '" + line + "'");
82              }
83  
84              return;
85          }
86  
87          addFile(new ScmFile(file, ScmFileStatus.CHECKED_IN));
88      }
89  
90      public List<ScmFile> getCheckedInFiles() {
91          return getFiles();
92      }
93  }