• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

oracle / opengrok / #3691

09 Nov 2023 04:15PM UTC coverage: 74.721% (+8.6%) from 66.08%
#3691

push

web-flow
avoid annotations for binary files (#4476)

fixes #4473

6 of 13 new or added lines in 4 files covered. (46.15%)

258 existing lines in 28 files now uncovered.

43797 of 58614 relevant lines covered (74.72%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/opengrok-indexer/src/main/java/org/opengrok/indexer/history/MercurialTagParser.java
1
/*
2
 * CDDL HEADER START
3
 *
4
 * The contents of this file are subject to the terms of the
5
 * Common Development and Distribution License (the "License").
6
 * You may not use this file except in compliance with the License.
7
 *
8
 * See LICENSE.txt included in this distribution for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing Covered Code, include this CDDL HEADER in each
12
 * file and include the License file at LICENSE.txt.
13
 * If applicable, add the following below this CDDL HEADER, with the
14
 * fields enclosed by brackets "[]" replaced with your own identifying
15
 * information: Portions Copyright [yyyy] [name of copyright owner]
16
 *
17
 * CDDL HEADER END
18
 */
19

20
/*
21
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
22
 */
23
package org.opengrok.indexer.history;
24

25
import java.io.BufferedReader;
26
import java.io.IOException;
27
import java.io.InputStream;
28
import java.io.InputStreamReader;
29
import java.util.TreeSet;
30
import java.util.logging.Level;
31
import java.util.logging.Logger;
32
import org.opengrok.indexer.logger.LoggerFactory;
33
import org.opengrok.indexer.util.Executor;
34

35
/**
36
 * handles parsing the output of the {@code hg tags} command
37
 * into a set of tag entries.
38
 */
UNCOV
39
public class MercurialTagParser implements Executor.StreamHandler {
×
UNCOV
40
    private static final Logger LOGGER = LoggerFactory.getLogger(MercurialTagParser.class);
×
41

42
    /**
43
     * Store tag entries created by processStream.
44
     */
UNCOV
45
    private TreeSet<TagEntry> entries = new TreeSet<>();
×
46

47
    /**
48
     * Returns the set of entries that has been created.
49
     *
50
     * @return entries a set of tag entries
51
     */
52
    public TreeSet<TagEntry> getEntries() {
UNCOV
53
        return entries;
×
54
    }
55

56
    @Override
57
    public void processStream(InputStream input) throws IOException {
58
        try {
UNCOV
59
            try (BufferedReader in = new BufferedReader(
×
60
                    new InputStreamReader(input))) {
61
                String line;
UNCOV
62
                while ((line = in.readLine()) != null) {
×
UNCOV
63
                    String[] parts = line.split("  *");
×
UNCOV
64
                    if (parts.length < 2) {
×
65
                        LOGGER.log(Level.WARNING,
×
66
                                "Failed to parse tag list: {0}",
67
                                "Tag line contains more than 2 columns: " + line);
68
                        entries = null;
×
69
                        break;
×
70
                    }
71
                    // Grrr, how to parse tags with spaces inside?
72
                    // This solution will lose multiple spaces ;-/
UNCOV
73
                    String tag = parts[0];
×
UNCOV
74
                    for (int i = 1; i < parts.length - 1; ++i) {
×
75
                        tag = tag.concat(" ");
×
76
                        tag = tag.concat(parts[i]);
×
77
                    }
78
                    // The implicit 'tip' tag only causes confusion so ignore it.
UNCOV
79
                    if (tag.contentEquals("tip")) {
×
UNCOV
80
                        continue;
×
81
                    }
UNCOV
82
                    String[] revParts = parts[parts.length - 1].split(":");
×
UNCOV
83
                    if (revParts.length != 2) {
×
84
                        LOGGER.log(Level.WARNING,
×
85
                                "Failed to parse tag list: {0}",
86
                                "Mercurial revision parsing error: "
87
                                        + parts[parts.length - 1]);
88
                        entries = null;
×
89
                        break;
×
90
                    }
UNCOV
91
                    TagEntry tagEntry
×
UNCOV
92
                            = new MercurialTagEntry(Integer.parseInt(revParts[0]),
×
93
                                    tag);
94
                    // Reverse the order of the list
UNCOV
95
                    entries.add(tagEntry);
×
UNCOV
96
                }
×
97
            }
98
        } catch (IOException e) {
×
99
            LOGGER.log(Level.WARNING,
×
100
                    "Failed to read tag list: {0}", e.getMessage());
×
101
            entries = null;
×
UNCOV
102
        }
×
UNCOV
103
    }
×
104
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc