Mercurial > hg > mercurial
changeset 1030:1c65ee703a92 release-84894
TW-64274 fix working dir may be locked on "hg pull"
author | nikolai.kulakov@DESKTOP-Q4QCGIH |
---|---|
date | Fri, 07 Aug 2020 12:13:57 +0300 |
parents | 9123ad25b082 |
children | 73fc84ac1d98 |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PullCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/UpdateCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VcsRootCommand.java |
diffstat | 3 files changed, 17 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PullCommand.java Thu Aug 06 12:15:36 2020 +0300 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PullCommand.java Fri Aug 07 12:13:57 2020 +0300 @@ -21,8 +21,6 @@ import java.io.File; import java.io.IOException; -import static com.intellij.openapi.util.io.FileUtil.delete; - /** * @author Pavel.Sher * Date: 14.07.2008 @@ -67,7 +65,8 @@ } public void call() throws VcsException { - ensureRepositoryIsNotLocked(); + removeLocks(); + MercurialCommandLine cli = createCommandLine(); cli.addParameter("pull"); if (myTraceback) @@ -90,17 +89,6 @@ runCommand(cli, settings); } - private void ensureRepositoryIsNotLocked() { - File lock = getRepositoryLock(); - if (lock.exists()) - delete(lock); - } - - @NotNull - private File getRepositoryLock() { - return new File(getWorkDirectory(), ".hg" + File.separator + "store" + File.separator + "lock"); - } - @NotNull @Override protected String getDescription() {
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/UpdateCommand.java Thu Aug 06 12:15:36 2020 +0300 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/UpdateCommand.java Fri Aug 07 12:13:57 2020 +0300 @@ -20,8 +20,6 @@ import java.io.File; -import static com.intellij.openapi.util.io.FileUtil.delete; - public class UpdateCommand extends AuthCommand { private static final int UPDATE_TIMEOUT_SECONDS = 8 * 3600;//8 hours @@ -63,7 +61,7 @@ } public void call() throws VcsException { - ensureWorkingDirIsNotLocked(); + removeLocks(); MercurialCommandLine cli = createCommandLine(); cli.addParameter("update"); @@ -82,17 +80,6 @@ runCommand(cli, myCommandSettings.setTimeout(UPDATE_TIMEOUT_SECONDS)); } - private void ensureWorkingDirIsNotLocked() { - File lock = getWorkingDirLock(); - if (lock.exists()) - delete(lock); - } - - @NotNull - private File getWorkingDirLock() { - return new File(getWorkDirectory(), ".hg" + File.separator + "wlock"); - } - @NotNull @Override protected String getDescription() {
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VcsRootCommand.java Thu Aug 06 12:15:36 2020 +0300 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VcsRootCommand.java Fri Aug 07 12:13:57 2020 +0300 @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.Set; +import static com.intellij.openapi.util.io.FileUtil.delete; import static jetbrains.buildServer.util.CollectionsUtil.setOf; /** @@ -46,4 +47,17 @@ return Collections.<String>emptySet(); return setOf(password, AuthSettings.escapePassword(password)); } + + protected void removeLocks() { + File repoLock = new File(getWorkDirectory(), ".hg" + File.separator + "store" + File.separator + "lock"); + if (repoLock.exists()) { + delete(repoLock); + } + + File workingDirLock = new File(getWorkDirectory(), ".hg" + File.separator + "wlock"); + if (workingDirLock.exists()) { + delete(workingDirLock); + } + } + }