Mercurial > wikked
changeset 450:ab47d3cf5e1e
scm: Slightly better object model for file/wiki history.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 07 Jan 2018 11:09:30 -0800 |
parents | ecc1c1e3e04c |
children | 6cd51ea6dfcf |
files | wikked/scm/base.py wikked/scm/mercurial.py wikked/templates/special-changes.html |
diffstat | 3 files changed, 22 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/wikked/scm/base.py Sun Jan 07 11:07:23 2018 -0800 +++ b/wikked/scm/base.py Sun Jan 07 11:09:30 2018 -0800 @@ -9,7 +9,8 @@ ACTION_ADD = 0 ACTION_DELETE = 1 ACTION_EDIT = 2 -ACTION_NAMES = ['add', 'delete', 'edit'] +ACTION_OTHER = 3 +ACTION_NAMES = ['add', 'delete', 'edit', 'other'] class SourceControl(object): @@ -61,6 +62,14 @@ return '%s <%s>' % (self.name, self.email) +class FileRevision: + def __init__(self, path=None, action=None): + self.path = path + self.action = action + if action is None: + self.action = ACTION_OTHER + + class Revision(object): def __init__(self, rev_id=-1): self.rev_id = rev_id @@ -78,6 +87,9 @@ def is_committed(self): return self.rev_id != -1 + def addFile(self, path, action=None): + self.files.append(FileRevision(path, action)) + class SourceControlError(Exception): def __init__(self, operation, message, command, output, *args): @@ -90,4 +102,3 @@ def __str__(self): return "Error running '%s': %s\nCommand: %s\nOutput: %s" % ( self.operation, self.message, self.command, self.output) -
--- a/wikked/scm/mercurial.py Sun Jan 07 11:07:23 2018 -0800 +++ b/wikked/scm/mercurial.py Sun Jan 07 11:09:30 2018 -0800 @@ -167,14 +167,10 @@ rev.description += lines[i] i += 1 - rev.files = [] for j in range(i + 1, len(lines)): if lines[j] == '': continue - rev.files.append({ - 'path': lines[j][2:], - 'action': self.actions[lines[j][0]] - }) + rev.addFile(lines[j][2:], self.actions.get(lines[j][0])) return rev @@ -230,7 +226,7 @@ try: import signal signal.signal(signal.SIGTERM, shutdown_commandserver) - except: + except: # NOQA # `mod_wsgi` prevents adding stuff to `SIGTERM` # so let's not make a big deal if this doesn't # go through. @@ -290,10 +286,8 @@ if needs_files: rev_statuses = self.client.status(change=rev.node) for rev_status in rev_statuses: - r.files.append({ - 'path': _s(rev_status[1]), - 'action': self.actions[_s(rev_status[0])] - }) + r.addFile(_s(rev_status[1]), + self.actions.get(_s(rev_status[0]))) revisions.append(r) return revisions @@ -345,4 +339,3 @@ self.client.revert(files=_b(paths), nobackup=True) else: self.client.revert(all=True, nobackup=True) -
--- a/wikked/templates/special-changes.html Sun Jan 07 11:07:23 2018 -0800 +++ b/wikked/templates/special-changes.html Sun Jan 07 11:09:30 2018 -0800 @@ -39,8 +39,11 @@ <ul class="pure-ul-unstyled"> {%for p in e.pages%} <li> - <a href="{{get_rev_url(p.url, e.rev_id)}}">{{p.url}}</a> - {{p.action_label}} + {%if p.url%} + <a href="{{get_rev_url(p.url, e.rev_id)}}">{{p.url}}</a> <em><small>({{p.action}})</small></em> + {%else%} + <code>{{p.path}}</code> <em>({{p.action}})</em> + {%endif%} </li> {%endfor%} </ul>