mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-15 10:06:16 +01:00
- fixed bug #376285:
* make_dir() and checkout_package() got a new optionally 'prj_dir' parameter. This parameter specifies in which dir we want to create new project/package dirs.
This commit is contained in:
parent
06fb595140
commit
a3f948dede
@ -819,7 +819,7 @@ class Osc(cmdln.Cmdln):
|
|||||||
|
|
||||||
elif package:
|
elif package:
|
||||||
checkout_package(conf.config['apiurl'], project, package,
|
checkout_package(conf.config['apiurl'], project, package,
|
||||||
rev, expand_link=opts.expand_link)
|
rev, expand_link=opts.expand_link, prj_dir=project)
|
||||||
|
|
||||||
elif project:
|
elif project:
|
||||||
if not os.path.exists(project):
|
if not os.path.exists(project):
|
||||||
@ -835,7 +835,7 @@ class Osc(cmdln.Cmdln):
|
|||||||
# all packages
|
# all packages
|
||||||
for package in meta_get_packagelist(conf.config['apiurl'], project):
|
for package in meta_get_packagelist(conf.config['apiurl'], project):
|
||||||
checkout_package(conf.config['apiurl'], project, package,
|
checkout_package(conf.config['apiurl'], project, package,
|
||||||
expand_link=opts.expand_link)
|
expand_link=opts.expand_link, prj_dir=project)
|
||||||
else:
|
else:
|
||||||
print >>sys.stderr, 'Missing argument.'
|
print >>sys.stderr, 'Missing argument.'
|
||||||
self.do_help([None, 'checkout'])
|
self.do_help([None, 'checkout'])
|
||||||
|
58
osc/core.py
58
osc/core.py
@ -256,14 +256,9 @@ class Project:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print 'checking out new package %s' % pac
|
print 'checking out new package %s' % pac
|
||||||
olddir = os.getcwd()
|
checkout_package(self.apiurl, self.name, pac, \
|
||||||
#os.chdir(os.pardir)
|
pathname=getTransActPath(os.path.join(self.dir, pac)), \
|
||||||
os.chdir(os.path.join(self.absdir, os.pardir))
|
prj_obj=self, prj_dir=self.dir)
|
||||||
#checkout_package(self.apiurl, self.name, pac, pathname = os.path.normpath(os.path.join(self.dir, pac)))
|
|
||||||
checkout_package(self.apiurl, self.name, pac, pathname = getTransActPath(os.path.join(self.dir, pac)), prj_obj=self)
|
|
||||||
os.chdir(olddir)
|
|
||||||
#self.new_package_entry(pac, ' ')
|
|
||||||
#self.pacs_have.append(pac)
|
|
||||||
|
|
||||||
def set_state(self, pac, state):
|
def set_state(self, pac, state):
|
||||||
node = self.get_package_node(pac)
|
node = self.get_package_node(pac)
|
||||||
@ -392,11 +387,8 @@ class Project:
|
|||||||
state = self.get_state(pac)
|
state = self.get_state(pac)
|
||||||
if pac in self.pacs_broken:
|
if pac in self.pacs_broken:
|
||||||
if self.get_state(pac) != 'A':
|
if self.get_state(pac) != 'A':
|
||||||
olddir = self.absdir
|
|
||||||
os.chdir(os.path.join(self.absdir, os.pardir))
|
|
||||||
checkout_package(self.apiurl, self.name, pac,
|
checkout_package(self.apiurl, self.name, pac,
|
||||||
pathname=getTransActPath(os.path.join(self.dir, pac)), prj_obj=self)
|
pathname=getTransActPath(os.path.join(self.dir, pac)), prj_obj=self, prj_dir=self.dir)
|
||||||
os.chdir(olddir)
|
|
||||||
elif state == ' ':
|
elif state == ' ':
|
||||||
# do a simple update
|
# do a simple update
|
||||||
p = Package(os.path.join(self.dir, pac))
|
p = Package(os.path.join(self.dir, pac))
|
||||||
@ -414,11 +406,8 @@ class Project:
|
|||||||
elif state == 'D':
|
elif state == 'D':
|
||||||
# TODO: Package::update has to fixed to behave like svn does
|
# TODO: Package::update has to fixed to behave like svn does
|
||||||
if pac in self.pacs_broken:
|
if pac in self.pacs_broken:
|
||||||
olddir = self.absdir
|
|
||||||
os.chdir(os.path.join(self.absdir, os.pardir))
|
|
||||||
checkout_package(self.apiurl, self.name, pac,
|
checkout_package(self.apiurl, self.name, pac,
|
||||||
pathname=getTransActPath(os.path.join(self.dir, pac)), prj_obj=self)
|
pathname=getTransActPath(os.path.join(self.dir, pac)), prj_obj=self, prj_dir=self.dir)
|
||||||
os.chdir(olddir)
|
|
||||||
else:
|
else:
|
||||||
Package(os.path.join(self.dir, pac)).update()
|
Package(os.path.join(self.dir, pac)).update()
|
||||||
elif state == 'A' and pac in self.pacs_available:
|
elif state == 'A' and pac in self.pacs_available:
|
||||||
@ -2217,29 +2206,35 @@ def pretty_diff(apiurl,
|
|||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
|
|
||||||
def make_dir(apiurl, project, package, pathname):
|
def make_dir(apiurl, project, package, pathname=None, prj_dir=None):
|
||||||
#print "creating directory '%s'" % project
|
"""
|
||||||
if not os.path.exists(project):
|
creates the plain directory structure for a package dir.
|
||||||
print statfrmt('A', project)
|
The 'apiurl' parameter is needed for the project dir initialization.
|
||||||
init_project_dir(apiurl, project, project)
|
The 'project' and 'package' parameters specify the name of the
|
||||||
#print "creating directory '%s/%s'" % (project, package)
|
project and the package. The optional 'pathname' parameter is used
|
||||||
if not pathname:
|
for printing out the message that a new dir was created (default: 'prj_dir/package').
|
||||||
pathname = os.path.join(project, package)
|
The optional 'prj_dir' parameter specifies the path to the project dir (default: 'project').
|
||||||
if not os.path.exists(os.path.join(project, package)):
|
"""
|
||||||
|
prj_dir = prj_dir or project
|
||||||
|
pathname = pathname or getTransActPath(os.path.join(prj_dir, package))
|
||||||
|
if not os.path.exists(prj_dir):
|
||||||
|
print statfrmt('A', prj_dir)
|
||||||
|
init_project_dir(apiurl, prj_dir, project)
|
||||||
|
if not os.path.exists(os.path.join(prj_dir, package)):
|
||||||
print statfrmt('A', pathname)
|
print statfrmt('A', pathname)
|
||||||
os.mkdir(os.path.join(project, package))
|
os.mkdir(os.path.join(prj_dir, package))
|
||||||
os.mkdir(os.path.join(project, package, store))
|
os.mkdir(os.path.join(prj_dir, package, store))
|
||||||
|
|
||||||
return(os.path.join(project, package))
|
return(os.path.join(prj_dir, package))
|
||||||
|
|
||||||
|
|
||||||
def checkout_package(apiurl, project, package,
|
def checkout_package(apiurl, project, package,
|
||||||
revision=None, pathname=None, prj_obj=None,
|
revision=None, pathname=None, prj_obj=None,
|
||||||
expand_link=False):
|
expand_link=False, prj_dir=os.getcwd()):
|
||||||
olddir = os.getcwd()
|
olddir = os.getcwd()
|
||||||
|
|
||||||
if not pathname:
|
if not pathname:
|
||||||
pathname = os.path.join(project, package)
|
pathname = getTransActPath(os.path.join(prj_dir, package))
|
||||||
|
|
||||||
path = (quote_plus(project), quote_plus(package))
|
path = (quote_plus(project), quote_plus(package))
|
||||||
if meta_exists(metatype='pkg', path_args=path, create_new=False, apiurl=apiurl) == None:
|
if meta_exists(metatype='pkg', path_args=path, create_new=False, apiurl=apiurl) == None:
|
||||||
@ -2253,8 +2248,7 @@ def checkout_package(apiurl, project, package,
|
|||||||
# it is a link - thus, we use the xsrcmd5 as the revision to be
|
# it is a link - thus, we use the xsrcmd5 as the revision to be
|
||||||
# checked out
|
# checked out
|
||||||
revision = x
|
revision = x
|
||||||
|
os.chdir(make_dir(apiurl, project, package, pathname, prj_dir))
|
||||||
os.chdir(make_dir(apiurl, project, package, pathname))
|
|
||||||
init_package_dir(apiurl, project, package, store, revision)
|
init_package_dir(apiurl, project, package, store, revision)
|
||||||
os.chdir(os.pardir)
|
os.chdir(os.pardir)
|
||||||
p = Package(package)
|
p = Package(package)
|
||||||
|
Loading…
Reference in New Issue
Block a user