comparison src/org/tmatesoft/hg/repo/HgRepository.java @ 486:d740edfff563

Provisional support for Mercurial lock mechanism
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 10 Aug 2012 21:03:03 +0200
parents ae4d6604debd
children db48a77ec8ff
comparison
equal deleted inserted replaced
485:cdd53e5884ae 486:d740edfff563
33 import org.tmatesoft.hg.core.Nodeid; 33 import org.tmatesoft.hg.core.Nodeid;
34 import org.tmatesoft.hg.core.SessionContext; 34 import org.tmatesoft.hg.core.SessionContext;
35 import org.tmatesoft.hg.internal.ByteArrayChannel; 35 import org.tmatesoft.hg.internal.ByteArrayChannel;
36 import org.tmatesoft.hg.internal.ConfigFile; 36 import org.tmatesoft.hg.internal.ConfigFile;
37 import org.tmatesoft.hg.internal.DataAccessProvider; 37 import org.tmatesoft.hg.internal.DataAccessProvider;
38 import org.tmatesoft.hg.internal.Experimental;
38 import org.tmatesoft.hg.internal.Filter; 39 import org.tmatesoft.hg.internal.Filter;
39 import org.tmatesoft.hg.internal.Internals; 40 import org.tmatesoft.hg.internal.Internals;
41 import org.tmatesoft.hg.internal.Lock;
40 import org.tmatesoft.hg.internal.RevlogStream; 42 import org.tmatesoft.hg.internal.RevlogStream;
41 import org.tmatesoft.hg.internal.SubrepoManager; 43 import org.tmatesoft.hg.internal.SubrepoManager;
42 import org.tmatesoft.hg.util.CancelledException; 44 import org.tmatesoft.hg.util.CancelledException;
43 import org.tmatesoft.hg.util.Pair; 45 import org.tmatesoft.hg.util.Pair;
44 import org.tmatesoft.hg.util.Path; 46 import org.tmatesoft.hg.util.Path;
418 getContext().getLog().dump(getClass(), Warn, "Failed to close %s after read", lastMessage); 420 getContext().getLog().dump(getClass(), Warn, "Failed to close %s after read", lastMessage);
419 } 421 }
420 } 422 }
421 } 423 }
422 } 424 }
423 425
426 private Lock wdLock, storeLock;
427
428 /**
429 * PROVISIONAL CODE, DO NOT USE
430 *
431 * Access repository lock that covers non-store parts of the repository (dirstate, branches, etc -
432 * everything that has to do with working directory state).
433 *
434 * Note, the lock object returned merely gives access to lock mechanism. NO ACTUAL LOCKING IS DONE.
435 * Use {@link Lock#acquire()} to actually lock the repository.
436 *
437 * @return lock object, never <code>null</code>
438 */
439 @Experimental(reason="WORK IN PROGRESS")
440 public Lock getWorkingDirLock() {
441 if (wdLock == null) {
442 synchronized (this) {
443 if (wdLock == null) {
444 wdLock = new Lock(new File(repoPathHelper.rewrite("wlock").toString()));
445 }
446 }
447 }
448 return wdLock;
449 }
450
451 @Experimental(reason="WORK IN PROGRESS")
452 public Lock getStoreLock() {
453 if (storeLock == null) {
454 synchronized (this) {
455 if (storeLock == null) {
456 storeLock = new Lock(new File(repoPathHelper.rewrite("store/lock").toString()));
457 }
458 }
459 }
460 return storeLock;
461 }
462
424 /** 463 /**
425 * Access bookmarks-related functionality 464 * Access bookmarks-related functionality
426 * @return facility to manage bookmarks, never <code>null</code> 465 * @return facility to manage bookmarks, never <code>null</code>
427 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> 466 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
428 */ 467 */