##// END OF EJS Templates
implemented simple diffs for history of files.
marcink -
r129:42d46deb default
parent child Browse files
Show More
@@ -0,0 +1,87 b''
1 div.codeblock {
2 overflow: auto;
3 padding: 0px;
4 border: 1px solid #ccc;
5 background: #f8f8f8;
6 font-size: 100%;
7 line-height: 100%;
8 /* new */
9 line-height: 125%;
10 }
11
12 .code-diff {
13 padding: 0px;
14 margin-top: 5px;
15 margin-bottom: 5px;
16 border-left: 2px solid #ccc;
17 }
18 .code-diff pre, .linenodiv pre {
19 padding: 5px;
20 margin: 0;
21 }
22 .linenos a { text-decoration: none; }
23
24
25 .code { display: block;}
26
27 .code-diff .hll { background-color: #ffffcc }
28 .code-diff { background: #ffffff; }
29 .code-diff .c { color: #888888 } /* Comment */
30 .code-diff .err { color: #a61717; background-color: #e3d2d2 } /* Error */
31 .code-diff .k { color: #008800; font-weight: bold } /* Keyword */
32 .code-diff .cm { color: #888888 } /* Comment.Multiline */
33 .code-diff .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
34 .code-diff .c1 { color: #888888 } /* Comment.Single */
35 .code-diff .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
36 .code-diff .gd { color: #000000; background-color: #ffdddd;width: 300px } /* Generic.Deleted */
37 .code-diff .ge { font-style: italic } /* Generic.Emph */
38 .code-diff .gr { color: #aa0000 } /* Generic.Error */
39 .code-diff .gh { color: #303030 } /* Generic.Heading */
40 .code-diff .gi { color: #000000; background-color: #ddffdd;width: 100% } /* Generic.Inserted */
41 .code-diff .go { color: #888888 } /* Generic.Output */
42 .code-diff .gp { color: #555555 } /* Generic.Prompt */
43 .code-diff .gs { font-weight: bold } /* Generic.Strong */
44 .code-diff .gu { color: #606060 } /* Generic.Subheading */
45 .code-diff .gt { color: #aa0000 } /* Generic.Traceback */
46 .code-diff .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
47 .code-diff .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
48 .code-diff .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
49 .code-diff .kp { color: #008800 } /* Keyword.Pseudo */
50 .code-diff .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
51 .code-diff .kt { color: #888888; font-weight: bold } /* Keyword.Type */
52 .code-diff .m { color: #0000DD; font-weight: bold } /* Literal.Number */
53 .code-diff .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
54 .code-diff .na { color: #336699 } /* Name.Attribute */
55 .code-diff .nb { color: #003388 } /* Name.Builtin */
56 .code-diff .nc { color: #bb0066; font-weight: bold } /* Name.Class */
57 .code-diff .no { color: #003366; font-weight: bold } /* Name.Constant */
58 .code-diff .nd { color: #555555 } /* Name.Decorator */
59 .code-diff .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
60 .code-diff .nf { color: #0066bb; font-weight: bold } /* Name.Function */
61 .code-diff .nl { color: #336699; font-style: italic } /* Name.Label */
62 .code-diff .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
63 .code-diff .py { color: #336699; font-weight: bold } /* Name.Property */
64 .code-diff .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
65 .code-diff .nv { color: #336699 } /* Name.Variable */
66 .code-diff .ow { color: #008800 } /* Operator.Word */
67 .code-diff .w { color: #bbbbbb } /* Text.Whitespace */
68 .code-diff .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
69 .code-diff .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
70 .code-diff .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
71 .code-diff .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
72 .code-diff .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
73 .code-diff .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
74 .code-diff .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
75 .code-diff .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
76 .code-diff .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
77 .code-diff .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
78 .code-diff .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
79 .code-diff .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
80 .code-diff .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
81 .code-diff .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
82 .code-diff .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
83 .code-diff .bp { color: #003388 } /* Name.Builtin.Pseudo */
84 .code-diff .vc { color: #336699 } /* Name.Variable.Class */
85 .code-diff .vg { color: #dd7700 } /* Name.Variable.Global */
86 .code-diff .vi { color: #3333bb } /* Name.Variable.Instance */
87 .code-diff .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
@@ -0,0 +1,35 b''
1 <%inherit file="/base/base.html"/>
2
3 <%def name="title()">
4 ${_('Repository managment')}
5 </%def>
6 <%def name="breadcrumbs()">
7 ${h.link_to(u'Home',h.url('/'))}
8 /
9 ${h.link_to(c.repo_name,h.url('files_home',repo_name=c.repo_name))}
10 /
11 ${_('files')}
12 </%def>
13 <%def name="page_nav()">
14 <form action="log">
15 <dl class="search">
16 <dt><label>Search: </label></dt>
17 <dd><input type="text" name="rev" /></dd>
18 </dl>
19 </form>
20
21 ${self.menu('files')}
22 </%def>
23 <%def name="css()">
24 <link rel="stylesheet" href="/css/monoblue_custom.css" type="text/css" />
25 <link rel="stylesheet" href="/css/pygments_diff.css" type="text/css" />
26 </%def>
27 <div></div>
28 <%def name="main()">
29 <h2 class="no-link no-border">${'%s: %s@%s %s %s' % (_('File diff'),c.f_path,c.diff2,'&rarr;',c.diff1)|n}</h2>
30 <div id="files_data">
31 <div id="body" class="codeblock">
32 ${h.pygmentize(c.diff,linenos=True,anchorlinenos=True,cssclass="code-diff")}
33 </div>
34 </div>
35 </%def> No newline at end of file
@@ -39,6 +39,6 b' def make_map(config):'
39 map.connect('tags_home', '/{repo_name}/tags', controller='tags')
39 map.connect('tags_home', '/{repo_name}/tags', controller='tags')
40 map.connect('graph_home', '/{repo_name}/graph/{revision}', controller='graph', revision='tip')
40 map.connect('graph_home', '/{repo_name}/graph/{revision}', controller='graph', revision='tip')
41 map.connect('files_home', '/{repo_name}/files/{revision}/{f_path:.*}', controller='files', revision='tip', f_path='')
41 map.connect('files_home', '/{repo_name}/files/{revision}/{f_path:.*}', controller='files', revision='tip', f_path='')
42
42 map.connect('files_diff_home', '/{repo_name}/diff/{f_path:.*}', controller='files', action='diff', revision='tip', f_path='')
43
43
44 return map
44 return map
@@ -25,13 +25,29 b' class FilesController(BaseController):'
25 c.file_history = self._get_history(repo, c.files_list, f_path)
25 c.file_history = self._get_history(repo, c.files_list, f_path)
26 return render('files/files.html')
26 return render('files/files.html')
27
27
28
28 def diff(self, repo_name, f_path):
29 hg_model = HgModel()
30 diff1 = request.GET.get('diff1')
31 diff2 = request.GET.get('diff2')
32 c.f_path = f_path
33 c.repo = hg_model.get_repo(c.repo_name)
34 c.changeset_1 = c.repo.get_changeset(diff1)
35 c.changeset_2 = c.repo.get_changeset(diff2)
36
37 c.file_1 = c.changeset_1.get_node(f_path).content
38 c.file_2 = c.changeset_2.get_node(f_path).content
39 c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1._short)
40 c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2._short)
41 from difflib import unified_diff
42 d = unified_diff(c.file_1.splitlines(1), c.file_2.splitlines(1))
43 c.diff = ''.join(d)
44 return render('files/file_diff.html')
45
29 def _get_history(self, repo, node, f_path):
46 def _get_history(self, repo, node, f_path):
30 from vcs.nodes import NodeKind
47 from vcs.nodes import NodeKind
31 if not node.kind is NodeKind.FILE:
48 if not node.kind is NodeKind.FILE:
32 return []
49 return []
33 changesets = list(node.history)
50 changesets = node.history
34 changesets.reverse()
35 hist_l = []
51 hist_l = []
36 for chs in changesets:
52 for chs in changesets:
37 n_desc = 'r%s:%s' % (chs.revision, chs._short)
53 n_desc = 'r%s:%s' % (chs.revision, chs._short)
@@ -7,7 +7,7 b''
7 <dd>history / annotate / raw </dd>
7 <dd>history / annotate / raw </dd>
8 <dt>${_('History')}</dt>
8 <dt>${_('History')}</dt>
9 <dd>
9 <dd>
10 ${h.form(h.url.current())}
10 ${h.form(h.url('files_diff_home',repo_name=c.repo_name,f_path=c.f_path),method='GET')}
11 ${h.hidden('diff2',c.files_list.changeset._short)}
11 ${h.hidden('diff2',c.files_list.changeset._short)}
12 ${h.select('diff1','',c.file_history)}
12 ${h.select('diff1','',c.file_history)}
13 ${h.submit('diff','diff')}
13 ${h.submit('diff','diff')}
General Comments 0
You need to be logged in to leave comments. Login now