def install
      if cached?
        # Update and checkout the correct ref
        Dir.chdir(cache_path) do
          hg %|pull|
        end
      else
        # Ensure the cache directory is present before doing anything
        FileUtils.mkdir_p(cache_path)

        Dir.chdir(cache_path) do
          hg %|clone #{uri} .|
        end
      end

      Dir.chdir(cache_path) do
        hg %|update --clean --rev #{revision || ref}|
        @revision ||= hg %|id -i|
      end

      # Gab the path where we should copy from (since it might be relative to
      # the root).
      copy_path = rel ? cache_path.join(rel) : cache_path

      begin 
        # Validate the thing we are copying is a Chef cookbook
        validate_cached!(copy_path)

        # Remove the current cookbook at this location (this is required or else
        # FileUtils will copy into a subdirectory in the next step)
        FileUtils.rm_rf(install_path)

        # Create the containing parent directory
        FileUtils.mkdir_p(install_path.parent)

        # Copy whatever is in the current cache over to the store
        FileUtils.cp_r(copy_path, install_path)

      ensure

        # Remove the .hg directory to save storage space
        # TODO this can have huge performance implications, 
        # make it a config option?
        if (hg_path = install_path.join('.hg')).exist?
          FileUtils.rm_r(hg_path)
        end

       FileUtils.rm_rf (copy_path)
      end
    end
def install
      if cached?
        # Update and checkout the correct ref
        Dir.chdir(cache_path) do
          hg %|pull|
        end
      else
        # Ensure the cache directory is present before doing anything
        FileUtils.mkdir_p(cache_path)

        Dir.chdir(cache_path) do
          hg %|clone #{uri} .|
        end
      end

      Dir.chdir(cache_path) do
        hg %|update --clean --rev #{revision || ref}|
        @revision ||= hg %|id -i|
      end

      # Gab the path where we should copy from (since it might be relative to
      # the root).
      copy_path = rel ? cache_path.join(rel) : cache_path

      begin 
        # Validate the thing we are copying is a Chef cookbook
        validate_cached!(copy_path)

        # Remove the current cookbook at this location (this is required or else
        # FileUtils will copy into a subdirectory in the next step)
        FileUtils.rm_rf(install_path)

        # Create the containing parent directory
        FileUtils.mkdir_p(install_path.parent)

        # Copy whatever is in the current cache over to the store
        FileUtils.cp_r(copy_path, install_path)

      ensure

        # Remove the .hg directory to save storage space
        # TODO this can have huge performance implications, 
        # make it a config option?
        if (hg_path = install_path.join('.hg')).exist?
          FileUtils.rm_r(hg_path)
        end

       FileUtils.rm_rf (copy_path)
      end
    end
Download the cookbook from the remote hg repository

 @return void