Skip to content

Commit 4bf5e98

Browse files
authored
Merge pull request #1606 from vladak/mercurial_subdir_fix
when directory is specified for Mercurial history view, limit the log…
2 parents 4266a9a + 570c485 commit 4bf5e98

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/org/opensolaris/opengrok/history/MercurialRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ Executor getHistoryLogExecutor(File file, String sinceRevision)
193193
// For files this does not matter since if getHistory() is called
194194
// for a file, the file has to be renamed so we want its complete history.
195195
cmd.add("--follow");
196+
}
197+
198+
if (!filename.isEmpty()) {
196199
cmd.add(filename);
197200
}
198201

test/org/opensolaris/opengrok/history/MercurialRepositoryTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,22 @@ public void testGetHistory() throws Exception {
115115
}
116116
}
117117

118+
@Test
119+
public void testGetHistorySubdir() throws Exception {
120+
setUpTestRepository();
121+
File root = new File(repository.getSourceRoot(), "mercurial");
122+
123+
// Add a subdirectory with some history.
124+
runHgCommand("import",
125+
root, getClass().getResource("hg-export-subdir.txt").getPath());
126+
127+
MercurialRepository mr
128+
= (MercurialRepository) RepositoryFactory.getRepository(root);
129+
History hist = mr.getHistory(new File(root, "subdir"));
130+
List<HistoryEntry> entries = hist.getHistoryEntries();
131+
assertEquals(1, entries.size());
132+
}
133+
118134
/**
119135
* Test that subset of changesets can be extracted based on penultimate
120136
* revision number. This works for directories only.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# HG changeset patch
2+
# User Vladimir Kotal <[email protected]>
3+
# Date 1495469596 -7200
4+
# Mon May 22 18:13:16 2017 +0200
5+
# Node ID c78fa757c524557fe29293c2a63480deb5c4f651
6+
# Parent 8b340409b3a81618750aa660cb113c65440688be
7+
add file in a subdir
8+
9+
diff -r 8b340409b3a8 -r c78fa757c524 subdir/foo.txt
10+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
11+
+++ b/subdir/foo.txt Mon May 22 18:13:16 2017 +0200
12+
@@ -0,0 +1,1 @@
13+
+Monday, May 22, 2017 06:12:42 PM CEST

0 commit comments

Comments
 (0)