Mercurial > jhg
diff src/org/tmatesoft/hg/repo/HgRepository.java @ 487:db48a77ec8ff
Access to reposiotry lock mechanism via HgRepositoryLock
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 13 Aug 2012 18:11:47 +0200 |
parents | d740edfff563 |
children | 45b3b6ca046f |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgRepository.java Fri Aug 10 21:03:03 2012 +0200 +++ b/src/org/tmatesoft/hg/repo/HgRepository.java Mon Aug 13 18:11:47 2012 +0200 @@ -38,7 +38,6 @@ import org.tmatesoft.hg.internal.Experimental; import org.tmatesoft.hg.internal.Filter; import org.tmatesoft.hg.internal.Internals; -import org.tmatesoft.hg.internal.Lock; import org.tmatesoft.hg.internal.RevlogStream; import org.tmatesoft.hg.internal.SubrepoManager; import org.tmatesoft.hg.util.CancelledException; @@ -423,7 +422,7 @@ } } - private Lock wdLock, storeLock; + private HgRepositoryLock wdLock, storeLock; /** * PROVISIONAL CODE, DO NOT USE @@ -432,16 +431,17 @@ * everything that has to do with working directory state). * * Note, the lock object returned merely gives access to lock mechanism. NO ACTUAL LOCKING IS DONE. - * Use {@link Lock#acquire()} to actually lock the repository. + * Use {@link HgRepositoryLock#acquire()} to actually lock the repository. * * @return lock object, never <code>null</code> */ @Experimental(reason="WORK IN PROGRESS") - public Lock getWorkingDirLock() { + public HgRepositoryLock getWorkingDirLock() { if (wdLock == null) { + int timeout = getLockTimeout(); synchronized (this) { if (wdLock == null) { - wdLock = new Lock(new File(repoPathHelper.rewrite("wlock").toString())); + wdLock = new HgRepositoryLock(new File(repoPathHelper.rewrite("wlock").toString()), timeout); } } } @@ -449,11 +449,12 @@ } @Experimental(reason="WORK IN PROGRESS") - public Lock getStoreLock() { + public HgRepositoryLock getStoreLock() { if (storeLock == null) { + int timeout = getLockTimeout(); synchronized (this) { if (storeLock == null) { - storeLock = new Lock(new File(repoPathHelper.rewrite("store/lock").toString())); + storeLock = new HgRepositoryLock(new File(repoPathHelper.rewrite("store/lock").toString()), timeout); } } } @@ -542,4 +543,8 @@ } return rv; } + + private int getLockTimeout() { + return getConfiguration().getIntegerValue("ui", "timeout", 600); + } }