# HG changeset patch # User Marcin Kuzminski # Date 2011-01-30 21:56:37 # Node ID 28524453bb76564f1c571d58f113c84c61b5a890 # Parent de535f8b1e8b001bc0fc95e414613fba3ed49a5a started work on #93 added rev ranges view, checkboxes in changelog to view ranges of changes diff --git a/rhodecode/controllers/changeset.py b/rhodecode/controllers/changeset.py --- a/rhodecode/controllers/changeset.py +++ b/rhodecode/controllers/changeset.py @@ -3,7 +3,8 @@ rhodecode.controllers.changeset ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - changeset controller for pylons + changeset controller for pylons showoing changes beetween + revisions :created_on: Apr 25, 2010 :author: marcink @@ -40,6 +41,7 @@ from rhodecode.model.scm import ScmModel from vcs.exceptions import RepositoryError, ChangesetError from vcs.nodes import FileNode from vcs.utils import diffs as differ +from vcs.utils.ordered_dict import OrderedDict log = logging.getLogger(__name__) @@ -63,25 +65,67 @@ class ChangesetController(BaseController ''' % str + def get_cs_range(repo, rev_start, rev_end): + """ + Temp fix function until VCS will handle that + see issue #48 + :param rev_start: + :param rev_end: + """ + + start_cs = repo.get_changeset(rev_start) + end_cs = repo.get_changeset(rev_end) + + if start_cs.revision >= end_cs.revision: + raise Exception('Start cannot be after End') + + yield start_cs + + while 1: + next = start_cs.next() + yield next + start_cs = next + if next == end_cs: + break + + #====================================================================== + # REAL CODE BELOW + #====================================================================== + #get ranges of revisions if preset + rev_range = revision.split('...')[:2] + try: - c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision) + repo = hg_model.get_repo(c.repo_name) + if len(rev_range) == 2: + rev_start = rev_range[0] + rev_end = rev_range[1] + rev_ranges = get_cs_range(repo, rev_start, rev_end) + + else: + rev_ranges = [repo.get_changeset(revision)] except RepositoryError, e: log.error(traceback.format_exc()) h.flash(str(e), category='warning') return redirect(url('home')) - else: - try: - c.changeset_old = c.changeset.parents[0] - except IndexError: - c.changeset_old = None - c.changes = [] + + c.changes = OrderedDict() + c.sum_added = 0 + c.sum_removed = 0 + + c.cs_ranges = list(rev_ranges) - #=================================================================== + for changeset in c.cs_ranges: + c.changes[changeset.raw_id] = [] + try: + changeset_parent = changeset.parents[0] + except IndexError: + changeset_parent = None + + + #================================================================== # ADDED FILES - #=================================================================== - c.sum_added = 0 - for node in c.changeset.added: - + #================================================================== + for node in changeset.added: filenode_old = FileNode(node.path, '', EmptyChangeset()) if filenode_old.is_binary or node.is_binary: diff = wrap_to_table(_('binary file')) @@ -97,15 +141,14 @@ class ChangesetController(BaseController cs1 = None cs2 = node.last_changeset.raw_id - c.changes.append(('added', node, diff, cs1, cs2)) + c.changes[changeset.raw_id].append(('added', node, diff, cs1, cs2)) - #=================================================================== + #================================================================== # CHANGED FILES - #=================================================================== - c.sum_removed = 0 - for node in c.changeset.changed: + #================================================================== + for node in changeset.changed: try: - filenode_old = c.changeset_old.get_node(node.path) + filenode_old = changeset_parent.get_node(node.path) except ChangesetError: filenode_old = FileNode(node.path, '', EmptyChangeset()) @@ -125,15 +168,21 @@ class ChangesetController(BaseController cs1 = filenode_old.last_changeset.raw_id cs2 = node.last_changeset.raw_id - c.changes.append(('changed', node, diff, cs1, cs2)) + c.changes[changeset.raw_id].append(('changed', node, diff, cs1, cs2)) - #=================================================================== + #================================================================== # REMOVED FILES - #=================================================================== - for node in c.changeset.removed: - c.changes.append(('removed', node, None, None, None)) + #================================================================== + for node in changeset.removed: + c.changes[changeset.raw_id].append(('removed', node, None, None, None)) - return render('changeset/changeset.html') + if len(c.cs_ranges) == 1: + c.changeset = c.cs_ranges[0] + c.changes = c.changes[c.changeset.raw_id] + + return render('changeset/changeset.html') + else: + return render('changeset/changeset_range.html') def raw_changeset(self, revision): @@ -148,9 +197,9 @@ class ChangesetController(BaseController return redirect(url('home')) else: try: - c.changeset_old = c.changeset.parents[0] + c.changeset_parent = c.changeset.parents[0] except IndexError: - c.changeset_old = None + c.changeset_parent = None c.changes = [] for node in c.changeset.added: @@ -166,7 +215,7 @@ class ChangesetController(BaseController c.changes.append(('added', node, diff, cs1, cs2)) for node in c.changeset.changed: - filenode_old = c.changeset_old.get_node(node.path) + filenode_old = c.changeset_parent.get_node(node.path) if filenode_old.is_binary or node.is_binary: diff = _('binary file') else: diff --git a/rhodecode/public/css/style.css b/rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css +++ b/rhodecode/public/css/style.css @@ -1510,7 +1510,9 @@ float:left; border:1px solid #CCC; padding:10px; } - +#graph_content #rev_range_container{ +padding:10px 0px; +} #graph_content .container { border-bottom:1px solid #CCC; border-left:1px solid #CCC; @@ -1531,6 +1533,9 @@ padding-bottom:5px; font-weight:700; padding-bottom:5px; } +#graph_content .container .left .date span{ +vertical-align: text-top; +} #graph_content .container .left .message { font-size:100%; diff --git a/rhodecode/templates/changelog/changelog.html b/rhodecode/templates/changelog/changelog.html --- a/rhodecode/templates/changelog/changelog.html +++ b/rhodecode/templates/changelog/changelog.html @@ -32,21 +32,25 @@
- - ${h.form(h.url.current(),method='get')} -
- ${_('Show')}: - ${h.text('size',size=1,value=c.size)} - ${_('revisions')} - ${h.submit('set',_('set'))} -
- ${h.end_form()} - + ${h.form(h.url.current(),method='get')} +
+ ${_('Show')}: + ${h.text('size',size=1,value=c.size)} + ${_('revisions')} + ${h.submit('set',_('set'))} + +
+ ${h.end_form()} +
+ %for cnt,cs in enumerate(c.pagination):
-
${_('commit')} ${cs.revision}: ${h.short_id(cs.raw_id)}@${cs.date}
+
+ ${h.checkbox(cs.short_id,class_="changeset_range")} + ${_('commit')} ${cs.revision}: ${h.short_id(cs.raw_id)}@${cs.date} +
gravatar @@ -113,6 +117,37 @@ %else: diff --git a/rhodecode/templates/changeset/changeset.html b/rhodecode/templates/changeset/changeset.html --- a/rhodecode/templates/changeset/changeset.html +++ b/rhodecode/templates/changeset/changeset.html @@ -23,7 +23,7 @@ ${self.breadcrumbs()}
-
+
${_('Changeset')} - r${c.changeset.revision}:${h.short_id(c.changeset.raw_id)} @@ -81,7 +81,7 @@ ${_('Files affected')}
%for change,filenode,diff,cs1,cs2 in c.changes: -
${h.link_to(filenode.path,h.url.current(anchor='CHANGE-%s'%filenode.path))}
+
${h.link_to(filenode.path,h.url.current(anchor=h.repo_name_slug('C%s' % filenode.path)))}
%endfor
@@ -91,8 +91,8 @@ %for change,filenode,diff,cs1,cs2 in c.changes: %if change !='removed':
-
-
+
+
${h.link_to_if(change!='removed',filenode.path,h.url('files_home',repo_name=c.repo_name, @@ -118,7 +118,5 @@
%endif %endfor -
-
- +
\ No newline at end of file diff --git a/rhodecode/templates/changeset/changeset_range.html b/rhodecode/templates/changeset/changeset_range.html new file mode 100644 --- /dev/null +++ b/rhodecode/templates/changeset/changeset_range.html @@ -0,0 +1,86 @@ +<%inherit file="/base/base.html"/> + +<%def name="title()"> + ${c.repo_name} ${_('Changesets')} - r${c.cs_ranges[0].revision}:${h.short_id(c.cs_ranges[0].raw_id)} -> r${c.cs_ranges[-1].revision}:${h.short_id(c.cs_ranges[-1].raw_id)} - ${c.rhodecode_name} + + +<%def name="breadcrumbs_links()"> + ${h.link_to(u'Home',h.url('/'))} + » + ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} + » + ${_('Changesets')} - r${c.cs_ranges[0].revision}:${h.short_id(c.cs_ranges[0].raw_id)} -> r${c.cs_ranges[-1].revision}:${h.short_id(c.cs_ranges[-1].raw_id)} + + +<%def name="page_nav()"> + ${self.menu('changelog')} + + +<%def name="main()"> +
+ +
+ ${self.breadcrumbs()} +
+
+
+
+
+ ${_('Changesets')} - r${c.cs_ranges[0].revision}:${h.short_id(c.cs_ranges[0].raw_id)} -> r${c.cs_ranges[-1].revision}:${h.short_id(c.cs_ranges[-1].raw_id)} + ##» ${h.link_to(_('raw diff'), + ##h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='show'))} + ##» ${h.link_to(_('download diff'), + ##h.url('raw_changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id,diff='download'))} +
+
+
+
+
+ +
+ ${_('Files affected')} +
+ %for cs in c.cs_ranges: + ${cs} + %for change,filenode,diff,cs1,cs2 in c.changes[cs.raw_id]: +
${h.link_to(filenode.path,h.url.current(anchor=h.repo_name_slug('C%s-%s' % (cs.short_id,filenode.path))))}
+ %endfor + %endfor +
+
+ +
+ %for cs in c.cs_ranges: + %for change,filenode,diff,cs1,cs2 in c.changes[cs.raw_id]: + %if change !='removed': +
+
+
+
+ + ${h.link_to_if(change!='removed',filenode.path,h.url('files_home',repo_name=c.repo_name, + revision=filenode.changeset.raw_id,f_path=filenode.path))} + + %if 1: + » ${h.link_to(_('diff'), + h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='diff'))} + » ${h.link_to(_('raw diff'), + h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='raw'))} + » ${h.link_to(_('download diff'), + h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='download'))} + %endif +
+
+
+ %if diff: + ${diff|n} + %else: + ${_('No changes in this file')} + %endif +
+
+ %endif + %endfor + %endfor +
+ \ No newline at end of file