瀏覽代碼

send_pack: simplify filtering of unsupported ref deletions

The previous implementation used filter() over a nontrivial nested
function with side-effects. A simple loop is a bit more readable.

Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Mike Edgar 10 年之前
父節點
當前提交
a1459ff04a
共有 1 個文件被更改,包括 5 次插入11 次删除
  1. 5 11
      dulwich/client.py

+ 5 - 11
dulwich/client.py

@@ -455,21 +455,15 @@ class TraditionalGitClient(GitClient):
 
             if not 'delete-refs' in server_capabilities:
                 # Server does not support deletions. Fail later.
-                def remove_del(pair):
-                    if pair[1] == ZERO_SHA:
+                new_refs = dict(orig_new_refs)
+                for ref, sha in orig_new_refs.iteritems():
+                    if sha == ZERO_SHA:
                         if 'report-status' in negotiated_capabilities:
                             report_status_parser._ref_statuses.append(
                                 'ng %s remote does not support deleting refs'
-                                % pair[1])
+                                % sha)
                             report_status_parser._ref_status_ok = False
-                        return False
-                    else:
-                        return True
-
-                new_refs = dict(
-                    filter(
-                        remove_del,
-                        [(ref, sha) for ref, sha in new_refs.iteritems()]))
+                        del new_refs[ref]
 
             if new_refs is None:
                 proto.write_pkt_line(None)