Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgRepository.java @ 252:a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Mon, 15 Aug 2011 18:51:41 +0200 |
| parents | df9d2854d3d6 |
| children | 35125450c804 |
comparison
equal
deleted
inserted
replaced
| 251:8c951645bea0 | 252:a6d19adc2636 |
|---|---|
| 55 | 55 |
| 56 // if new constants added, consider fixing HgInternals#wrongLocalRevision | 56 // if new constants added, consider fixing HgInternals#wrongLocalRevision |
| 57 public static final int TIP = -3; | 57 public static final int TIP = -3; |
| 58 public static final int BAD_REVISION = Integer.MIN_VALUE; | 58 public static final int BAD_REVISION = Integer.MIN_VALUE; |
| 59 public static final int WORKING_COPY = -2; | 59 public static final int WORKING_COPY = -2; |
| 60 | |
| 61 public static final String DEFAULT_BRANCH_NAME = "default"; | |
| 60 | 62 |
| 61 // temp aux marker method | 63 // temp aux marker method |
| 62 public static IllegalStateException notImplemented() { | 64 public static IllegalStateException notImplemented() { |
| 63 return new IllegalStateException("Not implemented"); | 65 return new IllegalStateException("Not implemented"); |
| 64 } | 66 } |
| 178 // only from readGlobal. Need to reconsider exceptions thrown from there | 180 // only from readGlobal. Need to reconsider exceptions thrown from there |
| 179 ex.printStackTrace(); // XXX need to decide what to do this. failure to read single revision shall not break complete cycle | 181 ex.printStackTrace(); // XXX need to decide what to do this. failure to read single revision shall not break complete cycle |
| 180 } | 182 } |
| 181 } | 183 } |
| 182 } | 184 } |
| 183 tags.readGlobal(new File(repoDir.getParentFile(), ".hgtags")); // XXX replace with HgDataFile.workingCopy | 185 tags.readGlobal(new File(getWorkingDir(), ".hgtags")); // XXX replace with HgDataFile.workingCopy |
| 184 tags.readLocal(new File(repoDir, "localtags")); | 186 tags.readLocal(new File(repoDir, "localtags")); |
| 185 } catch (IOException ex) { | 187 } catch (IOException ex) { |
| 186 ex.printStackTrace(); // FIXME log or othewise report | 188 ex.printStackTrace(); // FIXME log or othewise report |
| 187 } | 189 } |
| 188 } | 190 } |
| 233 | 235 |
| 234 @Experimental(reason="return type and possible values (presently null, perhaps Nodeid.NULL) may get changed") | 236 @Experimental(reason="return type and possible values (presently null, perhaps Nodeid.NULL) may get changed") |
| 235 public Pair<Nodeid,Nodeid> getWorkingCopyParents() { | 237 public Pair<Nodeid,Nodeid> getWorkingCopyParents() { |
| 236 Nodeid[] p = loadDirstate().parents(); | 238 Nodeid[] p = loadDirstate().parents(); |
| 237 return new Pair<Nodeid,Nodeid>(NULL == p[0] ? null : p[0], NULL == p[1] ? null : p[1]); | 239 return new Pair<Nodeid,Nodeid>(NULL == p[0] ? null : p[0], NULL == p[1] ? null : p[1]); |
| 240 } | |
| 241 | |
| 242 /** | |
| 243 * @return name of the branch associated with working directory, never <code>null</code>. | |
| 244 */ | |
| 245 public String getWorkingCopyBranchName() { | |
| 246 return loadDirstate().branch(); | |
| 238 } | 247 } |
| 239 | 248 |
| 240 /** | 249 /** |
| 241 * @return location where user files (shall) reside | 250 * @return location where user files (shall) reside |
| 242 */ | 251 */ |
| 261 return repoDir; | 270 return repoDir; |
| 262 } | 271 } |
| 263 | 272 |
| 264 // XXX package-local, unless there are cases when required from outside (guess, working dir/revision walkers may hide dirstate access and no public visibility needed) | 273 // XXX package-local, unless there are cases when required from outside (guess, working dir/revision walkers may hide dirstate access and no public visibility needed) |
| 265 /*package-local*/ final HgDirstate loadDirstate() { | 274 /*package-local*/ final HgDirstate loadDirstate() { |
| 266 return new HgDirstate(getDataAccess(), new File(repoDir, "dirstate")); | 275 return new HgDirstate(this, new File(repoDir, "dirstate")); |
| 267 } | 276 } |
| 268 | 277 |
| 269 // package-local, see comment for loadDirstate | 278 // package-local, see comment for loadDirstate |
| 270 /*package-local*/ final HgIgnore getIgnore() { | 279 /*package-local*/ final HgIgnore getIgnore() { |
| 271 // TODO read config for additional locations | 280 // TODO read config for additional locations |
| 272 if (ignore == null) { | 281 if (ignore == null) { |
| 273 ignore = new HgIgnore(); | 282 ignore = new HgIgnore(); |
| 274 try { | 283 try { |
| 275 File ignoreFile = new File(repoDir.getParentFile(), ".hgignore"); | 284 File ignoreFile = new File(getWorkingDir(), ".hgignore"); |
| 276 ignore.read(ignoreFile); | 285 ignore.read(ignoreFile); |
| 277 } catch (IOException ex) { | 286 } catch (IOException ex) { |
| 278 ex.printStackTrace(); // log warn | 287 ex.printStackTrace(); // log warn |
| 279 } | 288 } |
| 280 } | 289 } |
