Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgInternals.java @ 409:0f5696623512 smartgit3
Support glob path pattern rewrite to facilitate use of globs with Windows path separator
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Fri, 16 Mar 2012 20:14:47 +0100 |
| parents | 82336b7c54f4 |
| children | 63c5a9d7ca3f |
comparison
equal
deleted
inserted
replaced
| 408:e732521a9eb4 | 409:0f5696623512 |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 TMate Software Ltd | 2 * Copyright (c) 2011-2012 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 * |
| 27 | 27 |
| 28 import org.tmatesoft.hg.core.HgInvalidControlFileException; | 28 import org.tmatesoft.hg.core.HgInvalidControlFileException; |
| 29 import org.tmatesoft.hg.core.HgInvalidRevisionException; | 29 import org.tmatesoft.hg.core.HgInvalidRevisionException; |
| 30 import org.tmatesoft.hg.core.SessionContext; | 30 import org.tmatesoft.hg.core.SessionContext; |
| 31 import org.tmatesoft.hg.internal.Experimental; | 31 import org.tmatesoft.hg.internal.Experimental; |
| 32 import org.tmatesoft.hg.internal.Internals; | |
| 32 import org.tmatesoft.hg.internal.RelativePathRewrite; | 33 import org.tmatesoft.hg.internal.RelativePathRewrite; |
| 34 import org.tmatesoft.hg.internal.WinToNixPathRewrite; | |
| 33 import org.tmatesoft.hg.util.FileIterator; | 35 import org.tmatesoft.hg.util.FileIterator; |
| 34 import org.tmatesoft.hg.util.FileWalker; | 36 import org.tmatesoft.hg.util.FileWalker; |
| 35 import org.tmatesoft.hg.util.Path; | 37 import org.tmatesoft.hg.util.Path; |
| 36 import org.tmatesoft.hg.util.PathPool; | 38 import org.tmatesoft.hg.util.PathPool; |
| 37 import org.tmatesoft.hg.util.PathRewrite; | 39 import org.tmatesoft.hg.util.PathRewrite; |
| 85 | 87 |
| 86 public static File getRepositoryDir(HgRepository hgRepo) { | 88 public static File getRepositoryDir(HgRepository hgRepo) { |
| 87 return hgRepo.getRepositoryRoot(); | 89 return hgRepo.getRepositoryRoot(); |
| 88 } | 90 } |
| 89 | 91 |
| 90 public static HgIgnore newHgIgnore(Reader source) throws IOException { | 92 /** |
| 91 HgIgnore hgIgnore = new HgIgnore(); | 93 * @param source where to read definitions from |
| 94 * @param globPathRewrite <code>null</code> to use default, or pass an instance to override defaults | |
| 95 * @return | |
| 96 * @throws IOException | |
| 97 */ | |
| 98 public static HgIgnore newHgIgnore(Reader source, PathRewrite globPathRewrite) throws IOException { | |
| 99 if (globPathRewrite == null) { | |
| 100 // shall match that of HgRepository#getIgnore() (Internals#buildNormalizePathRewrite()) | |
| 101 if (Internals.runningOnWindows()) { | |
| 102 globPathRewrite = new WinToNixPathRewrite(); | |
| 103 } else { | |
| 104 globPathRewrite = new PathRewrite.Empty(); | |
| 105 } | |
| 106 } | |
| 107 HgIgnore hgIgnore = new HgIgnore(globPathRewrite); | |
| 92 BufferedReader br = source instanceof BufferedReader ? (BufferedReader) source : new BufferedReader(source); | 108 BufferedReader br = source instanceof BufferedReader ? (BufferedReader) source : new BufferedReader(source); |
| 93 hgIgnore.read(br); | 109 hgIgnore.read(br); |
| 94 br.close(); | 110 br.close(); |
| 95 return hgIgnore; | 111 return hgIgnore; |
| 96 } | 112 } |
