----- Original Message -----
From: "Vratislav Podzimek" vpodzime@redhat.com To: anaconda-patches@lists.fedorahosted.org Sent: Wednesday, November 26, 2014 8:37:31 AM Subject: [PATCH 1/2] Return device's children sorted by name
No code should rely on children order, but the list is sometimes transformed into something visual seen by users.
Related: rhbz#1166598 Signed-off-by: Vratislav Podzimek vpodzime@redhat.com
blivet/devicetree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py index 1a7b144..f6cf600 100644 --- a/blivet/devicetree.py +++ b/blivet/devicetree.py @@ -2483,7 +2483,7 @@ class DeviceTree(object):
def getChildren(self, device): """ Return a list of a device's children. """
return [c for c in self._devices if device in c.parents]
return sorted((c for c in self._devices if device in c.parents),
key=lambda c:c.name)
def resolveDevice(self, devspec, blkidTab=None, cryptTab=None, options=None): """ Return the device matching the provided device specification.
-- 1.9.3
anaconda-patches mailing list anaconda-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
There seems to be no reason for this patch.
Client code can sort the children by name if that's how it want to display them. It seems wrong for the DeviceTree code to decide that sorted by name is the correct order, when it is not an intrinsic order for the device.
Isn't it true that patch (2) does attempt to enforce an order, by start block? That seems like a much more reasonable order to maintain when returning the children.
If you actually were maintaining that order, sorted by start, then obviously the code in patch (2) could be a lot simpler.
- mulhern