File: 0001-Fix-API-breakage-in-dulwich-0.21.patch

package info (click to toggle)
hg-git 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,432 kB
  • sloc: python: 8,200; sh: 185; makefile: 23
file content (64 lines) | stat: -rw-r--r-- 2,351 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From: =?utf-8?q?Timo_R=C3=B6hling?= <roehling@debian.org>
Date: Mon, 6 Feb 2023 22:42:45 +0100
Subject: Fix API breakage in dulwich 0.21

---
 hggit/git_handler.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/hggit/git_handler.py b/hggit/git_handler.py
index 1dd1158..e0d6332 100644
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -16,6 +16,7 @@ from dulwich.refs import (
     LOCAL_TAG_PREFIX,
 )
 from dulwich.repo import Repo, check_ref_format
+from dulwich.object_store import MissingObjectFinder
 from dulwich import client
 from dulwich import config as dul_config
 from dulwich import diff_tree
@@ -72,6 +73,20 @@ RE_GIT_TOTALS_LINE = re.compile(
 RE_AUTHOR_FILE = re.compile(br'\s*=\s*')
 
 
+def move_in_pack(store, path, f):
+    """Move a specific file containing a pack into the pack directory.
+    Note: The file should be on the same file system as the
+        packs directory.
+    Args:
+      path: Path to the pack file.
+    """
+    from dulwich.pack import PackData, PackIndexer
+    f.seek(0)
+    with PackData(path, f) as pd:
+        indexer = PackIndexer.for_pack_data(pd, resolve_ext_ref=store.get_raw)
+        return store._complete_pack(f, path, len(pd), indexer)
+
+
 class GitProgress(object):
     """convert git server progress strings into mercurial progress
 
@@ -1372,10 +1387,7 @@ class GitHandler(object):
             commits = []
 
             with util.abort_push_on_keyerror():
-                missing = self.git.object_store.find_missing_objects(
-                    have,
-                    want,
-                )
+                missing = MissingObjectFinder(self.git.object_store, have, want)
 
             for sha, name in missing:
                 o = self.git.object_store[sha]
@@ -1538,9 +1550,7 @@ class GitHandler(object):
             if f.tell() != 0:
                 if move:
                     self.ui.debug(b'moving git pack into %s\n' % self.gitdir)
-                    # windows might have issues moving an open file?
-                    f.close()
-                    self.git.object_store.move_in_pack(f.name)
+                    move_in_pack(self.git.object_store, f.name, f)
                     delete = False
                 else:
                     self.ui.debug(b'adding git pack to %s\n' % self.gitdir)