From 418bacd37b4cc26117ef783d8b5ef540028eaea9 Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Mon, 29 Nov 2021 20:34:27 +0300 Subject: [PATCH] hg: support paths.default:pushurl config syntax * IDEA-185209 HG push doesn't use default:pushurl; * since hg version is around 3.7 new push path syntax is used; * update tests GitOrigin-RevId: b0018385b287e0856fb75e391fd9585b96fc4df7 --- .../hg4idea/src/org/zmlx/hg4idea/repo/HgConfig.java | 10 ++++++++-- .../testSrc/hg4idea/test/config/HgConfigTest.java | 9 ++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgConfig.java b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgConfig.java index 68458ab0088c..6c805a38308b 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgConfig.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgConfig.java @@ -35,8 +35,14 @@ public final class HgConfig { @Nullable public String getDefaultPushPath() { - String path = getNamedConfig("paths", "default-push"); - return path != null ? path : getNamedConfig("paths", "default"); + String path = getNamedConfig("paths", "default:pushurl"); + if (path == null) { + path = getNamedConfig("paths", "default-push"); + } + if (path == null) { + path = getNamedConfig("paths", "default"); + } + return path; } @Nullable diff --git a/plugins/hg4idea/testSrc/hg4idea/test/config/HgConfigTest.java b/plugins/hg4idea/testSrc/hg4idea/test/config/HgConfigTest.java index 1a3436f13abe..da35a69991b4 100644 --- a/plugins/hg4idea/testSrc/hg4idea/test/config/HgConfigTest.java +++ b/plugins/hg4idea/testSrc/hg4idea/test/config/HgConfigTest.java @@ -67,12 +67,15 @@ public class HgConfigTest extends HgPlatformTest { cd(myChildRepo); String pushPath = "somePath"; appendToHgrc(myChildRepo, "\n[paths]\n" + - "default-push=" + pushPath); + "default-push = " + pushPath); + appendToHgrc(myChildRepo, "\n[paths]\n" + + "default:pushurl = " + pushPath); updateRepoConfig(myProject, myChildRepo); final String defaultPushPath = HgUtil.getRepositoryDefaultPushPath(myProject, myChildRepo); assertNotNull(defaultPushPath); - assertEquals(FileUtil.toSystemIndependentName(myChildRepo.getPath() + "/" + pushPath), - FileUtil.toSystemIndependentName(defaultPushPath)); + String absolutePath = FileUtil.toSystemIndependentName(myChildRepo.getPath() + "/" + pushPath); + // after default-push config deprecation around version 3.7 ,hg reports the same value that is contained in hgrc file + assertTrue(absolutePath.contains(FileUtil.toSystemIndependentName(defaultPushPath))); } public void testPushPathWithoutAppropriateConfig() {