diff --git a/templates/file_revisions.html b/templates/file_revisions.html
index 9c856fa597..58cb0d53d2 100644
--- a/templates/file_revisions.html
+++ b/templates/file_revisions.html
@@ -42,7 +42,7 @@
{% if not commit.is_current_version %}
- 还原
+ 还原
{% endif %}
下载
查看
diff --git a/templates/repo.html b/templates/repo.html
index df6d667cc1..0bf1797c1e 100644
--- a/templates/repo.html
+++ b/templates/repo.html
@@ -184,7 +184,7 @@
更新
{% endif %}
{% if view_history and request.user.is_authenticated %}
- 还原
+ 还原
{% endif %}
diff --git a/views.py b/views.py
index 5adad0d4d2..b17ba17240 100644
--- a/views.py
+++ b/views.py
@@ -1801,8 +1801,9 @@ def render_file_revisions (request, repo_id):
def repo_revert_file (request, repo_id):
commit_id = request.GET.get('commit')
path = request.GET.get('p')
+ from_page = request.GET.get('from')
- if not (commit_id and path):
+ if not (commit_id and path and from_page):
return render_error(request, u"参数错误")
try:
@@ -1811,8 +1812,13 @@ def repo_revert_file (request, repo_id):
except Exception, e:
return render_error(request, str(e))
else:
- parent_dir = os.path.dirname(path)
- url = reverse('repo', args=[repo_id]) + ('?p=%s' % urllib2.quote(parent_dir.encode('utf-8')))
+ if from_page == 'repo_history':
+ # When revert file from repo history, we redirect to repo history
+ url = reverse('repo', args=[repo_id]) + u'?commit_id=%s&history=y' % commit_id
+ else:
+ # When revert file from file history, we redirect to parent dir of this file
+ parent_dir = os.path.dirname(path)
+ url = reverse('repo', args=[repo_id]) + ('?p=%s' % urllib2.quote(parent_dir.encode('utf-8')))
file_view_url = reverse('repo_view_file', args=[repo_id]) + u'?p=' + urllib2.quote(path.encode('utf-8'))
if ret == 1:
|