# HG changeset patch # User Ludovic Chabant # Date 1515352170 28800 # Node ID ab47d3cf5e1e1916d511dd10b2dc4a6984107342 # Parent ecc1c1e3e04c131f2b5bef19b5e58a97a15cf5ab scm: Slightly better object model for file/wiki history. diff -r ecc1c1e3e04c -r ab47d3cf5e1e wikked/scm/base.py --- 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) - diff -r ecc1c1e3e04c -r ab47d3cf5e1e wikked/scm/mercurial.py --- 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) - diff -r ecc1c1e3e04c -r ab47d3cf5e1e wikked/templates/special-changes.html --- 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 @@