# Persist Task

This module deals with persisting the “resources” (text files and the stack) to the git repo in the `JOY_HOME` directory.

class `joy.vui.persist_task.``PersistTask`(home)

  This class deals with saving changes to the git repo.

  `commit`(message='auto-commit')

    Commit.

  `handle`(message)

    Handle messages, dispatch to `handle_FOO()` methods.

  `handle_modify`(message)

    Foo.

  `handle_open`(message)

    Foo.

  `handle_persist`(message)

    Foo.

  `handle_persist_new`(message)

    Foo.

  `open`(name)

    Look up the named file in home and return its content_id and data.

  `persist`(content_id)

    Persist a resource.

  `scan`()

    Return a sorted list of all the files in the home dir.

  `task_run`()

    Stage any outstanding changes.

class `joy.vui.persist_task.``PickledResource`(filename, repo_relative_filename, thing=None)

  A `Resource` subclass that uses `pickle` on its file/thing.

class `joy.vui.persist_task.``Resource`(filename, repo_relative_filename, thing=None)

  Handle the content of a text files as a list of lines, deal with saving it and staging the changes to a repo.

  `persist`(repo)

    Save the lines to the file and stage the file in the repo.

`joy.vui.persist_task.``check_filename`(name)

  Sanity checks for filename.

`joy.vui.persist_task.``init_repo`(repo_dir)

  Initialize a git repository in the directory. Stage and commit all files (toplevel, not those in subdirectories if any) in the dir.

`joy.vui.persist_task.``make_repo_relative_path_maker`(repo)

  Helper function to return a function that returns a path given a path, that’s relative to the repository.

`joy.vui.persist_task.``open_repo`(repo_dir=None, initialize=False)

  Open, or create, and return a Dulwich git repo object for the given directory. If the dir path doesn’t exist it will be created. If it does exist but isn’t a repo the result depends on the `initialize` argument. If it is `False` (the default) a `NotGitRepository` exception is raised, otherwise `git init` is effected in the dir.