Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgSubrepoLocation.java @ 239:df9d2854d3d6
Initial access to subrepositories
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 16 Jun 2011 04:23:51 +0200 |
parents | |
children | 981f9f50bb6c |
comparison
equal
deleted
inserted
replaced
238:4817d4ccc50e | 239:df9d2854d3d6 |
---|---|
1 /* | |
2 * Copyright (c) 2011 TMate Software Ltd | |
3 * | |
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 | |
6 * the Free Software Foundation; version 2 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * For information on how to redistribute this software under | |
14 * the terms of a license other than GNU General Public License | |
15 * contact TMate Software at support@hg4j.com | |
16 */ | |
17 package org.tmatesoft.hg.repo; | |
18 | |
19 import java.io.File; | |
20 | |
21 import org.tmatesoft.hg.core.HgBadStateException; | |
22 import org.tmatesoft.hg.core.HgException; | |
23 import org.tmatesoft.hg.internal.Experimental; | |
24 import org.tmatesoft.hg.util.Path; | |
25 | |
26 /** | |
27 * WORK IN PROGRESS, DO NOT USE | |
28 * @author Artem Tikhomirov | |
29 * @author TMate Software Ltd. | |
30 */ | |
31 @Experimental(reason="Work in progress") | |
32 public class HgSubrepoLocation { | |
33 | |
34 private final HgRepository owner; | |
35 private final Kind kind; | |
36 private final Path location; | |
37 private final String source; | |
38 private final String revInfo; | |
39 | |
40 public enum Kind { Hg, SVN, Git, } | |
41 | |
42 public HgSubrepoLocation(HgRepository parentRepo, String repoLocation, String actualLocation, Kind type, String revision) { | |
43 owner = parentRepo; | |
44 location = Path.create(repoLocation); | |
45 source = actualLocation; | |
46 kind = type; | |
47 revInfo = revision; | |
48 } | |
49 | |
50 // as defined in .hgsub, key value | |
51 public Path getLocation() { | |
52 return location; | |
53 } | |
54 | |
55 // value from .hgsub | |
56 public String getSource() { | |
57 return source; | |
58 } | |
59 | |
60 public Kind getType() { | |
61 return kind; | |
62 } | |
63 | |
64 public String getRevision() { | |
65 return revInfo; | |
66 } | |
67 | |
68 /** | |
69 * @return whether this sub repository is known only locally | |
70 */ | |
71 public boolean isCommitted() { | |
72 return revInfo != null; | |
73 } | |
74 | |
75 /** | |
76 * @return <code>true</code> when there are local changes in the sub repository | |
77 */ | |
78 public boolean hasChanges() { | |
79 throw HgRepository.notImplemented(); | |
80 } | |
81 | |
82 // public boolean isLocal() { | |
83 // } | |
84 | |
85 public HgRepository getOwner() { | |
86 return owner; | |
87 } | |
88 | |
89 public HgRepository getRepo() throws HgException { | |
90 if (kind != Kind.Hg) { | |
91 throw new HgBadStateException(); | |
92 } | |
93 return new HgLookup().detect(new File(owner.getWorkingDir(), source)); | |
94 } | |
95 } |