mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
- rewrote "def commit"
- the upload revision isn't used anymore instead we commit via cmd=commitfilelist - extended and adjusted testcases
This commit is contained in:
parent
5c8b258a6b
commit
57a3832a8e
187
osc/core.py
187
osc/core.py
@ -923,28 +923,77 @@ class Package:
|
|||||||
u = makeurl(self.apiurl, ['source', self.prjname, self.name, pathname2url(n)], query=query)
|
u = makeurl(self.apiurl, ['source', self.prjname, self.name, pathname2url(n)], query=query)
|
||||||
http_DELETE(u)
|
http_DELETE(u)
|
||||||
|
|
||||||
def put_source_file(self, n):
|
def put_source_file(self, n, copy_only=False):
|
||||||
|
cdir = os.path.join(self.storedir, '_in_commit')
|
||||||
|
try:
|
||||||
|
if not os.path.isdir(cdir):
|
||||||
|
os.mkdir(cdir)
|
||||||
|
query = 'rev=repository'
|
||||||
|
tmpfile = os.path.join(cdir, n)
|
||||||
|
shutil.copyfile(os.path.join(self.dir, n), tmpfile)
|
||||||
# escaping '+' in the URL path (note: not in the URL query string) is
|
# escaping '+' in the URL path (note: not in the URL query string) is
|
||||||
# only a workaround for ruby on rails, which swallows it otherwise
|
# only a workaround for ruby on rails, which swallows it otherwise
|
||||||
query = 'rev=upload'
|
if not copy_only:
|
||||||
u = makeurl(self.apiurl, ['source', self.prjname, self.name, pathname2url(n)], query=query)
|
u = makeurl(self.apiurl, ['source', self.prjname, self.name, pathname2url(n)], query=query)
|
||||||
http_PUT(u, file = os.path.join(self.dir, n))
|
http_PUT(u, file = os.path.join(self.dir, n))
|
||||||
|
os.rename(tmpfile, os.path.join(self.storedir, n))
|
||||||
shutil.copyfile(os.path.join(self.dir, n), os.path.join(self.storedir, n))
|
finally:
|
||||||
|
if os.path.isdir(cdir):
|
||||||
|
shutil.rmtree(cdir)
|
||||||
if n in self.to_be_added:
|
if n in self.to_be_added:
|
||||||
self.to_be_added.remove(n)
|
self.to_be_added.remove(n)
|
||||||
|
|
||||||
|
def __generate_commitlist(self, todo_send):
|
||||||
|
root = ET.Element('directory')
|
||||||
|
keys = todo_send.keys()
|
||||||
|
keys.sort()
|
||||||
|
for i in keys:
|
||||||
|
ET.SubElement(root, 'entry', name=i, md5=todo_send[i])
|
||||||
|
return root
|
||||||
|
|
||||||
|
def __send_commitlog(self, msg, local_filelist):
|
||||||
|
"""send the commitlog and the local filelist to the server"""
|
||||||
|
query = {'cmd' : 'commitfilelist',
|
||||||
|
'user' : conf.get_apiurl_usr(self.apiurl),
|
||||||
|
'comment': msg}
|
||||||
|
if self.islink() and self.isexpanded():
|
||||||
|
query['keeplink'] = '1'
|
||||||
|
if conf.config['linkcontrol'] or self.isfrozen():
|
||||||
|
query['linkrev'] = self.linkinfo.srcmd5
|
||||||
|
if self.ispulled():
|
||||||
|
query['repairlink'] = '1'
|
||||||
|
query['linkrev'] = self.get_pulled_srcmd5()
|
||||||
|
if self.islinkrepair():
|
||||||
|
query['repairlink'] = '1'
|
||||||
|
u = makeurl(self.apiurl, ['source', self.prjname, self.name], query=query)
|
||||||
|
f = http_POST(u, data=ET.tostring(local_filelist))
|
||||||
|
root = ET.parse(f).getroot()
|
||||||
|
return root
|
||||||
|
|
||||||
|
def __get_todo_send(self, server_filelist):
|
||||||
|
"""parse todo from a previous __send_commitlog call"""
|
||||||
|
error = server_filelist.get('error')
|
||||||
|
if error is None:
|
||||||
|
return []
|
||||||
|
elif error != 'missing':
|
||||||
|
raise oscerr.PackageInternalError(self.prjname, self.name,
|
||||||
|
'__get_todo_send: unexpected \'error\' attr: \'%s\'' % error)
|
||||||
|
todo = []
|
||||||
|
for n in server_filelist.findall('entry'):
|
||||||
|
name = n.get('name')
|
||||||
|
if name is None:
|
||||||
|
raise oscerr.APIError('missing \'name\' attribute:\n%s\n' % ET.tostring(server_filelist))
|
||||||
|
todo.append(n.get('name'))
|
||||||
|
return todo
|
||||||
|
|
||||||
def commit(self, msg='', validators=None, verbose_validation=None):
|
def commit(self, msg='', validators=None, verbose_validation=None):
|
||||||
todo_send = []
|
|
||||||
todo_delete = []
|
|
||||||
# commit only if the upstream revision is the same as the working copy's
|
# commit only if the upstream revision is the same as the working copy's
|
||||||
upstream_rev = self.latest_rev()
|
upstream_rev = self.latest_rev()
|
||||||
if self.rev != upstream_rev:
|
if self.rev != upstream_rev:
|
||||||
raise oscerr.WorkingCopyOutdated((self.absdir, self.rev, upstream_rev))
|
raise oscerr.WorkingCopyOutdated((self.absdir, self.rev, upstream_rev))
|
||||||
|
|
||||||
if not self.todo:
|
if not self.todo:
|
||||||
self.todo = self.filenamelist_unvers + self.filenamelist
|
self.todo = [i for i in self.to_be_added if not i in self.filenamelist] + self.filenamelist
|
||||||
|
|
||||||
pathn = getTransActPath(self.dir)
|
pathn = getTransActPath(self.dir)
|
||||||
|
|
||||||
@ -965,74 +1014,69 @@ class Package:
|
|||||||
if p.wait() != 0:
|
if p.wait() != 0:
|
||||||
raise oscerr.ExtRuntimeError(p.stdout, validator )
|
raise oscerr.ExtRuntimeError(p.stdout, validator )
|
||||||
|
|
||||||
have_conflicts = False
|
todo_send = {}
|
||||||
for filename in self.todo:
|
todo_delete = []
|
||||||
if not filename.startswith('_service:') and not filename.startswith('_service_'):
|
real_send = []
|
||||||
|
for filename in self.filenamelist + [i for i in self.to_be_added if not i in self.filenamelist]:
|
||||||
|
if filename.startswith('_service:') or filename.startswith('_service_'):
|
||||||
|
continue
|
||||||
st = self.status(filename)
|
st = self.status(filename)
|
||||||
if st == 'A' or st == 'M' or st == 'R':
|
if st == 'C':
|
||||||
todo_send.append(filename)
|
print 'Please resolve all conflicts before committing using "osc resolved FILE"!'
|
||||||
|
return 1
|
||||||
|
elif filename in self.todo:
|
||||||
|
if st in ('A', 'R', 'M'):
|
||||||
|
todo_send[filename] = dgst(os.path.join(self.absdir, filename))
|
||||||
|
real_send.append(filename)
|
||||||
print statfrmt('Sending', os.path.join(pathn, filename))
|
print statfrmt('Sending', os.path.join(pathn, filename))
|
||||||
|
elif st in (' ', '!', 'S'):
|
||||||
|
f = self.findfilebyname(filename)
|
||||||
|
if f is None:
|
||||||
|
raise oscerr.PackageInternalError(self.prjname, self.name,
|
||||||
|
'error: file \'%s\' with state \'%s\' is not known by meta' \
|
||||||
|
% (filename, st))
|
||||||
|
todo_send[filename] = f.md5
|
||||||
elif st == 'D':
|
elif st == 'D':
|
||||||
todo_delete.append(filename)
|
todo_delete.append(filename)
|
||||||
print statfrmt('Deleting', os.path.join(pathn, filename))
|
print statfrmt('Deleting', os.path.join(pathn, filename))
|
||||||
elif st == 'C':
|
elif st in ('R', 'M', 'D', ' ', '!', 'S'):
|
||||||
have_conflicts = True
|
f = self.findfilebyname(filename)
|
||||||
|
if f is None:
|
||||||
|
raise oscerr.PackageInternalError(self.prjname, self.name,
|
||||||
|
'error: file \'%s\' with state \'%s\' is not known by meta' \
|
||||||
|
% (filename, st))
|
||||||
|
todo_send[filename] = f.md5
|
||||||
|
|
||||||
if have_conflicts:
|
if not real_send and not todo_delete and not self.islinkrepair() and not self.ispulled():
|
||||||
print 'Please resolve all conflicts before committing using "osc resolved FILE"!'
|
|
||||||
return 1
|
|
||||||
|
|
||||||
if not todo_send and not todo_delete and not self.rev == "upload" and not self.islinkrepair() and not self.ispulled():
|
|
||||||
print 'nothing to do for package %s' % self.name
|
print 'nothing to do for package %s' % self.name
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if self.islink() and self.isexpanded():
|
|
||||||
# resolve the link into the upload revision
|
|
||||||
# XXX: do this always?
|
|
||||||
query = { 'cmd': 'copy', 'rev': 'upload', 'orev': self.rev }
|
|
||||||
u = makeurl(self.apiurl, ['source', self.prjname, self.name], query=query)
|
|
||||||
f = http_POST(u)
|
|
||||||
|
|
||||||
print 'Transmitting file data ',
|
print 'Transmitting file data ',
|
||||||
try:
|
filelist = self.__generate_commitlist(todo_send)
|
||||||
for filename in todo_delete:
|
sfilelist = self.__send_commitlog(msg, filelist)
|
||||||
# do not touch local files on commit --
|
send = self.__get_todo_send(sfilelist)
|
||||||
# delete remotely instead
|
real_send = [i for i in real_send if not i in send]
|
||||||
self.delete_remote_source_file(filename)
|
# abort after 3 tries
|
||||||
self.to_be_deleted.remove(filename)
|
tries = 3
|
||||||
for filename in todo_send:
|
while len(send) and tries:
|
||||||
|
for filename in send[:]:
|
||||||
sys.stdout.write('.')
|
sys.stdout.write('.')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
self.put_source_file(filename)
|
self.put_source_file(filename)
|
||||||
|
send.remove(filename)
|
||||||
|
tries -= 1
|
||||||
|
sfilelist = self.__send_commitlog(msg, filelist)
|
||||||
|
send = self.__get_todo_send(sfilelist)
|
||||||
|
if len(send):
|
||||||
|
raise oscerr.PackageInternalError(self.prjname, self.name,
|
||||||
|
'server does not accept filelist:\n%s\nmissing:\n%s\n' \
|
||||||
|
% (ET.tostring(filelist), ET.tostring(sfilelist)))
|
||||||
|
# these files already exist on the server
|
||||||
|
# just copy them into the storedir
|
||||||
|
for filename in real_send:
|
||||||
|
self.put_source_file(filename, copy_only=True)
|
||||||
|
|
||||||
# all source files are committed - now comes the log
|
self.rev = sfilelist.get('rev')
|
||||||
query = { 'cmd' : 'commit',
|
|
||||||
'rev' : 'upload',
|
|
||||||
'user' : conf.get_apiurl_usr(self.apiurl),
|
|
||||||
'comment': msg }
|
|
||||||
if self.islink() and self.isexpanded():
|
|
||||||
query['keeplink'] = '1'
|
|
||||||
if conf.config['linkcontrol'] or self.isfrozen():
|
|
||||||
query['linkrev'] = self.linkinfo.srcmd5
|
|
||||||
if self.ispulled():
|
|
||||||
query['repairlink'] = '1'
|
|
||||||
query['linkrev'] = self.get_pulled_srcmd5()
|
|
||||||
if self.islinkrepair():
|
|
||||||
query['repairlink'] = '1'
|
|
||||||
u = makeurl(self.apiurl, ['source', self.prjname, self.name], query=query)
|
|
||||||
f = http_POST(u)
|
|
||||||
except Exception, e:
|
|
||||||
# delete upload revision
|
|
||||||
try:
|
|
||||||
query = { 'cmd': 'deleteuploadrev' }
|
|
||||||
u = makeurl(self.apiurl, ['source', self.prjname, self.name], query=query)
|
|
||||||
f = http_POST(u)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
raise e
|
|
||||||
|
|
||||||
root = ET.parse(f).getroot()
|
|
||||||
self.rev = int(root.get('rev'))
|
|
||||||
print
|
print
|
||||||
print 'Committed revision %s.' % self.rev
|
print 'Committed revision %s.' % self.rev
|
||||||
|
|
||||||
@ -1043,17 +1087,24 @@ class Package:
|
|||||||
self.linkrepair = False
|
self.linkrepair = False
|
||||||
# XXX: mark package as invalid?
|
# XXX: mark package as invalid?
|
||||||
print 'The source link has been repaired. This directory can now be removed.'
|
print 'The source link has been repaired. This directory can now be removed.'
|
||||||
|
|
||||||
if self.islink() and self.isexpanded():
|
if self.islink() and self.isexpanded():
|
||||||
self.update_local_filesmeta(revision=self.latest_rev())
|
li = Linkinfo()
|
||||||
else:
|
li.read(sfilelist.find('linkinfo'))
|
||||||
self.update_local_filesmeta(self.rev)
|
if li.xsrcmd5 is None:
|
||||||
|
raise oscerr.APIError('linkinfo has no xsrcmd5 attr:\n%s\n' % ET.tostring(sfilelist))
|
||||||
|
sfilelist = ET.fromstring(self.get_files_meta(revision=li.xsrcmd5))
|
||||||
|
for i in sfilelist.findall('entry'):
|
||||||
|
if i.get('name') in self.skipped:
|
||||||
|
i.set('skipped', 'true')
|
||||||
|
store_write_string(self.absdir, '_files', ET.tostring(sfilelist) + '\n')
|
||||||
|
for filename in todo_delete:
|
||||||
|
self.to_be_deleted.remove(filename)
|
||||||
|
self.delete_storefile(filename)
|
||||||
self.write_deletelist()
|
self.write_deletelist()
|
||||||
self.write_addlist()
|
self.write_addlist()
|
||||||
self.update_datastructs()
|
self.update_datastructs()
|
||||||
|
|
||||||
for filename in todo_delete:
|
|
||||||
self.delete_storefile(filename)
|
|
||||||
|
|
||||||
if self.filenamelist.count('_service'):
|
if self.filenamelist.count('_service'):
|
||||||
print 'The package contains a source service.'
|
print 'The package contains a source service.'
|
||||||
for filename in self.todo:
|
for filename in self.todo:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<directory name="simple" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
|
<directory name="add" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
|
||||||
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
||||||
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||||
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
||||||
|
1
tests/commit_fixtures/osctest/allstates/.osc/_apiurl
Normal file
1
tests/commit_fixtures/osctest/allstates/.osc/_apiurl
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://localhost
|
8
tests/commit_fixtures/osctest/allstates/.osc/_files
Normal file
8
tests/commit_fixtures/osctest/allstates/.osc/_files
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<directory name="allstates" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
|
||||||
|
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
||||||
|
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||||
|
<entry md5="676513fde5797c3785164942c97dfec1" mtime="1283506309" name="missing" size="8" />
|
||||||
|
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
||||||
|
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
|
||||||
|
<entry md5="ffffffffffffffffffffffffffffffff" mtime="1111111111" name="skipped" size="100" skipped="true" />
|
||||||
|
</directory>
|
@ -0,0 +1 @@
|
|||||||
|
1.0
|
1
tests/commit_fixtures/osctest/allstates/.osc/_package
Normal file
1
tests/commit_fixtures/osctest/allstates/.osc/_package
Normal file
@ -0,0 +1 @@
|
|||||||
|
allstates
|
1
tests/commit_fixtures/osctest/allstates/.osc/_project
Normal file
1
tests/commit_fixtures/osctest/allstates/.osc/_project
Normal file
@ -0,0 +1 @@
|
|||||||
|
osctest
|
@ -0,0 +1,2 @@
|
|||||||
|
add
|
||||||
|
missing
|
@ -0,0 +1 @@
|
|||||||
|
foo
|
1
tests/commit_fixtures/osctest/allstates/.osc/foo
Normal file
1
tests/commit_fixtures/osctest/allstates/.osc/foo
Normal file
@ -0,0 +1 @@
|
|||||||
|
This is a simple test.
|
4
tests/commit_fixtures/osctest/allstates/.osc/merge
Normal file
4
tests/commit_fixtures/osctest/allstates/.osc/merge
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Is it
|
||||||
|
possible to
|
||||||
|
merge this file?
|
||||||
|
I hope so...
|
1
tests/commit_fixtures/osctest/allstates/.osc/missing
Normal file
1
tests/commit_fixtures/osctest/allstates/.osc/missing
Normal file
@ -0,0 +1 @@
|
|||||||
|
missing
|
1
tests/commit_fixtures/osctest/allstates/.osc/nochange
Normal file
1
tests/commit_fixtures/osctest/allstates/.osc/nochange
Normal file
@ -0,0 +1 @@
|
|||||||
|
This file didn't change.
|
1
tests/commit_fixtures/osctest/allstates/.osc/test
Normal file
1
tests/commit_fixtures/osctest/allstates/.osc/test
Normal file
@ -0,0 +1 @@
|
|||||||
|
test
|
1
tests/commit_fixtures/osctest/allstates/add
Normal file
1
tests/commit_fixtures/osctest/allstates/add
Normal file
@ -0,0 +1 @@
|
|||||||
|
added file
|
0
tests/commit_fixtures/osctest/allstates/exists
Normal file
0
tests/commit_fixtures/osctest/allstates/exists
Normal file
1
tests/commit_fixtures/osctest/allstates/missing
Normal file
1
tests/commit_fixtures/osctest/allstates/missing
Normal file
@ -0,0 +1 @@
|
|||||||
|
replaced
|
1
tests/commit_fixtures/osctest/allstates/nochange
Normal file
1
tests/commit_fixtures/osctest/allstates/nochange
Normal file
@ -0,0 +1 @@
|
|||||||
|
This file did change.
|
1
tests/commit_fixtures/osctest/allstates/test
Normal file
1
tests/commit_fixtures/osctest/allstates/test
Normal file
@ -0,0 +1 @@
|
|||||||
|
test
|
1
tests/commit_fixtures/osctest/branch/.osc/_apiurl
Normal file
1
tests/commit_fixtures/osctest/branch/.osc/_apiurl
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://localhost
|
4
tests/commit_fixtures/osctest/branch/.osc/_files
Normal file
4
tests/commit_fixtures/osctest/branch/.osc/_files
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<directory name="unix" rev="9afa23b484de05e28364b18de7bb1432" srcmd5="9afa23b484de05e28364b18de7bb1432">
|
||||||
|
<linkinfo baserev="b63634ab40861fdb8b44e5f4f459c621" lsrcmd5="cd21541fe2442d3d324a6d6103752913" package="unique" project="btest" srcmd5="b63634ab40861fdb8b44e5f4f459c621" />
|
||||||
|
<entry md5="75d884cf1d235180faec5acb63063972" mtime="1283525196" name="simple" size="21" />
|
||||||
|
</directory>
|
5
tests/commit_fixtures/osctest/branch/.osc/_meta
Normal file
5
tests/commit_fixtures/osctest/branch/.osc/_meta
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<package project="home:Admin" name="unix">
|
||||||
|
<title/>
|
||||||
|
<description>This package was branched from btest in order to ...</description>
|
||||||
|
<person role="maintainer" userid="Admin"/>
|
||||||
|
</package>
|
@ -0,0 +1 @@
|
|||||||
|
1.0
|
1
tests/commit_fixtures/osctest/branch/.osc/_package
Normal file
1
tests/commit_fixtures/osctest/branch/.osc/_package
Normal file
@ -0,0 +1 @@
|
|||||||
|
branch
|
1
tests/commit_fixtures/osctest/branch/.osc/_project
Normal file
1
tests/commit_fixtures/osctest/branch/.osc/_project
Normal file
@ -0,0 +1 @@
|
|||||||
|
osctest
|
1
tests/commit_fixtures/osctest/branch/.osc/simple
Normal file
1
tests/commit_fixtures/osctest/branch/.osc/simple
Normal file
@ -0,0 +1 @@
|
|||||||
|
imple modified file.
|
5
tests/commit_fixtures/osctest/branch/cfilesremote
Normal file
5
tests/commit_fixtures/osctest/branch/cfilesremote
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<directory name="branch" rev="5" srcmd5="1d4bbfa2655ab3982074226e16e1e5ff" vrev="5">
|
||||||
|
<linkinfo baserev="b63634ab40861fdb8b44e5f4f459c621" lsrcmd5="1d4bbfa2655ab3982074226e16e1e5ff" package="bar" project="foo" srcmd5="b63634ab40861fdb8b44e5f4f459c621" xsrcmd5="87ea02aede261b0267aabaa97c756e7a" />
|
||||||
|
<entry md5="542f96b49b64095104d8a9e9dd313a9c" mtime="1283521153" name="_link" size="130" />
|
||||||
|
<entry md5="75da7f7167c22b2b02c6879366d78ad1" mtime="1283525027" name="simple" size="22" />
|
||||||
|
</directory>
|
4
tests/commit_fixtures/osctest/branch/files
Normal file
4
tests/commit_fixtures/osctest/branch/files
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<directory name="branch" rev="87ea02aede261b0267aabaa97c756e7a" srcmd5="87ea02aede261b0267aabaa97c756e7a">
|
||||||
|
<linkinfo baserev="b63634ab40861fdb8b44e5f4f459c621" lsrcmd5="1d4bbfa2655ab3982074226e16e1e5ff" package="bar" project="foo" srcmd5="b63634ab40861fdb8b44e5f4f459c621" />
|
||||||
|
<entry md5="75da7f7167c22b2b02c6879366d78ad1" mtime="1283525027" name="simple" size="22" />
|
||||||
|
</directory>
|
5
tests/commit_fixtures/osctest/branch/filesremote
Normal file
5
tests/commit_fixtures/osctest/branch/filesremote
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<directory name="branch" rev="6" srcmd5="cd21541fe2442d3d324a6d6103752913" vrev="6">
|
||||||
|
<linkinfo baserev="b63634ab40861fdb8b44e5f4f459c621" lsrcmd5="cd21541fe2442d3d324a6d6103752913" package="bar" project="foo" srcmd5="b63634ab40861fdb8b44e5f4f459c621" xsrcmd5="9afa23b484de05e28364b18de7bb1432" />
|
||||||
|
<entry md5="542f96b49b64095104d8a9e9dd313a9c" mtime="1283521153" name="_link" size="130" skipped="true" />
|
||||||
|
<entry md5="75d884cf1d235180faec5acb63063972" mtime="1283525196" name="simple" size="21" />
|
||||||
|
</directory>
|
1
tests/commit_fixtures/osctest/branch/simple
Normal file
1
tests/commit_fixtures/osctest/branch/simple
Normal file
@ -0,0 +1 @@
|
|||||||
|
simple modified file.
|
@ -1,4 +1,4 @@
|
|||||||
<directory name="simple" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
|
<directory name="delete" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
|
||||||
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
||||||
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||||
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<directory name="simple" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
|
<directory name="multiple" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
|
||||||
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
||||||
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||||
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
||||||
|
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
|
||||||
</directory>
|
</directory>
|
||||||
|
1
tests/commit_fixtures/osctest/multiple/.osc/test
Normal file
1
tests/commit_fixtures/osctest/multiple/.osc/test
Normal file
@ -0,0 +1 @@
|
|||||||
|
test
|
1
tests/commit_fixtures/osctest/multiple/test
Normal file
1
tests/commit_fixtures/osctest/multiple/test
Normal file
@ -0,0 +1 @@
|
|||||||
|
test
|
@ -1,4 +1,4 @@
|
|||||||
<directory name="simple" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
|
<directory name="nochanges" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
|
||||||
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" skipped="True" />
|
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" skipped="True" />
|
||||||
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||||
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
||||||
|
1
tests/commit_fixtures/testAddfile_lfilelist
Normal file
1
tests/commit_fixtures/testAddfile_lfilelist
Normal file
@ -0,0 +1 @@
|
|||||||
|
<directory><entry md5="b423d194c75e59ee4d8d2e07ba24323d" name="add" /><entry md5="0d62ceea6020d75154078a20d8c9f9ba" name="foo" /><entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" name="merge" /><entry md5="7efa70f68983fad1cf487f69dedf93e9" name="nochange" /></directory>
|
3
tests/commit_fixtures/testAddfile_missingfilelist
Normal file
3
tests/commit_fixtures/testAddfile_missingfilelist
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<directory error="missing" name="add">
|
||||||
|
<entry md5="b423d194c75e59ee4d8d2e07ba24323d" name="add" />
|
||||||
|
</directory>
|
8
tests/commit_fixtures/testAllStates_cfilesremote
Normal file
8
tests/commit_fixtures/testAllStates_cfilesremote
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<directory name="allstates" rev="2" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="2">
|
||||||
|
<entry md5="b423d194c75e59ee4d8d2e07ba24323d" mtime="3333333333" name="add" size="11" />
|
||||||
|
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||||
|
<entry md5="d908d26cac8092d475f40a5179ca6347" mtime="4444444444" name="missing" size="9" />
|
||||||
|
<entry md5="2abd19de6a38ff2890af64f453df96b1" mtime="2222222222" name="nochange" size="22" />
|
||||||
|
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
|
||||||
|
<entry md5="ffffffffffffffffffffffffffffffff" mtime="1111111111" name="skipped" size="100" />
|
||||||
|
</directory>
|
8
tests/commit_fixtures/testAllStates_expfiles
Normal file
8
tests/commit_fixtures/testAllStates_expfiles
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<directory name="allstates" rev="2" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="2">
|
||||||
|
<entry md5="b423d194c75e59ee4d8d2e07ba24323d" mtime="3333333333" name="add" size="11" />
|
||||||
|
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||||
|
<entry md5="d908d26cac8092d475f40a5179ca6347" mtime="4444444444" name="missing" size="9" />
|
||||||
|
<entry md5="2abd19de6a38ff2890af64f453df96b1" mtime="2222222222" name="nochange" size="22" />
|
||||||
|
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
|
||||||
|
<entry md5="ffffffffffffffffffffffffffffffff" mtime="1111111111" name="skipped" size="100" skipped="true" />
|
||||||
|
</directory>
|
8
tests/commit_fixtures/testAllStates_filesremote
Normal file
8
tests/commit_fixtures/testAllStates_filesremote
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<directory name="allstates" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
|
||||||
|
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
||||||
|
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||||
|
<entry md5="676513fde5797c3785164942c97dfec1" mtime="1283506309" name="missing" size="8" />
|
||||||
|
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
||||||
|
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
|
||||||
|
<entry md5="ffffffffffffffffffffffffffffffff" mtime="1111111111" name="skipped" size="100" />
|
||||||
|
</directory>
|
1
tests/commit_fixtures/testAllStates_lfilelist
Normal file
1
tests/commit_fixtures/testAllStates_lfilelist
Normal file
@ -0,0 +1 @@
|
|||||||
|
<directory><entry md5="b423d194c75e59ee4d8d2e07ba24323d" name="add" /><entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" name="merge" /><entry md5="d908d26cac8092d475f40a5179ca6347" name="missing" /><entry md5="2abd19de6a38ff2890af64f453df96b1" name="nochange" /><entry md5="ffffffffffffffffffffffffffffffff" name="skipped" /><entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" name="test" /></directory>
|
5
tests/commit_fixtures/testAllStates_missingfilelist
Normal file
5
tests/commit_fixtures/testAllStates_missingfilelist
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<directory error="missing" name="allstates">
|
||||||
|
<entry md5="b423d194c75e59ee4d8d2e07ba24323d" name="add" />
|
||||||
|
<entry md5="d908d26cac8092d475f40a5179ca6347" name="missing" />
|
||||||
|
<entry md5="2abd19de6a38ff2890af64f453df96b1" name="nochange" />
|
||||||
|
</directory>
|
1
tests/commit_fixtures/testDeletefile_lfilelist
Normal file
1
tests/commit_fixtures/testDeletefile_lfilelist
Normal file
@ -0,0 +1 @@
|
|||||||
|
<directory><entry md5="0d62ceea6020d75154078a20d8c9f9ba" name="foo" /><entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" name="merge" /></directory>
|
5
tests/commit_fixtures/testExpand_cfilesremote
Normal file
5
tests/commit_fixtures/testExpand_cfilesremote
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<directory name="branch" rev="7" srcmd5="1d4bbfa2655ab3982074226e16e1e5ff" vrev="7">
|
||||||
|
<linkinfo baserev="b63634ab40861fdb8b44e5f4f459c621" lsrcmd5="1d4bbfa2655ab3982074226e16e1e5ff" package="bar" project="foo" srcmd5="b63634ab40861fdb8b44e5f4f459c621" xsrcmd5="87ea02aede261b0267aabaa97c756e7a" />
|
||||||
|
<entry md5="542f96b49b64095104d8a9e9dd313a9c" mtime="1283521153" name="_link" size="130" />
|
||||||
|
<entry md5="75da7f7167c22b2b02c6879366d78ad1" mtime="1283525027" name="simple" size="22" />
|
||||||
|
</directory>
|
4
tests/commit_fixtures/testExpand_expandedfilesremote
Normal file
4
tests/commit_fixtures/testExpand_expandedfilesremote
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<directory name="branch" rev="87ea02aede261b0267aabaa97c756e7a" srcmd5="87ea02aede261b0267aabaa97c756e7a">
|
||||||
|
<linkinfo baserev="b63634ab40861fdb8b44e5f4f459c621" lsrcmd5="1d4bbfa2655ab3982074226e16e1e5ff" package="bar" project="foo" srcmd5="b63634ab40861fdb8b44e5f4f459c621" />
|
||||||
|
<entry md5="75da7f7167c22b2b02c6879366d78ad1" mtime="1283525027" name="simple" size="22" />
|
||||||
|
</directory>
|
5
tests/commit_fixtures/testExpand_filesremote
Normal file
5
tests/commit_fixtures/testExpand_filesremote
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<directory name="branch" rev="6" srcmd5="cd21541fe2442d3d324a6d6103752913" vrev="6">
|
||||||
|
<linkinfo baserev="b63634ab40861fdb8b44e5f4f459c621" lsrcmd5="cd21541fe2442d3d324a6d6103752913" package="bar" project="foo" srcmd5="b63634ab40861fdb8b44e5f4f459c621" xsrcmd5="9afa23b484de05e28364b18de7bb1432" />
|
||||||
|
<entry md5="542f96b49b64095104d8a9e9dd313a9c" mtime="1283521153" name="_link" size="130" skipped="true" />
|
||||||
|
<entry md5="75d884cf1d235180faec5acb63063972" mtime="1283525196" name="simple" size="21" />
|
||||||
|
</directory>
|
1
tests/commit_fixtures/testExpand_lfilelist
Normal file
1
tests/commit_fixtures/testExpand_lfilelist
Normal file
@ -0,0 +1 @@
|
|||||||
|
<directory><entry md5="75da7f7167c22b2b02c6879366d78ad1" name="simple" /></directory>
|
3
tests/commit_fixtures/testExpand_missingfilelist
Normal file
3
tests/commit_fixtures/testExpand_missingfilelist
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<directory error="missing" name="branch">
|
||||||
|
<entry md5="75da7f7167c22b2b02c6879366d78ad1" name="simple" />
|
||||||
|
</directory>
|
1
tests/commit_fixtures/testInterrupted_lfilelist
Normal file
1
tests/commit_fixtures/testInterrupted_lfilelist
Normal file
@ -0,0 +1 @@
|
|||||||
|
<directory><entry md5="0d62ceea6020d75154078a20d8c9f9ba" name="foo" /><entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" name="merge" /><entry md5="382588b92f5976de693f44c4d6df27b7" name="nochange" /></directory>
|
@ -2,4 +2,5 @@
|
|||||||
<entry md5="b423d194c75e59ee4d8d2e07ba24323d" mtime="1111111111" name="add" size="11" />
|
<entry md5="b423d194c75e59ee4d8d2e07ba24323d" mtime="1111111111" name="add" size="11" />
|
||||||
<entry md5="ea467af882b32a275fe62eb05aba6ee1" mtime="0000000000" name="add2" size="5" />
|
<entry md5="ea467af882b32a275fe62eb05aba6ee1" mtime="0000000000" name="add2" size="5" />
|
||||||
<entry md5="2abd19de6a38ff2890af64f453df96b1" mtime="2222222222" name="nochange" size="22" />
|
<entry md5="2abd19de6a38ff2890af64f453df96b1" mtime="2222222222" name="nochange" size="22" />
|
||||||
|
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
|
||||||
</directory>
|
</directory>
|
||||||
|
@ -2,4 +2,5 @@
|
|||||||
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
||||||
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||||
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
||||||
|
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
|
||||||
</directory>
|
</directory>
|
||||||
|
1
tests/commit_fixtures/testMultiple_lfilelist
Normal file
1
tests/commit_fixtures/testMultiple_lfilelist
Normal file
@ -0,0 +1 @@
|
|||||||
|
<directory><entry md5="b423d194c75e59ee4d8d2e07ba24323d" name="add" /><entry md5="ea467af882b32a275fe62eb05aba6ee1" name="add2" /><entry md5="2abd19de6a38ff2890af64f453df96b1" name="nochange" /><entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" name="test" /></directory>
|
5
tests/commit_fixtures/testMultiple_missingfilelist
Normal file
5
tests/commit_fixtures/testMultiple_missingfilelist
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<directory error="missing" name="add">
|
||||||
|
<entry md5="2abd19de6a38ff2890af64f453df96b1" name="nochange" />
|
||||||
|
<entry md5="b423d194c75e59ee4d8d2e07ba24323d" name="add" />
|
||||||
|
<entry md5="ea467af882b32a275fe62eb05aba6ee1" name="add2" />
|
||||||
|
</directory>
|
@ -1,5 +1,6 @@
|
|||||||
<directory name="simple" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
|
<directory name="simple" rev="2" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="2">
|
||||||
<entry md5="b423d194c75e59ee4d8d2e07ba24323d" mtime="1111111111" name="add" size="11" />
|
<entry md5="b423d194c75e59ee4d8d2e07ba24323d" mtime="1111111111" name="add" size="11" />
|
||||||
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||||
<entry md5="2abd19de6a38ff2890af64f453df96b1" mtime="2222222222" name="nochange" size="22" />
|
<entry md5="2abd19de6a38ff2890af64f453df96b1" mtime="2222222222" name="nochange" size="22" />
|
||||||
|
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
|
||||||
</directory>
|
</directory>
|
||||||
|
@ -2,4 +2,5 @@
|
|||||||
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
||||||
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||||
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
|
||||||
|
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
|
||||||
</directory>
|
</directory>
|
||||||
|
1
tests/commit_fixtures/testPartial_lfilelist
Normal file
1
tests/commit_fixtures/testPartial_lfilelist
Normal file
@ -0,0 +1 @@
|
|||||||
|
<directory><entry md5="b423d194c75e59ee4d8d2e07ba24323d" name="add" /><entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" name="merge" /><entry md5="2abd19de6a38ff2890af64f453df96b1" name="nochange" /><entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" name="test" /></directory>
|
4
tests/commit_fixtures/testPartial_missingfilelist
Normal file
4
tests/commit_fixtures/testPartial_missingfilelist
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<directory error="missing" name="partial">
|
||||||
|
<entry md5="b423d194c75e59ee4d8d2e07ba24323d" name="add" />
|
||||||
|
<entry md5="2abd19de6a38ff2890af64f453df96b1" name="nochange" />
|
||||||
|
</directory>
|
1
tests/commit_fixtures/testSimple_lfilelist
Normal file
1
tests/commit_fixtures/testSimple_lfilelist
Normal file
@ -0,0 +1 @@
|
|||||||
|
<directory><entry md5="0d62ceea6020d75154078a20d8c9f9ba" name="foo" /><entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" name="merge" /><entry md5="382588b92f5976de693f44c4d6df27b7" name="nochange" /></directory>
|
3
tests/commit_fixtures/testSimple_missingfilelist
Normal file
3
tests/commit_fixtures/testSimple_missingfilelist
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<directory error="missing" name="simple">
|
||||||
|
<entry md5="c4eaea5dcaff13418e38e7fea151dd49" name="nochange" />
|
||||||
|
</directory>
|
@ -55,9 +55,11 @@ class MyHTTPHandler(urllib2.HTTPHandler):
|
|||||||
raise RuntimeError('either specify exp or expfile')
|
raise RuntimeError('either specify exp or expfile')
|
||||||
elif kwargs.has_key('expfile'):
|
elif kwargs.has_key('expfile'):
|
||||||
exp = open(os.path.join(self.__fixtures_dir, kwargs['expfile']), 'r').read()
|
exp = open(os.path.join(self.__fixtures_dir, kwargs['expfile']), 'r').read()
|
||||||
|
elif exp is None:
|
||||||
|
raise RuntimeError('exp or expfile required')
|
||||||
if exp is not None:
|
if exp is not None:
|
||||||
if req.get_data() != exp:
|
if req.get_data() != exp:
|
||||||
raise RequestDataMismatch(req.get_full_url(), req.get_data(), exp)
|
raise RequestDataMismatch(req.get_full_url(), repr(req.get_data()), repr(exp))
|
||||||
return self.__get_response(req.get_full_url(), **kwargs)
|
return self.__get_response(req.get_full_url(), **kwargs)
|
||||||
|
|
||||||
def __get_response(self, url, **kwargs):
|
def __get_response(self, url, **kwargs):
|
||||||
|
@ -10,18 +10,19 @@ def suite():
|
|||||||
import unittest
|
import unittest
|
||||||
return unittest.makeSuite(TestCommit)
|
return unittest.makeSuite(TestCommit)
|
||||||
|
|
||||||
rev_dummy = '<revision rev="upload">\n <srcmd5>ffffffffffffffffffffffffffffffff</srcmd5>\n</revision>'
|
rev_dummy = '<revision rev="repository">\n <srcmd5>empty</srcmd5>\n</revision>'
|
||||||
|
|
||||||
class TestCommit(OscTestCase):
|
class TestCommit(OscTestCase):
|
||||||
def _get_fixtures_dir(self):
|
def _get_fixtures_dir(self):
|
||||||
return FIXTURES_DIR
|
return FIXTURES_DIR
|
||||||
|
|
||||||
@GET('http://localhost/source/osctest/simple?rev=latest', file='testSimple_filesremote')
|
@GET('http://localhost/source/osctest/simple?rev=latest', file='testSimple_filesremote')
|
||||||
@PUT('http://localhost/source/osctest/simple/nochange?rev=upload',
|
@POST('http://localhost/source/osctest/simple?comment=&cmd=commitfilelist&user=Admin',
|
||||||
|
file='testSimple_missingfilelist', expfile='testSimple_lfilelist')
|
||||||
|
@PUT('http://localhost/source/osctest/simple/nochange?rev=repository',
|
||||||
exp='This file didn\'t change but\nis modified.\n', text=rev_dummy)
|
exp='This file didn\'t change but\nis modified.\n', text=rev_dummy)
|
||||||
@POST('http://localhost/source/osctest/simple?comment=&cmd=commit&rev=upload&user=Admin', text='<revision rev="2" />',
|
@POST('http://localhost/source/osctest/simple?comment=&cmd=commitfilelist&user=Admin',
|
||||||
exp='')
|
file='testSimple_cfilesremote', expfile='testSimple_lfilelist')
|
||||||
@GET('http://localhost/source/osctest/simple?rev=2', file='testSimple_cfilesremote')
|
|
||||||
def test_simple(self):
|
def test_simple(self):
|
||||||
"""a simple commit (only one modified file)"""
|
"""a simple commit (only one modified file)"""
|
||||||
self._change_to_pkg('simple')
|
self._change_to_pkg('simple')
|
||||||
@ -33,13 +34,16 @@ class TestCommit(OscTestCase):
|
|||||||
self.assertTrue(os.path.exists('nochange'))
|
self.assertTrue(os.path.exists('nochange'))
|
||||||
self.assertEqual(open('nochange', 'r').read(), open(os.path.join('.osc', 'nochange'), 'r').read())
|
self.assertEqual(open('nochange', 'r').read(), open(os.path.join('.osc', 'nochange'), 'r').read())
|
||||||
self._check_status(p, 'nochange', ' ')
|
self._check_status(p, 'nochange', ' ')
|
||||||
|
self._check_status(p, 'foo', ' ')
|
||||||
|
self._check_status(p, 'merge', ' ')
|
||||||
|
|
||||||
@GET('http://localhost/source/osctest/add?rev=latest', file='testAddfile_filesremote')
|
@GET('http://localhost/source/osctest/add?rev=latest', file='testAddfile_filesremote')
|
||||||
@PUT('http://localhost/source/osctest/add/add?rev=upload',
|
@POST('http://localhost/source/osctest/add?comment=&cmd=commitfilelist&user=Admin',
|
||||||
|
file='testAddfile_missingfilelist', expfile='testAddfile_lfilelist')
|
||||||
|
@PUT('http://localhost/source/osctest/add/add?rev=repository',
|
||||||
exp='added file\n', text=rev_dummy)
|
exp='added file\n', text=rev_dummy)
|
||||||
@POST('http://localhost/source/osctest/add?comment=&cmd=commit&rev=upload&user=Admin', text='<revision rev="2" />',
|
@POST('http://localhost/source/osctest/add?comment=&cmd=commitfilelist&user=Admin',
|
||||||
exp='')
|
file='testAddfile_cfilesremote', expfile='testAddfile_lfilelist')
|
||||||
@GET('http://localhost/source/osctest/add?rev=2', file='testAddfile_cfilesremote')
|
|
||||||
def test_addfile(self):
|
def test_addfile(self):
|
||||||
"""commit a new file"""
|
"""commit a new file"""
|
||||||
self._change_to_pkg('add')
|
self._change_to_pkg('add')
|
||||||
@ -52,22 +56,26 @@ class TestCommit(OscTestCase):
|
|||||||
self.assertEqual(open('add', 'r').read(), open(os.path.join('.osc', 'add'), 'r').read())
|
self.assertEqual(open('add', 'r').read(), open(os.path.join('.osc', 'add'), 'r').read())
|
||||||
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
|
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
|
||||||
self._check_status(p, 'add', ' ')
|
self._check_status(p, 'add', ' ')
|
||||||
|
self._check_status(p, 'foo', ' ')
|
||||||
|
self._check_status(p, 'merge', ' ')
|
||||||
|
self._check_status(p, 'nochange', ' ')
|
||||||
|
|
||||||
@GET('http://localhost/source/osctest/delete?rev=latest', file='testDeletefile_filesremote')
|
@GET('http://localhost/source/osctest/delete?rev=latest', file='testDeletefile_filesremote')
|
||||||
@DELETE('http://localhost/source/osctest/delete/nochange?rev=upload', text='<status code="ok" />')
|
@POST('http://localhost/source/osctest/delete?comment=&cmd=commitfilelist&user=Admin',
|
||||||
@POST('http://localhost/source/osctest/delete?comment=&cmd=commit&rev=upload&user=Admin', text='<revision rev="2" />',
|
file='testDeletefile_cfilesremote', expfile='testDeletefile_lfilelist')
|
||||||
exp='')
|
|
||||||
@GET('http://localhost/source/osctest/delete?rev=2', file='testDeletefile_cfilesremote')
|
|
||||||
def test_deletefile(self):
|
def test_deletefile(self):
|
||||||
"""delete a file"""
|
"""delete a file"""
|
||||||
self._change_to_pkg('delete')
|
self._change_to_pkg('delete')
|
||||||
osc.core.Package('.').commit()
|
p = osc.core.Package('.')
|
||||||
|
p.commit()
|
||||||
exp = 'Deleting nochange\nTransmitting file data \nCommitted revision 2.\n'
|
exp = 'Deleting nochange\nTransmitting file data \nCommitted revision 2.\n'
|
||||||
self.assertEqual(sys.stdout.getvalue(), exp)
|
self.assertEqual(sys.stdout.getvalue(), exp)
|
||||||
self._check_digests('testDeletefile_cfilesremote')
|
self._check_digests('testDeletefile_cfilesremote')
|
||||||
self.assertFalse(os.path.exists('nochange'))
|
self.assertFalse(os.path.exists('nochange'))
|
||||||
self.assertFalse(os.path.exists(os.path.join('.osc', 'nochange')))
|
self.assertFalse(os.path.exists(os.path.join('.osc', 'nochange')))
|
||||||
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_deleted')))
|
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_deleted')))
|
||||||
|
self._check_status(p, 'foo', ' ')
|
||||||
|
self._check_status(p, 'merge', ' ')
|
||||||
|
|
||||||
@GET('http://localhost/source/osctest/conflict?rev=latest', file='testConflictfile_filesremote')
|
@GET('http://localhost/source/osctest/conflict?rev=latest', file='testConflictfile_filesremote')
|
||||||
def test_conflictfile(self):
|
def test_conflictfile(self):
|
||||||
@ -84,27 +92,30 @@ class TestCommit(OscTestCase):
|
|||||||
def test_nochanges(self):
|
def test_nochanges(self):
|
||||||
"""package has no changes (which can be committed)"""
|
"""package has no changes (which can be committed)"""
|
||||||
self._change_to_pkg('nochanges')
|
self._change_to_pkg('nochanges')
|
||||||
ret = osc.core.Package('.').commit()
|
p = osc.core.Package('.')
|
||||||
|
ret = p.commit()
|
||||||
self.assertTrue(ret == 1)
|
self.assertTrue(ret == 1)
|
||||||
exp = 'nothing to do for package nochanges\n'
|
exp = 'nothing to do for package nochanges\n'
|
||||||
self.assertEqual(sys.stdout.getvalue(), exp)
|
self.assertEqual(sys.stdout.getvalue(), exp)
|
||||||
|
self._check_status(p, 'foo', 'S')
|
||||||
|
self._check_status(p, 'merge', '!')
|
||||||
|
self._check_status(p, 'nochange', ' ')
|
||||||
|
|
||||||
@GET('http://localhost/source/osctest/multiple?rev=latest', file='testMultiple_filesremote')
|
@GET('http://localhost/source/osctest/multiple?rev=latest', file='testMultiple_filesremote')
|
||||||
@DELETE('http://localhost/source/osctest/multiple/foo?rev=upload', text='<status code="ok" />')
|
@POST('http://localhost/source/osctest/multiple?comment=&cmd=commitfilelist&user=Admin',
|
||||||
@DELETE('http://localhost/source/osctest/multiple/merge?rev=upload', text='<status code="ok" />')
|
file='testMultiple_missingfilelist', expfile='testMultiple_lfilelist')
|
||||||
@PUT('http://localhost/source/osctest/multiple/add?rev=upload', exp='added file\n', text=rev_dummy)
|
@PUT('http://localhost/source/osctest/multiple/nochange?rev=repository', exp='This file did change.\n', text=rev_dummy)
|
||||||
@PUT('http://localhost/source/osctest/multiple/add2?rev=upload', exp='add2\n', text=rev_dummy)
|
@PUT('http://localhost/source/osctest/multiple/add?rev=repository', exp='added file\n', text=rev_dummy)
|
||||||
@PUT('http://localhost/source/osctest/multiple/nochange?rev=upload', exp='This file did change.\n', text=rev_dummy)
|
@PUT('http://localhost/source/osctest/multiple/add2?rev=repository', exp='add2\n', text=rev_dummy)
|
||||||
@POST('http://localhost/source/osctest/multiple?comment=&cmd=commit&rev=upload&user=Admin', text='<revision rev="2" />',
|
@POST('http://localhost/source/osctest/multiple?comment=&cmd=commitfilelist&user=Admin',
|
||||||
exp='')
|
file='testMultiple_cfilesremote', expfile='testMultiple_lfilelist')
|
||||||
@GET('http://localhost/source/osctest/multiple?rev=2', file='testMultiple_cfilesremote')
|
|
||||||
def test_multiple(self):
|
def test_multiple(self):
|
||||||
"""a simple commit (only one modified file)"""
|
"""a simple commit (only one modified file)"""
|
||||||
self._change_to_pkg('multiple')
|
self._change_to_pkg('multiple')
|
||||||
p = osc.core.Package('.')
|
p = osc.core.Package('.')
|
||||||
p.commit()
|
p.commit()
|
||||||
exp = 'Sending add\nSending add2\nDeleting foo\nDeleting ' \
|
exp = 'Deleting foo\nDeleting merge\nSending nochange\n' \
|
||||||
'merge\nSending nochange\nTransmitting file data ...\nCommitted revision 2.\n'
|
'Sending add\nSending add2\nTransmitting file data ...\nCommitted revision 2.\n'
|
||||||
self.assertEqual(sys.stdout.getvalue(), exp)
|
self.assertEqual(sys.stdout.getvalue(), exp)
|
||||||
self._check_digests('testMultiple_cfilesremote')
|
self._check_digests('testMultiple_cfilesremote')
|
||||||
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
|
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
|
||||||
@ -118,21 +129,21 @@ class TestCommit(OscTestCase):
|
|||||||
self._check_status(p, 'nochange', ' ')
|
self._check_status(p, 'nochange', ' ')
|
||||||
|
|
||||||
@GET('http://localhost/source/osctest/multiple?rev=latest', file='testPartial_filesremote')
|
@GET('http://localhost/source/osctest/multiple?rev=latest', file='testPartial_filesremote')
|
||||||
@DELETE('http://localhost/source/osctest/multiple/foo?rev=upload', text='<status code="ok" />')
|
@POST('http://localhost/source/osctest/multiple?comment=&cmd=commitfilelist&user=Admin',
|
||||||
@PUT('http://localhost/source/osctest/multiple/add?rev=upload', exp='added file\n', text=rev_dummy)
|
file='testPartial_missingfilelist', expfile='testPartial_lfilelist')
|
||||||
@PUT('http://localhost/source/osctest/multiple/nochange?rev=upload', exp='This file did change.\n', text=rev_dummy)
|
@PUT('http://localhost/source/osctest/multiple/add?rev=repository', exp='added file\n', text=rev_dummy)
|
||||||
@POST('http://localhost/source/osctest/multiple?comment=&cmd=commit&rev=upload&user=Admin', text='<revision rev="2" />',
|
@PUT('http://localhost/source/osctest/multiple/nochange?rev=repository', exp='This file did change.\n', text=rev_dummy)
|
||||||
exp='')
|
@POST('http://localhost/source/osctest/multiple?comment=&cmd=commitfilelist&user=Admin',
|
||||||
@GET('http://localhost/source/osctest/multiple?rev=2', file='testPartial_cfilesremote')
|
file='testPartial_cfilesremote', expfile='testPartial_lfilelist')
|
||||||
def test_partial(self):
|
def test_partial(self):
|
||||||
"""commit only some files"""
|
"""commit only some files"""
|
||||||
self._change_to_pkg('multiple')
|
self._change_to_pkg('multiple')
|
||||||
p = osc.core.Package('.')
|
p = osc.core.Package('.')
|
||||||
p.todo = ['foo', 'add', 'nochange']
|
p.todo = ['foo', 'add', 'nochange']
|
||||||
p.commit()
|
p.commit()
|
||||||
exp = 'Sending add\nDeleting foo\n' \
|
exp = 'Deleting foo\nSending nochange\n' \
|
||||||
'Sending nochange\nTransmitting file data ...\nCommitted revision 2.\n'
|
'Sending add\nTransmitting file data ..\nCommitted revision 2.\n'
|
||||||
self.assertTrue(sys.stdout.getvalue(), exp)
|
self.assertEqual(sys.stdout.getvalue(), exp)
|
||||||
self._check_digests('testPartial_cfilesremote')
|
self._check_digests('testPartial_cfilesremote')
|
||||||
self._check_addlist('add2\n')
|
self._check_addlist('add2\n')
|
||||||
self._check_deletelist('merge\n')
|
self._check_deletelist('merge\n')
|
||||||
@ -143,21 +154,85 @@ class TestCommit(OscTestCase):
|
|||||||
self.assertRaises(osc.oscerr.OscIOError, p.status, 'foo')
|
self.assertRaises(osc.oscerr.OscIOError, p.status, 'foo')
|
||||||
|
|
||||||
@GET('http://localhost/source/osctest/simple?rev=latest', file='testSimple_filesremote')
|
@GET('http://localhost/source/osctest/simple?rev=latest', file='testSimple_filesremote')
|
||||||
@PUT('http://localhost/source/osctest/simple/nochange?rev=upload', exp='This file didn\'t change but\nis modified.\n',
|
@POST('http://localhost/source/osctest/simple?comment=&cmd=commitfilelist&user=Admin',
|
||||||
|
file='testSimple_missingfilelist', expfile='testSimple_lfilelist')
|
||||||
|
@PUT('http://localhost/source/osctest/simple/nochange?rev=repository', exp='This file didn\'t change but\nis modified.\n',
|
||||||
exception=IOError('test exception'), text=rev_dummy)
|
exception=IOError('test exception'), text=rev_dummy)
|
||||||
@POST('http://localhost/source/osctest/simple?comment=&cmd=deleteuploadrev&rev=upload&user=Admin', text='<revision rev="2" />',
|
|
||||||
exp='')
|
|
||||||
def test_interrupt(self):
|
def test_interrupt(self):
|
||||||
"""interrupt a commit"""
|
"""interrupt a commit"""
|
||||||
self._change_to_pkg('simple')
|
self._change_to_pkg('simple')
|
||||||
p = osc.core.Package('.')
|
p = osc.core.Package('.')
|
||||||
self.assertRaises(IOError, p.commit)
|
self.assertRaises(IOError, p.commit)
|
||||||
exp = 'Sending nochange\nTransmitting file data .'
|
exp = 'Sending nochange\nTransmitting file data .'
|
||||||
self.assertEqual(sys.stdout.getvalue(), exp)
|
self.assertTrue(sys.stdout.getvalue(), exp)
|
||||||
self._check_digests('testSimple_filesremote')
|
self._check_digests('testSimple_filesremote')
|
||||||
self.assertTrue(os.path.exists('nochange'))
|
self.assertTrue(os.path.exists('nochange'))
|
||||||
self._check_status(p, 'nochange', 'M')
|
self._check_status(p, 'nochange', 'M')
|
||||||
|
|
||||||
|
@GET('http://localhost/source/osctest/allstates?rev=latest', file='testPartial_filesremote')
|
||||||
|
@POST('http://localhost/source/osctest/allstates?comment=&cmd=commitfilelist&user=Admin',
|
||||||
|
file='testAllStates_missingfilelist', expfile='testAllStates_lfilelist')
|
||||||
|
@PUT('http://localhost/source/osctest/allstates/add?rev=repository', exp='added file\n', text=rev_dummy)
|
||||||
|
@PUT('http://localhost/source/osctest/allstates/missing?rev=repository', exp='replaced\n', text=rev_dummy)
|
||||||
|
@PUT('http://localhost/source/osctest/allstates/nochange?rev=repository', exp='This file did change.\n', text=rev_dummy)
|
||||||
|
@POST('http://localhost/source/osctest/allstates?comment=&cmd=commitfilelist&user=Admin',
|
||||||
|
file='testAllStates_cfilesremote', expfile='testAllStates_lfilelist')
|
||||||
|
def test_allstates(self):
|
||||||
|
"""commit all files (all states are available except 'C')"""
|
||||||
|
self._change_to_pkg('allstates')
|
||||||
|
p = osc.core.Package('.')
|
||||||
|
p.commit()
|
||||||
|
exp = 'Deleting foo\nSending missing\nSending nochange\n' \
|
||||||
|
'Sending add\nTransmitting file data ...\nCommitted revision 2.\n'
|
||||||
|
self.assertEqual(sys.stdout.getvalue(), exp)
|
||||||
|
self._check_digests('testAllStates_expfiles', 'skipped')
|
||||||
|
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
|
||||||
|
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_deleted')))
|
||||||
|
self.assertFalse(os.path.exists('foo'))
|
||||||
|
self.assertFalse(os.path.exists(os.path.join('.osc', 'foo')))
|
||||||
|
self._check_status(p, 'add', ' ')
|
||||||
|
self._check_status(p, 'nochange', ' ')
|
||||||
|
self._check_status(p, 'merge', '!')
|
||||||
|
self._check_status(p, 'missing', ' ')
|
||||||
|
self._check_status(p, 'skipped', 'S')
|
||||||
|
self._check_status(p, 'test', ' ')
|
||||||
|
|
||||||
|
@GET('http://localhost/source/osctest/add?rev=latest', file='testAddfile_filesremote')
|
||||||
|
@POST('http://localhost/source/osctest/add?comment=&cmd=commitfilelist&user=Admin',
|
||||||
|
file='testAddfile_cfilesremote', expfile='testAddfile_lfilelist')
|
||||||
|
def test_remoteexists(self):
|
||||||
|
"""file 'add' should be committed but already exists on the server"""
|
||||||
|
self._change_to_pkg('add')
|
||||||
|
p = osc.core.Package('.')
|
||||||
|
p.commit()
|
||||||
|
exp = 'Sending add\nTransmitting file data \nCommitted revision 2.\n'
|
||||||
|
self.assertEqual(sys.stdout.getvalue(), exp)
|
||||||
|
self._check_digests('testAddfile_cfilesremote')
|
||||||
|
self.assertTrue(os.path.exists('add'))
|
||||||
|
self.assertEqual(open('add', 'r').read(), open(os.path.join('.osc', 'add'), 'r').read())
|
||||||
|
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
|
||||||
|
self._check_status(p, 'add', ' ')
|
||||||
|
self._check_status(p, 'foo', ' ')
|
||||||
|
self._check_status(p, 'merge', ' ')
|
||||||
|
self._check_status(p, 'nochange', ' ')
|
||||||
|
|
||||||
|
@GET('http://localhost/source/osctest/branch?rev=latest', file='testExpand_filesremote')
|
||||||
|
@POST('http://localhost/source/osctest/branch?comment=&cmd=commitfilelist&user=Admin&keeplink=1',
|
||||||
|
file='testExpand_missingfilelist', expfile='testExpand_lfilelist')
|
||||||
|
@PUT('http://localhost/source/osctest/branch/simple?rev=repository', exp='simple modified file.\n', text=rev_dummy)
|
||||||
|
@POST('http://localhost/source/osctest/branch?comment=&cmd=commitfilelist&user=Admin&keeplink=1',
|
||||||
|
file='testExpand_cfilesremote', expfile='testExpand_lfilelist')
|
||||||
|
@GET('http://localhost/source/osctest/branch?rev=87ea02aede261b0267aabaa97c756e7a', file='testExpand_expandedfilesremote')
|
||||||
|
def test_expand(self):
|
||||||
|
"""commit an expanded package"""
|
||||||
|
self._change_to_pkg('branch')
|
||||||
|
p = osc.core.Package('.')
|
||||||
|
p.commit()
|
||||||
|
exp = 'Sending simple\nTransmitting file data .\nCommitted revision 7.\n'
|
||||||
|
self.assertEqual(sys.stdout.getvalue(), exp)
|
||||||
|
self._check_digests('testExpand_expandedfilesremote')
|
||||||
|
self._check_status(p, 'simple', ' ')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import unittest
|
import unittest
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user