Home Home > GIT Browse > SLE12-SP4
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Suchanek <msuchanek@suse.de>2019-08-08 13:00:49 +0200
committerMichal Suchanek <msuchanek@suse.de>2019-08-08 13:00:49 +0200
commitc202ccb03528fb752dd755e705fe9dbca4a33d48 (patch)
tree7712060cd5ddf5d631cba62a25c4eb83e12a3bdc
parent6ff490777a36d405af5c50ccf8e6de69e47a0e96 (diff)
parentaa6b5279bf9c7b56d23fc934e4dff233b9dc9d2e (diff)
Merge branch 'scripts' into SLE15
-rw-r--r--scripts/git_sort/README.md2
-rw-r--r--scripts/git_sort/lib.py80
-rwxr-xr-xscripts/git_sort/merge_tool.py8
-rwxr-xr-xscripts/run_oldconfig.sh3
4 files changed, 88 insertions, 5 deletions
diff --git a/scripts/git_sort/README.md b/scripts/git_sort/README.md
index b9881372cd..09b09cf3a7 100644
--- a/scripts/git_sort/README.md
+++ b/scripts/git_sort/README.md
@@ -29,7 +29,7 @@ copy.
Packages are available in the following OBS project
https://build.opensuse.org/package/show/home:benjamin_poirier:series_sort/quilt-ks
Source is avaible from
-https://gitlab.suse.de/benjamin_poirier/quilt
+https://github.com/gobenji/quilt
The packages in home:benjamin_poirier:series_sort are signed with the key
from home:benjamin_poirier which has the following fingerprint:
diff --git a/scripts/git_sort/lib.py b/scripts/git_sort/lib.py
index 9f7da0efb6..4a4f9d3241 100644
--- a/scripts/git_sort/lib.py
+++ b/scripts/git_sort/lib.py
@@ -26,6 +26,7 @@ import re
import signal
import subprocess
import sys
+import weakref
import pygit2_wrapper as pygit2
@@ -558,3 +559,82 @@ def sequence_insert(series, rev, top):
"Please run scripts/series_sort.py.")
return (name, commit_pos - top_index,)
+
+
+# https://github.com/ActiveState/code/tree/master/recipes/Python/576696_OrderedSet_with_Weakrefs
+class Link(object):
+ __slots__ = 'prev', 'next', 'key', '__weakref__'
+
+
+class OrderedSet(collections.MutableSet):
+ 'Set the remembers the order elements were added'
+ # Big-O running times for all methods are the same as for regular sets.
+ # The internal self.__map dictionary maps keys to links in a doubly linked list.
+ # The circular doubly linked list starts and ends with a sentinel element.
+ # The sentinel element never gets deleted (this simplifies the algorithm).
+ # The prev/next links are weakref proxies (to prevent circular references).
+ # Individual links are kept alive by the hard reference in self.__map.
+ # Those hard references disappear when a key is deleted from an OrderedSet.
+
+ def __init__(self, iterable=None):
+ self.__root = root = Link() # sentinel node for doubly linked list
+ root.prev = root.next = root
+ self.__map = {} # key --> link
+ if iterable is not None:
+ self |= iterable
+
+ def __len__(self):
+ return len(self.__map)
+
+ def __contains__(self, key):
+ return key in self.__map
+
+ def add(self, key):
+ # Store new key in a new link at the end of the linked list
+ if key not in self.__map:
+ self.__map[key] = link = Link()
+ root = self.__root
+ last = root.prev
+ link.prev, link.next, link.key = last, root, key
+ last.next = root.prev = weakref.proxy(link)
+
+ def discard(self, key):
+ # Remove an existing item using self.__map to find the link which is
+ # then removed by updating the links in the predecessor and successors.
+ if key in self.__map:
+ link = self.__map.pop(key)
+ link.prev.next = link.next
+ link.next.prev = link.prev
+
+ def __iter__(self):
+ # Traverse the linked list in order.
+ root = self.__root
+ curr = root.next
+ while curr is not root:
+ yield curr.key
+ curr = curr.next
+
+ def __reversed__(self):
+ # Traverse the linked list in reverse order.
+ root = self.__root
+ curr = root.prev
+ while curr is not root:
+ yield curr.key
+ curr = curr.prev
+
+ def pop(self, last=True):
+ if not self:
+ raise KeyError('set is empty')
+ key = next(reversed(self)) if last else next(iter(self))
+ self.discard(key)
+ return key
+
+ def __repr__(self):
+ if not self:
+ return '%s()' % (self.__class__.__name__,)
+ return '%s(%r)' % (self.__class__.__name__, list(self))
+
+ def __eq__(self, other):
+ if isinstance(other, OrderedSet):
+ return len(self) == len(other) and list(self) == list(other)
+ return not self.isdisjoint(other)
diff --git a/scripts/git_sort/merge_tool.py b/scripts/git_sort/merge_tool.py
index fda4c3478f..60433fcbba 100755
--- a/scripts/git_sort/merge_tool.py
+++ b/scripts/git_sort/merge_tool.py
@@ -63,9 +63,9 @@ if __name__ == "__main__":
# (before, inside, after, set(inside),)
local, base, remote = (
- (s[0], s[1], s[2], set([series_conf.firstword(l)
- for l in s[1]
- if series_conf.filter_patches(l)]),)
+ (s[0], s[1], s[2], lib.OrderedSet([series_conf.firstword(l)
+ for l in s[1]
+ if series_conf.filter_patches(l)]),)
for s in [
series_conf.split(open(s_path))
for s_path in (local_path, base_path, remote_path,)
@@ -74,7 +74,7 @@ if __name__ == "__main__":
added = remote[3] - base[3]
removed = base[3] - remote[3]
- moved = set(lib.list_moved_patches(base[1], remote[1]))
+ moved = lib.OrderedSet(lib.list_moved_patches(base[1], remote[1]))
if added or removed:
print("%d commits added, %d commits removed from base to remote." %
diff --git a/scripts/run_oldconfig.sh b/scripts/run_oldconfig.sh
index c3c0651ab8..fb49596553 100755
--- a/scripts/run_oldconfig.sh
+++ b/scripts/run_oldconfig.sh
@@ -455,6 +455,9 @@ for config in $config_files; do
else
config_base="$(dirname "$config")/default"
fi
+ if ! [ -f "$config_base" ] && [ -n "$VARIANT" ] ; then
+ config_base="$(dirname "$config")/${VARIANT#-}"
+ fi
${scripts}/config-merge "$config_base" "$config" >$config_orig
else
cp "$config" $config_orig