mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-09 22:36:14 +01:00
- allow 'up' of a project directory (will automatically pull in all new
packages) - add NEWS file
This commit is contained in:
parent
4b7d1bc176
commit
2c37f7287d
13
NEWS
Normal file
13
NEWS
Normal file
@ -0,0 +1,13 @@
|
||||
0.4:
|
||||
- allow 'up' inside a project directory (will automatically pull in all new
|
||||
packages)
|
||||
- checkout: preserve mtimes
|
||||
|
||||
|
||||
0.3:
|
||||
- use the new file metadata, which provides checksum, size and mtime
|
||||
- faster 'status', 'update', 'diff'
|
||||
- improve argument handling, now e.g. 'osc up *' is possible
|
||||
- on first usage, ask for username and password and store them in .oscrc
|
||||
(.netrc can still be used)
|
||||
|
@ -189,6 +189,23 @@ def main():
|
||||
elif cmd == 'up' or cmd == 'update':
|
||||
|
||||
args = parseargs()
|
||||
|
||||
for arg in args:
|
||||
|
||||
# when 'update' is run inside a project dir, it should...
|
||||
if is_project_dir(arg):
|
||||
|
||||
prj = Project(arg)
|
||||
|
||||
# (a) update all packages
|
||||
for i in prj.pacs_have:
|
||||
args.append(i)
|
||||
|
||||
# (b) fetch new packages
|
||||
prj.checkout_missing_pacs()
|
||||
args.remove(arg)
|
||||
|
||||
|
||||
pacs = findpacs(args)
|
||||
|
||||
for p in pacs:
|
||||
@ -230,7 +247,7 @@ def main():
|
||||
|
||||
p.update_pacmeta()
|
||||
|
||||
print 'At revision %s.' % p.rev
|
||||
print ljust(p.name, 45), 'At revision %s.' % p.rev
|
||||
|
||||
|
||||
|
||||
|
53
osc/core.py
53
osc/core.py
@ -13,6 +13,7 @@ import urllib2
|
||||
from urlparse import urlunsplit
|
||||
import cElementTree as ET
|
||||
from cStringIO import StringIO
|
||||
from string import ljust
|
||||
|
||||
|
||||
from xml.dom.ext.reader import Sax2
|
||||
@ -37,6 +38,51 @@ class File:
|
||||
return self.name
|
||||
|
||||
|
||||
class Project:
|
||||
"""represent a project directory, holding packages"""
|
||||
def __init__(self, dir):
|
||||
self.dir = dir
|
||||
if self.dir.startswith('/'):
|
||||
self.absdir = dir
|
||||
elif self.dir == os.curdir:
|
||||
self.absdir = os.getcwd()
|
||||
else:
|
||||
self.absdir = os.path.join(os.getcwd(), dir)
|
||||
|
||||
self.name = store_read_project(self.dir)
|
||||
|
||||
self.pacs_available = meta_get_packagelist(self.name)
|
||||
|
||||
self.pacs_have = []
|
||||
for i in os.listdir(self.dir):
|
||||
if i in self.pacs_available:
|
||||
self.pacs_have.append(i)
|
||||
|
||||
self.pacs_missing = []
|
||||
for i in self.pacs_available:
|
||||
if i not in self.pacs_have:
|
||||
self.pacs_missing.append(i)
|
||||
|
||||
def checkout_missing_pacs(self):
|
||||
for pac in self.pacs_missing:
|
||||
print 'checking out new package %s' % pac
|
||||
olddir = os.getcwd()
|
||||
os.chdir(os.pardir)
|
||||
checkout_package(self.name, pac)
|
||||
os.chdir(olddir)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
r = []
|
||||
r.append('*****************************************************')
|
||||
r.append('Project %s (dir=%s, absdir=%s)' % (self.name, self.dir, self.absdir))
|
||||
r.append('have pacs:\n%s' % ', '.join(self.pacs_have))
|
||||
r.append('missing pacs:\n%s' % ', '.join(self.pacs_missing))
|
||||
r.append('*****************************************************')
|
||||
return '\n'.join(r)
|
||||
|
||||
|
||||
|
||||
class Package:
|
||||
"""represent a package (its directory) and read/keep/write its metadata"""
|
||||
def __init__(self, workingdir):
|
||||
@ -206,6 +252,13 @@ rev: %s
|
||||
return r
|
||||
|
||||
|
||||
def is_project_dir(d):
|
||||
if os.path.exists(os.path.join(d, store, '_project')) and not \
|
||||
os.path.exists(os.path.join(d, store, '_package')):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def findpacs(files):
|
||||
pacs = []
|
||||
|
Loading…
Reference in New Issue
Block a user