[Python-checkins] r88797 - in tracker/instances/python-dev: extensions/create_patch.py html/issue.item.html schema.py
martin.v.loewis
python-checkins at python.org
Thu Mar 24 08:08:52 CET 2011
Author: martin.v.loewis
Date: Thu Mar 24 08:08:52 2011
New Revision: 88797
Log:
Support branch on hgrepos.
Modified:
tracker/instances/python-dev/extensions/create_patch.py
tracker/instances/python-dev/html/issue.item.html
tracker/instances/python-dev/schema.py
Modified: tracker/instances/python-dev/extensions/create_patch.py
==============================================================================
--- tracker/instances/python-dev/extensions/create_patch.py (original)
+++ tracker/instances/python-dev/extensions/create_patch.py Thu Mar 24 08:08:52 2011
@@ -4,7 +4,7 @@
class NotChanged(ValueError):
pass
-def download_patch(source, lastrev):
+def download_patch(source, lastrev, patchbranch):
from mercurial import hg, ui, localrepo, commands, bundlerepo
UI = ui.ui()
bundle = tempfile.mktemp(dir="/var/tmp")
@@ -15,10 +15,12 @@
repo0.ui.quiet=True
repo0.ui.pushbuffer()
commands.pull(repo0.ui, repo0, quiet=True)
- commands.update(repo0.ui, repo0)
repo0.ui.popbuffer() # discard all pull output
+ # find out what the head revision of the given branch is
repo0.ui.pushbuffer()
- if commands.incoming(repo0.ui, repo0, source=source, branch=['default'], bundle=bundle, force=False) != 0:
+ head = repo0.ui.popbuffer().strip()
+ repo0.ui.pushbuffer()
+ if commands.incoming(repo0.ui, repo0, source=source, branch=[patchbranch], bundle=bundle, force=False) != 0:
raise ValueError, "Repository contains no changes"
rhead = repo0.ui.popbuffer()
if rhead:
@@ -28,7 +30,8 @@
raise NotChanged
repo=bundlerepo.bundlerepository(UI, ".", bundle)
repo.ui.pushbuffer()
- commands.diff(repo.ui, repo, rev=['ancestor(.,default)', 'default'])
+ old = 'max(p1(min(outgoing() and branch(%s))) or p2(max(merge() and outgoing() and branch(%s))))' % (patchbranch, patchbranch)
+ commands.diff(repo.ui, repo, rev=[old, patchbranch])
result = repo.ui.popbuffer()
finally:
os.chdir(cwd)
@@ -53,8 +56,11 @@
self.client.error_message.append('unknown hgrepo url')
return
lastrev = db.hgrepo.get(repo, 'lastrev')
+ branch = db.hgrepo.get(repo, 'patchbranch')
+ if not branch:
+ branch = 'default'
try:
- diff, head = download_patch(url, lastrev)
+ diff, head = download_patch(url, lastrev, branch)
except NotChanged:
self.client.error_message.append('%s.diff is already available' % lastrev)
return
Modified: tracker/instances/python-dev/html/issue.item.html
==============================================================================
--- tracker/instances/python-dev/html/issue.item.html (original)
+++ tracker/instances/python-dev/html/issue.item.html Thu Mar 24 08:08:52 2011
@@ -269,11 +269,27 @@
</table>
<table class="files" tal:condition="context/hgrepos">
- <tr><th class="Header" colspan="2">Repositories containing patches</th></tr>
+ <tr><th class="Header" colspan="4">Repositories containing patches</th></tr>
<tr tal:repeat="hgrepo python:context.hgrepos.sorted('creation')">
<td>
<a tal:attributes="href hgrepo/url"
- tal:content="hgrepo/url">link</a>
+ tal:content="hgrepo/url">link</a><tal:block
+ tal:condition="hgrepo/patchbranch">:<a
+ tal:attributes="href string:${hgrepo/url}/shortlog/${hgrepo/patchbranch}"
+ tal:content="hgrepo/patchbranch"/>
+ </tal:block>
+ </td>
+ <td><tal:block tal:condition="hgrepo/is_edit_ok"><a
+ tal:attributes="href string:hgrepo${hgrepo/id}">edit</a> (change branch)
+ </tal:block>
+ </td>
+ <td>
+ <form style="padding:0" method="post" tal:condition="hgrepo/is_edit_ok"
+ tal:attributes="action string:issue${context/id}">
+ <input type="hidden" name="@remove at files" tal:attributes="value hgrepo/id">
+ <input type="hidden" name="@action" value="edit">
+ <input type="submit" value="Remove">
+ </form>
</td>
<td>
<form style="padding:0" method="post" tal:condition="context/is_edit_ok"
Modified: tracker/instances/python-dev/schema.py
==============================================================================
--- tracker/instances/python-dev/schema.py (original)
+++ tracker/instances/python-dev/schema.py Thu Mar 24 08:08:52 2011
@@ -143,8 +143,10 @@
patchset=String(),)
hgrepo = Class(db, "hgrepo",
- url=String(),
- lastrev=String())
+ url=String(),
+ lastrev=String(),
+ patchbranch=String(),
+ )
# IssueClass automatically gets these properties in addition to the Class ones:
# title = String()
@@ -199,9 +201,11 @@
db.security.addPermissionToRole('User', 'View', cl)
db.security.addPermissionToRole('Anonymous', 'View', cl)
+def may_edit_hgrepo(db, userid, itemid):
+ return userid == db.hgrepo.get(itemid, "creator")
db.security.addPermissionToRole('User', 'Create', 'hgrepo')
-p = db.security.addPermission(name='Edit', klass='hgrepo',
- properties=['url'])
+p = db.security.addPermission(name='Edit', klass='hgrepo', check=may_edit_hgrepo,
+ properties=['url', 'patchbranch'])
db.security.addPermissionToRole('User', p)
class may_view_spam:
@@ -305,7 +309,8 @@
# Coordinator permissions
##########################
for cl in ('issue_type', 'severity', 'component',
- 'version', 'priority', 'stage', 'status', 'resolution', 'issue', 'file', 'msg'):
+ 'version', 'priority', 'stage', 'status', 'resolution', 'issue',
+ 'file', 'msg', 'hgrepo'):
db.security.addPermissionToRole('Coordinator', 'View', cl)
db.security.addPermissionToRole('Coordinator', 'Edit', cl)
db.security.addPermissionToRole('Coordinator', 'Create', cl)
More information about the Python-checkins
mailing list