mirror of
https://github.com/vitalif/viewvc-4intranet
synced 2019-04-16 04:14:59 +03:00
Compare commits
12 Commits
custis
...
custishack
Author | SHA1 | Date | |
---|---|---|---|
61714c2d19 | |||
32d423de05 | |||
f9dae8cb57 | |||
ce7baead57 | |||
![]() |
50189983d6 | ||
![]() |
a0251a2d88 | ||
![]() |
c948ae95a2 | ||
![]() |
301ca87070 | ||
![]() |
cc4b8471c0 | ||
![]() |
049748da6f | ||
![]() |
5cac879028 | ||
![]() |
0e73f94af3 |
137
lib/viewvc.py
137
lib/viewvc.py
@@ -40,6 +40,7 @@ import urllib
|
||||
import datetime
|
||||
import locale
|
||||
import string
|
||||
import cgi
|
||||
|
||||
# These modules come from our library (the stub has set up the path)
|
||||
from common import _item, _RCSDIFF_NO_CHANGES, _RCSDIFF_IS_BINARY, _RCSDIFF_ERROR, TemplateData
|
||||
@@ -820,6 +821,9 @@ _legal_params = {
|
||||
|
||||
# FeedOnFeeds sudo authorization
|
||||
'fof_sudo' : None,
|
||||
|
||||
# Custispatcher parameter
|
||||
'xml' : None,
|
||||
}
|
||||
|
||||
def _path_join(path_parts):
|
||||
@@ -4765,7 +4769,7 @@ def build_commit(request, files, max_files, dir_strip, format):
|
||||
commit.short_log = None
|
||||
else:
|
||||
lf = LogFormatter(request, desc)
|
||||
htmlize = (format != 'rss')
|
||||
htmlize = (format != 'rss' and format != 'custispatcher')
|
||||
commit.log = lf.get(maxlen=0, htmlize=htmlize)
|
||||
commit.short_log = lf.get(maxlen=cfg.options.short_log_len, htmlize=htmlize)
|
||||
commit.author = request.server.escape(author)
|
||||
@@ -4911,6 +4915,117 @@ def query_patch(request, commits):
|
||||
except:
|
||||
pass
|
||||
|
||||
# --- START UGLY HACK ---
|
||||
# FIXME Remove this from here to some hook package
|
||||
# CustIS "patcher" format for PL/SQL packages (Bug 96691)
|
||||
# <put file="../i-basket/pi_shp_basket_cards.sp4" revision="1.364" schema="*ADMIN"/>
|
||||
def custispatcher_slug(commits):
|
||||
header_re = re.compile('^\s*_package\s*\(\s*[^,]*,\s*([^,\s]+)', re.M)
|
||||
by_fn = {}
|
||||
bugmsg = re.compile('bug\s*(\d+)', re.I)
|
||||
msgs = {}
|
||||
bugs = {}
|
||||
for commit in commits:
|
||||
found = 0
|
||||
for fileinfo in commit.files:
|
||||
ext = fileinfo.file.lower()
|
||||
sp4 = ext.endswith('.sp4')
|
||||
xml = ext.endswith('.xml')
|
||||
if sp4 or xml:
|
||||
found = 1
|
||||
fn = _path_join([fileinfo.dir, fileinfo.file])
|
||||
rfn = fn.replace('sm-code/shop/', '../')
|
||||
# Only latest revision of each file
|
||||
if fn not in by_fn or rev_cmp(by_fn[fn][1], fileinfo.rev) < 0:
|
||||
if sp4:
|
||||
parts = _path_parts(fn)
|
||||
fd, _ = fileinfo.root.repos.openfile(parts, fileinfo.rev, {})
|
||||
header = fd.read(4096)
|
||||
fd.close()
|
||||
# Try to find _package() declaration with schema in file header
|
||||
schema = header_re.search(header)
|
||||
if schema:
|
||||
schema = schema.group(1)
|
||||
else:
|
||||
schema = ''
|
||||
s = '<put file="'+rfn+'" revision="'+fileinfo.rev+'" schema="*'+schema+'" />\n'
|
||||
elif xml:
|
||||
schema = 'HARDCODE'
|
||||
s = '\n<put file="'+rfn+'" revision="'+fileinfo.rev+'" schema="*OWNER">\n'+\
|
||||
' <proc name="store-dyn"/>\n <proc name="package-get"/>\n'+\
|
||||
' <proc name="trigger"/>\n <proc name="grant"/>\n</put>\n'+\
|
||||
'<put file="'+rfn+'" revision="'+fileinfo.rev+'" schema="*ADMIN">\n'+\
|
||||
' <proc name="ini"/>\n <proc name="ini-gen"/>\n</put>\n'
|
||||
by_fn[fn] = [s, fileinfo.rev, schema]
|
||||
if found:
|
||||
msg = re.sub(r'<[^>]*?>', '', commit.log).replace(' ', ' ').strip()
|
||||
b = bugmsg.match(msg)
|
||||
if b:
|
||||
bugs[b.group(1)] = 1
|
||||
msgs[msg] = 1
|
||||
bugs = bugs.keys()
|
||||
r = ''
|
||||
r2 = ''
|
||||
r3 = ''
|
||||
# Put commit messages first
|
||||
if len(msgs):
|
||||
r += '<!-- '+'\n'.join(msgs.keys())+' -->\n\n'
|
||||
# Then schema OWNER, then others, then XML files
|
||||
for i in by_fn:
|
||||
if by_fn[i][2] == 'OWNER':
|
||||
r += by_fn[i][0]
|
||||
elif by_fn[i][2] == 'HARDCODE':
|
||||
r3 += by_fn[i][0]
|
||||
else:
|
||||
r2 += by_fn[i][0]
|
||||
r += r2
|
||||
r += r3
|
||||
return r, bugs
|
||||
|
||||
def query_custispatcher(request, commits):
|
||||
request.server.header('text/plain; charset=utf-8')
|
||||
if not commits:
|
||||
print '# No changes were selected by the query.'
|
||||
print '# There is nothing to show.'
|
||||
return
|
||||
r, bugs = custispatcher_slug(commits)
|
||||
if request.query_dict.get('xml', None):
|
||||
global cvsdb
|
||||
import cvsdb
|
||||
db = cvsdb.ConnectDatabaseReadOnly(request.cfg, request)
|
||||
# In the spirit of the whole ugly hack read bug descriptions directly from the DB
|
||||
sql = "SELECT short_desc, cf_extbug FROM bugs3.bugs WHERE bug_id=%s"
|
||||
ext_descs = ''
|
||||
extbugs = []
|
||||
for b in bugs:
|
||||
cursor = db.db.cursor()
|
||||
cursor.execute(sql, (b, ))
|
||||
try:
|
||||
(short_desc, cf_extbug) = cursor.fetchone()
|
||||
if cf_extbug:
|
||||
cursor.execute(sql, (cf_extbug, ))
|
||||
(extbug_desc, _) = cursor.fetchone()
|
||||
ext_descs += extbug_desc.encode('utf-8')+'\n'
|
||||
extbugs.append(str(cf_extbug))
|
||||
except:
|
||||
raise
|
||||
r = '<hotfix name="bug'+'_'.join(extbugs)+'" for-versions="" bugs="'+' '.join(bugs)+'">\n\
|
||||
<description>'+cgi.escape(ext_descs.rstrip().decode('utf-8'))+'</description>\n\
|
||||
<portion num="" repeatable="1" deploy-safety="dangerous">\n\
|
||||
'+r.rstrip().replace('\n', '\n ')+'\n\
|
||||
</portion>\n\
|
||||
</hotfix>\n'
|
||||
server_fp = get_writeready_server_file(request, 'text/plain; charset=utf-8')
|
||||
server_fp.write(r.encode('utf-8'))
|
||||
|
||||
def found_custispatcher_sp4(commits):
|
||||
for commit in commits:
|
||||
for fileinfo in commit.files:
|
||||
if fileinfo.file.endswith('.sp4'):
|
||||
return 1
|
||||
return 0
|
||||
# --- END UGLY HACK ---
|
||||
|
||||
def view_query(request):
|
||||
if not is_query_supported(request):
|
||||
raise debug.ViewVCException('Can not query project root "%s" at "%s".'
|
||||
@@ -5118,6 +5233,17 @@ def view_query(request):
|
||||
params['format'] = 'patch'
|
||||
patch_href = request.get_url(params=params, escape=1)
|
||||
|
||||
# --- BEGIN UGLY HACK ---
|
||||
# FIXME Remove this from here to some hook package
|
||||
# CustIS "patcher" format for PL/SQL packages (Bug 96691)
|
||||
if found_custispatcher_sp4(commits):
|
||||
params = request.query_dict.copy()
|
||||
params['format'] = 'custispatcher'
|
||||
custispatcher_href = request.get_url(params=params, escape=1)
|
||||
else:
|
||||
custispatcher_href = None
|
||||
# --- END UGLY HACK ---
|
||||
|
||||
# rss link
|
||||
params = request.query_dict.copy()
|
||||
params['format'] = 'rss'
|
||||
@@ -5158,6 +5284,10 @@ def view_query(request):
|
||||
query_patch(request, commits)
|
||||
return
|
||||
|
||||
if format == 'custispatcher':
|
||||
query_custispatcher(request, commits)
|
||||
return
|
||||
|
||||
data = common_template_data(request)
|
||||
data.merge(TemplateData({
|
||||
'repos_root': request.server.escape(repos_root_t),
|
||||
@@ -5181,6 +5311,11 @@ def view_query(request):
|
||||
'limit_changes': limit_changes,
|
||||
'limit_changes_href': limit_changes_href,
|
||||
'rss_link_href': rss_link_href,
|
||||
# --- BEGIN UGLY HACK ---
|
||||
# FIXME Remove this from here to some hook package
|
||||
# CustIS "patcher" format for PL/SQL packages (Bug 96691)
|
||||
'custispatcher_href': custispatcher_href,
|
||||
# --- END UGLY HACK ---
|
||||
}))
|
||||
if format == 'rss':
|
||||
generate_page(request, "rss", data, "application/rss+xml")
|
||||
|
@@ -29,6 +29,10 @@
|
||||
<a href="[patch_href]">Show a patch built from these changes</a>
|
||||
[if-any patch_unsecure]<br /><b>CAUTION: selected changes are not contiguous, patch may include differences from other commits.</b>[end]
|
||||
</p>
|
||||
[if-any custispatcher_href]
|
||||
<p><a href="[custispatcher_href]">Show XML slug for CustIS patcher</a></p>
|
||||
<p><a href="[custispatcher_href]&xml=1">Show typical CustIS patcher hotfix XML</a></p>
|
||||
[end]
|
||||
|
||||
<p><strong>+[plus_count]/-[minus_count]</strong> changed lines total.</p>
|
||||
|
||||
|
@@ -29,6 +29,10 @@
|
||||
<a href="[patch_href]">Show a patch built from these changes</a>
|
||||
[if-any patch_unsecure]<br /><b>CAUTION: selected changes are not contiguous, patch may include differences from other commits.</b>[end]
|
||||
</p>
|
||||
[if-any custispatcher_href]
|
||||
<p><a href="[custispatcher_href]">Show XML slug for CustIS patcher</a></p>
|
||||
<p><a href="[custispatcher_href]&xml=1">Show typical CustIS patcher hotfix XML</a></p>
|
||||
[end]
|
||||
|
||||
<p><strong>+[plus_count]/-[minus_count]</strong> lines changed.</p>
|
||||
|
||||
|
Reference in New Issue
Block a user