        def hg(*args, &block)
          # as of hg 4.4.1, early parsing of bool options is not terminated at '--'
          if args.any? { |s| s =~ HG_EARLY_BOOL_ARG }
            raise HgCommandArgumentError, "malicious command argument detected"
          end
          if args.take_while { |s| s != '--' }.any? { |s| s =~ HG_EARLY_LIST_ARG }
            raise HgCommandArgumentError, "malicious command argument detected"
          end

          repo_path = root_url || url
          full_args = ['-R', repo_path, '--encoding', 'utf-8']
          full_args << '--config' << "extensions.redminehelper=#{HG_HELPER_EXT}"
          full_args << '--config' << 'diff.git=false'
          full_args += args
          ret = shellout(
                   self.class.sq_bin + ' ' + full_args.map { |e| shell_quote e.to_s }.join(' '),
                   &block
                   )
          if $? && $?.exitstatus != 0
            raise HgCommandAborted, "hg exited with non-zero status: #{$?.exitstatus}"
          end
          ret
        end