Mercurial > p > roundup > code
changeset 4220:e2b1d38236ac gsoc-2009
some more attempts at making this work
| author | Pygi <pygi@users.sourceforge.net> |
|---|---|
| date | Fri, 17 Jul 2009 14:38:06 +0000 |
| parents | 35416881b33d |
| children | 7f33415a0ee0 |
| files | scripts/notify-roundup/extensions/hg_revision_info.py scripts/notify-roundup/extensions/svn_revision_info.py |
| diffstat | 2 files changed, 28 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/notify-roundup/extensions/hg_revision_info.py Fri Jul 17 14:08:51 2009 +0000 +++ b/scripts/notify-roundup/extensions/hg_revision_info.py Fri Jul 17 14:38:06 2009 +0000 @@ -1,6 +1,8 @@ import commands from difflib import HtmlDiff +path = '/home/mario/TestInstances/hgrepo' + def _dump_files(path, revision): """Download file from repository and store it in local temporary.""" @@ -10,20 +12,37 @@ output2 = open(file2, 'w+') if path is not None: output.write(commands.getoutput('hg cat ' + " --rev " + revision + " " + path)) - output2.write(commands.getoutput('hg cat ' + " --rev " + revision-1 + " " + path)) + output2.write(commands.getoutput('hg cat ' + " --rev " + int(revision-1) + " " + path)) output.close() output2.close() return file, file2 -def diff (path, revision): - """ Diff between two revisions.""" +class ChangeSetItem: + def __init__(self, path, change): + + self.path = path + #if change.path: + self.action = change.added and 'new' or 'modified' + #else: + # self.action = 'delete' + self.change = change + + def diff(self): + from difflib import HtmlDiff + + from_file, to_file = _dump_file(path, -1) + html = HtmlDiff() + return html.make_file(open(from_file, 'r').readlines(), + open(to_file, 'r').readlines(), + 'original', 'new') + + return html_diff(file1, file2) def info(path, revision): dict = {} changes = commands.getoutput("hg log -p -r " + revision + " " + path + " | lsdiff -s --strip=1") - return changes line_changes = changes.splitlines() for line in line_changes: check = line.str('+') @@ -42,7 +61,8 @@ split_check = line.split() dict['Modified:'] = split_check[1] continue - +def info(path, revision): + return _info(path, int(revision)) def init(instance):
--- a/scripts/notify-roundup/extensions/svn_revision_info.py Fri Jul 17 14:08:51 2009 +0000 +++ b/scripts/notify-roundup/extensions/svn_revision_info.py Fri Jul 17 14:38:06 2009 +0000 @@ -8,6 +8,8 @@ from svn import core, fs, delta, repos from libsvn.fs import svn_fs_file_contents as file_contents import tempfile +import logging + def _dump_file(root, path): @@ -67,6 +69,7 @@ changeset = editor.changes.items() changeset.sort() + logging.debug(changeset) return [ChangeSetItem(new_root, old_root, path, change) for path, change in changeset]
