comparison src/org/tmatesoft/hg/repo/HgIgnore.java @ 564:e6407313bab7

Recognize re: in-line prefix for regular expressions as native client does, despite silence in hgingore.5
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 03 Apr 2013 21:28:06 +0200
parents 7f136a3fa671
children 5c68567b3645
comparison
equal deleted inserted replaced
563:ca56a36c2eea 564:e6407313bab7
1 /* 1 /*
2 * Copyright (c) 2010-2012 TMate Software Ltd 2 * Copyright (c) 2010-2013 TMate Software Ltd
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License. 6 * the Free Software Foundation; version 2 of the License.
7 * 7 *
57 } 57 }
58 } 58 }
59 59
60 /* package-local */ List<String> read(BufferedReader content) throws IOException { 60 /* package-local */ List<String> read(BufferedReader content) throws IOException {
61 final String REGEXP = "regexp", GLOB = "glob"; 61 final String REGEXP = "regexp", GLOB = "glob";
62 final String REGEXP_PREFIX = REGEXP + ":", GLOB_PREFIX = GLOB + ":"; 62 final String REGEXP_PREFIX1 = REGEXP + ":", REGEXP_PREFIX2 = "re:", GLOB_PREFIX = GLOB + ":";
63 ArrayList<String> errors = new ArrayList<String>(); 63 ArrayList<String> errors = new ArrayList<String>();
64 ArrayList<Pattern> result = new ArrayList<Pattern>(entries); // start with existing 64 ArrayList<Pattern> result = new ArrayList<Pattern>(entries); // start with existing
65 String syntax = REGEXP; 65 String syntax = REGEXP;
66 String line; 66 String line;
67 while ((line = content.readLine()) != null) { 67 while ((line = content.readLine()) != null) {
92 // syntax in use without affecting default kind. 92 // syntax in use without affecting default kind.
93 String lineSyntax; 93 String lineSyntax;
94 if (line.startsWith(GLOB_PREFIX)) { 94 if (line.startsWith(GLOB_PREFIX)) {
95 line = line.substring(GLOB_PREFIX.length()).trim(); 95 line = line.substring(GLOB_PREFIX.length()).trim();
96 lineSyntax = GLOB; 96 lineSyntax = GLOB;
97 } else if (line.startsWith(REGEXP_PREFIX)) { 97 } else if (line.startsWith(REGEXP_PREFIX1)) {
98 line = line.substring(REGEXP_PREFIX.length()).trim(); 98 line = line.substring(REGEXP_PREFIX1.length()).trim();
99 lineSyntax = REGEXP;
100 } else if (line.startsWith(REGEXP_PREFIX2)) {
101 line = line.substring(REGEXP_PREFIX2.length()).trim();
99 lineSyntax = REGEXP; 102 lineSyntax = REGEXP;
100 } else { 103 } else {
101 lineSyntax = syntax; 104 lineSyntax = syntax;
102 } 105 }
103 if (line.length() == 0) { 106 if (line.length() == 0) {