1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00

- work around ruby on rails issue, which swallows '+' signs in filenames in PUT

requests [#153725, 181593]
- before committing, make sure that the working copy is up to date (added
  show_rev() function)
- add 'commit' as subcommand alias for 'ci/checkin'
- use os.path.abspath() in Project and Package classes
This commit is contained in:
Dr. Peter Poeml 2006-06-06 10:50:40 +00:00
parent 749a1f76c9
commit 24a49bbfd6
2 changed files with 21 additions and 10 deletions

View File

@ -22,7 +22,7 @@ Available subcommands:
add
addremove
checkin (ci)
commit (checkin, ci)
checkout (co)
diff
editmeta
@ -293,7 +293,7 @@ usage: addremove
def checkin(args):
"""checkin (ci): Upload change content from your working copy to the repository
"""commit (ci): Upload change content from your working copy to the repository
usage: ci # current dir
ci <dir>
@ -307,6 +307,14 @@ usage: ci # current dir
pacs = findpacs(args)
for p in pacs:
# commit only if the upstream revision is the same as the working copy's
upstream_rev = show_upstream_rev(p.prjname, p.name)
if p.rev != upstream_rev:
print 'Working copy \'%s\' is out of date (rev %s vs rev %s).' % (p.absdir, p.rev, upstream_rev)
print 'Looks as if you need to update it first.'
sys.exit(1)
p.todo = p.filenamelist_unvers + p.filenamelist
for filename in p.todo:
@ -583,7 +591,7 @@ usage: help [SUBCOMMAND...]
def resolve_cmd_alias(cmd):
if cmd == 'ci': return 'checkin'
if cmd in ['commit', 'ci']: return 'checkin'
if cmd == 'co': return 'checkout'
if cmd == 'st': return 'status'
if cmd == 'up': return 'update'

View File

@ -62,12 +62,7 @@ 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.absdir = os.path.abspath(dir)
self.name = store_read_project(self.dir)
@ -107,6 +102,7 @@ class Package:
"""represent a package (its directory) and read/keep/write its metadata"""
def __init__(self, workingdir):
self.dir = workingdir
self.absdir = os.path.abspath(self.dir)
self.storedir = os.path.join(self.dir, store)
check_store_version(self.dir)
@ -211,7 +207,9 @@ class Package:
def put_source_file(self, n):
import othermethods
u = makeurl(['source', self.prjname, self.name, n])
# escaping '+' in the URL path (note: not in the URL query string) is
# only a workaround for ruby on rails, which swallows it otherwise
u = makeurl(['source', self.prjname, self.name, n.replace('+', '%2B')])
othermethods.putfile(u, os.path.join(self.dir, n), username, password)
shutil.copy2(os.path.join(self.dir, n), os.path.join(self.storedir, n))
@ -806,6 +804,11 @@ def show_files_meta(prj, pac):
return f.readlines()
def show_upstream_rev(prj, pac):
m = show_files_meta(prj, pac)
return ET.parse(StringIO(''.join(m))).getroot().get('rev')
def read_meta_from_spec(specfile):
"""read Name, Summary and %description from spec file"""
in_descr = False