Mercurial > jhg
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 486:d740edfff563 | 487:db48a77ec8ff |
|---|---|
| 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.Experimental; |
| 39 import org.tmatesoft.hg.internal.Filter; | 39 import org.tmatesoft.hg.internal.Filter; |
| 40 import org.tmatesoft.hg.internal.Internals; | 40 import org.tmatesoft.hg.internal.Internals; |
| 41 import org.tmatesoft.hg.internal.Lock; | |
| 42 import org.tmatesoft.hg.internal.RevlogStream; | 41 import org.tmatesoft.hg.internal.RevlogStream; |
| 43 import org.tmatesoft.hg.internal.SubrepoManager; | 42 import org.tmatesoft.hg.internal.SubrepoManager; |
| 44 import org.tmatesoft.hg.util.CancelledException; | 43 import org.tmatesoft.hg.util.CancelledException; |
| 45 import org.tmatesoft.hg.util.Pair; | 44 import org.tmatesoft.hg.util.Pair; |
| 46 import org.tmatesoft.hg.util.Path; | 45 import org.tmatesoft.hg.util.Path; |
| 421 } | 420 } |
| 422 } | 421 } |
| 423 } | 422 } |
| 424 } | 423 } |
| 425 | 424 |
| 426 private Lock wdLock, storeLock; | 425 private HgRepositoryLock wdLock, storeLock; |
| 427 | 426 |
| 428 /** | 427 /** |
| 429 * PROVISIONAL CODE, DO NOT USE | 428 * PROVISIONAL CODE, DO NOT USE |
| 430 * | 429 * |
| 431 * Access repository lock that covers non-store parts of the repository (dirstate, branches, etc - | 430 * Access repository lock that covers non-store parts of the repository (dirstate, branches, etc - |
| 432 * everything that has to do with working directory state). | 431 * everything that has to do with working directory state). |
| 433 * | 432 * |
| 434 * Note, the lock object returned merely gives access to lock mechanism. NO ACTUAL LOCKING IS DONE. | 433 * 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. | 434 * Use {@link HgRepositoryLock#acquire()} to actually lock the repository. |
| 436 * | 435 * |
| 437 * @return lock object, never <code>null</code> | 436 * @return lock object, never <code>null</code> |
| 438 */ | 437 */ |
| 439 @Experimental(reason="WORK IN PROGRESS") | 438 @Experimental(reason="WORK IN PROGRESS") |
| 440 public Lock getWorkingDirLock() { | 439 public HgRepositoryLock getWorkingDirLock() { |
| 441 if (wdLock == null) { | 440 if (wdLock == null) { |
| 441 int timeout = getLockTimeout(); | |
| 442 synchronized (this) { | 442 synchronized (this) { |
| 443 if (wdLock == null) { | 443 if (wdLock == null) { |
| 444 wdLock = new Lock(new File(repoPathHelper.rewrite("wlock").toString())); | 444 wdLock = new HgRepositoryLock(new File(repoPathHelper.rewrite("wlock").toString()), timeout); |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 } | 447 } |
| 448 return wdLock; | 448 return wdLock; |
| 449 } | 449 } |
| 450 | 450 |
| 451 @Experimental(reason="WORK IN PROGRESS") | 451 @Experimental(reason="WORK IN PROGRESS") |
| 452 public Lock getStoreLock() { | 452 public HgRepositoryLock getStoreLock() { |
| 453 if (storeLock == null) { | 453 if (storeLock == null) { |
| 454 int timeout = getLockTimeout(); | |
| 454 synchronized (this) { | 455 synchronized (this) { |
| 455 if (storeLock == null) { | 456 if (storeLock == null) { |
| 456 storeLock = new Lock(new File(repoPathHelper.rewrite("store/lock").toString())); | 457 storeLock = new HgRepositoryLock(new File(repoPathHelper.rewrite("store/lock").toString()), timeout); |
| 457 } | 458 } |
| 458 } | 459 } |
| 459 } | 460 } |
| 460 return storeLock; | 461 return storeLock; |
| 461 } | 462 } |
| 540 rv.add(f); | 541 rv.add(f); |
| 541 } | 542 } |
| 542 } | 543 } |
| 543 return rv; | 544 return rv; |
| 544 } | 545 } |
| 546 | |
| 547 private int getLockTimeout() { | |
| 548 return getConfiguration().getIntegerValue("ui", "timeout", 600); | |
| 549 } | |
| 545 } | 550 } |
