upgrades: added AreUpgradesDefined

This function return true if there are upgrade operations defined
between the version specified and the running software version. The
logic shared by this and PerformUpgrade has been extracted to an
iterator.
cmd/jujud: avoid entering upgrade mode if no upgrade is required

This is a backport of what has already been merged in to trunk.
Merge pull request #542 from mjs/1350111-avoid-unnecessary-upgrade-mode-1.20

Avoid unnecessary upgrade mode (v1.20)

This is rehashed backport of various changes from trunk which ensure the machine agent doesn't enter upgrade mode unless it actually needs to. 

The consequences of entered upgrade mode aren't as severe in 1.20 as in 1.21 (API isn't restricted for users) but it's still worth making these changes.