|
|
@ -29,7 +29,7 @@ def git_hash_data(data, typ='blob'):
|
|
|
|
return hashlib.sha1(b'blob %d\0%s' % (len(data), data)).hexdigest()
|
|
|
|
return hashlib.sha1(b'blob %d\0%s' % (len(data), data)).hexdigest()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OrderedSet(collections.MutableSet):
|
|
|
|
class OrderedSet(collections.abc.MutableSet):
|
|
|
|
# from http://code.activestate.com/recipes/576694/
|
|
|
|
# from http://code.activestate.com/recipes/576694/
|
|
|
|
def __init__(self, iterable=None):
|
|
|
|
def __init__(self, iterable=None):
|
|
|
|
self.end = end = []
|
|
|
|
self.end = end = []
|
|
|
@ -73,20 +73,20 @@ class OrderedSet(collections.MutableSet):
|
|
|
|
yield curr[0]
|
|
|
|
yield curr[0]
|
|
|
|
curr = curr[1]
|
|
|
|
curr = curr[1]
|
|
|
|
|
|
|
|
|
|
|
|
def add(self, key):
|
|
|
|
def add(self, value):
|
|
|
|
if key not in self.data:
|
|
|
|
if value not in self.data:
|
|
|
|
end = self.end
|
|
|
|
end = self.end
|
|
|
|
curr = end[1]
|
|
|
|
curr = end[1]
|
|
|
|
curr[2] = end[1] = self.data[key] = [key, curr, end]
|
|
|
|
curr[2] = end[1] = self.data[value] = [value, curr, end]
|
|
|
|
|
|
|
|
|
|
|
|
def difference_update(self, *others):
|
|
|
|
def difference_update(self, *others):
|
|
|
|
for other in others:
|
|
|
|
for other in others:
|
|
|
|
for i in other:
|
|
|
|
for i in other:
|
|
|
|
self.discard(i)
|
|
|
|
self.discard(i)
|
|
|
|
|
|
|
|
|
|
|
|
def discard(self, key):
|
|
|
|
def discard(self, value):
|
|
|
|
if key in self.data:
|
|
|
|
if value in self.data:
|
|
|
|
key, prev, nxt = self.data.pop(key)
|
|
|
|
value, prev, nxt = self.data.pop(value)
|
|
|
|
prev[2] = nxt
|
|
|
|
prev[2] = nxt
|
|
|
|
nxt[1] = prev
|
|
|
|
nxt[1] = prev
|
|
|
|
|
|
|
|
|
|
|
|