https://codereview.appspot.com/8540050/diff/23001/cmd/juju/upgradecharm.go#oldcode95
cmd/juju/upgradecharm.go:95: return fmt.Errorf("already running latest
charm %q", curl)
On 2013/04/28 10:41:25, fwereade wrote:
> Hmm. If the --force flag is set to something different to before, we
might
> actually want to allow this case (and other error below)?.
Pre-existing bug,
> doesn't have to be addressed in this CL, but if it isn't it should be
recorded.
> oldURL, _ := service.CharmURL()
> var newURL *charm.URL
> if c.SwitchURL != "" {
> // A new charm URL was explicitly specified.
> conf, err := conn.State.EnvironConfig()
> if err != nil {
> return err
> }
> newURL, err = charm.InferURL(c.SwitchURL, conf.DefaultSeries())
> if err != nil {
> return err
> }
> } else {
> // No new URL was specified, but a revision might have been.
> newURL = oldURL.WithRevision(c.Revision)
> }
> repo, err := charm.InferRepository(newURL, ctx.AbsPath(c.RepoPath))
> if err != nil {
> return err
> }
> // If no revision was explicitly specified by either Revision or
> // SwitchURL, discover the latest from the repo.
> if newURL.Revision == -1 {
> latest, err := repo.Latest(newURL)
> if err != nil {
> return err
> }
> newURL = newURL.WithRevision(latest)
> }
> if *newURL == *oldURL {
> if _, isLocal := repo.(*charm.LocalRepository); !isLocal {
> // etc
I prefer to keep it as is, if you don't mind, and I don't think it's any
more clear the suggested way.
Does it fulfill the required set of cases? I think so.
Please take a look.
https:/ /codereview. appspot. com/8540050/ diff/23001/ cmd/juju/ upgradecharm. go upgradecharm. go (left):
File cmd/juju/
https:/ /codereview. appspot. com/8540050/ diff/23001/ cmd/juju/ upgradecharm. go#oldcode66 upgradecharm. go:66: } "--switch and --revision are mutually
cmd/juju/
On 2013/04/28 10:41:25, fwereade wrote:
> if c.SwitchURL != "" && c.Revision != -1 {
> return fmt.Errorf(
exclusive")
> }
> ...or something
Done.
https:/ /codereview. appspot. com/8540050/ diff/23001/ cmd/juju/ upgradecharm. go#oldcode95 upgradecharm. go:95: return fmt.Errorf("already running latest
cmd/juju/
charm %q", curl)
On 2013/04/28 10:41:25, fwereade wrote:
> Hmm. If the --force flag is set to something different to before, we
might
> actually want to allow this case (and other error below)?.
Pre-existing bug,
> doesn't have to be addressed in this CL, but if it isn't it should be
recorded.
I added a TODO
https:/ /codereview. appspot. com/8540050/ diff/23001/ cmd/juju/ upgradecharm. go upgradecharm. go (right):
File cmd/juju/
https:/ /codereview. appspot. com/8540050/ diff/23001/ cmd/juju/ upgradecharm. go#newcode111 upgradecharm. go:111: return fmt.Errorf("cannot specify --switch
cmd/juju/
and --revision together")
On 2013/04/28 10:41:25, fwereade wrote:
> This can and should be detected at Init() time.
Done.
https:/ /codereview. appspot. com/8540050/ diff/23001/ cmd/juju/ upgradecharm. go#newcode113 upgradecharm. go:113: var err error
cmd/juju/
On 2013/04/28 10:41:25, fwereade wrote:
> Not needed (but read the next comment before addressing it).
See the answer below.
https:/ /codereview. appspot. com/8540050/ diff/23001/ cmd/juju/ upgradecharm. go#newcode161 upgradecharm. go:161: if considerBumpRev ision {
cmd/juju/
On 2013/04/28 10:41:25, fwereade wrote:
> I think this can all be simpler.
> oldURL, _ := service.CharmURL() EnvironConfig( ) c.SwitchURL, conf.DefaultSer ies()) WithRevision( c.Revision) sitory( newURL, ctx.AbsPath( c.RepoPath) ) WithRevision( latest) charm.LocalRepo sitory) ; !isLocal {
> var newURL *charm.URL
> if c.SwitchURL != "" {
> // A new charm URL was explicitly specified.
> conf, err := conn.State.
> if err != nil {
> return err
> }
> newURL, err = charm.InferURL(
> if err != nil {
> return err
> }
> } else {
> // No new URL was specified, but a revision might have been.
> newURL = oldURL.
> }
> repo, err := charm.InferRepo
> if err != nil {
> return err
> }
> // If no revision was explicitly specified by either Revision or
> // SwitchURL, discover the latest from the repo.
> if newURL.Revision == -1 {
> latest, err := repo.Latest(newURL)
> if err != nil {
> return err
> }
> newURL = newURL.
> }
> if *newURL == *oldURL {
> if _, isLocal := repo.(*
> // etc
I prefer to keep it as is, if you don't mind, and I don't think it's any
more clear the suggested way.
Does it fulfill the required set of cases? I think so.
https:/ /codereview. appspot. com/8540050/