Skip to content

Commit

Permalink
Apply lib2to3.fixes.tuple_params, and provied sensible names and docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
garyvdm committed Apr 2, 2014
1 parent 6ce5aca commit 55124a5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
10 changes: 8 additions & 2 deletions dulwich/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,14 @@ def sorted_tree_items(entries, name_order):
yield TreeEntry(name, mode, hexsha)


def cmp_entry((name1, value1), (name2, value2)):
"""Compare two tree entries in tree order."""
def cmp_entry(entry1, entry2):
"""Compare two tree entries in tree order.
:param entry1: (name, value) tuple
:param entry2: (name, value) tuple
"""
(name1, value1) = entry1
(name2, value2) = entry2
if stat.S_ISDIR(value1[0]):
name1 += "/"
if stat.S_ISDIR(value2[0]):
Expand Down
3 changes: 2 additions & 1 deletion dulwich/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,9 @@ def unpack_object(read_all, read_some=None, compute_crc32=False,
return unpacked, unused


def _compute_object_size((num, obj)):
def _compute_object_size(value):
"""Compute the size of a unresolved object for use with LRUSizeCache."""
(num, obj) = value
if num in DELTA_TYPES:
return chunks_length(obj[1])
return chunks_length(obj)
Expand Down
19 changes: 10 additions & 9 deletions dulwich/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,20 @@ def is_binary(content):
return '\0' in content[:FIRST_FEW_BYTES]


def write_object_diff(f, store, (old_path, old_mode, old_id),
(new_path, new_mode, new_id),
diff_binary=False):
def write_object_diff(f, store, old_file, new_file, diff_binary=False):
"""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_path, old_mode, old_hexsha): Old file
:param (new_path, new_mode, new_hexsha): New file
:param old_file: (path, mode, hexsha) tuple
:param new_file: (path, mode, hexsha) tuple
:param diff_binary: Whether to diff files even if they
are considered binary files by is_binary().
:note: the tuple elements should be None for nonexistant files
"""
(old_path, old_mode, old_id) = old_file
(new_path, new_mode, new_id) = new_file
def shortid(hexsha):
if hexsha is None:
return "0" * 7
Expand Down Expand Up @@ -177,16 +177,17 @@ def lines(content):
old_path, new_path))


def write_blob_diff(f, (old_path, old_mode, old_blob),
(new_path, new_mode, new_blob)):
def write_blob_diff(f, old_file, new_file):
"""Write diff file header.
:param f: File-like object to write to
:param (old_path, old_mode, old_blob): Previous file (None if nonexisting)
:param (new_path, new_mode, new_blob): New file (None if nonexisting)
:param old_file: (path, mode, hexsha) tuple (None if nonexisting)
:param new_file: (path, mode, hexsha) tuple (None if nonexisting)
:note: The use of write_object_diff is recommended over this function.
"""
(old_path, old_mode, old_blob) = old_file
(new_path, new_mode, new_blob) = new_file
def blob_id(blob):
if blob is None:
return "0" * 7
Expand Down
3 changes: 2 additions & 1 deletion dulwich/tests/compat/server_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,9 @@ def capabilities(cls):
if c != 'side-band-64k')


def ignore_error((e_type, e_value, e_tb)):
def ignore_error(error):
"""Check whether this error is safe to ignore."""
(e_type, e_value, e_tb) = error
return (issubclass(e_type, socket.error) and
e_value[0] in (errno.ECONNRESET, errno.EPIPE))

0 comments on commit 55124a5

Please sign in to comment.