Merge pull request #16117 from EricFromCanada/hg-branches-tags

This commit is contained in:
Mike McQuaid 2023-10-17 07:45:46 +01:00 committed by GitHub
commit 23ee8afa94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1282,21 +1282,46 @@ class MercurialDownloadStrategy < VCSDownloadStrategy
sig { params(timeout: T.nilable(Time)).void } sig { params(timeout: T.nilable(Time)).void }
def clone_repo(timeout: nil) def clone_repo(timeout: nil)
command! "hg", args: ["clone", @url, cached_location], timeout: timeout&.remaining clone_args = %w[clone]
case @ref_type
when :branch
clone_args << "--branch" << @ref
when :revision, :tag
clone_args << "--rev" << @ref
end
clone_args << @url << cached_location.to_s
command! "hg", args: clone_args, timeout: timeout&.remaining
end end
sig { params(timeout: T.nilable(Time)).void } sig { params(timeout: T.nilable(Time)).void }
def update(timeout: nil) def update(timeout: nil)
command! "hg", args: ["--cwd", cached_location, "pull", "--update"], timeout: timeout&.remaining pull_args = %w[pull]
update_args = if @ref_type && @ref case @ref_type
ohai "Checking out #{@ref_type} #{@ref}" when :branch
[@ref] pull_args << "--branch" << @ref
else when :revision, :tag
["--clean"] pull_args << "--rev" << @ref
end end
command! "hg", args: ["--cwd", cached_location, "update", *update_args], timeout: timeout&.remaining command! "hg", args: ["--cwd", cached_location, *pull_args], timeout: timeout&.remaining
update_args = %w[update --clean]
update_args << if @ref_type && @ref
ohai "Checking out #{@ref_type} #{@ref}"
@ref
else
"default"
end
command! "hg", args: ["--cwd", cached_location, *update_args], timeout: timeout&.remaining
end
def current_revision
out, = silent_command("hg", args: ["--cwd", cached_location, "identify", "--id"])
out.strip
end end
end end