Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgInternals.java @ 338:3cfa4d908fc9
Add options to control DataAccessProvider, allow to turn off use of file memory mapping in particular to solve potential sharing violation (os file handle gets released on MappedByteByffer being GC'd, not on FileChannel.close())
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 15 Nov 2011 04:47:03 +0100 |
parents | a37ce7145c3f |
children | 863356c2847e |
rev | line source |
---|---|
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
2 * Copyright (c) 2011 TMate Software Ltd |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
3 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
7 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
11 * GNU General Public License for more details. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
12 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
13 * For information on how to redistribute this software under |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
102
a3a2e5deb320
Updated contact address to support@hg4j.com
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
96
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
17 package org.tmatesoft.hg.repo; |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
18 |
148
1a7a9a20e1f9
Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
19 import static org.tmatesoft.hg.repo.HgRepository.*; |
1a7a9a20e1f9
Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
20 |
269
7af843ecc378
Respect glob pattern with alternatives {a,b}
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
237
diff
changeset
|
21 import java.io.BufferedReader; |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
22 import java.io.File; |
269
7af843ecc378
Respect glob pattern with alternatives {a,b}
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
237
diff
changeset
|
23 import java.io.IOException; |
7af843ecc378
Respect glob pattern with alternatives {a,b}
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
237
diff
changeset
|
24 import java.io.Reader; |
128
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
25 import java.net.InetAddress; |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
26 import java.net.UnknownHostException; |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
27 |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
28 import org.tmatesoft.hg.core.SessionContext; |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
29 import org.tmatesoft.hg.internal.Experimental; |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
30 import org.tmatesoft.hg.internal.RelativePathRewrite; |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
31 import org.tmatesoft.hg.util.FileIterator; |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
32 import org.tmatesoft.hg.util.FileWalker; |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
128
diff
changeset
|
33 import org.tmatesoft.hg.util.Path; |
284
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
269
diff
changeset
|
34 import org.tmatesoft.hg.util.PathPool; |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
35 import org.tmatesoft.hg.util.PathRewrite; |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
36 |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 /** |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 * DO NOT USE THIS CLASS, INTENDED FOR TESTING PURPOSES. |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 * |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
41 * This class gives access to repository internals, and holds methods that I'm not confident have to be widely accessible |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 * Debug helper, to access otherwise restricted (package-local) methods |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 * |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
44 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
45 * @author TMate Software Ltd. |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 */ |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
47 @Experimental(reason="Perhaps, shall split methods with debug purpose from methods that are experimental API") |
96
ace7042a5ce6
Internals to HgInternals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
91
diff
changeset
|
48 public class HgInternals { |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 private final HgRepository repo; |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 |
96
ace7042a5ce6
Internals to HgInternals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
91
diff
changeset
|
52 public HgInternals(HgRepository hgRepo) { |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
53 repo = hgRepo; |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 } |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 public void dumpDirstate() { |
296
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
57 getDirstate().dump(); |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
58 } |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
59 |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
60 public HgDirstate getDirstate() { |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
61 return repo.loadDirstate(new PathPool(new PathRewrite.Empty())); |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
62 } |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
63 |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
64 // tests |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
65 public HgDirstate createDirstate(boolean caseSensitiveFileSystem) { |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
66 PathRewrite canonicalPath = null; |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
67 if (!caseSensitiveFileSystem) { |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
68 canonicalPath = new PathRewrite() { |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
69 |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
70 public CharSequence rewrite(CharSequence path) { |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
71 return path.toString().toLowerCase(); |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
72 } |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
73 }; |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
74 } |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
75 return new HgDirstate(repo, new File(repo.getRepositoryRoot(), "dirstate"), new PathPool(new PathRewrite.Empty()), canonicalPath); |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
76 } |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
77 |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
78 public Path[] checkKnown(HgDirstate dirstate, Path[] toCheck) { |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
79 Path[] rv = new Path[toCheck.length]; |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
80 for (int i = 0; i < toCheck.length; i++) { |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
81 rv[i] = dirstate.known(toCheck[i]); |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
82 } |
02f2963c70fa
Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
83 return rv; |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
84 } |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 public boolean[] checkIgnored(String... toCheck) { |
91
c2ce1cfaeb9e
ignore file with regex and 'honest' glob support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
87 HgIgnore ignore = repo.getIgnore(); |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
88 boolean[] rv = new boolean[toCheck.length]; |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
89 for (int i = 0; i < toCheck.length; i++) { |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
128
diff
changeset
|
90 rv[i] = ignore.isIgnored(Path.create(toCheck[i])); |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
91 } |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
92 return rv; |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
93 } |
114
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
94 |
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
95 public File getRepositoryDir() { |
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
96 return repo.getRepositoryRoot(); |
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
97 } |
46291ec605a0
Filters to read and initialize according to configuration files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
98 |
269
7af843ecc378
Respect glob pattern with alternatives {a,b}
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
237
diff
changeset
|
99 public static HgIgnore newHgIgnore(Reader source) throws IOException { |
7af843ecc378
Respect glob pattern with alternatives {a,b}
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
237
diff
changeset
|
100 HgIgnore hgIgnore = new HgIgnore(); |
7af843ecc378
Respect glob pattern with alternatives {a,b}
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
237
diff
changeset
|
101 BufferedReader br = source instanceof BufferedReader ? (BufferedReader) source : new BufferedReader(source); |
7af843ecc378
Respect glob pattern with alternatives {a,b}
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
237
diff
changeset
|
102 hgIgnore.read(br); |
7af843ecc378
Respect glob pattern with alternatives {a,b}
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
237
diff
changeset
|
103 br.close(); |
7af843ecc378
Respect glob pattern with alternatives {a,b}
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
237
diff
changeset
|
104 return hgIgnore; |
7af843ecc378
Respect glob pattern with alternatives {a,b}
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
237
diff
changeset
|
105 } |
128
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
106 |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
107 // in fact, need a setter for this anyway, shall move to internal.Internals perhaps? |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
108 public String getNextCommitUsername() { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
109 String hgUser = System.getenv("HGUSER"); |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
110 if (hgUser != null && hgUser.trim().length() > 0) { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
111 return hgUser.trim(); |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
112 } |
331
a37ce7145c3f
Access to repository configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
300
diff
changeset
|
113 String configValue = repo.getConfiguration().getStringValue("ui", "username", null); |
128
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
114 if (configValue != null) { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
115 return configValue; |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
116 } |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
117 String email = System.getenv("EMAIL"); |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
118 if (email != null && email.trim().length() > 0) { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
119 return email; |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
120 } |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
121 String username = System.getProperty("user.name"); |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
122 try { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
123 String hostname = InetAddress.getLocalHost().getHostName(); |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
124 return username + '@' + hostname; |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
125 } catch (UnknownHostException ex) { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
126 return username; |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
127 } |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
114
diff
changeset
|
128 } |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
129 |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
130 @Experimental(reason="Don't want to expose io.File from HgRepository; need to create FileIterator for working dir. Need a place to keep that code") |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
131 /*package-local*/ FileIterator createWorkingDirWalker(Path.Matcher workindDirScope) { |
237
6e1373b54e9b
Allow access to working copy content through HgDataFile. Give access to repository's working dir
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
229
diff
changeset
|
132 File repoRoot = repo.getWorkingDir(); |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
133 Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(repoRoot), repo.getToRepoPathHelper())); |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
134 // Impl note: simple source is enough as files in the working dir are all unique |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
135 // even if they might get reused (i.e. after FileIterator#reset() and walking once again), |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
136 // path caching is better to be done in the code which knows that path are being reused |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
137 return new FileWalker(repoRoot, pathSrc, workindDirScope); |
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
138 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
139 |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
140 // expose othewise package-local information primarily to use in our own o.t.hg.core package |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
141 public static SessionContext getContext(HgRepository repo) { |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
142 return repo.getContext(); |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
284
diff
changeset
|
143 } |
229
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
144 |
148
1a7a9a20e1f9
Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
145 |
1a7a9a20e1f9
Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
146 // Convenient check of local revision number for validity (not all negative values are wrong as long as we use negative constants) |
1a7a9a20e1f9
Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
147 public static boolean wrongLocalRevision(int rev) { |
1a7a9a20e1f9
Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
148 return rev < 0 && rev != TIP && rev != WORKING_COPY && rev != BAD_REVISION; |
1a7a9a20e1f9
Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
149 } |
300
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
150 |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
151 // throws IllegalArgumentException if [start..end] range is not a subrange of [0..lastRevision] |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
152 public static void checkRevlogRange(int start, int end, int lastRevision) { |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
153 if (start < 0 || start > lastRevision) { |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
154 throw new IllegalArgumentException(String.format("Bad left range boundary %d in [0..%d]", start, lastRevision)); |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
155 } |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
156 if (end < 0 || end > lastRevision) { |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
157 throw new IllegalArgumentException(String.format("Bad right range boundary %d in [0..%d]", end, lastRevision)); |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
158 } |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
159 if (end < start) { |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
160 throw new IllegalArgumentException(String.format("Bad range [%d..%d]", start, end)); |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
161 } |
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
296
diff
changeset
|
162 } |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
163 } |