annotate src/org/tmatesoft/hg/repo/HgRepositoryFiles.java @ 494:2743641f2f12

Defect: use of 0 as configuration value for mapio boundary results in every file being memmap-ed
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 18 Oct 2012 19:51:07 +0200
parents ae4d6604debd
children 47b7bedf0569
rev   line source
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2012 TMate Software Ltd
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.repo;
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
19
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20 /**
442
6865eb742883 Tests for subrepo API, refactor status tests for reuse, better subrepos API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 373
diff changeset
21 * Names of some Mercurial configuration/service files.
6865eb742883 Tests for subrepo API, refactor status tests for reuse, better subrepos API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 373
diff changeset
22 *
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 * @author Artem Tikhomirov
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 * @author TMate Software Ltd.
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25 */
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 public enum HgRepositoryFiles {
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 HgIgnore(".hgignore"), HgTags(".hgtags"), HgEol(".hgeol"),
482
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
29 Dirstate(false, "dirstate"), HgLocalTags(false, "localtags"),
481
a458f9fb00ce Access to user-supplied message of last commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 456
diff changeset
30 HgSub(".hgsub"), HgSubstate(".hgsubstate"),
484
ae4d6604debd Bookmarks support added
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 482
diff changeset
31 LastMessage(false, "last-message.txt"),
ae4d6604debd Bookmarks support added
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 482
diff changeset
32 Bookmarks(false, "bookmarks"), BookmarksCurrent(false, "bookmarks.current");
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33
482
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
34 private final String fname;
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
35 private final boolean livesInWC;
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37 private HgRepositoryFiles(String filename) {
482
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
38 this(true, filename);
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39 }
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40
482
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
41 private HgRepositoryFiles(boolean wcNotRepoRoot, String filename) {
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
42 fname = filename;
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
43 livesInWC = wcNotRepoRoot;
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
44 }
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
45
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
46 /**
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
47 * Path to the file, relative to the parent it lives in.
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
48 *
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
49 * For repository files that reside in working directory, return their location relative to the working dir.
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
50 * For files that reside under repository root, path returned would include '.hg/' prefix.
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
51 * @return file location, never <code>null</code>
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
52 */
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
53 public String getPath() {
482
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
54 return livesInWC ? getName() : ".hg/" + getName();
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
55 }
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
56
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
57 /**
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
58 * File name without any path information
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
59 * @return file name, never <code>null</code>
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
60 */
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
61 public String getName() {
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
62 return fname;
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
63 }
482
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
64
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
65 /**
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
66 * Files that reside under working directory may be accessed like:
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
67 * <pre>
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
68 * HgRepository hgRepo = ...;
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
69 * File f = new File(hgRepo.getWorkingDir(), HgRepositoryFiles.HgIgnore.getPath())
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
70 * </pre>
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
71 * @return <code>true</code> if file lives in working tree
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
72 */
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
73 public boolean residesUnderWorkingDir() {
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
74 return livesInWC;
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
75 }
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
76
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
77 /**
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
78 * @return <code>true</code> if file lives under '.hg/'
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
79 */
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
80 public boolean residesUnderRepositoryRoot() {
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
81 return !livesInWC;
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
82 }
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 }