Mercurial > jhg
annotate src/org/tmatesoft/hg/repo/HgRepositoryFiles.java @ 670:52af7f62e731
AIOOBE in BundleGenerator.ChunkGenerator.iterate when there are no outgoing changes on push
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 12 Jul 2013 15:27:43 +0200 |
parents | c75297c17867 |
children | 42b88709e41d |
rev | line source |
---|---|
373
dd492acd2431
Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
626
5afc7eedb3dd
@since, TODOs. Tests: add 1 sec to deal with fs timestamp granularity on linux
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
617
diff
changeset
|
2 * Copyright (c) 2012-2013 TMate Software Ltd |
373
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 |
647
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
28 HgIgnore(Home.Root, ".hgignore"), HgTags(Home.Root, ".hgtags"), HgEol(Home.Root, ".hgeol"), |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
29 Dirstate(Home.Repo, "dirstate"), HgLocalTags(Home.Repo, "localtags"), |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
30 HgSub(Home.Root, ".hgsub"), HgSubstate(Home.Root, ".hgsubstate"), |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
31 LastMessage(Home.Repo, "last-message.txt"), |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
32 Bookmarks(Home.Repo, "bookmarks"), BookmarksCurrent(Home.Repo, "bookmarks.current"), |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
33 Branch(Home.Repo, "branch"), |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
34 UndoBranch(Home.Repo, "undo.branch"), UndoDirstate(Home.Repo, "undo.dirstate"), |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
35 Phaseroots(Home.Store, "phaseroots"), FNCache(Home.Store, "fncache"), |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
36 WorkingCopyLock(Home.Repo, "wlock"), StoreLock(Home.Store, "lock"); |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
37 |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
38 /** |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
39 * Possible file locations |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
40 */ |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
41 public enum Home { |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
42 Root, Repo, Store |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
43 } |
373
dd492acd2431
Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 |
482
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
45 private final String fname; |
647
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
46 private final Home residesIn; |
373
dd492acd2431
Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 |
647
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
48 private HgRepositoryFiles(Home home, 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
|
49 fname = filename; |
647
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
50 residesIn = home; |
482
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
51 } |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
52 |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
53 /** |
647
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
54 * Path to the file, relative to the repository root. |
482
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 * For repository files that reside in working directory, return their location relative to the working dir. |
647
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
57 * For files that reside under repository root, path returned includes '.hg/' prefix. |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
58 * For files from {@link Home#Store} storage area, path starts with '.hg/store/', although actual use of 'store' folder |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
59 * is controlled by repository requirements. Returned value shall be deemed as 'most likely' path in a general environment. |
482
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
60 * @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
|
61 */ |
373
dd492acd2431
Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
62 public String getPath() { |
647
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
63 switch (residesIn) { |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
64 case Store : return ".hg/store/" + getName(); |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
65 case Repo : return ".hg/" + getName(); |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
66 default : return getName(); |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
67 } |
482
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
68 } |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
69 |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
70 /** |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
71 * 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
|
72 * @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
|
73 */ |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
74 public String getName() { |
373
dd492acd2431
Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 return fname; |
dd492acd2431
Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
76 } |
482
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 /** |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
79 * 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
|
80 * <pre> |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
81 * 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
|
82 * 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
|
83 * </pre> |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
84 * @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
|
85 */ |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
86 public boolean residesUnderWorkingDir() { |
647
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
87 return residesIn == Home.Root; |
482
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
88 } |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
89 |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
90 /** |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
91 * @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
|
92 */ |
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
93 public boolean residesUnderRepositoryRoot() { |
647
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
94 return residesIn == Home.Repo; |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
95 } |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
96 |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
97 /** |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
98 * Identify a root the file lives under |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
99 */ |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
100 public Home getHome() { |
c75297c17867
Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
626
diff
changeset
|
101 return residesIn; |
482
6c67debed07e
Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
481
diff
changeset
|
102 } |
373
dd492acd2431
Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
103 } |