diff --git a/osc/commandline.py b/osc/commandline.py index 7cbcd719..6072e854 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -4368,29 +4368,28 @@ Please submit there instead, or use --nodevelproject to force direct submission. """ if not is_package_dir('.'): - raise oscerr.NoWorkingCopy("Error: \"%s\" is not an osc working copy." % os.path.abspath(".")) - p = Package('.') + raise oscerr.NoWorkingCopy('Error: \'%s\' is not an osc working copy.' % os.path.abspath('.')) + p = Package('.') # check if everything is committed - for filename in p.filenamelist: - st = p.status(filename) - if st != ' ': - raise oscerr.WrongArgs('Please commit your local changes first!') + for filename in p.filenamelist: + if p.status(filename) != ' ': + raise oscerr.WrongArgs('Please commit your local changes first!') # check if we need to update upstream_rev = p.latest_rev() if p.rev != upstream_rev: - raise oscerr.WorkingCopyOutdated((p.absdir, p.rev, upstream_rev)) - if not p.islink(): - raise oscerr.WrongArgs('osc pull only works on linked packages.') - if not p.isexpanded(): - raise oscerr.WrongArgs('osc pull only works on expanded links.') + raise oscerr.WorkingCopyOutdated((p.absdir, p.rev, upstream_rev)) + elif not p.islink(): + raise oscerr.WrongArgs('osc pull only works on linked packages.') + elif not p.isexpanded(): + raise oscerr.WrongArgs('osc pull only works on expanded links.') - # hack - conf.config['linkcontrol'] = 0 - # do the update - pulledrev=p.latest_rev() - if pulledrev == p.rev: - raise oscerr.WrongArgs('Already up-to-date.') - p.update(rev=pulledrev) + # hack + conf.config['linkcontrol'] = 0 + # do the update + pulledrev=p.latest_rev() + if pulledrev == p.rev: + raise oscerr.WrongArgs('Already up-to-date.') + p.update(rev=pulledrev) store_write_string(p.absdir, '_pulled', '') diff --git a/osc/core.py b/osc/core.py index 2d46f7bb..ab4532c7 100644 --- a/osc/core.py +++ b/osc/core.py @@ -857,8 +857,8 @@ class Package: 'comment': msg } if self.islink() and self.isexpanded(): query['keeplink'] = '1' - if conf.config['linkcontrol']: - query['linkrev'] = self.linkinfo.srcmd5 + if conf.config['linkcontrol']: + query['linkrev'] = self.linkinfo.srcmd5 if self.islinkrepair(): query['repairlink'] = '1' u = makeurl(self.apiurl, ['source', self.prjname, self.name], query=query) @@ -878,7 +878,8 @@ class Package: print print 'Committed revision %s.' % self.rev - os.unlink(os.path.join(self.storedir, '_pulled')) + if self.ispulled(): + os.unlink(os.path.join(self.storedir, '_pulled')) if self.islinkrepair(): os.unlink(os.path.join(self.storedir, '_linkrepair')) self.linkrepair = False @@ -1251,10 +1252,10 @@ rev: %s if self.islinkrepair(): upstream_rev = show_upstream_xsrcmd5(self.apiurl, self.prjname, self.name, linkrepair=1) elif self.islink() and self.isexpanded(): - if conf.config['linkcontrol'] and self.ispulled(): - upstream_rev = show_upstream_xsrcmd5(self.apiurl, self.prjname, self.name, linkrev=self.linkinfo.srcmd5) - else: - upstream_rev = show_upstream_xsrcmd5(self.apiurl, self.prjname, self.name) + if conf.config['linkcontrol'] and self.ispulled(): + upstream_rev = show_upstream_xsrcmd5(self.apiurl, self.prjname, self.name, linkrev=self.linkinfo.srcmd5) + else: + upstream_rev = show_upstream_xsrcmd5(self.apiurl, self.prjname, self.name) else: upstream_rev = show_upstream_rev(self.apiurl, self.prjname, self.name) return upstream_rev