annotate src/org/tmatesoft/hg/repo/HgRepositoryFiles.java @ 712:a864fb309e4b

Issue 49: NoClassDefFoundError: org/tmatesoft/hg/auth/HgAuthenticator. Missing package in the binary bundle
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sun, 03 Aug 2014 18:04:13 +0200
parents a62079bc422b
children
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"),
707
42b88709e41d Merge: support 'unresolved' resolution with MergeStateBuilder
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 647
diff changeset
36 WorkingCopyLock(Home.Repo, "wlock"), StoreLock(Home.Store, "lock"),
711
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 707
diff changeset
37 MergeState(Home.Repo, "merge/state"),
a62079bc422b Keyword filtering that doesn't depend on input buffer size and the way input lines got split between filter() calls. KewordFilter got state to keep processed suspicious ...$ lines
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 707
diff changeset
38 RepoConfig(Home.Repo, "hgrc");
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
39
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 /**
707
42b88709e41d Merge: support 'unresolved' resolution with MergeStateBuilder
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 647
diff changeset
41 * Possible file locations
42b88709e41d Merge: support 'unresolved' resolution with MergeStateBuilder
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 647
diff changeset
42 * <ul>
42b88709e41d Merge: support 'unresolved' resolution with MergeStateBuilder
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 647
diff changeset
43 * <li>{@link #Root} lives in working copy
42b88709e41d Merge: support 'unresolved' resolution with MergeStateBuilder
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 647
diff changeset
44 * <li>{@link #Repo} files under <samp>.hg/</samp>
42b88709e41d Merge: support 'unresolved' resolution with MergeStateBuilder
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 647
diff changeset
45 * <li>#{@link #Store} files in storage area, either <samp>.hg/store/</samp> or <samp>.hg/</samp>
42b88709e41d Merge: support 'unresolved' resolution with MergeStateBuilder
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 647
diff changeset
46 * </ul>
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
47 */
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 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
49 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
50 }
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
51
482
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
52 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
53 private final Home residesIn;
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
54
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
55 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
56 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
57 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
58 }
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
59
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
60 /**
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
61 * 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
62 *
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
63 * 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
64 * 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
65 * 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
66 * 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
67 * @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
68 */
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
69 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
70 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
71 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
72 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
73 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
74 }
482
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 * 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
79 * @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
80 */
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
81 public String getName() {
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
82 return fname;
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 }
482
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
84
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 * 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
87 * <pre>
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
88 * 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
89 * 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
90 * </pre>
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 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
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 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
94 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
95 }
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
96
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
97 /**
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
98 * @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
99 */
6c67debed07e Distinguish files in wc from files under repo root, use these constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 481
diff changeset
100 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
101 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
102 }
c75297c17867 Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 626
diff changeset
103
c75297c17867 Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 626
diff changeset
104 /**
c75297c17867 Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 626
diff changeset
105 * 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
106 */
c75297c17867 Location of repository files as enumeration, use file constants instead of plain names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 626
diff changeset
107 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
108 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
109 }
373
dd492acd2431 Constants for well-known repository file names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
110 }