Mercurial > jhg
diff 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 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgRepository.java Thu Aug 09 15:45:18 2012 +0200 +++ b/src/org/tmatesoft/hg/repo/HgRepository.java Fri Aug 10 21:03:03 2012 +0200 @@ -35,8 +35,10 @@ import org.tmatesoft.hg.internal.ByteArrayChannel; import org.tmatesoft.hg.internal.ConfigFile; import org.tmatesoft.hg.internal.DataAccessProvider; +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; @@ -420,7 +422,44 @@ } } } - + + private Lock wdLock, storeLock; + + /** + * PROVISIONAL CODE, DO NOT USE + * + * Access repository lock that covers non-store parts of the repository (dirstate, branches, etc - + * 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. + * + * @return lock object, never <code>null</code> + */ + @Experimental(reason="WORK IN PROGRESS") + public Lock getWorkingDirLock() { + if (wdLock == null) { + synchronized (this) { + if (wdLock == null) { + wdLock = new Lock(new File(repoPathHelper.rewrite("wlock").toString())); + } + } + } + return wdLock; + } + + @Experimental(reason="WORK IN PROGRESS") + public Lock getStoreLock() { + if (storeLock == null) { + synchronized (this) { + if (storeLock == null) { + storeLock = new Lock(new File(repoPathHelper.rewrite("store/lock").toString())); + } + } + } + return storeLock; + } + /** * Access bookmarks-related functionality * @return facility to manage bookmarks, never <code>null</code>