Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestIgnore.java @ 612:dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 10 May 2013 14:29:35 +0200 |
parents | 0f5696623512 |
children |
comparison
equal
deleted
inserted
replaced
611:7fc7fba4df30 | 612:dca70c0b1f74 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011-2012 TMate Software Ltd | 2 * Copyright (c) 2011-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 * |
26 import org.junit.Rule; | 26 import org.junit.Rule; |
27 import org.junit.Test; | 27 import org.junit.Test; |
28 import org.tmatesoft.hg.internal.WinToNixPathRewrite; | 28 import org.tmatesoft.hg.internal.WinToNixPathRewrite; |
29 import org.tmatesoft.hg.repo.HgIgnore; | 29 import org.tmatesoft.hg.repo.HgIgnore; |
30 import org.tmatesoft.hg.repo.HgInternals; | 30 import org.tmatesoft.hg.repo.HgInternals; |
31 import org.tmatesoft.hg.repo.HgLookup; | |
32 import org.tmatesoft.hg.repo.HgRepository; | |
33 import org.tmatesoft.hg.repo.HgRepositoryFiles; | |
31 import org.tmatesoft.hg.util.Path; | 34 import org.tmatesoft.hg.util.Path; |
32 | 35 |
33 /** | 36 /** |
34 * | 37 * |
35 * @author Artem Tikhomirov | 38 * @author Artem Tikhomirov |
185 // create("a/dir/c.a"), | 188 // create("a/dir/c.a"), |
186 // create("b/dir-c/d.a"), | 189 // create("b/dir-c/d.a"), |
187 create("src/_ReSharper-1/file/x"), | 190 create("src/_ReSharper-1/file/x"), |
188 }; | 191 }; |
189 doAssert(hgIgnore, toIgnore, toPass); | 192 doAssert(hgIgnore, toIgnore, toPass); |
193 } | |
194 | |
195 @Test | |
196 public void testRefreshOnChange() throws Exception { | |
197 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-refresh-hgignore", false); | |
198 File hgignoreFile = new File(repoLoc, HgRepositoryFiles.HgIgnore.getPath()); | |
199 RepoUtils.createFile(hgignoreFile, "bin/"); | |
200 HgRepository hgRepo = new HgLookup().detect(repoLoc); | |
201 final Path p1 = Path.create("bin/a/b/c"); | |
202 final Path p2 = Path.create("src/a/b/c"); | |
203 HgIgnore ignore = hgRepo.getIgnore(); | |
204 errorCollector.assertTrue(ignore.isIgnored(p1)); | |
205 errorCollector.assertFalse(ignore.isIgnored(p2)); | |
206 Thread.sleep(1000); // Linux granularity for modification time is 1 second | |
207 // file of the same length | |
208 RepoUtils.createFile(hgignoreFile, "src/"); | |
209 ignore = hgRepo.getIgnore(); | |
210 errorCollector.assertFalse(ignore.isIgnored(p1)); | |
211 errorCollector.assertTrue(ignore.isIgnored(p2)); | |
212 | |
190 } | 213 } |
191 | 214 |
192 private void doAssert(HgIgnore hgIgnore, Path[] toIgnore, Path[] toPass) { | 215 private void doAssert(HgIgnore hgIgnore, Path[] toIgnore, Path[] toPass) { |
193 if (toIgnore == null && toPass == null) { | 216 if (toIgnore == null && toPass == null) { |
194 throw new IllegalArgumentException(); | 217 throw new IllegalArgumentException(); |