summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-07-27 16:50:11 +0200
committerIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2021-08-05 14:09:08 +0000
commit3dc25c6c35dc1067560cc27e894cee992dc600d8 (patch)
tree33eb2f4d8a76a75ac8fa8811ccf2e825a2c86c05
parent0c603672be63f86731916b26e99d696f1c8bdc7f (diff)
Adapt to dulwich.index.IndexEntry changing size
Somewhere between 0.20.15 and 0.20.23 IndexEntry grew an extraflags parameter that must be supplied to the constructor. So work round that by calling it via a wrapper that adds as many zero entries at the end as it may need. Change-Id: Icb526086ab8e3093d6c668805044b6912fe2eab8 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rwxr-xr-xscripts/api-review/resetboring.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/scripts/api-review/resetboring.py b/scripts/api-review/resetboring.py
index 98f39321..f2e7c579 100755
--- a/scripts/api-review/resetboring.py
+++ b/scripts/api-review/resetboring.py
@@ -209,10 +209,25 @@ class Selector(object): # Select interesting changes, discard boring.
return self.__as_entry('\n'.join(self.__hybrid), self.__mode)
- from dulwich.objects import Blob
from dulwich.index import IndexEntry
+ @staticmethod
+ def __index_entry(mode, size, blobid, entry=IndexEntry):
+ """Wrap IndexEntry to cope with variably many entries in tuple.
+
+ Up to (at least) version 0.20.15, there were ten entries in
+ the tuple; but 0.20.23-1 has an eleventh entry; and a
+ namedtuple doesn't support leaving out entries to give them a
+ default value.
+ """
+ # (ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags [, extraflags])
+ seq = ((0, 0), (0, 0), 0, 0, mode, 0, 0, size, blobid)
+ seq += (len(entry._fields) - len(seq)) * (0,)
+ return entry(*seq)
+ del IndexEntry
+
+ from dulwich.objects import Blob
def __as_entry(self, text, mode,
- blob=Blob.from_string, entry=IndexEntry):
+ blob=Blob.from_string):
"""Turn a file's proposed contents into an IndexEntry.
The returned IndexEntry's properties are mostly filler, as
@@ -222,11 +237,11 @@ class Selector(object): # Select interesting changes, discard boring.
dull = blob(text)
assert len(dull.id) == 40
self.__store.add_object(dull)
- # entry((ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags))
- return entry((0, 0), (0, 0), 0, 0, mode, 0, 0, len(text), dull.id, 0)
+ return self.__index_entry(mode, len(text), dull.id)
+ del Blob
- @staticmethod
- def restore(blob, mode, entry=IndexEntry):
+ @classmethod
+ def restore(cls, blob, mode):
"""Index entry for a specified extant blob.
Requires exactly two arguments (do *not* pass a third):
@@ -237,9 +252,7 @@ class Selector(object): # Select interesting changes, discard boring.
Can be used to put back a deleted file.
"""
assert len(blob.id) == 40, blob.id
- return entry((0, 0), (0, 0), 0, 0, mode, 0, 0,
- len(blob.as_raw_string()), blob.id, 0)
- del Blob, IndexEntry
+ return cls.__index_entry(mode, len(blob.as_raw_string()), blob.id)
def __copy(self, tag, startOld, endOld, startNew, endNew):
assert tag in ('equal', 'implicit'), tag