candlepin/candlepin — pull request #173 by wottop (2013-02-08 19:23:27+00:00)
Title: Wottop/manifest import update

Previous method used upstream pool id in existing subscription to match with new entitlements.
The possibility of having multiple entitlements from the same upstream pool makes this error prone.
New method will first match upstream pool and entitlement id from incoming entitlements.
Next it will match upstream pool and exact quantity to cover scenarios where the intent is to re-establish the distributor from the host.
It will then match using the quantity by ordering the remaining incoming entitlements and remaining existing subscriptions in descending order.
The highest will match on down from there.
Either remaining subscriptions will be deleted, or unmatched incoming entitlements will be turned into new subscriptions.