Skip to content

Commit

Permalink
Merge pull request #303 from Tak/mercurial
Browse files Browse the repository at this point in the history
Restrict mercurial-ruby command override to windows, workaround ruby 1.8 api difference
  • Loading branch information
matthutchinson committed Apr 11, 2016
2 parents 59d9d24 + 6ea621f commit 443accd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
45 changes: 26 additions & 19 deletions lib/core_ext/mercurial-ruby/command.rb
@@ -1,28 +1,35 @@
# need to use popen3 on windows - popen4 always eventually calls fork
module Mercurial
class Command
private
if Lolcommits::Platform.platform_windows?

def execution_proc
proc do
debug(command)
result = ''
error = ''
status = nil
Open3.popen3(command) do |_stdin, stdout, stderr, wait_thread|
Timeout.timeout(timeout) do
while (tmp = stdout.read(102_400))
result += tmp
module Mercurial
class Command
private

def execution_proc
proc do
debug(command)
result = ''
error = ''
status = nil
Open3.popen3(command) do |_stdin, stdout, stderr, wait_thread|
Timeout.timeout(timeout) do
while (tmp = stdout.read(102_400))
result += tmp
end
end
end

while (tmp = stderr.read(1024))
error += tmp
while (tmp = stderr.read(1024))
error += tmp
end
status = if RUBY_VERSION =~ /^1\.8/
error.empty? ? 0 : 1
else
wait_thread.value
end
end
status = wait_thread.value
raise_error_if_needed(status, error)
result
end
raise_error_if_needed(status, error)
result
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/lolcommits.rb
Expand Up @@ -11,7 +11,6 @@
require 'methadone'
require 'date'
require 'mercurial-ruby'
require 'core_ext/mercurial-ruby/command'
require 'core_ext/mercurial-ruby/shell'

require 'lolcommits/version'
Expand All @@ -22,6 +21,9 @@
require 'lolcommits/plugin'
require 'lolcommits/platform'

# after lolcommits/platform, so that we can do platform-conditional override
require 'core_ext/mercurial-ruby/command'

# backends
require 'lolcommits/backends/installation_git'
require 'lolcommits/backends/installation_mercurial'
Expand Down

0 comments on commit 443accd

Please sign in to comment.