Browse Source

Port remainder of docstrings to Google style.

Jelmer Vernooij 5 năm trước cách đây
mục cha
commit
aa73abcedb

+ 6 - 5
dulwich/_diff_tree.c

@@ -62,11 +62,12 @@ static void free_objects(PyObject **objs, Py_ssize_t n)
 /**
 /**
  * Get the entries of a tree, prepending the given path.
  * Get the entries of a tree, prepending the given path.
  *
  *
- * :param path: The path to prepend, without trailing slashes.
- * :param path_len: The length of path.
- * :param tree: The Tree object to iterate.
- * :param n: Set to the length of result.
- * :return: A (C) array of PyObject pointers to TreeEntry objects for each path
+ * Args:
+ *   path: The path to prepend, without trailing slashes.
+ *   path_len: The length of path.
+ *   tree: The Tree object to iterate.
+ *   n: Set to the length of result.
+ * Returns: A (C) array of PyObject pointers to TreeEntry objects for each path
  *     in tree.
  *     in tree.
  */
  */
 static PyObject **tree_entries(char *path, Py_ssize_t path_len, PyObject *tree,
 static PyObject **tree_entries(char *path, Py_ssize_t path_len, PyObject *tree,

+ 1 - 1
dulwich/config.py

@@ -175,7 +175,7 @@ class Config(object):
     def itersections(self):
     def itersections(self):
         """Iterate over the sections.
         """Iterate over the sections.
 
 
-        :return: Iterator over section tuples
+        Returns: Iterator over section tuples
         """
         """
         raise NotImplementedError(self.itersections)
         raise NotImplementedError(self.itersections)
 
 

+ 10 - 8
dulwich/contrib/swift.py

@@ -356,7 +356,7 @@ class SwiftConnector(object):
     def test_root_exists(self):
     def test_root_exists(self):
         """Check that Swift container exist
         """Check that Swift container exist
 
 
-        :return: True if exist or None it not
+        Returns: True if exist or None it not
         """
         """
         ret = self.httpclient.request('HEAD', self.base_path)
         ret = self.httpclient.request('HEAD', self.base_path)
         if ret.status_code == 404:
         if ret.status_code == 404:
@@ -369,7 +369,8 @@ class SwiftConnector(object):
     def create_root(self):
     def create_root(self):
         """Create the Swift container
         """Create the Swift container
 
 
-        :raise: `SwiftException` if unable to create
+        Raises:
+          SwiftException: if unable to create
         """
         """
         if not self.test_root_exists():
         if not self.test_root_exists():
             ret = self.httpclient.request('PUT', self.base_path)
             ret = self.httpclient.request('PUT', self.base_path)
@@ -380,7 +381,7 @@ class SwiftConnector(object):
     def get_container_objects(self):
     def get_container_objects(self):
         """Retrieve objects list in a container
         """Retrieve objects list in a container
 
 
-        :return: A list of dict that describe objects
+        Returns: A list of dict that describe objects
                  or None if container does not exist
                  or None if container does not exist
         """
         """
         qs = '?format=json'
         qs = '?format=json'
@@ -488,7 +489,8 @@ class SwiftConnector(object):
     def del_root(self):
     def del_root(self):
         """Delete the root container by removing container content
         """Delete the root container by removing container content
 
 
-        :raise: `SwiftException` if unable to delete
+        Raises:
+          SwiftException: if unable to delete
         """
         """
         for obj in self.get_container_objects():
         for obj in self.get_container_objects():
             self.del_object(obj['name'])
             self.del_object(obj['name'])
@@ -566,7 +568,7 @@ class SwiftPackReader(object):
     def read_checksum(self):
     def read_checksum(self):
         """Read the checksum from the pack
         """Read the checksum from the pack
 
 
-        :return: the checksum bytestring
+        Returns: the checksum bytestring
         """
         """
         return self.scon.get_object(self.filename, range="-20")
         return self.scon.get_object(self.filename, range="-20")
 
 
@@ -681,7 +683,7 @@ class SwiftObjectStore(PackBasedObjectStore):
     def iter_shas(self, finder):
     def iter_shas(self, finder):
         """An iterator over pack's ObjectStore.
         """An iterator over pack's ObjectStore.
 
 
-        :return: a `ObjectStoreIterator` or `GreenThreadsObjectStoreIterator`
+        Returns: a `ObjectStoreIterator` or `GreenThreadsObjectStoreIterator`
                  instance if gevent is enabled
                  instance if gevent is enabled
         """
         """
         shas = iter(finder.next, None)
         shas = iter(finder.next, None)
@@ -725,7 +727,7 @@ class SwiftObjectStore(PackBasedObjectStore):
     def add_pack(self):
     def add_pack(self):
         """Add a new pack to this object store.
         """Add a new pack to this object store.
 
 
-        :return: Fileobject to write to and a commit function to
+        Returns: Fileobject to write to and a commit function to
             call when the pack is finished.
             call when the pack is finished.
         """
         """
         f = BytesIO()
         f = BytesIO()
@@ -938,7 +940,7 @@ class SwiftRepo(BaseRepo):
     def _determine_file_mode(self):
     def _determine_file_mode(self):
         """Probe the file-system to determine whether permissions can be trusted.
         """Probe the file-system to determine whether permissions can be trusted.
 
 
-        :return: True if permissions can be trusted, False otherwise.
+        Returns: True if permissions can be trusted, False otherwise.
         """
         """
         return False
         return False
 
 

+ 6 - 5
dulwich/file.py

@@ -69,9 +69,9 @@ def _fancy_rename(oldname, newname):
 def GitFile(filename, mode='rb', bufsize=-1):
 def GitFile(filename, mode='rb', bufsize=-1):
     """Create a file object that obeys the git file locking protocol.
     """Create a file object that obeys the git file locking protocol.
 
 
-    :return: a builtin file object or a _GitFile object
+    Returns: a builtin file object or a _GitFile object
 
 
-    :note: See _GitFile for a description of the file locking protocol.
+    Note: See _GitFile for a description of the file locking protocol.
 
 
     Only read-only and write-only (binary) modes are supported; r+, w+, and a
     Only read-only and write-only (binary) modes are supported; r+, w+, and a
     are not.  To read and write from the same file, you can take advantage of
     are not.  To read and write from the same file, you can take advantage of
@@ -106,7 +106,7 @@ class _GitFile(object):
     directory, and the lockfile will be renamed to overwrite the original file
     directory, and the lockfile will be renamed to overwrite the original file
     on close.
     on close.
 
 
-    :note: You *must* call close() or abort() on a _GitFile for the lock to be
+    Note: You *must* call close() or abort() on a _GitFile for the lock to be
         released. Typically this will happen in a finally block.
         released. Typically this will happen in a finally block.
     """
     """
 
 
@@ -157,11 +157,12 @@ class _GitFile(object):
     def close(self):
     def close(self):
         """Close this file, saving the lockfile over the original.
         """Close this file, saving the lockfile over the original.
 
 
-        :note: If this method fails, it will attempt to delete the lockfile.
+        Note: If this method fails, it will attempt to delete the lockfile.
             However, it is not guaranteed to do so (e.g. if a filesystem
             However, it is not guaranteed to do so (e.g. if a filesystem
             becomes suddenly read-only), which will prevent future writes to
             becomes suddenly read-only), which will prevent future writes to
             this file until the lockfile is removed manually.
             this file until the lockfile is removed manually.
-        :raises OSError: if the original file could not be overwritten. The
+        Raises:
+          OSError: if the original file could not be overwritten. The
             lock file is still closed, so further attempts to write to the same
             lock file is still closed, so further attempts to write to the same
             file object will raise ValueError.
             file object will raise ValueError.
         """
         """

+ 1 - 1
dulwich/ignore.py

@@ -213,7 +213,7 @@ class IgnoreFilter(object):
 
 
         For directories, include a trailing slash.
         For directories, include a trailing slash.
 
 
-        :return: status is None if file is not mentioned, True if it is
+        Returns: status is None if file is not mentioned, True if it is
             included, False if it is explicitly excluded.
             included, False if it is explicitly excluded.
         """
         """
         status = None
         status = None

+ 39 - 29
dulwich/patch.py

@@ -41,9 +41,11 @@ def write_commit_patch(f, commit, contents, progress, version=None,
                        encoding=None):
                        encoding=None):
     """Write a individual file patch.
     """Write a individual file patch.
 
 
-    :param commit: Commit object
-    :param progress: Tuple with current patch number and total.
-    :return: tuple with filename and contents
+    Args:
+      commit: Commit object
+      progress: Tuple with current patch number and total.
+    Returns:
+      tuple with filename and contents
     """
     """
     encoding = encoding or getattr(f, "encoding", "ascii")
     encoding = encoding or getattr(f, "encoding", "ascii")
     if isinstance(contents, str):
     if isinstance(contents, str):
@@ -80,8 +82,9 @@ def write_commit_patch(f, commit, contents, progress, version=None,
 def get_summary(commit):
 def get_summary(commit):
     """Determine the summary line for use in a filename.
     """Determine the summary line for use in a filename.
 
 
-    :param commit: Commit
-    :return: Summary string
+    Args:
+      commit: Commit
+    Returns: Summary string
     """
     """
     decoded = commit.message.decode(errors='replace')
     decoded = commit.message.decode(errors='replace')
     return decoded.splitlines()[0].replace(" ", "-")
     return decoded.splitlines()[0].replace(" ", "-")
@@ -153,7 +156,8 @@ def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
 def is_binary(content):
 def is_binary(content):
     """See if the first few bytes contain any null characters.
     """See if the first few bytes contain any null characters.
 
 
-    :param content: Bytestring to check for binary content
+    Args:
+      content: Bytestring to check for binary content
     """
     """
     return b'\0' in content[:FIRST_FEW_BYTES]
     return b'\0' in content[:FIRST_FEW_BYTES]
 
 
@@ -175,14 +179,15 @@ def patch_filename(p, root):
 def write_object_diff(f, store, old_file, new_file, diff_binary=False):
 def write_object_diff(f, store, old_file, new_file, diff_binary=False):
     """Write the diff for an object.
     """Write the diff for an object.
 
 
-    :param f: File-like object to write to
-    :param store: Store to retrieve objects from, if necessary
-    :param old_file: (path, mode, hexsha) tuple
-    :param new_file: (path, mode, hexsha) tuple
-    :param diff_binary: Whether to diff files even if they
+    Args:
+      f: File-like object to write to
+      store: Store to retrieve objects from, if necessary
+      old_file: (path, mode, hexsha) tuple
+      new_file: (path, mode, hexsha) tuple
+      diff_binary: Whether to diff files even if they
         are considered binary files by is_binary().
         are considered binary files by is_binary().
 
 
-    :note: the tuple elements should be None for nonexistant files
+    Note: the tuple elements should be None for nonexistant files
     """
     """
     (old_path, old_mode, old_id) = old_file
     (old_path, old_mode, old_id) = old_file
     (new_path, new_mode, new_id) = new_file
     (new_path, new_mode, new_id) = new_file
@@ -225,9 +230,10 @@ def write_object_diff(f, store, old_file, new_file, diff_binary=False):
 def gen_diff_header(paths, modes, shas):
 def gen_diff_header(paths, modes, shas):
     """Write a blob diff header.
     """Write a blob diff header.
 
 
-    :param paths: Tuple with old and new path
-    :param modes: Tuple with old and new modes
-    :param shas: Tuple with old and new shas
+    Args:
+      paths: Tuple with old and new path
+      modes: Tuple with old and new modes
+      shas: Tuple with old and new shas
     """
     """
     (old_path, new_path) = paths
     (old_path, new_path) = paths
     (old_mode, new_mode) = modes
     (old_mode, new_mode) = modes
@@ -257,11 +263,12 @@ def gen_diff_header(paths, modes, shas):
 def write_blob_diff(f, old_file, new_file):
 def write_blob_diff(f, old_file, new_file):
     """Write blob diff.
     """Write blob diff.
 
 
-    :param f: File-like object to write to
-    :param old_file: (path, mode, hexsha) tuple (None if nonexisting)
-    :param new_file: (path, mode, hexsha) tuple (None if nonexisting)
+    Args:
+      f: File-like object to write to
+      old_file: (path, mode, hexsha) tuple (None if nonexisting)
+      new_file: (path, mode, hexsha) tuple (None if nonexisting)
 
 
-    :note: The use of write_object_diff is recommended over this function.
+    Note: The use of write_object_diff is recommended over this function.
     """
     """
     (old_path, old_mode, old_blob) = old_file
     (old_path, old_mode, old_blob) = old_file
     (new_path, new_mode, new_blob) = new_file
     (new_path, new_mode, new_blob) = new_file
@@ -285,10 +292,11 @@ def write_blob_diff(f, old_file, new_file):
 def write_tree_diff(f, store, old_tree, new_tree, diff_binary=False):
 def write_tree_diff(f, store, old_tree, new_tree, diff_binary=False):
     """Write tree diff.
     """Write tree diff.
 
 
-    :param f: File-like object to write to.
-    :param old_tree: Old tree id
-    :param new_tree: New tree id
-    :param diff_binary: Whether to diff files even if they
+    Args:
+      f: File-like object to write to.
+      old_tree: Old tree id
+      new_tree: New tree id
+      diff_binary: Whether to diff files even if they
         are considered binary files by is_binary().
         are considered binary files by is_binary().
     """
     """
     changes = store.tree_changes(old_tree, new_tree)
     changes = store.tree_changes(old_tree, new_tree)
@@ -300,9 +308,10 @@ def write_tree_diff(f, store, old_tree, new_tree, diff_binary=False):
 def git_am_patch_split(f, encoding=None):
 def git_am_patch_split(f, encoding=None):
     """Parse a git-am-style patch and split it up into bits.
     """Parse a git-am-style patch and split it up into bits.
 
 
-    :param f: File-like object to parse
-    :param encoding: Encoding to use when creating Git objects
-    :return: Tuple with commit object, diff contents and git version
+    Args:
+      f: File-like object to parse
+      encoding: Encoding to use when creating Git objects
+    Returns: Tuple with commit object, diff contents and git version
     """
     """
     encoding = encoding or getattr(f, "encoding", "ascii")
     encoding = encoding or getattr(f, "encoding", "ascii")
     encoding = encoding or "ascii"
     encoding = encoding or "ascii"
@@ -320,9 +329,10 @@ def git_am_patch_split(f, encoding=None):
 def parse_patch_message(msg, encoding=None):
 def parse_patch_message(msg, encoding=None):
     """Extract a Commit object and patch from an e-mail message.
     """Extract a Commit object and patch from an e-mail message.
 
 
-    :param msg: An email message (email.message.Message)
-    :param encoding: Encoding to use to encode Git commits
-    :return: Tuple with commit object, diff contents and git version
+    Args:
+      msg: An email message (email.message.Message)
+      encoding: Encoding to use to encode Git commits
+    Returns: Tuple with commit object, diff contents and git version
     """
     """
     c = Commit()
     c = Commit()
     c.author = msg["from"].encode(encoding)
     c.author = msg["from"].encode(encoding)

+ 214 - 165
dulwich/porcelain.py

@@ -199,9 +199,10 @@ def path_to_tree_path(repopath, path):
     """Convert a path to a path usable in an index, e.g. bytes and relative to
     """Convert a path to a path usable in an index, e.g. bytes and relative to
     the repository root.
     the repository root.
 
 
-    :param repopath: Repository path, absolute or relative to the cwd
-    :param path: A path, absolute or relative to the cwd
-    :return: A path formatted for use in e.g. an index
+    Args:
+      repopath: Repository path, absolute or relative to the cwd
+      path: A path, absolute or relative to the cwd
+    Returns: A path formatted for use in e.g. an index
     """
     """
     if not isinstance(path, bytes):
     if not isinstance(path, bytes):
         path = path.encode(sys.getfilesystemencoding())
         path = path.encode(sys.getfilesystemencoding())
@@ -219,10 +220,11 @@ def archive(repo, committish=None, outstream=default_bytes_out_stream,
             errstream=default_bytes_err_stream):
             errstream=default_bytes_err_stream):
     """Create an archive.
     """Create an archive.
 
 
-    :param repo: Path of repository for which to generate an archive.
-    :param committish: Commit SHA1 or ref to use
-    :param outstream: Output stream (defaults to stdout)
-    :param errstream: Error stream (defaults to stderr)
+    Args:
+      repo: Path of repository for which to generate an archive.
+      committish: Commit SHA1 or ref to use
+      outstream: Output stream (defaults to stdout)
+      errstream: Error stream (defaults to stderr)
     """
     """
 
 
     if committish is None:
     if committish is None:
@@ -238,7 +240,8 @@ def archive(repo, committish=None, outstream=default_bytes_out_stream,
 def update_server_info(repo="."):
 def update_server_info(repo="."):
     """Update server info files for a repository.
     """Update server info files for a repository.
 
 
-    :param repo: path to the repository
+    Args:
+      repo: path to the repository
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         server_update_server_info(r)
         server_update_server_info(r)
@@ -247,9 +250,10 @@ def update_server_info(repo="."):
 def symbolic_ref(repo, ref_name, force=False):
 def symbolic_ref(repo, ref_name, force=False):
     """Set git symbolic ref into HEAD.
     """Set git symbolic ref into HEAD.
 
 
-    :param repo: path to the repository
-    :param ref_name: short name of the new ref
-    :param force: force settings without checking if it exists in refs/heads
+    Args:
+      repo: path to the repository
+      ref_name: short name of the new ref
+      force: force settings without checking if it exists in refs/heads
     """
     """
     with open_repo_closing(repo) as repo_obj:
     with open_repo_closing(repo) as repo_obj:
         ref_path = _make_branch_ref(ref_name)
         ref_path = _make_branch_ref(ref_name)
@@ -261,11 +265,12 @@ def symbolic_ref(repo, ref_name, force=False):
 def commit(repo=".", message=None, author=None, committer=None, encoding=None):
 def commit(repo=".", message=None, author=None, committer=None, encoding=None):
     """Create a new commit.
     """Create a new commit.
 
 
-    :param repo: Path to repository
-    :param message: Optional commit message
-    :param author: Optional author name and email
-    :param committer: Optional committer name and email
-    :return: SHA1 of the new commit
+    Args:
+      repo: Path to repository
+      message: Optional commit message
+      author: Optional author name and email
+      committer: Optional committer name and email
+    Returns: SHA1 of the new commit
     """
     """
     # FIXME: Support --all argument
     # FIXME: Support --all argument
     # FIXME: Support --signoff argument
     # FIXME: Support --signoff argument
@@ -284,10 +289,11 @@ def commit(repo=".", message=None, author=None, committer=None, encoding=None):
 def commit_tree(repo, tree, message=None, author=None, committer=None):
 def commit_tree(repo, tree, message=None, author=None, committer=None):
     """Create a new commit object.
     """Create a new commit object.
 
 
-    :param repo: Path to repository
-    :param tree: An existing tree object
-    :param author: Optional author name and email
-    :param committer: Optional committer name and email
+    Args:
+      repo: Path to repository
+      tree: An existing tree object
+      author: Optional author name and email
+      committer: Optional committer name and email
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         return r.do_commit(
         return r.do_commit(
@@ -297,9 +303,10 @@ def commit_tree(repo, tree, message=None, author=None, committer=None):
 def init(path=".", bare=False):
 def init(path=".", bare=False):
     """Create a new git repository.
     """Create a new git repository.
 
 
-    :param path: Path to repository.
-    :param bare: Whether to create a bare repository.
-    :return: A Repo instance
+    Args:
+      path: Path to repository.
+      bare: Whether to create a bare repository.
+    Returns: A Repo instance
     """
     """
     if not os.path.exists(path):
     if not os.path.exists(path):
         os.mkdir(path)
         os.mkdir(path)
@@ -315,15 +322,16 @@ def clone(source, target=None, bare=False, checkout=None,
           origin=b"origin", depth=None, **kwargs):
           origin=b"origin", depth=None, **kwargs):
     """Clone a local or remote git repository.
     """Clone a local or remote git repository.
 
 
-    :param source: Path or URL for source repository
-    :param target: Path to target repository (optional)
-    :param bare: Whether or not to create a bare repository
-    :param checkout: Whether or not to check-out HEAD after cloning
-    :param errstream: Optional stream to write progress to
-    :param outstream: Optional stream to write progress to (deprecated)
-    :param origin: Name of remote from the repository used to clone
-    :param depth: Depth to fetch at
-    :return: The new repository
+    Args:
+      source: Path or URL for source repository
+      target: Path to target repository (optional)
+      bare: Whether or not to create a bare repository
+      checkout: Whether or not to check-out HEAD after cloning
+      errstream: Optional stream to write progress to
+      outstream: Optional stream to write progress to (deprecated)
+      origin: Name of remote from the repository used to clone
+      depth: Depth to fetch at
+    Returns: The new repository
     """
     """
     # TODO(jelmer): This code overlaps quite a bit with Repo.clone
     # TODO(jelmer): This code overlaps quite a bit with Repo.clone
     if outstream is not None:
     if outstream is not None:
@@ -383,9 +391,10 @@ def clone(source, target=None, bare=False, checkout=None,
 def add(repo=".", paths=None):
 def add(repo=".", paths=None):
     """Add files to the staging area.
     """Add files to the staging area.
 
 
-    :param repo: Repository for the files
-    :param paths: Paths to add.  No value passed stages all modified files.
-    :return: Tuple with set of added files and ignored files
+    Args:
+      repo: Repository for the files
+      paths: Paths to add.  No value passed stages all modified files.
+    Returns: Tuple with set of added files and ignored files
     """
     """
     ignored = set()
     ignored = set()
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
@@ -426,8 +435,9 @@ def clean(repo=".", target_dir=None):
 
 
     Equivalent to running `git clean -fd` in target_dir.
     Equivalent to running `git clean -fd` in target_dir.
 
 
-    :param repo: Repository where the files may be tracked
-    :param target_dir: Directory to clean - current directory if None
+    Args:
+      repo: Repository where the files may be tracked
+      target_dir: Directory to clean - current directory if None
     """
     """
     if target_dir is None:
     if target_dir is None:
         target_dir = os.getcwd()
         target_dir = os.getcwd()
@@ -463,8 +473,9 @@ def clean(repo=".", target_dir=None):
 def remove(repo=".", paths=None, cached=False):
 def remove(repo=".", paths=None, cached=False):
     """Remove files from the staging area.
     """Remove files from the staging area.
 
 
-    :param repo: Repository for the files
-    :param paths: Paths to remove
+    Args:
+      repo: Repository for the files
+      paths: Paths to remove
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         index = r.open_index()
         index = r.open_index()
@@ -518,8 +529,9 @@ def commit_decode(commit, contents, default_encoding=DEFAULT_ENCODING):
 def print_commit(commit, decode, outstream=sys.stdout):
 def print_commit(commit, decode, outstream=sys.stdout):
     """Write a human-readable commit log entry.
     """Write a human-readable commit log entry.
 
 
-    :param commit: A `Commit` object
-    :param outstream: A stream file to write to
+    Args:
+      commit: A `Commit` object
+      outstream: A stream file to write to
     """
     """
     outstream.write("-" * 50 + "\n")
     outstream.write("-" * 50 + "\n")
     outstream.write("commit: " + commit.id.decode('ascii') + "\n")
     outstream.write("commit: " + commit.id.decode('ascii') + "\n")
@@ -543,9 +555,10 @@ def print_commit(commit, decode, outstream=sys.stdout):
 def print_tag(tag, decode, outstream=sys.stdout):
 def print_tag(tag, decode, outstream=sys.stdout):
     """Write a human-readable tag.
     """Write a human-readable tag.
 
 
-    :param tag: A `Tag` object
-    :param decode: Function for decoding bytes to unicode string
-    :param outstream: A stream to write to
+    Args:
+      tag: A `Tag` object
+      decode: Function for decoding bytes to unicode string
+      outstream: A stream to write to
     """
     """
     outstream.write("Tagger: " + decode(tag.tagger) + "\n")
     outstream.write("Tagger: " + decode(tag.tagger) + "\n")
     time_tuple = time.gmtime(tag.tag_time + tag.tag_timezone)
     time_tuple = time.gmtime(tag.tag_time + tag.tag_timezone)
@@ -560,10 +573,11 @@ def print_tag(tag, decode, outstream=sys.stdout):
 def show_blob(repo, blob, decode, outstream=sys.stdout):
 def show_blob(repo, blob, decode, outstream=sys.stdout):
     """Write a blob to a stream.
     """Write a blob to a stream.
 
 
-    :param repo: A `Repo` object
-    :param blob: A `Blob` object
-    :param decode: Function for decoding bytes to unicode string
-    :param outstream: A stream file to write to
+    Args:
+      repo: A `Repo` object
+      blob: A `Blob` object
+      decode: Function for decoding bytes to unicode string
+      outstream: A stream file to write to
     """
     """
     outstream.write(decode(blob.data))
     outstream.write(decode(blob.data))
 
 
@@ -571,10 +585,11 @@ def show_blob(repo, blob, decode, outstream=sys.stdout):
 def show_commit(repo, commit, decode, outstream=sys.stdout):
 def show_commit(repo, commit, decode, outstream=sys.stdout):
     """Show a commit to a stream.
     """Show a commit to a stream.
 
 
-    :param repo: A `Repo` object
-    :param commit: A `Commit` object
-    :param decode: Function for decoding bytes to unicode string
-    :param outstream: Stream to write to
+    Args:
+      repo: A `Repo` object
+      commit: A `Commit` object
+      decode: Function for decoding bytes to unicode string
+      outstream: Stream to write to
     """
     """
     print_commit(commit, decode=decode, outstream=outstream)
     print_commit(commit, decode=decode, outstream=outstream)
     if commit.parents:
     if commit.parents:
@@ -595,10 +610,11 @@ def show_commit(repo, commit, decode, outstream=sys.stdout):
 def show_tree(repo, tree, decode, outstream=sys.stdout):
 def show_tree(repo, tree, decode, outstream=sys.stdout):
     """Print a tree to a stream.
     """Print a tree to a stream.
 
 
-    :param repo: A `Repo` object
-    :param tree: A `Tree` object
-    :param decode: Function for decoding bytes to unicode string
-    :param outstream: Stream to write to
+    Args:
+      repo: A `Repo` object
+      tree: A `Tree` object
+      decode: Function for decoding bytes to unicode string
+      outstream: Stream to write to
     """
     """
     for n in tree:
     for n in tree:
         outstream.write(decode(n) + "\n")
         outstream.write(decode(n) + "\n")
@@ -607,10 +623,11 @@ def show_tree(repo, tree, decode, outstream=sys.stdout):
 def show_tag(repo, tag, decode, outstream=sys.stdout):
 def show_tag(repo, tag, decode, outstream=sys.stdout):
     """Print a tag to a stream.
     """Print a tag to a stream.
 
 
-    :param repo: A `Repo` object
-    :param tag: A `Tag` object
-    :param decode: Function for decoding bytes to unicode string
-    :param outstream: Stream to write to
+    Args:
+      repo: A `Repo` object
+      tag: A `Tag` object
+      decode: Function for decoding bytes to unicode string
+      outstream: Stream to write to
     """
     """
     print_tag(tag, decode, outstream)
     print_tag(tag, decode, outstream)
     show_object(repo, repo[tag.object[1]], decode, outstream)
     show_object(repo, repo[tag.object[1]], decode, outstream)
@@ -659,12 +676,13 @@ def log(repo=".", paths=None, outstream=sys.stdout, max_entries=None,
         reverse=False, name_status=False):
         reverse=False, name_status=False):
     """Write commit logs.
     """Write commit logs.
 
 
-    :param repo: Path to repository
-    :param paths: Optional set of specific paths to print entries for
-    :param outstream: Stream to write log output to
-    :param reverse: Reverse order in which entries are printed
-    :param name_status: Print name status
-    :param max_entries: Optional maximum number of entries to display
+    Args:
+      repo: Path to repository
+      paths: Optional set of specific paths to print entries for
+      outstream: Stream to write log output to
+      reverse: Reverse order in which entries are printed
+      name_status: Print name status
+      max_entries: Optional maximum number of entries to display
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         walker = r.get_walker(
         walker = r.get_walker(
@@ -683,10 +701,11 @@ def show(repo=".", objects=None, outstream=sys.stdout,
          default_encoding=DEFAULT_ENCODING):
          default_encoding=DEFAULT_ENCODING):
     """Print the changes in a commit.
     """Print the changes in a commit.
 
 
-    :param repo: Path to repository
-    :param objects: Objects to show (defaults to [HEAD])
-    :param outstream: Stream to write to
-    :param default_encoding: Default encoding to use if none is set in the
+    Args:
+      repo: Path to repository
+      objects: Objects to show (defaults to [HEAD])
+      outstream: Stream to write to
+      default_encoding: Default encoding to use if none is set in the
         commit
         commit
     """
     """
     if objects is None:
     if objects is None:
@@ -708,10 +727,11 @@ def show(repo=".", objects=None, outstream=sys.stdout,
 def diff_tree(repo, old_tree, new_tree, outstream=sys.stdout):
 def diff_tree(repo, old_tree, new_tree, outstream=sys.stdout):
     """Compares the content and mode of blobs found via two tree objects.
     """Compares the content and mode of blobs found via two tree objects.
 
 
-    :param repo: Path to repository
-    :param old_tree: Id of old tree
-    :param new_tree: Id of new tree
-    :param outstream: Stream to write to
+    Args:
+      repo: Path to repository
+      old_tree: Id of old tree
+      new_tree: Id of new tree
+      outstream: Stream to write to
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         write_tree_diff(outstream, r.object_store, old_tree, new_tree)
         write_tree_diff(outstream, r.object_store, old_tree, new_tree)
@@ -720,9 +740,10 @@ def diff_tree(repo, old_tree, new_tree, outstream=sys.stdout):
 def rev_list(repo, commits, outstream=sys.stdout):
 def rev_list(repo, commits, outstream=sys.stdout):
     """Lists commit objects in reverse chronological order.
     """Lists commit objects in reverse chronological order.
 
 
-    :param repo: Path to repository
-    :param commits: Commits over which to iterate
-    :param outstream: Stream to write to
+    Args:
+      repo: Path to repository
+      commits: Commits over which to iterate
+      outstream: Stream to write to
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         for entry in r.get_walker(include=[r[c].id for c in commits]):
         for entry in r.get_walker(include=[r[c].id for c in commits]):
@@ -742,15 +763,16 @@ def tag_create(
         sign=False):
         sign=False):
     """Creates a tag in git via dulwich calls:
     """Creates a tag in git via dulwich calls:
 
 
-    :param repo: Path to repository
-    :param tag: tag string
-    :param author: tag author (optional, if annotated is set)
-    :param message: tag message (optional)
-    :param annotated: whether to create an annotated tag
-    :param objectish: object the tag should point at, defaults to HEAD
-    :param tag_time: Optional time for annotated tag
-    :param tag_timezone: Optional timezone for annotated tag
-    :param sign: GPG Sign the tag
+    Args:
+      repo: Path to repository
+      tag: tag string
+      author: tag author (optional, if annotated is set)
+      message: tag message (optional)
+      annotated: whether to create an annotated tag
+      objectish: object the tag should point at, defaults to HEAD
+      tag_time: Optional time for annotated tag
+      tag_timezone: Optional timezone for annotated tag
+      sign: GPG Sign the tag
     """
     """
 
 
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
@@ -798,8 +820,9 @@ def list_tags(*args, **kwargs):
 def tag_list(repo, outstream=sys.stdout):
 def tag_list(repo, outstream=sys.stdout):
     """List all tags.
     """List all tags.
 
 
-    :param repo: Path to repository
-    :param outstream: Stream to write tags to
+    Args:
+      repo: Path to repository
+      outstream: Stream to write tags to
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         tags = sorted(r.refs.as_dict(b"refs/tags"))
         tags = sorted(r.refs.as_dict(b"refs/tags"))
@@ -809,8 +832,9 @@ def tag_list(repo, outstream=sys.stdout):
 def tag_delete(repo, name):
 def tag_delete(repo, name):
     """Remove a tag.
     """Remove a tag.
 
 
-    :param repo: Path to repository
-    :param name: Name of tag to remove
+    Args:
+      repo: Path to repository
+      name: Name of tag to remove
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         if isinstance(name, bytes):
         if isinstance(name, bytes):
@@ -826,9 +850,10 @@ def tag_delete(repo, name):
 def reset(repo, mode, treeish="HEAD"):
 def reset(repo, mode, treeish="HEAD"):
     """Reset current HEAD to the specified state.
     """Reset current HEAD to the specified state.
 
 
-    :param repo: Path to repository
-    :param mode: Mode ("hard", "soft", "mixed")
-    :param treeish: Treeish to reset to
+    Args:
+      repo: Path to repository
+      mode: Mode ("hard", "soft", "mixed")
+      treeish: Treeish to reset to
     """
     """
 
 
     if mode != "hard":
     if mode != "hard":
@@ -844,11 +869,12 @@ def push(repo, remote_location, refspecs,
          errstream=default_bytes_err_stream, **kwargs):
          errstream=default_bytes_err_stream, **kwargs):
     """Remote push with dulwich via dulwich.client
     """Remote push with dulwich via dulwich.client
 
 
-    :param repo: Path to repository
-    :param remote_location: Location of the remote
-    :param refspecs: Refs to push to remote
-    :param outstream: A stream file to write output
-    :param errstream: A stream file to write errors
+    Args:
+      repo: Path to repository
+      remote_location: Location of the remote
+      refspecs: Refs to push to remote
+      outstream: A stream file to write output
+      errstream: A stream file to write errors
     """
     """
 
 
     # Open the repo
     # Open the repo
@@ -891,11 +917,12 @@ def pull(repo, remote_location=None, refspecs=None,
          errstream=default_bytes_err_stream, **kwargs):
          errstream=default_bytes_err_stream, **kwargs):
     """Pull from remote via dulwich.client
     """Pull from remote via dulwich.client
 
 
-    :param repo: Path to repository
-    :param remote_location: Location of the remote
-    :param refspec: refspecs to fetch
-    :param outstream: A stream file to write to output
-    :param errstream: A stream file to write to errors
+    Args:
+      repo: Path to repository
+      remote_location: Location of the remote
+      refspec: refspecs to fetch
+      outstream: A stream file to write to output
+      errstream: A stream file to write to errors
     """
     """
     # Open the repo
     # Open the repo
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
@@ -928,9 +955,10 @@ def pull(repo, remote_location=None, refspecs=None,
 def status(repo=".", ignored=False):
 def status(repo=".", ignored=False):
     """Returns staged, unstaged, and untracked changes relative to the HEAD.
     """Returns staged, unstaged, and untracked changes relative to the HEAD.
 
 
-    :param repo: Path to repository or repository object
-    :param ignored: Whether to include ignored files in `untracked`
-    :return: GitStatus tuple,
+    Args:
+      repo: Path to repository or repository object
+      ignored: Whether to include ignored files in `untracked`
+    Returns: GitStatus tuple,
         staged -  dict with lists of staged paths (diff index/HEAD)
         staged -  dict with lists of staged paths (diff index/HEAD)
         unstaged -  list of unstaged paths (diff index/working-tree)
         unstaged -  list of unstaged paths (diff index/working-tree)
         untracked - list of untracked, un-ignored & non-.git paths
         untracked - list of untracked, un-ignored & non-.git paths
@@ -959,8 +987,9 @@ def status(repo=".", ignored=False):
 def _walk_working_dir_paths(frompath, basepath):
 def _walk_working_dir_paths(frompath, basepath):
     """Get path, is_dir for files in working dir from frompath
     """Get path, is_dir for files in working dir from frompath
 
 
-    :param frompath: Path to begin walk
-    :param basepath: Path to compare to
+    Args:
+      frompath: Path to begin walk
+      basepath: Path to compare to
     """
     """
     for dirpath, dirnames, filenames in os.walk(frompath):
     for dirpath, dirnames, filenames in os.walk(frompath):
         # Skip .git and below.
         # Skip .git and below.
@@ -984,9 +1013,10 @@ def _walk_working_dir_paths(frompath, basepath):
 def get_untracked_paths(frompath, basepath, index):
 def get_untracked_paths(frompath, basepath, index):
     """Get untracked paths.
     """Get untracked paths.
 
 
+    Args:
     ;param frompath: Path to walk
     ;param frompath: Path to walk
-    :param basepath: Path to compare to
-    :param index: Index to check against
+      basepath: Path to compare to
+      index: Index to check against
     """
     """
     for ap, is_dir in _walk_working_dir_paths(frompath, basepath):
     for ap, is_dir in _walk_working_dir_paths(frompath, basepath):
         if not is_dir:
         if not is_dir:
@@ -998,8 +1028,9 @@ def get_untracked_paths(frompath, basepath, index):
 def get_tree_changes(repo):
 def get_tree_changes(repo):
     """Return add/delete/modify changes to tree by comparing index to HEAD.
     """Return add/delete/modify changes to tree by comparing index to HEAD.
 
 
-    :param repo: repo path or object
-    :return: dict with lists for each type of change
+    Args:
+      repo: repo path or object
+    Returns: dict with lists for each type of change
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         index = r.open_index()
         index = r.open_index()
@@ -1032,9 +1063,10 @@ def get_tree_changes(repo):
 def daemon(path=".", address=None, port=None):
 def daemon(path=".", address=None, port=None):
     """Run a daemon serving Git requests over TCP/IP.
     """Run a daemon serving Git requests over TCP/IP.
 
 
-    :param path: Path to the directory to serve.
-    :param address: Optional address to listen on (defaults to ::)
-    :param port: Optional port to listen on (defaults to TCP_GIT_PORT)
+    Args:
+      path: Path to the directory to serve.
+      address: Optional address to listen on (defaults to ::)
+      port: Optional port to listen on (defaults to TCP_GIT_PORT)
     """
     """
     # TODO(jelmer): Support git-daemon-export-ok and --export-all.
     # TODO(jelmer): Support git-daemon-export-ok and --export-all.
     backend = FileSystemBackend(path)
     backend = FileSystemBackend(path)
@@ -1045,9 +1077,10 @@ def daemon(path=".", address=None, port=None):
 def web_daemon(path=".", address=None, port=None):
 def web_daemon(path=".", address=None, port=None):
     """Run a daemon serving Git requests over HTTP.
     """Run a daemon serving Git requests over HTTP.
 
 
-    :param path: Path to the directory to serve
-    :param address: Optional address to listen on (defaults to ::)
-    :param port: Optional port to listen on (defaults to 80)
+    Args:
+      path: Path to the directory to serve
+      address: Optional address to listen on (defaults to ::)
+      port: Optional port to listen on (defaults to 80)
     """
     """
     from dulwich.web import (
     from dulwich.web import (
         make_wsgi_chain,
         make_wsgi_chain,
@@ -1066,9 +1099,10 @@ def web_daemon(path=".", address=None, port=None):
 def upload_pack(path=".", inf=None, outf=None):
 def upload_pack(path=".", inf=None, outf=None):
     """Upload a pack file after negotiating its contents using smart protocol.
     """Upload a pack file after negotiating its contents using smart protocol.
 
 
-    :param path: Path to the repository
-    :param inf: Input stream to communicate with client
-    :param outf: Output stream to communicate with client
+    Args:
+      path: Path to the repository
+      inf: Input stream to communicate with client
+      outf: Output stream to communicate with client
     """
     """
     if outf is None:
     if outf is None:
         outf = getattr(sys.stdout, 'buffer', sys.stdout)
         outf = getattr(sys.stdout, 'buffer', sys.stdout)
@@ -1090,9 +1124,10 @@ def upload_pack(path=".", inf=None, outf=None):
 def receive_pack(path=".", inf=None, outf=None):
 def receive_pack(path=".", inf=None, outf=None):
     """Receive a pack file after negotiating its contents using smart protocol.
     """Receive a pack file after negotiating its contents using smart protocol.
 
 
-    :param path: Path to the repository
-    :param inf: Input stream to communicate with client
-    :param outf: Output stream to communicate with client
+    Args:
+      path: Path to the repository
+      inf: Input stream to communicate with client
+      outf: Output stream to communicate with client
     """
     """
     if outf is None:
     if outf is None:
         outf = getattr(sys.stdout, 'buffer', sys.stdout)
         outf = getattr(sys.stdout, 'buffer', sys.stdout)
@@ -1126,8 +1161,9 @@ def _make_tag_ref(name):
 def branch_delete(repo, name):
 def branch_delete(repo, name):
     """Delete a branch.
     """Delete a branch.
 
 
-    :param repo: Path to the repository
-    :param name: Name of the branch
+    Args:
+      repo: Path to the repository
+      name: Name of the branch
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         if isinstance(name, list):
         if isinstance(name, list):
@@ -1141,10 +1177,11 @@ def branch_delete(repo, name):
 def branch_create(repo, name, objectish=None, force=False):
 def branch_create(repo, name, objectish=None, force=False):
     """Create a branch.
     """Create a branch.
 
 
-    :param repo: Path to the repository
-    :param name: Name of the new branch
-    :param objectish: Target object to point new branch at (defaults to HEAD)
-    :param force: Force creation of branch, even if it already exists
+    Args:
+      repo: Path to the repository
+      name: Name of the new branch
+      objectish: Target object to point new branch at (defaults to HEAD)
+      force: Force creation of branch, even if it already exists
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         if objectish is None:
         if objectish is None:
@@ -1162,7 +1199,8 @@ def branch_create(repo, name, objectish=None, force=False):
 def branch_list(repo):
 def branch_list(repo):
     """List all branches.
     """List all branches.
 
 
-    :param repo: Path to the repository
+    Args:
+      repo: Path to the repository
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         return r.refs.keys(base=LOCAL_BRANCH_PREFIX)
         return r.refs.keys(base=LOCAL_BRANCH_PREFIX)
@@ -1248,7 +1286,8 @@ def repack(repo):
 
 
     Currently this only packs loose objects.
     Currently this only packs loose objects.
 
 
-    :param repo: Path to the repository
+    Args:
+      repo: Path to the repository
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         r.object_store.pack_loose_objects()
         r.object_store.pack_loose_objects()
@@ -1257,10 +1296,11 @@ def repack(repo):
 def pack_objects(repo, object_ids, packf, idxf, delta_window_size=None):
 def pack_objects(repo, object_ids, packf, idxf, delta_window_size=None):
     """Pack objects into a file.
     """Pack objects into a file.
 
 
-    :param repo: Path to the repository
-    :param object_ids: List of object ids to write
-    :param packf: File-like object to write to
-    :param idxf: File-like object to write to (can be None)
+    Args:
+      repo: Path to the repository
+      object_ids: List of object ids to write
+      packf: File-like object to write to
+      idxf: File-like object to write to (can be None)
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         entries, data_sum = write_pack_objects(
         entries, data_sum = write_pack_objects(
@@ -1276,11 +1316,12 @@ def ls_tree(repo, treeish=b"HEAD", outstream=sys.stdout, recursive=False,
             name_only=False):
             name_only=False):
     """List contents of a tree.
     """List contents of a tree.
 
 
-    :param repo: Path to the repository
-    :param tree_ish: Tree id to list
-    :param outstream: Output stream (defaults to stdout)
-    :param recursive: Whether to recursively list files
-    :param name_only: Only print item name
+    Args:
+      repo: Path to the repository
+      tree_ish: Tree id to list
+      outstream: Output stream (defaults to stdout)
+      recursive: Whether to recursively list files
+      name_only: Only print item name
     """
     """
     def list_tree(store, treeid, base):
     def list_tree(store, treeid, base):
         for (name, mode, sha) in store[treeid].iteritems():
         for (name, mode, sha) in store[treeid].iteritems():
@@ -1300,9 +1341,10 @@ def ls_tree(repo, treeish=b"HEAD", outstream=sys.stdout, recursive=False,
 def remote_add(repo, name, url):
 def remote_add(repo, name, url):
     """Add a remote.
     """Add a remote.
 
 
-    :param repo: Path to the repository
-    :param name: Remote name
-    :param url: Remote URL
+    Args:
+      repo: Path to the repository
+      name: Remote name
+      url: Remote URL
     """
     """
     if not isinstance(name, bytes):
     if not isinstance(name, bytes):
         name = name.encode(DEFAULT_ENCODING)
         name = name.encode(DEFAULT_ENCODING)
@@ -1320,10 +1362,11 @@ def remote_add(repo, name, url):
 def check_ignore(repo, paths, no_index=False):
 def check_ignore(repo, paths, no_index=False):
     """Debug gitignore files.
     """Debug gitignore files.
 
 
-    :param repo: Path to the repository
-    :param paths: List of paths to check for
-    :param no_index: Don't check index
-    :return: List of ignored files
+    Args:
+      repo: Path to the repository
+      paths: List of paths to check for
+      no_index: Don't check index
+    Returns: List of ignored files
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         index = r.open_index()
         index = r.open_index()
@@ -1342,10 +1385,11 @@ def update_head(repo, target, detached=False, new_branch=None):
 
 
     Note that this does not actually update the working tree.
     Note that this does not actually update the working tree.
 
 
-    :param repo: Path to the repository
-    :param detach: Create a detached head
-    :param target: Branch or committish to switch to
-    :param new_branch: New branch to create
+    Args:
+      repo: Path to the repository
+      detach: Create a detached head
+      target: Branch or committish to switch to
+      new_branch: New branch to create
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         if new_branch is not None:
         if new_branch is not None:
@@ -1367,9 +1411,10 @@ def update_head(repo, target, detached=False, new_branch=None):
 def check_mailmap(repo, contact):
 def check_mailmap(repo, contact):
     """Check canonical name and email of contact.
     """Check canonical name and email of contact.
 
 
-    :param repo: Path to the repository
-    :param contact: Contact name and/or email
-    :return: Canonical contact data
+    Args:
+      repo: Path to the repository
+      contact: Contact name and/or email
+    Returns: Canonical contact data
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         from dulwich.mailmap import Mailmap
         from dulwich.mailmap import Mailmap
@@ -1386,8 +1431,9 @@ def check_mailmap(repo, contact):
 def fsck(repo):
 def fsck(repo):
     """Check a repository.
     """Check a repository.
 
 
-    :param repo: A path to the repository
-    :return: Iterator over errors/warnings
+    Args:
+      repo: A path to the repository
+    Returns: Iterator over errors/warnings
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         # TODO(jelmer): check pack files
         # TODO(jelmer): check pack files
@@ -1434,8 +1480,9 @@ def ls_files(repo):
 def describe(repo):
 def describe(repo):
     """Describe the repository version.
     """Describe the repository version.
 
 
-    :param projdir: git repository root
-    :returns: a string description of the current git revision
+    Args:
+      projdir: git repository root
+    Returns: a string description of the current git revision
 
 
     Examples: "gabcdefh", "v0.1" or "v0.1-5-gabcdefh".
     Examples: "gabcdefh", "v0.1" or "v0.1-5-gabcdefh".
     """
     """
@@ -1503,10 +1550,11 @@ def describe(repo):
 def get_object_by_path(repo, path, committish=None):
 def get_object_by_path(repo, path, committish=None):
     """Get an object by path.
     """Get an object by path.
 
 
-    :param repo: A path to the repository
-    :param path: Path to look up
-    :param committish: Commit to look up path in
-    :return: A `ShaFile` object
+    Args:
+      repo: A path to the repository
+      path: Path to look up
+      committish: Commit to look up path in
+    Returns: A `ShaFile` object
     """
     """
     if committish is None:
     if committish is None:
         committish = "HEAD"
         committish = "HEAD"
@@ -1525,8 +1573,9 @@ def get_object_by_path(repo, path, committish=None):
 def write_tree(repo):
 def write_tree(repo):
     """Write a tree object from the index.
     """Write a tree object from the index.
 
 
-    :param repo: Repository for which to write tree
-    :return: tree id for the tree that was written
+    Args:
+      repo: Repository for which to write tree
+    Returns: tree id for the tree that was written
     """
     """
     with open_repo_closing(repo) as r:
     with open_repo_closing(repo) as r:
         return r.open_index().commit(r.object_store)
         return r.open_index().commit(r.object_store)

+ 28 - 19
dulwich/protocol.py

@@ -144,8 +144,9 @@ class ProtocolFile(object):
 def pkt_line(data):
 def pkt_line(data):
     """Wrap data in a pkt-line.
     """Wrap data in a pkt-line.
 
 
-    :param data: The data to wrap, as a str or None.
-    :return: The data prefixed with its length in pkt-line format; if data was
+    Args:
+      data: The data to wrap, as a str or None.
+    Returns: The data prefixed with its length in pkt-line format; if data was
         None, returns the flush-pkt ('0000').
         None, returns the flush-pkt ('0000').
     """
     """
     if data is None:
     if data is None:
@@ -187,7 +188,7 @@ class Protocol(object):
 
 
         This method may read from the readahead buffer; see unread_pkt_line.
         This method may read from the readahead buffer; see unread_pkt_line.
 
 
-        :return: The next string from the stream, without the length prefix, or
+        Returns: The next string from the stream, without the length prefix, or
             None for a flush-pkt ('0000').
             None for a flush-pkt ('0000').
         """
         """
         if self._readahead is None:
         if self._readahead is None:
@@ -223,7 +224,7 @@ class Protocol(object):
         Note that this refers to the actual stream EOF and not just a
         Note that this refers to the actual stream EOF and not just a
         flush-pkt.
         flush-pkt.
 
 
-        :return: True if the stream is at EOF, False otherwise.
+        Returns: True if the stream is at EOF, False otherwise.
         """
         """
         try:
         try:
             next_line = self.read_pkt_line()
             next_line = self.read_pkt_line()
@@ -238,8 +239,10 @@ class Protocol(object):
         This method can be used to unread a single pkt-line into a fixed
         This method can be used to unread a single pkt-line into a fixed
         readahead buffer.
         readahead buffer.
 
 
-        :param data: The data to unread, without the length prefix.
-        :raise ValueError: If more than one pkt-line is unread.
+        Args:
+          data: The data to unread, without the length prefix.
+        Raises:
+          ValueError: If more than one pkt-line is unread.
         """
         """
         if self._readahead is not None:
         if self._readahead is not None:
             raise ValueError('Attempted to unread multiple pkt-lines.')
             raise ValueError('Attempted to unread multiple pkt-lines.')
@@ -248,7 +251,7 @@ class Protocol(object):
     def read_pkt_seq(self):
     def read_pkt_seq(self):
         """Read a sequence of pkt-lines from the remote git process.
         """Read a sequence of pkt-lines from the remote git process.
 
 
-        :return: Yields each line of data up to but not including the next
+        Returns: Yields each line of data up to but not including the next
             flush-pkt.
             flush-pkt.
         """
         """
         pkt = self.read_pkt_line()
         pkt = self.read_pkt_line()
@@ -259,7 +262,8 @@ class Protocol(object):
     def write_pkt_line(self, line):
     def write_pkt_line(self, line):
         """Sends a pkt-line to the remote git process.
         """Sends a pkt-line to the remote git process.
 
 
-        :param line: A string containing the data to send, without the length
+        Args:
+          line: A string containing the data to send, without the length
             prefix.
             prefix.
         """
         """
         try:
         try:
@@ -294,8 +298,9 @@ class Protocol(object):
     def write_sideband(self, channel, blob):
     def write_sideband(self, channel, blob):
         """Write multiplexed data to the sideband.
         """Write multiplexed data to the sideband.
 
 
-        :param channel: An int specifying the channel to write to.
-        :param blob: A blob of data (as a string) to send on this channel.
+        Args:
+          channel: An int specifying the channel to write to.
+          blob: A blob of data (as a string) to send on this channel.
         """
         """
         # a pktline can be a max of 65520. a sideband line can therefore be
         # a pktline can be a max of 65520. a sideband line can therefore be
         # 65520-5 = 65515
         # 65520-5 = 65515
@@ -309,8 +314,9 @@ class Protocol(object):
 
 
         Only used for the TCP git protocol (git://).
         Only used for the TCP git protocol (git://).
 
 
-        :param cmd: The remote service to access.
-        :param args: List of arguments to send to remove service.
+        Args:
+          cmd: The remote service to access.
+          args: List of arguments to send to remove service.
         """
         """
         self.write_pkt_line(cmd + b" " + b"".join([(a + b"\0") for a in args]))
         self.write_pkt_line(cmd + b" " + b"".join([(a + b"\0") for a in args]))
 
 
@@ -319,7 +325,7 @@ class Protocol(object):
 
 
         Only used for the TCP git protocol (git://).
         Only used for the TCP git protocol (git://).
 
 
-        :return: A tuple of (command, [list of arguments]).
+        Returns: A tuple of (command, [list of arguments]).
         """
         """
         line = self.read_pkt_line()
         line = self.read_pkt_line()
         splice_at = line.find(b" ")
         splice_at = line.find(b" ")
@@ -439,8 +445,9 @@ class ReceivableProtocol(Protocol):
 def extract_capabilities(text):
 def extract_capabilities(text):
     """Extract a capabilities list from a string, if present.
     """Extract a capabilities list from a string, if present.
 
 
-    :param text: String to extract from
-    :return: Tuple with text with capabilities removed and list of capabilities
+    Args:
+      text: String to extract from
+    Returns: Tuple with text with capabilities removed and list of capabilities
     """
     """
     if b"\0" not in text:
     if b"\0" not in text:
         return text, []
         return text, []
@@ -456,8 +463,9 @@ def extract_want_line_capabilities(text):
 
 
         want obj-id cap1 cap2 ...
         want obj-id cap1 cap2 ...
 
 
-    :param text: Want line to extract from
-    :return: Tuple with text with capabilities removed and list of capabilities
+    Args:
+      text: Want line to extract from
+    Returns: Tuple with text with capabilities removed and list of capabilities
     """
     """
     split_text = text.rstrip().split(b" ")
     split_text = text.rstrip().split(b" ")
     if len(split_text) < 3:
     if len(split_text) < 3:
@@ -485,8 +493,9 @@ class BufferedPktLineWriter(object):
     def __init__(self, write, bufsize=65515):
     def __init__(self, write, bufsize=65515):
         """Initialize the BufferedPktLineWriter.
         """Initialize the BufferedPktLineWriter.
 
 
-        :param write: A write callback for the underlying writer.
-        :param bufsize: The internal buffer size, including length prefixes.
+        Args:
+          write: A write callback for the underlying writer.
+          bufsize: The internal buffer size, including length prefixes.
         """
         """
         self._write = write
         self._write = write
         self._bufsize = bufsize
         self._bufsize = bufsize

+ 13 - 10
dulwich/reflog.py

@@ -38,12 +38,13 @@ def format_reflog_line(old_sha, new_sha, committer, timestamp, timezone,
                        message):
                        message):
     """Generate a single reflog line.
     """Generate a single reflog line.
 
 
-    :param old_sha: Old Commit SHA
-    :param new_sha: New Commit SHA
-    :param committer: Committer name and e-mail
-    :param timestamp: Timestamp
-    :param timezone: Timezone
-    :param message: Message
+    Args:
+      old_sha: Old Commit SHA
+      new_sha: New Commit SHA
+      committer: Committer name and e-mail
+      timestamp: Timestamp
+      timezone: Timezone
+      message: Message
     """
     """
     if old_sha is None:
     if old_sha is None:
         old_sha = ZERO_SHA
         old_sha = ZERO_SHA
@@ -55,8 +56,9 @@ def format_reflog_line(old_sha, new_sha, committer, timestamp, timezone,
 def parse_reflog_line(line):
 def parse_reflog_line(line):
     """Parse a reflog line.
     """Parse a reflog line.
 
 
-    :param line: Line to parse
-    :return: Tuple of (old_sha, new_sha, committer, timestamp, timezone,
+    Args:
+      line: Line to parse
+    Returns: Tuple of (old_sha, new_sha, committer, timestamp, timezone,
         message)
         message)
     """
     """
     (begin, message) = line.split(b'\t', 1)
     (begin, message) = line.split(b'\t', 1)
@@ -69,8 +71,9 @@ def parse_reflog_line(line):
 def read_reflog(f):
 def read_reflog(f):
     """Read reflog.
     """Read reflog.
 
 
-    :param f: File-like object
-    :returns: Iterator over Entry objects
+    Args:
+      f: File-like object
+    Returns: Iterator over Entry objects
     """
     """
     for l in f:
     for l in f:
         yield parse_reflog_line(l)
         yield parse_reflog_line(l)

+ 95 - 69
dulwich/refs.py

@@ -51,8 +51,9 @@ ANNOTATED_TAG_SUFFIX = b'^{}'
 def parse_symref_value(contents):
 def parse_symref_value(contents):
     """Parse a symref value.
     """Parse a symref value.
 
 
-    :param contents: Contents to parse
-    :return: Destination
+    Args:
+      contents: Contents to parse
+    Returns: Destination
     """
     """
     if contents.startswith(SYMREF):
     if contents.startswith(SYMREF):
         return contents[len(SYMREF):].rstrip(b'\r\n')
         return contents[len(SYMREF):].rstrip(b'\r\n')
@@ -67,8 +68,9 @@ def check_ref_format(refname):
     [1]
     [1]
     http://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
     http://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
 
 
-    :param refname: The refname to check
-    :return: True if refname is valid, False otherwise
+    Args:
+      refname: The refname to check
+    Returns: True if refname is valid, False otherwise
     """
     """
     # These could be combined into one big expression, but are listed
     # These could be combined into one big expression, but are listed
     # separately to parallel [1].
     # separately to parallel [1].
@@ -111,18 +113,19 @@ class RefsContainer(object):
                          timezone=None, message=None):
                          timezone=None, message=None):
         """Make a ref point at another ref.
         """Make a ref point at another ref.
 
 
-        :param name: Name of the ref to set
-        :param other: Name of the ref to point at
-        :param message: Optional message
+        Args:
+          name: Name of the ref to set
+          other: Name of the ref to point at
+          message: Optional message
         """
         """
         raise NotImplementedError(self.set_symbolic_ref)
         raise NotImplementedError(self.set_symbolic_ref)
 
 
     def get_packed_refs(self):
     def get_packed_refs(self):
         """Get contents of the packed-refs file.
         """Get contents of the packed-refs file.
 
 
-        :return: Dictionary mapping ref names to SHA1s
+        Returns: Dictionary mapping ref names to SHA1s
 
 
-        :note: Will return an empty dictionary when no packed-refs file is
+        Note: Will return an empty dictionary when no packed-refs file is
             present.
             present.
         """
         """
         raise NotImplementedError(self.get_packed_refs)
         raise NotImplementedError(self.get_packed_refs)
@@ -130,8 +133,9 @@ class RefsContainer(object):
     def get_peeled(self, name):
     def get_peeled(self, name):
         """Return the cached peeled value of a ref, if available.
         """Return the cached peeled value of a ref, if available.
 
 
-        :param name: Name of the ref to peel
-        :return: The peeled value of the ref. If the ref is known not point to
+        Args:
+          name: Name of the ref to peel
+        Returns: The peeled value of the ref. If the ref is known not point to
             a tag, this will be the SHA the ref refers to. If the ref may point
             a tag, this will be the SHA the ref refers to. If the ref may point
             to a tag, but no cached information is available, None is returned.
             to a tag, but no cached information is available, None is returned.
         """
         """
@@ -164,8 +168,9 @@ class RefsContainer(object):
     def keys(self, base=None):
     def keys(self, base=None):
         """Refs present in this container.
         """Refs present in this container.
 
 
-        :param base: An optional base to return refs under.
-        :return: An unsorted set of valid refs in this container, including
+        Args:
+          base: An optional base to return refs under.
+        Returns: An unsorted set of valid refs in this container, including
             packed refs.
             packed refs.
         """
         """
         if base is not None:
         if base is not None:
@@ -176,8 +181,9 @@ class RefsContainer(object):
     def subkeys(self, base):
     def subkeys(self, base):
         """Refs present in this container under a base.
         """Refs present in this container under a base.
 
 
-        :param base: The base to return refs under.
-        :return: A set of valid refs in this container under the base; the base
+        Args:
+          base: The base to return refs under.
+        Returns: A set of valid refs in this container under the base; the base
             prefix is stripped from the ref names returned.
             prefix is stripped from the ref names returned.
         """
         """
         keys = set()
         keys = set()
@@ -213,8 +219,10 @@ class RefsContainer(object):
         refnames without the leading 'refs/', but this class requires that
         refnames without the leading 'refs/', but this class requires that
         so it cannot touch anything outside the refs dir (or HEAD).
         so it cannot touch anything outside the refs dir (or HEAD).
 
 
-        :param name: The name of the reference.
-        :raises KeyError: if a refname is not HEAD or is otherwise not valid.
+        Args:
+          name: The name of the reference.
+        Raises:
+          KeyError: if a refname is not HEAD or is otherwise not valid.
         """
         """
         if name in (b'HEAD', b'refs/stash'):
         if name in (b'HEAD', b'refs/stash'):
             return
             return
@@ -224,8 +232,9 @@ class RefsContainer(object):
     def read_ref(self, refname):
     def read_ref(self, refname):
         """Read a reference without following any references.
         """Read a reference without following any references.
 
 
-        :param refname: The name of the reference
-        :return: The contents of the ref file, or None if it does
+        Args:
+          refname: The name of the reference
+        Returns: The contents of the ref file, or None if it does
             not exist.
             not exist.
         """
         """
         contents = self.read_loose_ref(refname)
         contents = self.read_loose_ref(refname)
@@ -236,8 +245,9 @@ class RefsContainer(object):
     def read_loose_ref(self, name):
     def read_loose_ref(self, name):
         """Read a loose reference and return its contents.
         """Read a loose reference and return its contents.
 
 
-        :param name: the refname to read
-        :return: The contents of the ref file, or None if it does
+        Args:
+          name: the refname to read
+        Returns: The contents of the ref file, or None if it does
             not exist.
             not exist.
         """
         """
         raise NotImplementedError(self.read_loose_ref)
         raise NotImplementedError(self.read_loose_ref)
@@ -245,7 +255,7 @@ class RefsContainer(object):
     def follow(self, name):
     def follow(self, name):
         """Follow a reference name.
         """Follow a reference name.
 
 
-        :return: a tuple of (refnames, sha), wheres refnames are the names of
+        Returns: a tuple of (refnames, sha), wheres refnames are the names of
             references in the chain
             references in the chain
         """
         """
         contents = SYMREF + name
         contents = SYMREF + name
@@ -295,21 +305,23 @@ class RefsContainer(object):
         subclass, and can be used to perform an atomic compare-and-swap
         subclass, and can be used to perform an atomic compare-and-swap
         operation.
         operation.
 
 
-        :param name: The refname to set.
-        :param old_ref: The old sha the refname must refer to, or None to set
+        Args:
+          name: The refname to set.
+          old_ref: The old sha the refname must refer to, or None to set
             unconditionally.
             unconditionally.
-        :param new_ref: The new sha the refname will refer to.
-        :param message: Message for reflog
-        :return: True if the set was successful, False otherwise.
+          new_ref: The new sha the refname will refer to.
+          message: Message for reflog
+        Returns: True if the set was successful, False otherwise.
         """
         """
         raise NotImplementedError(self.set_if_equals)
         raise NotImplementedError(self.set_if_equals)
 
 
     def add_if_new(self, name, ref):
     def add_if_new(self, name, ref):
         """Add a new reference only if it does not already exist.
         """Add a new reference only if it does not already exist.
 
 
-        :param name: Ref name
-        :param ref: Ref value
-        :param message: Message for reflog
+        Args:
+          name: Ref name
+          ref: Ref value
+          message: Message for reflog
         """
         """
         raise NotImplementedError(self.add_if_new)
         raise NotImplementedError(self.add_if_new)
 
 
@@ -319,11 +331,13 @@ class RefsContainer(object):
         This method follows all symbolic references if applicable for the
         This method follows all symbolic references if applicable for the
         subclass.
         subclass.
 
 
-        :note: This method unconditionally overwrites the contents of a
+        Note: This method unconditionally overwrites the contents of a
             reference. To update atomically only if the reference has not
             reference. To update atomically only if the reference has not
             changed, use set_if_equals().
             changed, use set_if_equals().
-        :param name: The refname to set.
-        :param ref: The new sha the refname will refer to.
+
+        Args:
+          name: The refname to set.
+          ref: The new sha the refname will refer to.
         """
         """
         self.set_if_equals(name, None, ref)
         self.set_if_equals(name, None, ref)
 
 
@@ -335,11 +349,12 @@ class RefsContainer(object):
         the subclass. It can be used to perform an atomic compare-and-delete
         the subclass. It can be used to perform an atomic compare-and-delete
         operation.
         operation.
 
 
-        :param name: The refname to delete.
-        :param old_ref: The old sha the refname must refer to, or None to
+        Args:
+          name: The refname to delete.
+          old_ref: The old sha the refname must refer to, or None to
             delete unconditionally.
             delete unconditionally.
-        :param message: Message for reflog
-        :return: True if the delete was successful, False otherwise.
+          message: Message for reflog
+        Returns: True if the delete was successful, False otherwise.
         """
         """
         raise NotImplementedError(self.remove_if_equals)
         raise NotImplementedError(self.remove_if_equals)
 
 
@@ -349,18 +364,19 @@ class RefsContainer(object):
         This method does not follow symbolic references, even if applicable for
         This method does not follow symbolic references, even if applicable for
         the subclass.
         the subclass.
 
 
-        :note: This method unconditionally deletes the contents of a reference.
+        Note: This method unconditionally deletes the contents of a reference.
             To delete atomically only if the reference has not changed, use
             To delete atomically only if the reference has not changed, use
             remove_if_equals().
             remove_if_equals().
 
 
-        :param name: The refname to delete.
+        Args:
+          name: The refname to delete.
         """
         """
         self.remove_if_equals(name, None)
         self.remove_if_equals(name, None)
 
 
     def get_symrefs(self):
     def get_symrefs(self):
         """Get a dict with all symrefs in this container.
         """Get a dict with all symrefs in this container.
 
 
-        :return: Dictionary mapping source ref to target ref
+        Returns: Dictionary mapping source ref to target ref
         """
         """
         ret = {}
         ret = {}
         for src in self.allkeys():
         for src in self.allkeys():
@@ -559,9 +575,9 @@ class DiskRefsContainer(RefsContainer):
     def get_packed_refs(self):
     def get_packed_refs(self):
         """Get contents of the packed-refs file.
         """Get contents of the packed-refs file.
 
 
-        :return: Dictionary mapping ref names to SHA1s
+        Returns: Dictionary mapping ref names to SHA1s
 
 
-        :note: Will return an empty dictionary when no packed-refs file is
+        Note: Will return an empty dictionary when no packed-refs file is
             present.
             present.
         """
         """
         # TODO: invalidate the cache on repacking
         # TODO: invalidate the cache on repacking
@@ -594,8 +610,9 @@ class DiskRefsContainer(RefsContainer):
     def get_peeled(self, name):
     def get_peeled(self, name):
         """Return the cached peeled value of a ref, if available.
         """Return the cached peeled value of a ref, if available.
 
 
-        :param name: Name of the ref to peel
-        :return: The peeled value of the ref. If the ref is known not point to
+        Args:
+          name: Name of the ref to peel
+        Returns: The peeled value of the ref. If the ref is known not point to
             a tag, this will be the SHA the ref refers to. If the ref may point
             a tag, this will be the SHA the ref refers to. If the ref may point
             to a tag, but no cached information is available, None is returned.
             to a tag, but no cached information is available, None is returned.
         """
         """
@@ -615,10 +632,12 @@ class DiskRefsContainer(RefsContainer):
         If the reference file a symbolic reference, only read the first line of
         If the reference file a symbolic reference, only read the first line of
         the file. Otherwise, only read the first 40 bytes.
         the file. Otherwise, only read the first 40 bytes.
 
 
-        :param name: the refname to read, relative to refpath
-        :return: The contents of the ref file, or None if the file does not
+        Args:
+          name: the refname to read, relative to refpath
+        Returns: The contents of the ref file, or None if the file does not
             exist.
             exist.
-        :raises IOError: if any other error occurs
+        Raises:
+          IOError: if any other error occurs
         """
         """
         filename = self.refpath(name)
         filename = self.refpath(name)
         try:
         try:
@@ -660,9 +679,10 @@ class DiskRefsContainer(RefsContainer):
                          timezone=None, message=None):
                          timezone=None, message=None):
         """Make a ref point at another ref.
         """Make a ref point at another ref.
 
 
-        :param name: Name of the ref to set
-        :param other: Name of the ref to point at
-        :param message: Optional message to describe the change
+        Args:
+          name: Name of the ref to set
+          other: Name of the ref to point at
+          message: Optional message to describe the change
         """
         """
         self._check_refname(name)
         self._check_refname(name)
         self._check_refname(other)
         self._check_refname(other)
@@ -687,12 +707,13 @@ class DiskRefsContainer(RefsContainer):
         This method follows all symbolic references, and can be used to perform
         This method follows all symbolic references, and can be used to perform
         an atomic compare-and-swap operation.
         an atomic compare-and-swap operation.
 
 
-        :param name: The refname to set.
-        :param old_ref: The old sha the refname must refer to, or None to set
+        Args:
+          name: The refname to set.
+          old_ref: The old sha the refname must refer to, or None to set
             unconditionally.
             unconditionally.
-        :param new_ref: The new sha the refname will refer to.
-        :param message: Set message for reflog
-        :return: True if the set was successful, False otherwise.
+          new_ref: The new sha the refname will refer to.
+          message: Set message for reflog
+        Returns: True if the set was successful, False otherwise.
         """
         """
         self._check_refname(name)
         self._check_refname(name)
         try:
         try:
@@ -742,10 +763,11 @@ class DiskRefsContainer(RefsContainer):
         This method follows symrefs, and only ensures that the last ref in the
         This method follows symrefs, and only ensures that the last ref in the
         chain does not exist.
         chain does not exist.
 
 
-        :param name: The refname to set.
-        :param ref: The new sha the refname will refer to.
-        :param message: Optional message for reflog
-        :return: True if the add was successful, False otherwise.
+        Args:
+          name: The refname to set.
+          ref: The new sha the refname will refer to.
+          message: Optional message for reflog
+        Returns: True if the add was successful, False otherwise.
         """
         """
         try:
         try:
             realnames, contents = self.follow(name)
             realnames, contents = self.follow(name)
@@ -779,11 +801,12 @@ class DiskRefsContainer(RefsContainer):
         This method does not follow symbolic references. It can be used to
         This method does not follow symbolic references. It can be used to
         perform an atomic compare-and-delete operation.
         perform an atomic compare-and-delete operation.
 
 
-        :param name: The refname to delete.
-        :param old_ref: The old sha the refname must refer to, or None to
+        Args:
+          name: The refname to delete.
+          old_ref: The old sha the refname must refer to, or None to
             delete unconditionally.
             delete unconditionally.
-        :param message: Optional message
-        :return: True if the delete was successful, False otherwise.
+          message: Optional message
+        Returns: True if the delete was successful, False otherwise.
         """
         """
         self._check_refname(name)
         self._check_refname(name)
         filename = self.refpath(name)
         filename = self.refpath(name)
@@ -850,8 +873,9 @@ def _split_ref_line(line):
 def read_packed_refs(f):
 def read_packed_refs(f):
     """Read a packed refs file.
     """Read a packed refs file.
 
 
-    :param f: file-like object to read from
-    :return: Iterator over tuples with SHA1s and ref names.
+    Args:
+      f: file-like object to read from
+    Returns: Iterator over tuples with SHA1s and ref names.
     """
     """
     for l in f:
     for l in f:
         if l.startswith(b'#'):
         if l.startswith(b'#'):
@@ -869,7 +893,8 @@ def read_packed_refs_with_peeled(f):
     Assumes the "# pack-refs with: peeled" line was already read. Yields tuples
     Assumes the "# pack-refs with: peeled" line was already read. Yields tuples
     with ref names, SHA1s, and peeled SHA1s (or None).
     with ref names, SHA1s, and peeled SHA1s (or None).
 
 
-    :param f: file-like object to read from, seek'ed to the second line
+    Args:
+      f: file-like object to read from, seek'ed to the second line
     """
     """
     last = None
     last = None
     for line in f:
     for line in f:
@@ -897,9 +922,10 @@ def read_packed_refs_with_peeled(f):
 def write_packed_refs(f, packed_refs, peeled_refs=None):
 def write_packed_refs(f, packed_refs, peeled_refs=None):
     """Write a packed refs file.
     """Write a packed refs file.
 
 
-    :param f: empty file-like object to write to
-    :param packed_refs: dict of refname to sha of packed refs to write
-    :param peeled_refs: dict of refname to peeled value of sha
+    Args:
+      f: empty file-like object to write to
+      packed_refs: dict of refname to sha of packed refs to write
+      peeled_refs: dict of refname to peeled value of sha
     """
     """
     if peeled_refs is None:
     if peeled_refs is None:
         peeled_refs = {}
         peeled_refs = {}

+ 162 - 120
dulwich/repo.py

@@ -183,8 +183,10 @@ def get_user_identity(config, kind=None):
 def check_user_identity(identity):
 def check_user_identity(identity):
     """Verify that a user identity is formatted correctly.
     """Verify that a user identity is formatted correctly.
 
 
-    :param identity: User identity bytestring
-    :raise InvalidUserIdentity: Raised when identity is invalid
+    Args:
+      identity: User identity bytestring
+    Raises:
+      InvalidUserIdentity: Raised when identity is invalid
     """
     """
     try:
     try:
         fst, snd = identity.split(b' <', 1)
         fst, snd = identity.split(b' <', 1)
@@ -197,7 +199,8 @@ def check_user_identity(identity):
 def parse_graftpoints(graftpoints):
 def parse_graftpoints(graftpoints):
     """Convert a list of graftpoints into a dict
     """Convert a list of graftpoints into a dict
 
 
-    :param graftpoints: Iterator of graftpoint lines
+    Args:
+      graftpoints: Iterator of graftpoint lines
 
 
     Each line is formatted as:
     Each line is formatted as:
         <commit sha1> <parent sha1> [<parent sha1>]*
         <commit sha1> <parent sha1> [<parent sha1>]*
@@ -282,8 +285,9 @@ class BaseRepo(object):
         This shouldn't be called directly, but rather through one of the
         This shouldn't be called directly, but rather through one of the
         base classes, such as MemoryRepo or Repo.
         base classes, such as MemoryRepo or Repo.
 
 
-        :param object_store: Object store to use
-        :param refs: Refs container to use
+        Args:
+          object_store: Object store to use
+          refs: Refs container to use
         """
         """
         self.object_store = object_store
         self.object_store = object_store
         self.refs = refs
         self.refs = refs
@@ -294,7 +298,7 @@ class BaseRepo(object):
     def _determine_file_mode(self):
     def _determine_file_mode(self):
         """Probe the file-system to determine whether permissions can be trusted.
         """Probe the file-system to determine whether permissions can be trusted.
 
 
-        :return: True if permissions can be trusted, False otherwise.
+        Returns: True if permissions can be trusted, False otherwise.
         """
         """
         raise NotImplementedError(self._determine_file_mode)
         raise NotImplementedError(self._determine_file_mode)
 
 
@@ -323,16 +327,18 @@ class BaseRepo(object):
         the control dir in a disk-based Repo, the object returned need not be
         the control dir in a disk-based Repo, the object returned need not be
         pointing to a file in that location.
         pointing to a file in that location.
 
 
-        :param path: The path to the file, relative to the control dir.
-        :return: An open file object, or None if the file does not exist.
+        Args:
+          path: The path to the file, relative to the control dir.
+        Returns: An open file object, or None if the file does not exist.
         """
         """
         raise NotImplementedError(self.get_named_file)
         raise NotImplementedError(self.get_named_file)
 
 
     def _put_named_file(self, path, contents):
     def _put_named_file(self, path, contents):
         """Write a file to the control dir with the given name and contents.
         """Write a file to the control dir with the given name and contents.
 
 
-        :param path: The path to the file, relative to the control dir.
-        :param contents: A string to write to the file.
+        Args:
+          path: The path to the file, relative to the control dir.
+          contents: A string to write to the file.
         """
         """
         raise NotImplementedError(self._put_named_file)
         raise NotImplementedError(self._put_named_file)
 
 
@@ -343,20 +349,22 @@ class BaseRepo(object):
     def open_index(self):
     def open_index(self):
         """Open the index for this repository.
         """Open the index for this repository.
 
 
-        :raise NoIndexPresent: If no index is present
-        :return: The matching `Index`
+        Raises:
+          NoIndexPresent: If no index is present
+        Returns: The matching `Index`
         """
         """
         raise NotImplementedError(self.open_index)
         raise NotImplementedError(self.open_index)
 
 
     def fetch(self, target, determine_wants=None, progress=None, depth=None):
     def fetch(self, target, determine_wants=None, progress=None, depth=None):
         """Fetch objects into another repository.
         """Fetch objects into another repository.
 
 
-        :param target: The target repository
-        :param determine_wants: Optional function to determine what refs to
+        Args:
+          target: The target repository
+          determine_wants: Optional function to determine what refs to
             fetch.
             fetch.
-        :param progress: Optional progress function
-        :param depth: Optional shallow fetch depth
-        :return: The local refs
+          progress: Optional progress function
+          depth: Optional shallow fetch depth
+        Returns: The local refs
         """
         """
         if determine_wants is None:
         if determine_wants is None:
             determine_wants = target.object_store.determine_wants_all
             determine_wants = target.object_store.determine_wants_all
@@ -370,17 +378,18 @@ class BaseRepo(object):
                         get_tagged=None, depth=None):
                         get_tagged=None, depth=None):
         """Fetch the pack data required for a set of revisions.
         """Fetch the pack data required for a set of revisions.
 
 
-        :param determine_wants: Function that takes a dictionary with heads
+        Args:
+          determine_wants: Function that takes a dictionary with heads
             and returns the list of heads to fetch.
             and returns the list of heads to fetch.
-        :param graph_walker: Object that can iterate over the list of revisions
+          graph_walker: Object that can iterate over the list of revisions
             to fetch and has an "ack" method that will be called to acknowledge
             to fetch and has an "ack" method that will be called to acknowledge
             that a revision is present.
             that a revision is present.
-        :param progress: Simple progress function that will be called with
+          progress: Simple progress function that will be called with
             updated progress strings.
             updated progress strings.
-        :param get_tagged: Function that returns a dict of pointed-to sha ->
+          get_tagged: Function that returns a dict of pointed-to sha ->
             tag sha for including tags.
             tag sha for including tags.
-        :param depth: Shallow fetch depth
-        :return: count and iterator over pack data
+          depth: Shallow fetch depth
+        Returns: count and iterator over pack data
         """
         """
         # TODO(jelmer): Fetch pack data directly, don't create objects first.
         # TODO(jelmer): Fetch pack data directly, don't create objects first.
         objects = self.fetch_objects(determine_wants, graph_walker, progress,
         objects = self.fetch_objects(determine_wants, graph_walker, progress,
@@ -391,17 +400,18 @@ class BaseRepo(object):
                       get_tagged=None, depth=None):
                       get_tagged=None, depth=None):
         """Fetch the missing objects required for a set of revisions.
         """Fetch the missing objects required for a set of revisions.
 
 
-        :param determine_wants: Function that takes a dictionary with heads
+        Args:
+          determine_wants: Function that takes a dictionary with heads
             and returns the list of heads to fetch.
             and returns the list of heads to fetch.
-        :param graph_walker: Object that can iterate over the list of revisions
+          graph_walker: Object that can iterate over the list of revisions
             to fetch and has an "ack" method that will be called to acknowledge
             to fetch and has an "ack" method that will be called to acknowledge
             that a revision is present.
             that a revision is present.
-        :param progress: Simple progress function that will be called with
+          progress: Simple progress function that will be called with
             updated progress strings.
             updated progress strings.
-        :param get_tagged: Function that returns a dict of pointed-to sha ->
+          get_tagged: Function that returns a dict of pointed-to sha ->
             tag sha for including tags.
             tag sha for including tags.
-        :param depth: Shallow fetch depth
-        :return: iterator over objects, with __len__ implemented
+          depth: Shallow fetch depth
+        Returns: iterator over objects, with __len__ implemented
         """
         """
         if depth not in (None, 0):
         if depth not in (None, 0):
             raise NotImplementedError("depth not supported yet")
             raise NotImplementedError("depth not supported yet")
@@ -467,8 +477,9 @@ class BaseRepo(object):
         A graph walker is used by a remote repository (or proxy)
         A graph walker is used by a remote repository (or proxy)
         to find out which objects are present in this repository.
         to find out which objects are present in this repository.
 
 
-        :param heads: Repository heads to use (optional)
-        :return: A graph walker object
+        Args:
+          heads: Repository heads to use (optional)
+        Returns: A graph walker object
         """
         """
         if heads is None:
         if heads is None:
             heads = [
             heads = [
@@ -480,7 +491,7 @@ class BaseRepo(object):
     def get_refs(self):
     def get_refs(self):
         """Get dictionary with all refs.
         """Get dictionary with all refs.
 
 
-        :return: A ``dict`` mapping ref names to SHA1s
+        Returns: A ``dict`` mapping ref names to SHA1s
         """
         """
         return self.refs.as_dict()
         return self.refs.as_dict()
 
 
@@ -508,9 +519,11 @@ class BaseRepo(object):
     def get_object(self, sha):
     def get_object(self, sha):
         """Retrieve the object with the specified SHA.
         """Retrieve the object with the specified SHA.
 
 
-        :param sha: SHA to retrieve
-        :return: A ShaFile object
-        :raise KeyError: when the object can not be found
+        Args:
+          sha: SHA to retrieve
+        Returns: A ShaFile object
+        Raises:
+          KeyError: when the object can not be found
         """
         """
         return self.object_store[sha]
         return self.object_store[sha]
 
 
@@ -520,9 +533,10 @@ class BaseRepo(object):
         If the specific commit is a graftpoint, the graft parents
         If the specific commit is a graftpoint, the graft parents
         will be returned instead.
         will be returned instead.
 
 
-        :param sha: SHA of the commit for which to retrieve the parents
-        :param commit: Optional commit matching the sha
-        :return: List of parents
+        Args:
+          sha: SHA of the commit for which to retrieve the parents
+          commit: Optional commit matching the sha
+        Returns: List of parents
         """
         """
 
 
         try:
         try:
@@ -535,14 +549,14 @@ class BaseRepo(object):
     def get_config(self):
     def get_config(self):
         """Retrieve the config object.
         """Retrieve the config object.
 
 
-        :return: `ConfigFile` object for the ``.git/config`` file.
+        Returns: `ConfigFile` object for the ``.git/config`` file.
         """
         """
         raise NotImplementedError(self.get_config)
         raise NotImplementedError(self.get_config)
 
 
     def get_description(self):
     def get_description(self):
         """Retrieve the description for this repository.
         """Retrieve the description for this repository.
 
 
-        :return: String with the description of the repository
+        Returns: String with the description of the repository
             as set by the user.
             as set by the user.
         """
         """
         raise NotImplementedError(self.get_description)
         raise NotImplementedError(self.get_description)
@@ -550,7 +564,8 @@ class BaseRepo(object):
     def set_description(self, description):
     def set_description(self, description):
         """Set the description for this repository.
         """Set the description for this repository.
 
 
-        :param description: Text to set as description for this repository.
+        Args:
+          description: Text to set as description for this repository.
         """
         """
         raise NotImplementedError(self.set_description)
         raise NotImplementedError(self.set_description)
 
 
@@ -561,7 +576,7 @@ class BaseRepo(object):
         itself (.git/config) and the global configuration, which usually
         itself (.git/config) and the global configuration, which usually
         lives in ~/.gitconfig.
         lives in ~/.gitconfig.
 
 
-        :return: `Config` instance for this repository
+        Returns: `Config` instance for this repository
         """
         """
         from dulwich.config import StackedConfig
         from dulwich.config import StackedConfig
         backends = [self.get_config()] + StackedConfig.default_backends()
         backends = [self.get_config()] + StackedConfig.default_backends()
@@ -570,7 +585,7 @@ class BaseRepo(object):
     def get_shallow(self):
     def get_shallow(self):
         """Get the set of shallow commits.
         """Get the set of shallow commits.
 
 
-        :return: Set of shallow commits.
+        Returns: Set of shallow commits.
         """
         """
         f = self.get_named_file('shallow')
         f = self.get_named_file('shallow')
         if f is None:
         if f is None:
@@ -581,8 +596,9 @@ class BaseRepo(object):
     def update_shallow(self, new_shallow, new_unshallow):
     def update_shallow(self, new_shallow, new_unshallow):
         """Update the list of shallow objects.
         """Update the list of shallow objects.
 
 
-        :param new_shallow: Newly shallow objects
-        :param new_unshallow: Newly no longer shallow objects
+        Args:
+          new_shallow: Newly shallow objects
+          new_unshallow: Newly no longer shallow objects
         """
         """
         shallow = self.get_shallow()
         shallow = self.get_shallow()
         if new_shallow:
         if new_shallow:
@@ -596,8 +612,9 @@ class BaseRepo(object):
     def get_peeled(self, ref):
     def get_peeled(self, ref):
         """Get the peeled value of a ref.
         """Get the peeled value of a ref.
 
 
-        :param ref: The refname to peel.
-        :return: The fully-peeled SHA1 of a tag object, after peeling all
+        Args:
+          ref: The refname to peel.
+        Returns: The fully-peeled SHA1 of a tag object, after peeling all
             intermediate tags; if the original ref does not point to a tag,
             intermediate tags; if the original ref does not point to a tag,
             this will equal the original SHA1.
             this will equal the original SHA1.
         """
         """
@@ -609,27 +626,28 @@ class BaseRepo(object):
     def get_walker(self, include=None, *args, **kwargs):
     def get_walker(self, include=None, *args, **kwargs):
         """Obtain a walker for this repository.
         """Obtain a walker for this repository.
 
 
-        :param include: Iterable of SHAs of commits to include along with their
+        Args:
+          include: Iterable of SHAs of commits to include along with their
             ancestors. Defaults to [HEAD]
             ancestors. Defaults to [HEAD]
-        :param exclude: Iterable of SHAs of commits to exclude along with their
+          exclude: Iterable of SHAs of commits to exclude along with their
             ancestors, overriding includes.
             ancestors, overriding includes.
-        :param order: ORDER_* constant specifying the order of results.
+          order: ORDER_* constant specifying the order of results.
             Anything other than ORDER_DATE may result in O(n) memory usage.
             Anything other than ORDER_DATE may result in O(n) memory usage.
-        :param reverse: If True, reverse the order of output, requiring O(n)
+          reverse: If True, reverse the order of output, requiring O(n)
             memory.
             memory.
-        :param max_entries: The maximum number of entries to yield, or None for
+          max_entries: The maximum number of entries to yield, or None for
             no limit.
             no limit.
-        :param paths: Iterable of file or subtree paths to show entries for.
-        :param rename_detector: diff.RenameDetector object for detecting
+          paths: Iterable of file or subtree paths to show entries for.
+          rename_detector: diff.RenameDetector object for detecting
             renames.
             renames.
-        :param follow: If True, follow path across renames/copies. Forces a
+          follow: If True, follow path across renames/copies. Forces a
             default rename_detector.
             default rename_detector.
-        :param since: Timestamp to list commits after.
-        :param until: Timestamp to list commits before.
-        :param queue_cls: A class to use for a queue of commits, supporting the
+          since: Timestamp to list commits after.
+          until: Timestamp to list commits before.
+          queue_cls: A class to use for a queue of commits, supporting the
             iterator protocol. The constructor takes a single argument, the
             iterator protocol. The constructor takes a single argument, the
             Walker.
             Walker.
-        :return: A `Walker` object
+        Returns: A `Walker` object
         """
         """
         from dulwich.walk import Walker
         from dulwich.walk import Walker
         if include is None:
         if include is None:
@@ -645,9 +663,11 @@ class BaseRepo(object):
     def __getitem__(self, name):
     def __getitem__(self, name):
         """Retrieve a Git object by SHA1 or ref.
         """Retrieve a Git object by SHA1 or ref.
 
 
-        :param name: A Git object SHA1 or a ref name
-        :return: A `ShaFile` object, such as a Commit or Blob
-        :raise KeyError: when the specified ref or object does not exist
+        Args:
+          name: A Git object SHA1 or a ref name
+        Returns: A `ShaFile` object, such as a Commit or Blob
+        Raises:
+          KeyError: when the specified ref or object does not exist
         """
         """
         if not isinstance(name, bytes):
         if not isinstance(name, bytes):
             raise TypeError("'name' must be bytestring, not %.80s" %
             raise TypeError("'name' must be bytestring, not %.80s" %
@@ -665,7 +685,8 @@ class BaseRepo(object):
     def __contains__(self, name):
     def __contains__(self, name):
         """Check if a specific Git object or ref is present.
         """Check if a specific Git object or ref is present.
 
 
-        :param name: Git object SHA1 or ref name
+        Args:
+          name: Git object SHA1 or ref name
         """
         """
         if len(name) in (20, 40):
         if len(name) in (20, 40):
             return name in self.object_store or name in self.refs
             return name in self.object_store or name in self.refs
@@ -675,8 +696,9 @@ class BaseRepo(object):
     def __setitem__(self, name, value):
     def __setitem__(self, name, value):
         """Set a ref.
         """Set a ref.
 
 
-        :param name: ref name
-        :param value: Ref value - either a ShaFile object, or a hex sha
+        Args:
+          name: ref name
+          value: Ref value - either a ShaFile object, or a hex sha
         """
         """
         if name.startswith(b"refs/") or name == b'HEAD':
         if name.startswith(b"refs/") or name == b'HEAD':
             if isinstance(value, ShaFile):
             if isinstance(value, ShaFile):
@@ -691,7 +713,8 @@ class BaseRepo(object):
     def __delitem__(self, name):
     def __delitem__(self, name):
         """Remove a ref.
         """Remove a ref.
 
 
-        :param name: Name of the ref to remove
+        Args:
+          name: Name of the ref to remove
         """
         """
         if name.startswith(b"refs/") or name == b"HEAD":
         if name.startswith(b"refs/") or name == b"HEAD":
             del self.refs[name]
             del self.refs[name]
@@ -707,7 +730,8 @@ class BaseRepo(object):
     def _add_graftpoints(self, updated_graftpoints):
     def _add_graftpoints(self, updated_graftpoints):
         """Add or modify graftpoints
         """Add or modify graftpoints
 
 
-        :param updated_graftpoints: Dict of commit shas to list of parent shas
+        Args:
+          updated_graftpoints: Dict of commit shas to list of parent shas
         """
         """
 
 
         # Simple validation
         # Simple validation
@@ -720,7 +744,8 @@ class BaseRepo(object):
     def _remove_graftpoints(self, to_remove=[]):
     def _remove_graftpoints(self, to_remove=[]):
         """Remove graftpoints
         """Remove graftpoints
 
 
-        :param to_remove: List of commit shas
+        Args:
+          to_remove: List of commit shas
         """
         """
         for sha in to_remove:
         for sha in to_remove:
             del self._graftpoints[sha]
             del self._graftpoints[sha]
@@ -739,21 +764,22 @@ class BaseRepo(object):
                   ref=b'HEAD', merge_heads=None):
                   ref=b'HEAD', merge_heads=None):
         """Create a new commit.
         """Create a new commit.
 
 
-        :param message: Commit message
-        :param committer: Committer fullname
-        :param author: Author fullname (defaults to committer)
-        :param commit_timestamp: Commit timestamp (defaults to now)
-        :param commit_timezone: Commit timestamp timezone (defaults to GMT)
-        :param author_timestamp: Author timestamp (defaults to commit
+        Args:
+          message: Commit message
+          committer: Committer fullname
+          author: Author fullname (defaults to committer)
+          commit_timestamp: Commit timestamp (defaults to now)
+          commit_timezone: Commit timestamp timezone (defaults to GMT)
+          author_timestamp: Author timestamp (defaults to commit
             timestamp)
             timestamp)
-        :param author_timezone: Author timestamp timezone
+          author_timezone: Author timestamp timezone
             (defaults to commit timestamp timezone)
             (defaults to commit timestamp timezone)
-        :param tree: SHA1 of the tree root to use (if not specified the
+          tree: SHA1 of the tree root to use (if not specified the
             current index will be committed).
             current index will be committed).
-        :param encoding: Encoding
-        :param ref: Optional ref to commit to (defaults to current branch)
-        :param merge_heads: Merge heads (defaults to .git/MERGE_HEADS)
-        :return: New commit SHA1
+          encoding: Encoding
+          ref: Optional ref to commit to (defaults to current branch)
+          merge_heads: Merge heads (defaults to .git/MERGE_HEADS)
+        Returns: New commit SHA1
         """
         """
         import time
         import time
         c = Commit()
         c = Commit()
@@ -860,8 +886,9 @@ def read_gitfile(f):
 
 
     The first line of the file should start with "gitdir: "
     The first line of the file should start with "gitdir: "
 
 
-    :param f: File-like object to read from
-    :return: A path
+    Args:
+      f: File-like object to read from
+    Returns: A path
     """
     """
     cs = f.read()
     cs = f.read()
     if not cs.startswith("gitdir: "):
     if not cs.startswith("gitdir: "):
@@ -959,7 +986,8 @@ class Repo(BaseRepo):
         Return a Repo object for the first parent directory that looks like a
         Return a Repo object for the first parent directory that looks like a
         Git repository.
         Git repository.
 
 
-        :param start: The directory to start discovery from (defaults to '.')
+        Args:
+          start: The directory to start discovery from (defaults to '.')
         """
         """
         remaining = True
         remaining = True
         path = os.path.abspath(start)
         path = os.path.abspath(start)
@@ -989,7 +1017,7 @@ class Repo(BaseRepo):
     def _determine_file_mode(self):
     def _determine_file_mode(self):
         """Probe the file-system to determine whether permissions can be trusted.
         """Probe the file-system to determine whether permissions can be trusted.
 
 
-        :return: True if permissions can be trusted, False otherwise.
+        Returns: True if permissions can be trusted, False otherwise.
         """
         """
         fname = os.path.join(self.path, '.probe-permissions')
         fname = os.path.join(self.path, '.probe-permissions')
         with open(fname, 'w') as f:
         with open(fname, 'w') as f:
@@ -1014,8 +1042,9 @@ class Repo(BaseRepo):
     def _put_named_file(self, path, contents):
     def _put_named_file(self, path, contents):
         """Write a file to the control dir with the given name and contents.
         """Write a file to the control dir with the given name and contents.
 
 
-        :param path: The path to the file, relative to the control dir.
-        :param contents: A string to write to the file.
+        Args:
+          path: The path to the file, relative to the control dir.
+          contents: A string to write to the file.
         """
         """
         path = path.lstrip(os.path.sep)
         path = path.lstrip(os.path.sep)
         with GitFile(os.path.join(self.controldir(), path), 'wb') as f:
         with GitFile(os.path.join(self.controldir(), path), 'wb') as f:
@@ -1036,10 +1065,11 @@ class Repo(BaseRepo):
         the control dir in a disk-based Repo, the object returned need not be
         the control dir in a disk-based Repo, the object returned need not be
         pointing to a file in that location.
         pointing to a file in that location.
 
 
-        :param path: The path to the file, relative to the control dir.
-        :param basedir: Optional argument that specifies an alternative to the
+        Args:
+          path: The path to the file, relative to the control dir.
+          basedir: Optional argument that specifies an alternative to the
             control dir.
             control dir.
-        :return: An open file object, or None if the file does not exist.
+        Returns: An open file object, or None if the file does not exist.
         """
         """
         # TODO(dborowitz): sanitize filenames, since this is used directly by
         # TODO(dborowitz): sanitize filenames, since this is used directly by
         # the dumb web serving code.
         # the dumb web serving code.
@@ -1060,8 +1090,9 @@ class Repo(BaseRepo):
     def open_index(self):
     def open_index(self):
         """Open the index for this repository.
         """Open the index for this repository.
 
 
-        :raise NoIndexPresent: If no index is present
-        :return: The matching `Index`
+        Raises:
+          NoIndexPresent: If no index is present
+        Returns: The matching `Index`
         """
         """
         from dulwich.index import Index
         from dulwich.index import Index
         if not self.has_index():
         if not self.has_index():
@@ -1077,7 +1108,8 @@ class Repo(BaseRepo):
     def stage(self, fs_paths):
     def stage(self, fs_paths):
         """Stage a set of paths.
         """Stage a set of paths.
 
 
-        :param fs_paths: List of paths, relative to the repository path
+        Args:
+          fs_paths: List of paths, relative to the repository path
         """
         """
 
 
         root_path_bytes = self.path.encode(sys.getfilesystemencoding())
         root_path_bytes = self.path.encode(sys.getfilesystemencoding())
@@ -1125,12 +1157,13 @@ class Repo(BaseRepo):
               origin=b"origin", checkout=None):
               origin=b"origin", checkout=None):
         """Clone this repository.
         """Clone this repository.
 
 
-        :param target_path: Target path
-        :param mkdir: Create the target directory
-        :param bare: Whether to create a bare repository
-        :param origin: Base name for refs in target repository
+        Args:
+          target_path: Target path
+          mkdir: Create the target directory
+          bare: Whether to create a bare repository
+          origin: Base name for refs in target repository
             cloned from this repository
             cloned from this repository
-        :return: Created repository as `Repo`
+        Returns: Created repository as `Repo`
         """
         """
         if not bare:
         if not bare:
             target = self.init(target_path, mkdir=mkdir)
             target = self.init(target_path, mkdir=mkdir)
@@ -1179,7 +1212,8 @@ class Repo(BaseRepo):
     def reset_index(self, tree=None):
     def reset_index(self, tree=None):
         """Reset the index back to a specific tree.
         """Reset the index back to a specific tree.
 
 
-        :param tree: Tree SHA to reset to, None for current HEAD tree.
+        Args:
+          tree: Tree SHA to reset to, None for current HEAD tree.
         """
         """
         from dulwich.index import (
         from dulwich.index import (
             build_index_from_tree,
             build_index_from_tree,
@@ -1203,7 +1237,7 @@ class Repo(BaseRepo):
     def get_config(self):
     def get_config(self):
         """Retrieve the config object.
         """Retrieve the config object.
 
 
-        :return: `ConfigFile` object for the ``.git/config`` file.
+        Returns: `ConfigFile` object for the ``.git/config`` file.
         """
         """
         from dulwich.config import ConfigFile
         from dulwich.config import ConfigFile
         path = os.path.join(self._controldir, 'config')
         path = os.path.join(self._controldir, 'config')
@@ -1219,7 +1253,7 @@ class Repo(BaseRepo):
     def get_description(self):
     def get_description(self):
         """Retrieve the description of this repository.
         """Retrieve the description of this repository.
 
 
-        :return: A string describing the repository or None.
+        Returns: A string describing the repository or None.
         """
         """
         path = os.path.join(self._controldir, 'description')
         path = os.path.join(self._controldir, 'description')
         try:
         try:
@@ -1236,7 +1270,8 @@ class Repo(BaseRepo):
     def set_description(self, description):
     def set_description(self, description):
         """Set the description for this repository.
         """Set the description for this repository.
 
 
-        :param description: Text to set as description for this repository.
+        Args:
+          description: Text to set as description for this repository.
         """
         """
 
 
         self._put_named_file('description', description)
         self._put_named_file('description', description)
@@ -1255,9 +1290,10 @@ class Repo(BaseRepo):
     def init(cls, path, mkdir=False):
     def init(cls, path, mkdir=False):
         """Create a new repository.
         """Create a new repository.
 
 
-        :param path: Path in which to create the repository
-        :param mkdir: Whether to create the directory
-        :return: `Repo` instance
+        Args:
+          path: Path in which to create the repository
+          mkdir: Whether to create the directory
+        Returns: `Repo` instance
         """
         """
         if mkdir:
         if mkdir:
             os.mkdir(path)
             os.mkdir(path)
@@ -1272,11 +1308,12 @@ class Repo(BaseRepo):
                                     mkdir=False):
                                     mkdir=False):
         """Create a new working directory linked to a repository.
         """Create a new working directory linked to a repository.
 
 
-        :param path: Path in which to create the working tree.
-        :param main_repo: Main repository to reference
-        :param identifier: Worktree identifier
-        :param mkdir: Whether to create the directory
-        :return: `Repo` instance
+        Args:
+          path: Path in which to create the working tree.
+          main_repo: Main repository to reference
+          identifier: Worktree identifier
+          mkdir: Whether to create the directory
+        Returns: `Repo` instance
         """
         """
         if mkdir:
         if mkdir:
             os.mkdir(path)
             os.mkdir(path)
@@ -1315,8 +1352,9 @@ class Repo(BaseRepo):
 
 
         ``path`` should already exist and be an empty directory.
         ``path`` should already exist and be an empty directory.
 
 
-        :param path: Path to create bare repository in
-        :return: a `Repo` instance
+        Args:
+          path: Path to create bare repository in
+        Returns: a `Repo` instance
         """
         """
         if mkdir:
         if mkdir:
             os.mkdir(path)
             os.mkdir(path)
@@ -1373,15 +1411,16 @@ class MemoryRepo(BaseRepo):
     def _determine_file_mode(self):
     def _determine_file_mode(self):
         """Probe the file-system to determine whether permissions can be trusted.
         """Probe the file-system to determine whether permissions can be trusted.
 
 
-        :return: True if permissions can be trusted, False otherwise.
+        Returns: True if permissions can be trusted, False otherwise.
         """
         """
         return sys.platform != 'win32'
         return sys.platform != 'win32'
 
 
     def _put_named_file(self, path, contents):
     def _put_named_file(self, path, contents):
         """Write a file to the control dir with the given name and contents.
         """Write a file to the control dir with the given name and contents.
 
 
-        :param path: The path to the file, relative to the control dir.
-        :param contents: A string to write to the file.
+        Args:
+          path: The path to the file, relative to the control dir.
+          contents: A string to write to the file.
         """
         """
         self._named_files[path] = contents
         self._named_files[path] = contents
 
 
@@ -1398,8 +1437,9 @@ class MemoryRepo(BaseRepo):
         the control dir in a disk-baked Repo, the object returned need not be
         the control dir in a disk-baked Repo, the object returned need not be
         pointing to a file in that location.
         pointing to a file in that location.
 
 
-        :param path: The path to the file, relative to the control dir.
-        :return: An open file object, or None if the file does not exist.
+        Args:
+          path: The path to the file, relative to the control dir.
+        Returns: An open file object, or None if the file does not exist.
         """
         """
         contents = self._named_files.get(path, None)
         contents = self._named_files.get(path, None)
         if contents is None:
         if contents is None:
@@ -1409,14 +1449,15 @@ class MemoryRepo(BaseRepo):
     def open_index(self):
     def open_index(self):
         """Fail to open index for this repo, since it is bare.
         """Fail to open index for this repo, since it is bare.
 
 
-        :raise NoIndexPresent: Raised when no index is present
+        Raises:
+          NoIndexPresent: Raised when no index is present
         """
         """
         raise NoIndexPresent()
         raise NoIndexPresent()
 
 
     def get_config(self):
     def get_config(self):
         """Retrieve the config object.
         """Retrieve the config object.
 
 
-        :return: `ConfigFile` object.
+        Returns: `ConfigFile` object.
         """
         """
         return self._config
         return self._config
 
 
@@ -1424,9 +1465,10 @@ class MemoryRepo(BaseRepo):
     def init_bare(cls, objects, refs):
     def init_bare(cls, objects, refs):
         """Create a new bare repository in memory.
         """Create a new bare repository in memory.
 
 
-        :param objects: Objects for the new repository,
+        Args:
+          objects: Objects for the new repository,
             as iterable
             as iterable
-        :param refs: Refs as dictionary, mapping names
+          refs: Refs as dictionary, mapping names
             to object SHA1s
             to object SHA1s
         """
         """
         ret = cls()
         ret = cls()

+ 50 - 36
dulwich/server.py

@@ -127,9 +127,11 @@ class Backend(object):
     def open_repository(self, path):
     def open_repository(self, path):
         """Open the repository at a path.
         """Open the repository at a path.
 
 
-        :param path: Path to the repository
-        :raise NotGitRepository: no git repository was found at path
-        :return: Instance of BackendRepo
+        Args:
+          path: Path to the repository
+        Raises:
+          NotGitRepository: no git repository was found at path
+        Returns: Instance of BackendRepo
         """
         """
         raise NotImplementedError(self.open_repository)
         raise NotImplementedError(self.open_repository)
 
 
@@ -148,15 +150,16 @@ class BackendRepo(object):
         """
         """
         Get all the refs in the repository
         Get all the refs in the repository
 
 
-        :return: dict of name -> sha
+        Returns: dict of name -> sha
         """
         """
         raise NotImplementedError
         raise NotImplementedError
 
 
     def get_peeled(self, name):
     def get_peeled(self, name):
         """Return the cached peeled value of a ref, if available.
         """Return the cached peeled value of a ref, if available.
 
 
-        :param name: Name of the ref to peel
-        :return: The peeled value of the ref. If the ref is known not point to
+        Args:
+          name: Name of the ref to peel
+        Returns: The peeled value of the ref. If the ref is known not point to
             a tag, this will be the SHA the ref refers to. If no cached
             a tag, this will be the SHA the ref refers to. If no cached
             information about a tag is available, this method may return None,
             information about a tag is available, this method may return None,
             but it should attempt to peel the tag if possible.
             but it should attempt to peel the tag if possible.
@@ -168,8 +171,9 @@ class BackendRepo(object):
         """
         """
         Yield the objects required for a list of commits.
         Yield the objects required for a list of commits.
 
 
-        :param progress: is a callback to send progress messages to the client
-        :param get_tagged: Function that returns a dict of pointed-to sha ->
+        Args:
+          progress: is a callback to send progress messages to the client
+          get_tagged: Function that returns a dict of pointed-to sha ->
             tag sha for including tags.
             tag sha for including tags.
         """
         """
         raise NotImplementedError
         raise NotImplementedError
@@ -312,11 +316,12 @@ class UploadPackHandler(PackHandler):
     def get_tagged(self, refs=None, repo=None):
     def get_tagged(self, refs=None, repo=None):
         """Get a dict of peeled values of tags to their original tag shas.
         """Get a dict of peeled values of tags to their original tag shas.
 
 
-        :param refs: dict of refname -> sha of possible tags; defaults to all
+        Args:
+          refs: dict of refname -> sha of possible tags; defaults to all
             of the backend's refs.
             of the backend's refs.
-        :param repo: optional Repo instance for getting peeled refs; defaults
+          repo: optional Repo instance for getting peeled refs; defaults
             to the backend's repo, if available
             to the backend's repo, if available
-        :return: dict of peeled_sha -> tag_sha, where tag_sha is the sha of a
+        Returns: dict of peeled_sha -> tag_sha, where tag_sha is the sha of a
             tag whose peeled value is peeled_sha.
             tag whose peeled value is peeled_sha.
         """
         """
         if not self.has_capability(CAPABILITY_INCLUDE_TAG):
         if not self.has_capability(CAPABILITY_INCLUDE_TAG):
@@ -385,18 +390,20 @@ class UploadPackHandler(PackHandler):
 def _split_proto_line(line, allowed):
 def _split_proto_line(line, allowed):
     """Split a line read from the wire.
     """Split a line read from the wire.
 
 
-    :param line: The line read from the wire.
-    :param allowed: An iterable of command names that should be allowed.
+    Args:
+      line: The line read from the wire.
+      allowed: An iterable of command names that should be allowed.
         Command names not listed below as possible return values will be
         Command names not listed below as possible return values will be
         ignored.  If None, any commands from the possible return values are
         ignored.  If None, any commands from the possible return values are
         allowed.
         allowed.
-    :return: a tuple having one of the following forms:
+    Returns: a tuple having one of the following forms:
         ('want', obj_id)
         ('want', obj_id)
         ('have', obj_id)
         ('have', obj_id)
         ('done', None)
         ('done', None)
         (None, None)  (for a flush-pkt)
         (None, None)  (for a flush-pkt)
 
 
-    :raise UnexpectedCommandError: if the line cannot be parsed into one of the
+    Raises:
+      UnexpectedCommandError: if the line cannot be parsed into one of the
         allowed return values.
         allowed return values.
     """
     """
     if not line:
     if not line:
@@ -422,11 +429,12 @@ def _split_proto_line(line, allowed):
 def _find_shallow(store, heads, depth):
 def _find_shallow(store, heads, depth):
     """Find shallow commits according to a given depth.
     """Find shallow commits according to a given depth.
 
 
-    :param store: An ObjectStore for looking up objects.
-    :param heads: Iterable of head SHAs to start walking from.
-    :param depth: The depth of ancestors to include. A depth of one includes
+    Args:
+      store: An ObjectStore for looking up objects.
+      heads: Iterable of head SHAs to start walking from.
+      depth: The depth of ancestors to include. A depth of one includes
         only the heads themselves.
         only the heads themselves.
-    :return: A tuple of (shallow, not_shallow), sets of SHAs that should be
+    Returns: A tuple of (shallow, not_shallow), sets of SHAs that should be
         considered shallow and unshallow according to the arguments. Note that
         considered shallow and unshallow according to the arguments. Note that
         these sets may overlap if a commit is reachable along multiple paths.
         these sets may overlap if a commit is reachable along multiple paths.
     """
     """
@@ -484,10 +492,11 @@ def _want_satisfied(store, haves, want, earliest):
 def _all_wants_satisfied(store, haves, wants):
 def _all_wants_satisfied(store, haves, wants):
     """Check whether all the current wants are satisfied by a set of haves.
     """Check whether all the current wants are satisfied by a set of haves.
 
 
-    :param store: Object store to retrieve objects from
-    :param haves: A set of commits we know the client has.
-    :param wants: A set of commits the client wants
-    :note: Wants are specified with set_wants rather than passed in since
+    Args:
+      store: Object store to retrieve objects from
+      haves: A set of commits we know the client has.
+      wants: A set of commits the client wants
+    Note: Wants are specified with set_wants rather than passed in since
         in the current interface they are determined outside this class.
         in the current interface they are determined outside this class.
     """
     """
     haves = set(haves)
     haves = set(haves)
@@ -546,8 +555,9 @@ class _ProtocolGraphWalker(object):
         walking the graph. Additionally, later code depends on this method
         walking the graph. Additionally, later code depends on this method
         consuming everything up to the first 'have' line.
         consuming everything up to the first 'have' line.
 
 
-        :param heads: a dict of refname->SHA1 to advertise
-        :return: a list of SHA1s requested by the client
+        Args:
+          heads: a dict of refname->SHA1 to advertise
+        Returns: a list of SHA1s requested by the client
         """
         """
         symrefs = self.get_symrefs()
         symrefs = self.get_symrefs()
         values = set(heads.values())
         values = set(heads.values())
@@ -638,9 +648,11 @@ class _ProtocolGraphWalker(object):
     def read_proto_line(self, allowed):
     def read_proto_line(self, allowed):
         """Read a line from the wire.
         """Read a line from the wire.
 
 
-        :param allowed: An iterable of command names that should be allowed.
-        :return: A tuple of (command, value); see _split_proto_line.
-        :raise UnexpectedCommandError: If an error occurred reading the line.
+        Args:
+          allowed: An iterable of command names that should be allowed.
+        Returns: A tuple of (command, value); see _split_proto_line.
+        Raises:
+          UnexpectedCommandError: If an error occurred reading the line.
         """
         """
         return _split_proto_line(self.proto.read_pkt_line(), allowed)
         return _split_proto_line(self.proto.read_pkt_line(), allowed)
 
 
@@ -691,8 +703,9 @@ class _ProtocolGraphWalker(object):
     def all_wants_satisfied(self, haves):
     def all_wants_satisfied(self, haves):
         """Check whether all the current wants are satisfied by a set of haves.
         """Check whether all the current wants are satisfied by a set of haves.
 
 
-        :param haves: A set of commits we know the client has.
-        :note: Wants are specified with set_wants rather than passed in since
+        Args:
+          haves: A set of commits we know the client has.
+        Note: Wants are specified with set_wants rather than passed in since
             in the current interface they are determined outside this class.
             in the current interface they are determined outside this class.
         """
         """
         return _all_wants_satisfied(self.store, haves, self._wants)
         return _all_wants_satisfied(self.store, haves, self._wants)
@@ -1133,12 +1146,13 @@ def serve_command(handler_cls, argv=sys.argv, backend=None, inf=sys.stdin,
     This is mostly useful for the implementation of commands used by e.g.
     This is mostly useful for the implementation of commands used by e.g.
     git+ssh.
     git+ssh.
 
 
-    :param handler_cls: `Handler` class to use for the request
-    :param argv: execv-style command-line arguments. Defaults to sys.argv.
-    :param backend: `Backend` to use
-    :param inf: File-like object to read from, defaults to standard input.
-    :param outf: File-like object to write to, defaults to standard output.
-    :return: Exit code for use with sys.exit. 0 on success, 1 on failure.
+    Args:
+      handler_cls: `Handler` class to use for the request
+      argv: execv-style command-line arguments. Defaults to sys.argv.
+      backend: `Backend` to use
+      inf: File-like object to read from, defaults to standard input.
+      outf: File-like object to write to, defaults to standard output.
+    Returns: Exit code for use with sys.exit. 0 on success, 1 on failure.
     """
     """
     if backend is None:
     if backend is None:
         backend = FileSystemBackend()
         backend = FileSystemBackend()

+ 4 - 3
dulwich/stash.py

@@ -72,9 +72,10 @@ class Stash(object):
     def push(self, committer=None, author=None, message=None):
     def push(self, committer=None, author=None, message=None):
         """Create a new stash.
         """Create a new stash.
 
 
-        :param committer: Optional committer name to use
-        :param author: Optional author name to use
-        :param message: Optional commit message
+        Args:
+          committer: Optional committer name to use
+          author: Optional author name to use
+          message: Optional commit message
         """
         """
         # First, create the index commit.
         # First, create the index commit.
         commit_kwargs = {}
         commit_kwargs = {}

+ 6 - 4
dulwich/tests/__init__.py

@@ -64,8 +64,9 @@ class BlackboxTestCase(TestCase):
     def bin_path(self, name):
     def bin_path(self, name):
         """Determine the full path of a binary.
         """Determine the full path of a binary.
 
 
-        :param name: Name of the script
-        :return: Full path
+        Args:
+          name: Name of the script
+        Returns: Full path
         """
         """
         for d in self.bin_directories:
         for d in self.bin_directories:
             p = os.path.join(d, name)
             p = os.path.join(d, name)
@@ -77,8 +78,9 @@ class BlackboxTestCase(TestCase):
     def run_command(self, name, args):
     def run_command(self, name, args):
         """Run a Dulwich command.
         """Run a Dulwich command.
 
 
-        :param name: Name of the command, as it exists in bin/
-        :param args: Arguments to the command
+        Args:
+          name: Name of the command, as it exists in bin/
+          args: Arguments to the command
         """
         """
         env = dict(os.environ)
         env = dict(os.environ)
         env["PYTHONPATH"] = os.pathsep.join(sys.path)
         env["PYTHONPATH"] = os.pathsep.join(sys.path)

+ 4 - 3
dulwich/tests/compat/test_repository.py

@@ -133,10 +133,11 @@ class WorkingTreeTestCase(ObjectStoreTestCase):
     def create_new_worktree(self, repo_dir, branch):
     def create_new_worktree(self, repo_dir, branch):
         """Create a new worktree using git-worktree.
         """Create a new worktree using git-worktree.
 
 
-        :param repo_dir: The directory of the main working tree.
-        :param branch: The branch or commit to checkout in the new worktree.
+        Args:
+          repo_dir: The directory of the main working tree.
+          branch: The branch or commit to checkout in the new worktree.
 
 
-        :returns: The path to the new working tree.
+        Returns: The path to the new working tree.
         """
         """
         temp_dir = tempfile.mkdtemp()
         temp_dir = tempfile.mkdtemp()
         run_git_or_fail(['worktree', 'add', temp_dir, branch],
         run_git_or_fail(['worktree', 'add', temp_dir, branch],

+ 30 - 22
dulwich/tests/compat/utils.py

@@ -48,9 +48,10 @@ _REPOS_DATA_DIR = os.path.abspath(os.path.join(
 def git_version(git_path=_DEFAULT_GIT):
 def git_version(git_path=_DEFAULT_GIT):
     """Attempt to determine the version of git currently installed.
     """Attempt to determine the version of git currently installed.
 
 
-    :param git_path: Path to the git executable; defaults to the version in
+    Args:
+      git_path: Path to the git executable; defaults to the version in
         the system path.
         the system path.
-    :return: A tuple of ints of the form (major, minor, point, sub-point), or
+    Returns: A tuple of ints of the form (major, minor, point, sub-point), or
         None if no git installation was found.
         None if no git installation was found.
     """
     """
     try:
     try:
@@ -77,12 +78,14 @@ def git_version(git_path=_DEFAULT_GIT):
 def require_git_version(required_version, git_path=_DEFAULT_GIT):
 def require_git_version(required_version, git_path=_DEFAULT_GIT):
     """Require git version >= version, or skip the calling test.
     """Require git version >= version, or skip the calling test.
 
 
-    :param required_version: A tuple of ints of the form (major, minor, point,
+    Args:
+      required_version: A tuple of ints of the form (major, minor, point,
         sub-point); ommitted components default to 0.
         sub-point); ommitted components default to 0.
-    :param git_path: Path to the git executable; defaults to the version in
+      git_path: Path to the git executable; defaults to the version in
         the system path.
         the system path.
-    :raise ValueError: if the required version tuple has too many parts.
-    :raise SkipTest: if no suitable git version was found at the given path.
+    Raises:
+      ValueError: if the required version tuple has too many parts.
+      SkipTest: if no suitable git version was found at the given path.
     """
     """
     found_version = git_version(git_path=git_path)
     found_version = git_version(git_path=git_path)
     if found_version is None:
     if found_version is None:
@@ -112,15 +115,17 @@ def run_git(args, git_path=_DEFAULT_GIT, input=None, capture_stdout=False,
     Input is piped from the input parameter and output is sent to the standard
     Input is piped from the input parameter and output is sent to the standard
     streams, unless capture_stdout is set.
     streams, unless capture_stdout is set.
 
 
-    :param args: A list of args to the git command.
-    :param git_path: Path to to the git executable.
-    :param input: Input data to be sent to stdin.
-    :param capture_stdout: Whether to capture and return stdout.
-    :param popen_kwargs: Additional kwargs for subprocess.Popen;
+    Args:
+      args: A list of args to the git command.
+      git_path: Path to to the git executable.
+      input: Input data to be sent to stdin.
+      capture_stdout: Whether to capture and return stdout.
+      popen_kwargs: Additional kwargs for subprocess.Popen;
         stdin/stdout args are ignored.
         stdin/stdout args are ignored.
-    :return: A tuple of (returncode, stdout contents). If capture_stdout is
+    Returns: A tuple of (returncode, stdout contents). If capture_stdout is
         False, None will be returned as stdout contents.
         False, None will be returned as stdout contents.
-    :raise OSError: if the git executable was not found.
+    Raises:
+      OSError: if the git executable was not found.
     """
     """
 
 
     env = popen_kwargs.pop('env', {})
     env = popen_kwargs.pop('env', {})
@@ -155,9 +160,10 @@ def import_repo_to_dir(name):
     These are used rather than binary repos for compat tests because they are
     These are used rather than binary repos for compat tests because they are
     more compact and human-editable, and we already depend on git.
     more compact and human-editable, and we already depend on git.
 
 
-    :param name: The name of the repository export file, relative to
+    Args:
+      name: The name of the repository export file, relative to
         dulwich/tests/data/repos.
         dulwich/tests/data/repos.
-    :returns: The path to the imported repository.
+    Returns: The path to the imported repository.
     """
     """
     temp_dir = tempfile.mkdtemp()
     temp_dir = tempfile.mkdtemp()
     export_path = os.path.join(_REPOS_DATA_DIR, name)
     export_path = os.path.join(_REPOS_DATA_DIR, name)
@@ -175,11 +181,12 @@ def check_for_daemon(limit=10, delay=0.1, timeout=0.1, port=TCP_GIT_PORT):
 
 
     Defaults to checking 10 times with a delay of 0.1 sec between tries.
     Defaults to checking 10 times with a delay of 0.1 sec between tries.
 
 
-    :param limit: Number of attempts before deciding no daemon is running.
-    :param delay: Delay between connection attempts.
-    :param timeout: Socket timeout for connection attempts.
-    :param port: Port on which we expect the daemon to appear.
-    :returns: A boolean, true if a daemon is running on the specified port,
+    Args:
+      limit: Number of attempts before deciding no daemon is running.
+      delay: Delay between connection attempts.
+      timeout: Socket timeout for connection attempts.
+      port: Port on which we expect the daemon to appear.
+    Returns: A boolean, true if a daemon is running on the specified port,
         false if not.
         false if not.
     """
     """
     for _ in range(limit):
     for _ in range(limit):
@@ -231,9 +238,10 @@ class CompatTestCase(TestCase):
     def import_repo(self, name):
     def import_repo(self, name):
         """Import a repo from a fast-export file in a temporary directory.
         """Import a repo from a fast-export file in a temporary directory.
 
 
-        :param name: The name of the repository export file, relative to
+        Args:
+          name: The name of the repository export file, relative to
             dulwich/tests/data/repos.
             dulwich/tests/data/repos.
-        :returns: An initialized Repo object that lives in a temporary
+        Returns: An initialized Repo object that lives in a temporary
             directory.
             directory.
         """
         """
         path = import_repo_to_dir(name)
         path = import_repo_to_dir(name)

+ 3 - 2
dulwich/tests/test_fastexport.py

@@ -213,8 +213,9 @@ M 100644 :1 a
     def make_file_commit(self, file_cmds):
     def make_file_commit(self, file_cmds):
         """Create a trivial commit with the specified file commands.
         """Create a trivial commit with the specified file commands.
 
 
-        :param file_cmds: File commands to run.
-        :return: The created commit object
+        Args:
+          file_cmds: File commands to run.
+        Returns: The created commit object
         """
         """
         from fastimport import commands
         from fastimport import commands
         cmd = commands.CommitCommand(
         cmd = commands.CommitCommand(

+ 30 - 22
dulwich/tests/utils.py

@@ -67,11 +67,12 @@ def open_repo(name, temp_dir=None):
     accidentally or intentionally modifying those repos in place. Use
     accidentally or intentionally modifying those repos in place. Use
     tear_down_repo to delete any temp files created.
     tear_down_repo to delete any temp files created.
 
 
-    :param name: The name of the repository, relative to
+    Args:
+      name: The name of the repository, relative to
         dulwich/tests/data/repos
         dulwich/tests/data/repos
-    :param temp_dir: temporary directory to initialize to. If not provided, a
+      temp_dir: temporary directory to initialize to. If not provided, a
         temporary directory will be created.
         temporary directory will be created.
-    :returns: An initialized Repo object that lives in a temporary directory.
+    Returns: An initialized Repo object that lives in a temporary directory.
     """
     """
     if temp_dir is None:
     if temp_dir is None:
         temp_dir = tempfile.mkdtemp()
         temp_dir = tempfile.mkdtemp()
@@ -95,8 +96,9 @@ def make_object(cls, **attrs):
     reassignment, which is not otherwise possible with objects having
     reassignment, which is not otherwise possible with objects having
     __slots__.
     __slots__.
 
 
-    :param attrs: dict of attributes to set on the new object.
-    :return: A newly initialized object of type cls.
+    Args:
+      attrs: dict of attributes to set on the new object.
+    Returns: A newly initialized object of type cls.
     """
     """
 
 
     class TestObject(cls):
     class TestObject(cls):
@@ -123,8 +125,9 @@ def make_object(cls, **attrs):
 def make_commit(**attrs):
 def make_commit(**attrs):
     """Make a Commit object with a default set of members.
     """Make a Commit object with a default set of members.
 
 
-    :param attrs: dict of attributes to overwrite from the default values.
-    :return: A newly initialized Commit object.
+    Args:
+      attrs: dict of attributes to overwrite from the default values.
+    Returns: A newly initialized Commit object.
     """
     """
     default_time = 1262304000  # 2010-01-01 00:00:00
     default_time = 1262304000  # 2010-01-01 00:00:00
     all_attrs = {'author': b'Test Author <test@nodomain.com>',
     all_attrs = {'author': b'Test Author <test@nodomain.com>',
@@ -143,9 +146,10 @@ def make_commit(**attrs):
 def make_tag(target, **attrs):
 def make_tag(target, **attrs):
     """Make a Tag object with a default set of values.
     """Make a Tag object with a default set of values.
 
 
-    :param target: object to be tagged (Commit, Blob, Tree, etc)
-    :param attrs: dict of attributes to overwrite from the default values.
-    :return: A newly initialized Tag object.
+    Args:
+      target: object to be tagged (Commit, Blob, Tree, etc)
+      attrs: dict of attributes to overwrite from the default values.
+    Returns: A newly initialized Tag object.
     """
     """
     target_id = target.id
     target_id = target.id
     target_type = object_class(target.type_name)
     target_type = object_class(target.type_name)
@@ -186,9 +190,10 @@ def ext_functest_builder(method, func):
         test_foo = functest_builder(_do_some_test, foo_py)
         test_foo = functest_builder(_do_some_test, foo_py)
         test_foo_extension = ext_functest_builder(_do_some_test, _foo_c)
         test_foo_extension = ext_functest_builder(_do_some_test, _foo_c)
 
 
-    :param method: The method to run. It must must two parameters, self and the
+    Args:
+      method: The method to run. It must must two parameters, self and the
         function implementation to test.
         function implementation to test.
-    :param func: The function implementation to pass to method.
+      func: The function implementation to pass to method.
     """
     """
 
 
     def do_test(self):
     def do_test(self):
@@ -202,8 +207,9 @@ def ext_functest_builder(method, func):
 def build_pack(f, objects_spec, store=None):
 def build_pack(f, objects_spec, store=None):
     """Write test pack data from a concise spec.
     """Write test pack data from a concise spec.
 
 
-    :param f: A file-like object to write the pack to.
-    :param objects_spec: A list of (type_num, obj). For non-delta types, obj
+    Args:
+      f: A file-like object to write the pack to.
+      objects_spec: A list of (type_num, obj). For non-delta types, obj
         is the string of that object's data.
         is the string of that object's data.
         For delta types, obj is a tuple of (base, data), where:
         For delta types, obj is a tuple of (base, data), where:
 
 
@@ -213,8 +219,8 @@ def build_pack(f, objects_spec, store=None):
         * data is a string of the full, non-deltified data for that object.
         * data is a string of the full, non-deltified data for that object.
 
 
         Note that offsets/refs and deltas are computed within this function.
         Note that offsets/refs and deltas are computed within this function.
-    :param store: An optional ObjectStore for looking up external refs.
-    :return: A list of tuples in the order specified by objects_spec:
+      store: An optional ObjectStore for looking up external refs.
+    Returns: A list of tuples in the order specified by objects_spec:
         (offset, type num, data, sha, CRC32)
         (offset, type num, data, sha, CRC32)
     """
     """
     sf = SHA1Writer(f)
     sf = SHA1Writer(f)
@@ -285,21 +291,23 @@ def build_commit_graph(object_store, commit_spec, trees=None, attrs=None):
     If not otherwise specified, commits will refer to the empty tree and have
     If not otherwise specified, commits will refer to the empty tree and have
     commit times increasing in the same order as the commit spec.
     commit times increasing in the same order as the commit spec.
 
 
-    :param object_store: An ObjectStore to commit objects to.
-    :param commit_spec: An iterable of iterables of ints defining the commit
+    Args:
+      object_store: An ObjectStore to commit objects to.
+      commit_spec: An iterable of iterables of ints defining the commit
         graph. Each entry defines one commit, and entries must be in
         graph. Each entry defines one commit, and entries must be in
         topological order. The first element of each entry is a commit number,
         topological order. The first element of each entry is a commit number,
         and the remaining elements are its parents. The commit numbers are only
         and the remaining elements are its parents. The commit numbers are only
         meaningful for the call to make_commits; since real commit objects are
         meaningful for the call to make_commits; since real commit objects are
         created, they will get created with real, opaque SHAs.
         created, they will get created with real, opaque SHAs.
-    :param trees: An optional dict of commit number -> tree spec for building
+      trees: An optional dict of commit number -> tree spec for building
         trees for commits. The tree spec is an iterable of (path, blob, mode)
         trees for commits. The tree spec is an iterable of (path, blob, mode)
         or (path, blob) entries; if mode is omitted, it defaults to the normal
         or (path, blob) entries; if mode is omitted, it defaults to the normal
         file mode (0100644).
         file mode (0100644).
-    :param attrs: A dict of commit number -> (dict of attribute -> value) for
+      attrs: A dict of commit number -> (dict of attribute -> value) for
         assigning additional values to the commits.
         assigning additional values to the commits.
-    :return: The list of commit objects created.
-    :raise ValueError: If an undefined commit identifier is listed as a parent.
+    Returns: The list of commit objects created.
+    Raises:
+      ValueError: If an undefined commit identifier is listed as a parent.
     """
     """
     if trees is None:
     if trees is None:
         trees = {}
         trees = {}

+ 27 - 22
dulwich/walk.py

@@ -60,10 +60,11 @@ class WalkEntry(object):
     def changes(self, path_prefix=None):
     def changes(self, path_prefix=None):
         """Get the tree changes for this entry.
         """Get the tree changes for this entry.
 
 
-        :param path_prefix: Portion of the path in the repository to
+        Args:
+          path_prefix: Portion of the path in the repository to
             use to filter changes. Must be a directory name. Must be
             use to filter changes. Must be a directory name. Must be
             a full, valid, path reference (no partial names or wildcards).
             a full, valid, path reference (no partial names or wildcards).
-        :return: For commits with up to one parent, a list of TreeChange
+        Returns: For commits with up to one parent, a list of TreeChange
             objects; if the commit has no parents, these will be relative to
             objects; if the commit has no parents, these will be relative to
             the empty tree. For merge commits, a list of lists of TreeChange
             the empty tree. For merge commits, a list of lists of TreeChange
             objects; see dulwich.diff.tree_changes_for_merge.
             objects; see dulwich.diff.tree_changes_for_merge.
@@ -238,26 +239,27 @@ class Walker(object):
                  queue_cls=_CommitTimeQueue):
                  queue_cls=_CommitTimeQueue):
         """Constructor.
         """Constructor.
 
 
-        :param store: ObjectStore instance for looking up objects.
-        :param include: Iterable of SHAs of commits to include along with their
+        Args:
+          store: ObjectStore instance for looking up objects.
+          include: Iterable of SHAs of commits to include along with their
             ancestors.
             ancestors.
-        :param exclude: Iterable of SHAs of commits to exclude along with their
+          exclude: Iterable of SHAs of commits to exclude along with their
             ancestors, overriding includes.
             ancestors, overriding includes.
-        :param order: ORDER_* constant specifying the order of results.
+          order: ORDER_* constant specifying the order of results.
             Anything other than ORDER_DATE may result in O(n) memory usage.
             Anything other than ORDER_DATE may result in O(n) memory usage.
-        :param reverse: If True, reverse the order of output, requiring O(n)
+          reverse: If True, reverse the order of output, requiring O(n)
             memory.
             memory.
-        :param max_entries: The maximum number of entries to yield, or None for
+          max_entries: The maximum number of entries to yield, or None for
             no limit.
             no limit.
-        :param paths: Iterable of file or subtree paths to show entries for.
-        :param rename_detector: diff.RenameDetector object for detecting
+          paths: Iterable of file or subtree paths to show entries for.
+          rename_detector: diff.RenameDetector object for detecting
             renames.
             renames.
-        :param follow: If True, follow path across renames/copies. Forces a
+          follow: If True, follow path across renames/copies. Forces a
             default rename_detector.
             default rename_detector.
-        :param since: Timestamp to list commits after.
-        :param until: Timestamp to list commits before.
-        :param get_parents: Method to retrieve the parents of a commit
-        :param queue_cls: A class to use for a queue of commits, supporting the
+          since: Timestamp to list commits after.
+          until: Timestamp to list commits before.
+          get_parents: Method to retrieve the parents of a commit
+          queue_cls: A class to use for a queue of commits, supporting the
             iterator protocol. The constructor takes a single argument, the
             iterator protocol. The constructor takes a single argument, the
             Walker.
             Walker.
         """
         """
@@ -317,8 +319,9 @@ class Walker(object):
     def _should_return(self, entry):
     def _should_return(self, entry):
         """Determine if a walk entry should be returned..
         """Determine if a walk entry should be returned..
 
 
-        :param entry: The WalkEntry to consider.
-        :return: True if the WalkEntry should be returned by this walk, or
+        Args:
+          entry: The WalkEntry to consider.
+        Returns: True if the WalkEntry should be returned by this walk, or
             False otherwise (e.g. if it doesn't match any requested paths).
             False otherwise (e.g. if it doesn't match any requested paths).
         """
         """
         commit = entry.commit
         commit = entry.commit
@@ -364,9 +367,10 @@ class Walker(object):
     def _reorder(self, results):
     def _reorder(self, results):
         """Possibly reorder a results iterator.
         """Possibly reorder a results iterator.
 
 
-        :param results: An iterator of WalkEntry objects, in the order returned
+        Args:
+          results: An iterator of WalkEntry objects, in the order returned
             from the queue_cls.
             from the queue_cls.
-        :return: An iterator or list of WalkEntry objects, in the order
+        Returns: An iterator or list of WalkEntry objects, in the order
             required by the Walker.
             required by the Walker.
         """
         """
         if self.order == ORDER_TOPO:
         if self.order == ORDER_TOPO:
@@ -385,9 +389,10 @@ def _topo_reorder(entries, get_parents=lambda commit: commit.parents):
     This works best assuming the entries are already in almost-topological
     This works best assuming the entries are already in almost-topological
     order, e.g. in commit time order.
     order, e.g. in commit time order.
 
 
-    :param entries: An iterable of WalkEntry objects.
-    :param get_parents: Optional function for getting the parents of a commit.
-    :return: iterator over WalkEntry objects from entries in FIFO order, except
+    Args:
+      entries: An iterable of WalkEntry objects.
+      get_parents: Optional function for getting the parents of a commit.
+    Returns: iterator over WalkEntry objects from entries in FIFO order, except
         where a parent would be yielded before any of its children.
         where a parent would be yielded before any of its children.
     """
     """
     todo = collections.deque()
     todo = collections.deque()

+ 8 - 6
dulwich/web.py

@@ -89,8 +89,9 @@ def date_time_string(timestamp=None):
 def url_prefix(mat):
 def url_prefix(mat):
     """Extract the URL prefix from a regex match.
     """Extract the URL prefix from a regex match.
 
 
-    :param mat: A regex match object.
-    :returns: The URL prefix, defined as the text before the match in the
+    Args:
+      mat: A regex match object.
+    Returns: The URL prefix, defined as the text before the match in the
         original string. Normalized to start with one leading slash and end
         original string. Normalized to start with one leading slash and end
         with zero.
         with zero.
     """
     """
@@ -105,10 +106,11 @@ def get_repo(backend, mat):
 def send_file(req, f, content_type):
 def send_file(req, f, content_type):
     """Send a file-like object to the request output.
     """Send a file-like object to the request output.
 
 
-    :param req: The HTTPGitRequest object to send output to.
-    :param f: An open file-like object to send; will be closed.
-    :param content_type: The MIME type for the file.
-    :return: Iterator over the contents of the file, as chunks.
+    Args:
+      req: The HTTPGitRequest object to send output to.
+      f: An open file-like object to send; will be closed.
+      content_type: The MIME type for the file.
+    Returns: Iterator over the contents of the file, as chunks.
     """
     """
     if f is None:
     if f is None:
         yield req.not_found('File not found')
         yield req.not_found('File not found')