# HG changeset patch # User Artem Tikhomirov # Date 1354309080 -3600 # Node ID bf352ce2b97f909830f2a2d90798de5e0c3fc3ac # Parent 0bd2d0441d8f7f0cdb1f245af7924272296a3702 Allow to override lock timeout from within Hg4J diff -r 0bd2d0441d8f -r bf352ce2b97f src/org/tmatesoft/hg/internal/Internals.java --- a/src/org/tmatesoft/hg/internal/Internals.java Wed Oct 31 15:17:21 2012 +0100 +++ b/src/org/tmatesoft/hg/internal/Internals.java Fri Nov 30 21:58:00 2012 +0100 @@ -73,6 +73,19 @@ */ public static final String CFG_PROPERTY_FS_FILENAME_ENCODING = "hg.fs.filename.encoding"; + /** + * Timeout, in seconds, to acquire filesystem {@link HgRepositoryLock lock}. + * + * Mercurial provides 'ui.timeout' in hgrc (defaults to 600 seconds) to specify how long + * it shall try to acquire a lock for storage or working directory prior to fail. + * + * This configuration property allows to override timeout value from Mercurial's configuration + * file and use Hg4J-specific value instead. + * + * Integer value, use negative for attempts to acquire lock until success, and zero to try once and fail immediately. + */ + public static final String CFG_PROPERTY_FS_LOCK_TIMEOUT = "hg4j.fs.lock.timeout"; + private List filterFactories; private final HgRepository repo; private final File repoDir; diff -r 0bd2d0441d8f -r bf352ce2b97f src/org/tmatesoft/hg/repo/HgRepository.java --- a/src/org/tmatesoft/hg/repo/HgRepository.java Wed Oct 31 15:17:21 2012 +0100 +++ b/src/org/tmatesoft/hg/repo/HgRepository.java Fri Nov 30 21:58:00 2012 +0100 @@ -37,6 +37,7 @@ import org.tmatesoft.hg.internal.Experimental; import org.tmatesoft.hg.internal.Filter; import org.tmatesoft.hg.internal.Internals; +import org.tmatesoft.hg.internal.PropertyMarshal; import org.tmatesoft.hg.internal.RevlogStream; import org.tmatesoft.hg.internal.SubrepoManager; import org.tmatesoft.hg.repo.ext.HgExtensionsManager; @@ -558,6 +559,10 @@ } private int getLockTimeout() { - return getConfiguration().getIntegerValue("ui", "timeout", 600); + int cfgValue = getConfiguration().getIntegerValue("ui", "timeout", 600); + if (getSessionContext().getConfigurationProperty(Internals.CFG_PROPERTY_FS_LOCK_TIMEOUT, null) != null) { + return new PropertyMarshal(sessionContext).getInt(Internals.CFG_PROPERTY_FS_LOCK_TIMEOUT, cfgValue); + } + return cfgValue; } }