Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/ManifestOutputParser.java @ 67:64bddc2dcc0e
Tests for manifest cmd
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 21 Jan 2011 19:21:43 +0100 |
parents | |
children | 993f6f8e1314 |
comparison
equal
deleted
inserted
replaced
66:52dc3f4cfc76 | 67:64bddc2dcc0e |
---|---|
1 /* | |
2 * Copyright (c) 2011 TMate Software Ltd | |
3 * | |
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 | |
6 * the Free Software Foundation; version 2 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * For information on how to redistribute this software under | |
14 * the terms of a license other than GNU General Public License | |
15 * contact TMate Software at support@svnkit.com | |
16 */ | |
17 package org.tmatesoft.hg.test; | |
18 | |
19 import java.util.LinkedHashMap; | |
20 import java.util.Map; | |
21 import java.util.regex.Matcher; | |
22 import java.util.regex.Pattern; | |
23 | |
24 import org.tmatesoft.hg.core.Path; | |
25 | |
26 import com.tmate.hgkit.ll.Nodeid; | |
27 | |
28 /** | |
29 * | |
30 * @author Artem Tikhomirov | |
31 * @author TMate Software Ltd. | |
32 */ | |
33 public class ManifestOutputParser implements OutputParser { | |
34 | |
35 private final Pattern pattern; | |
36 private final LinkedHashMap<Path, Nodeid> result = new LinkedHashMap<Path, Nodeid>(); | |
37 | |
38 public ManifestOutputParser() { | |
39 pattern = Pattern.compile("^([a-z0-9]{40}) (\\d{3}) (.+)$", Pattern.MULTILINE); | |
40 } | |
41 | |
42 public void reset() { | |
43 result.clear(); | |
44 } | |
45 | |
46 public Map<Path, Nodeid> getResult() { | |
47 return result; | |
48 } | |
49 | |
50 public void parse(CharSequence seq) { | |
51 Matcher m = pattern.matcher(seq); | |
52 while (m.find()) { | |
53 result.put(Path.create(m.group(3)), Nodeid.fromAscii(m.group(1).getBytes(), 0, 40)); | |
54 } | |
55 } | |
56 } |