1 package org.apache.maven.scm.provider.svn.svnexe.command.checkout;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.commons.lang.StringUtils;
23 import org.apache.maven.scm.ScmFile;
24 import org.apache.maven.scm.ScmFileStatus;
25 import org.apache.maven.scm.log.ScmLogger;
26 import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer;
27
28 import java.io.File;
29 import java.util.ArrayList;
30 import java.util.List;
31
32
33
34
35
36
37 public class SvnCheckOutConsumer
38 extends AbstractFileCheckingConsumer
39 {
40 private static final String CHECKED_OUT_REVISION_TOKEN = "Checked out revision";
41
42 private List<ScmFile> files = new ArrayList<ScmFile>();
43
44 public SvnCheckOutConsumer( ScmLogger logger, File workingDirectory )
45 {
46 super( logger, workingDirectory );
47 }
48
49
50
51
52 protected void parseLine( String line )
53 {
54 String statusString = line.substring( 0, 1 );
55
56 String file = line.substring( 3 ).trim();
57
58 if ( file.startsWith( getWorkingDirectory().getAbsolutePath() ) )
59 {
60 file = StringUtils.substring( file, getWorkingDirectory().getAbsolutePath().length() + 1 );
61 }
62
63 ScmFileStatus status;
64
65 if ( line.startsWith( CHECKED_OUT_REVISION_TOKEN ) )
66 {
67 String revisionString = line.substring( CHECKED_OUT_REVISION_TOKEN.length() + 1, line.length() - 1 );
68
69 revision = parseInt( revisionString );
70
71 return;
72 }
73 else if ( statusString.equals( "A" ) )
74 {
75 status = ScmFileStatus.ADDED;
76 }
77 else if ( statusString.equals( "U" ) )
78 {
79 status = ScmFileStatus.UPDATED;
80 }
81 else
82 {
83
84
85 return;
86 }
87
88 addFile( new ScmFile( file, status ) );
89 }
90
91
92
93
94
95 public List<ScmFile> getCheckedOutFiles()
96 {
97 return getFiles();
98 }
99
100 protected void addFile( ScmFile file )
101 {
102 files.add( file );
103 }
104
105 protected List<ScmFile> getFiles()
106 {
107 List<ScmFile> onlyFiles = new ArrayList<ScmFile>();
108 for ( ScmFile file : files )
109 {
110
111 if ( !( !file.getStatus().equals( ScmFileStatus.DELETED ) && !new File( getWorkingDirectory(),
112 file.getPath() ).isFile() ) || !(
113 !file.getStatus().equals( ScmFileStatus.DELETED ) && !new File( getWorkingDirectory().getParent(),
114 file.getPath() ).isFile() ) )
115 {
116 onlyFiles.add( file );
117 }
118 }
119
120 return onlyFiles;
121 }
122
123 }