1 package org.apache.maven.scm.provider.bazaar.command.tag; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import java.io.File; 23 import java.util.LinkedList; 24 import java.util.List; 25 26 import org.apache.maven.scm.ScmFile; 27 import org.apache.maven.scm.ScmFileStatus; 28 import org.apache.maven.scm.log.ScmLogger; 29 import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer; 30 31 /** 32 * Parse output from "bzr ls". 33 * @author <a href="mailto:johan.walles@gmail.com">Johan Walles</a> 34 * @author Olivier Lamy 35 * 36 */ 37 class BazaarLsConsumer 38 extends BazaarConsumer 39 { 40 /** 41 * The root directory of this bazaar repository. 42 */ 43 private File repositoryRoot; 44 45 /** 46 * A list of the files found by ls. 47 */ 48 private List<ScmFile> files; 49 50 /** 51 * Create a new "bzr ls" consumer. 52 * @param repositoryRoot The root directory of this bazaar repository. 53 * @param wantedStatus The status we'll report for the files listed. 54 */ 55 public BazaarLsConsumer( ScmLogger logger, File repositoryRoot, ScmFileStatus wantedStatus ) 56 { 57 super( logger ); 58 files = new LinkedList<ScmFile>(); 59 } 60 61 public void doConsume( ScmFileStatus status, String trimmedLine ) 62 { 63 if ( trimmedLine.endsWith( File.separator ) ) 64 { 65 // Don't report directories 66 return; 67 } 68 69 String path = new File( repositoryRoot, trimmedLine ).toString(); 70 files.add( new ScmFile( path, ScmFileStatus.TAGGED ) ); 71 } 72 73 /** 74 * Answer what files were listed by bzr ls. 75 * @return A list of files listed by bzr ls. 76 */ 77 public List<ScmFile> getListedFiles() 78 { 79 return files; 80 } 81 }