Commit 322a9f48 authored by Christophe Dumez's avatar Christophe Dumez

- added support for diff between 2 old revisions


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6804 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5e2e9ae8
...@@ -251,11 +251,15 @@ try: ...@@ -251,11 +251,15 @@ try:
# Since plain Python classes are not convenient in Zope, convert the objects. # Since plain Python classes are not convenient in Zope, convert the objects.
return [Status(x) for x in self.client.status(path, **kw)] return [Status(x) for x in self.client.status(path, **kw)]
def diff(self, path): def diff(self, path, revision1, revision2):
self._getPreferences() self._getPreferences()
tmp = mktemp() tmp = mktemp()
os.system('mkdir -p %s'%tmp) os.system('mkdir -p %s'%tmp)
diff = self.client.diff(tmp_path=tmp, url_or_path=path, recurse=False) if not revision1 or not revision2:
diff = self.client.diff(tmp_path=tmp, url_or_path=path, recurse=False)
else:
diff = self.client.diff(tmp_path=tmp, url_or_path=path, recurse=False, revision1=pysvn.Revision(pysvn.opt_revision_kind.number,revision1), revision2=pysvn.Revision(pysvn.opt_revision_kind.number,revision2))
# clean up temp dir
os.system('rm -rf %s'%tmp) os.system('rm -rf %s'%tmp)
return diff return diff
......
...@@ -188,7 +188,7 @@ class DiffFile: ...@@ -188,7 +188,7 @@ class DiffFile:
def toHTML(self): def toHTML(self):
# Adding header of the table # Adding header of the table
if self.binary: if self.binary:
return '<b>Binary File!</b><br><br><br>' return '<b>Binary File or no changes!</b><br><br><br>'
html = ''' html = '''
<table style="text-align: left; width: 100%%;" border="0" cellpadding="0" cellspacing="0"> <table style="text-align: left; width: 100%%;" border="0" cellpadding="0" cellspacing="0">
...@@ -520,8 +520,8 @@ class SubversionTool(UniqueObject, Folder): ...@@ -520,8 +520,8 @@ class SubversionTool(UniqueObject, Folder):
trust_item_list, permanent = loads(b64decode(trust)) trust_item_list, permanent = loads(b64decode(trust))
return dict(trust_item_list), permanent return dict(trust_item_list), permanent
def diffHTML(self, file_path): def diffHTML(self, file_path, revision1=None, revision2=None):
raw_diff = self.diff(file_path) raw_diff = self.diff(file_path, revision1, revision2)
return DiffFile(raw_diff).toHTML() return DiffFile(raw_diff).toHTML()
# Display a file content in HTML # Display a file content in HTML
...@@ -652,11 +652,11 @@ class SubversionTool(UniqueObject, Folder): ...@@ -652,11 +652,11 @@ class SubversionTool(UniqueObject, Folder):
return client.ls(path) return client.ls(path)
security.declareProtected('Import/Export objects', 'diff') security.declareProtected('Import/Export objects', 'diff')
def diff(self, path): def diff(self, path, revision1=None, revision2=None):
"""Make a diff for a file or a directory. """Make a diff for a file or a directory.
""" """
client = self._getClient() client = self._getClient()
return client.diff(path) return client.diff(path, revision1, revision2)
security.declareProtected('Import/Export objects', 'revert') security.declareProtected('Import/Export objects', 'revert')
def revert(self, path): def revert(self, path):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment