annotate src/org/tmatesoft/hg/internal/LineReader.java @ 704:7743a9c10bfa

Merge command introduced
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 14 Aug 2013 20:07:26 +0200
parents 12a4f60ea972
children
rev   line source
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
539
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
2 * Copyright (c) 2012-2013 TMate Software Ltd
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.internal;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
19 import java.io.BufferedReader;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20 import java.io.File;
539
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
21 import java.io.FileInputStream;
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22 import java.io.FileReader;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 import java.io.IOException;
539
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
24 import java.io.InputStreamReader;
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
25 import java.io.Reader;
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
26 import java.nio.charset.Charset;
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 import java.util.Collection;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28
628
6526d8adbc0f Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 624
diff changeset
29 import org.tmatesoft.hg.core.HgIOException;
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 import org.tmatesoft.hg.util.LogFacility;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32 /**
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 * Handy class to read line-based configuration files
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 *
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35 * @author Artem Tikhomirov
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 * @author TMate Software Ltd.
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37 */
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 public final class LineReader {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40 public interface LineConsumer<T> {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 // boolean begin(File f, T paramObj) throws IOException;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 boolean consume(String line, T paramObj) throws IOException;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43 // boolean end(File f, T paramObj) throws IOException;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
44 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46 public static class SimpleLineCollector implements LineReader.LineConsumer<Collection<String>> {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48 public boolean consume(String line, Collection<String> result) throws IOException {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49 result.add(line);
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 return true;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
51 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
52 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
53
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
54 private final File file;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
55 private final LogFacility log;
539
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
56 private final Charset encoding;
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
57 private boolean trimLines = true;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
58 private boolean skipEmpty = true;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
59 private String ignoreThatStarts = null;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 public LineReader(File f, LogFacility logFacility) {
539
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
62 this(f, logFacility, null);
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
63 }
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
64
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
65 public LineReader(File f, LogFacility logFacility, Charset lineEncoding) {
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
66 file = f;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
67 log = logFacility;
539
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
68 encoding = lineEncoding;
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
69 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
70
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
71 /**
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
72 * default: <code>true</code>
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
73 * <code>false</code> to return line as is
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
74 */
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
75 public LineReader trimLines(boolean trim) {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
76 trimLines = trim;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
77 return this;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
78 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
79
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
80 /**
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
81 * default: <code>true</code>
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
82 * <code>false</code> to pass empty lines to consumer
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 */
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
84 public LineReader skipEmpty(boolean skip) {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
85 skipEmpty = skip;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
86 return this;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
87 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
88
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
89 /**
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
90 * default: doesn't skip any line.
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
91 * set e.g. to "#" or "//" to skip lines that start with such prefix
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
92 */
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
93 public LineReader ignoreLineComments(String lineStart) {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
94 ignoreThatStarts = lineStart;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
95 return this;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
96 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
97
649
e79cf9a8130b Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
98 /**
e79cf9a8130b Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
99 *
e79cf9a8130b Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
100 * @param consumer where to pipe read lines to
e79cf9a8130b Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
101 * @param paramObj parameterizes consumer
e79cf9a8130b Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
102 * @return paramObj value for convenience
e79cf9a8130b Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
103 * @throws HgIOException if there's {@link IOException} while reading file
e79cf9a8130b Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
104 */
e79cf9a8130b Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
105 public <T> T read(LineConsumer<T> consumer, T paramObj) throws HgIOException {
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
106 BufferedReader statusFileReader = null;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
107 try {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
108 // consumer.begin(file, paramObj);
539
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
109 Reader fileReader;
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
110 if (encoding == null) {
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
111 fileReader = new FileReader(file);
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
112 } else {
590
8cbc2a883d95 Use requested encoding in LineReader
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 539
diff changeset
113 fileReader = new InputStreamReader(new FileInputStream(file), encoding);
539
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
114 }
9edfd5a223b8 Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 483
diff changeset
115 statusFileReader = new BufferedReader(fileReader);
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
116 String line;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
117 boolean ok = true;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
118 while (ok && (line = statusFileReader.readLine()) != null) {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
119 if (trimLines) {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
120 line = line.trim();
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
121 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
122 if (ignoreThatStarts != null && line.startsWith(ignoreThatStarts)) {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
123 continue;
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
124 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
125 if (!skipEmpty || line.length() > 0) {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
126 ok = consumer.consume(line, paramObj);
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
127 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
128 }
649
e79cf9a8130b Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
129 return paramObj;
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
130 } catch (IOException ex) {
628
6526d8adbc0f Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 624
diff changeset
131 throw new HgIOException(ex.getMessage(), ex, file);
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
132 } finally {
654
12a4f60ea972 1) Console push tool. 2) Pass class to blame into FileUtils
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 649
diff changeset
133 new FileUtils(log, this).closeQuietly(statusFileReader);
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
134 // try {
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
135 // consumer.end(file, paramObj);
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
136 // } catch (IOException ex) {
624
507602cb4fb3 FIXMEs and TODOs: pay some technical debt
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 590
diff changeset
137 // log.warn(getClass(), ex, null);
480
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
138 // }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
139 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
140 }
f3fab7a20841 Refactor LineReader utility as stanalone class to facilitate reuse
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
141 }