Example #1
0
 def parse_sources(props):
     sources = {}
     for line in props[name].splitlines():
         path, revs = line.split(':', 1)
         spath = _path_within_scope(repos.scope, path)
         if spath is not None:
             sources[spath] = set(Ranges(revs.strip()))
     return sources
Example #2
0
 def parse_sources(props):
     sources = {}
     for line in props[name].splitlines():
         path, revs = line.split(":", 1)
         spath = _path_within_scope(repos.scope, path)
         if spath is not None:
             inheritable, non_inheritable = _partition_inheritable(revs)
             sources[spath] = (set(Ranges(inheritable)), set(Ranges(non_inheritable)))
     return sources
Example #3
0
 def parse_sources(props):
     sources = {}
     for line in props[name].splitlines():
         path, revs = line.split(':', 1)
         spath = _path_within_scope(repos.scope, path)
         if spath is not None:
             inheritable, non_inheritable = _partition_inheritable(revs)
             sources[spath] = (set(Ranges(inheritable)),
                               set(Ranges(non_inheritable)))
     return sources
Example #4
0
 def render_property(self, name, mode, context, props):
     """Parse svn:mergeinfo and svnmerge-* properties, converting branch
     names to links and providing links to the revision log for merged
     and eligible revisions.
     """
     has_eligible = name in ('svnmerge-integrated', 'svn:mergeinfo')
     revs_label = (_('merged'), _('blocked'))[name.endswith('blocked')]
     revs_cols = has_eligible and 2 or None
     reponame = context.resource.parent.id
     target_path = context.resource.id
     repos = RepositoryManager(self.env).get_repository(reponame)
     target_rev = context.resource.version
     if has_eligible:
         node = repos.get_node(target_path, target_rev)
         branch_starts = {}
         for path, rev in node.get_copy_ancestry(): 
             if path not in branch_starts:
                 branch_starts[path] = rev + 1
     rows = []
     if name.startswith('svnmerge-'):
         sources = props[name].split()
     else:
         sources = props[name].splitlines()
     for line in sources:
         path, revs = line.split(':', 1)
         spath = _path_within_scope(repos.scope, path)
         if spath is None:
             continue
         revs = revs.strip()
         inheritable, non_inheritable = _partition_inheritable(revs)
         revs = ','.join(inheritable)
         deleted = False
         try:
             node = repos.get_node(spath, target_rev)
             resource = context.resource.parent.child('source', spath)
             if 'LOG_VIEW' in context.perm(resource):
                 row = [_get_source_link(spath, context),
                        _get_revs_link(revs_label, context, spath, revs)]
                 if non_inheritable:
                     non_inheritable = ','.join(non_inheritable)
                     row.append(_get_revs_link(_('non-inheritable'), context,
                                               spath, non_inheritable,
                                               _('merged on the directory '
                                                 'itself but not below')))
                 if has_eligible:
                     first_rev = branch_starts.get(spath)
                     if not first_rev:
                         first_rev = node.get_branch_origin()
                     eligible = set(xrange(first_rev or 1, target_rev + 1))
                     eligible -= set(Ranges(revs))
                     blocked = _get_blocked_revs(props, name, spath)
                     if blocked:
                         eligible -= set(Ranges(blocked))
                     if eligible:
                         nrevs = repos._get_node_revs(spath, max(eligible),
                                                      min(eligible))
                         eligible &= set(nrevs)
                     eligible = to_ranges(eligible)
                     row.append(_get_revs_link(_('eligible'), context,
                                               spath, eligible))
                 rows.append((False, spath, [tag.td(each) for each in row]))
                 continue
         except NoSuchNode:
             deleted = True
         revs = revs.replace(',', u',\u200b')
         rows.append((deleted, spath,
                      [tag.td('/' + spath),
                       tag.td(revs, colspan=revs_cols)]))
     if not rows:
         return None
     rows.sort()
     has_deleted = rows and rows[-1][0] or None
     return tag(has_deleted and tag.a(_('(toggle deleted branches)'),
                                      class_='trac-toggledeleted',
                                      href='#'),
                tag.table(tag.tbody(
                    [tag.tr(row, class_=deleted and 'trac-deleted' or None)
                     for deleted, spath, row in rows]), class_='props'))
Example #5
0
 def render_property(self, name, mode, context, props):
     """Parse svn:mergeinfo and svnmerge-* properties, converting branch
     names to links and providing links to the revision log for merged
     and eligible revisions.
     """
     has_eligible = name in ('svnmerge-integrated', 'svn:mergeinfo')
     revs_label = (_('merged'), _('blocked'))[name.endswith('blocked')]
     revs_cols = has_eligible and 2 or None
     reponame = context.resource.parent.id
     target_path = context.resource.id
     repos = RepositoryManager(self.env).get_repository(reponame)
     target_rev = context.resource.version
     if has_eligible:
         node = repos.get_node(target_path, target_rev)
         branch_starts = {}
         for path, rev in node.get_copy_ancestry():
             if path not in branch_starts:
                 branch_starts[path] = rev + 1
     rows = []
     if name.startswith('svnmerge-'):
         sources = props[name].split()
     else:
         sources = props[name].splitlines()
     for line in sources:
         path, revs = line.split(':', 1)
         spath = _path_within_scope(repos.scope, path)
         if spath is None:
             continue
         revs = revs.strip()
         inheritable, non_inheritable = _partition_inheritable(revs)
         revs = ','.join(inheritable)
         deleted = False
         try:
             node = repos.get_node(spath, target_rev)
             resource = context.resource.parent.child('source', spath)
             if 'LOG_VIEW' in context.perm(resource):
                 row = [
                     _get_source_link(spath, context),
                     _get_revs_link(revs_label, context, spath, revs)
                 ]
                 if non_inheritable:
                     non_inheritable = ','.join(non_inheritable)
                     row.append(
                         _get_revs_link(
                             _('non-inheritable'), context, spath,
                             non_inheritable,
                             _('merged on the directory '
                               'itself but not below')))
                 if has_eligible:
                     first_rev = branch_starts.get(spath)
                     if not first_rev:
                         first_rev = node.get_branch_origin()
                     eligible = set(xrange(first_rev or 1, target_rev + 1))
                     eligible -= set(Ranges(revs))
                     blocked = _get_blocked_revs(props, name, spath)
                     if blocked:
                         eligible -= set(Ranges(blocked))
                     if eligible:
                         nrevs = repos._get_node_revs(
                             spath, max(eligible), min(eligible))
                         eligible &= set(nrevs)
                     eligible = to_ranges(eligible)
                     row.append(
                         _get_revs_link(_('eligible'), context, spath,
                                        eligible))
                 rows.append((False, spath, [tag.td(each) for each in row]))
                 continue
         except NoSuchNode:
             deleted = True
         revs = revs.replace(',', u',\u200b')
         rows.append(
             (deleted, spath,
              [tag.td('/' + spath),
               tag.td(revs, colspan=revs_cols)]))
     if not rows:
         return None
     rows.sort()
     has_deleted = rows and rows[-1][0] or None
     return tag(
         has_deleted and tag.a(_('(toggle deleted branches)'),
                               class_='trac-toggledeleted',
                               href='#'),
         tag.table(tag.tbody([
             tag.tr(row, class_=deleted and 'trac-deleted' or None)
             for deleted, spath, row in rows
         ]),
                   class_='props'))
Example #6
0
 def render_property(self, name, mode, context, props):
     """Parse svn:mergeinfo and svnmerge-* properties, converting branch
     names to links and providing links to the revision log for merged
     and eligible revisions.
     """
     has_eligible = name in ("svnmerge-integrated", "svn:mergeinfo")
     revs_label = _("blocked") if name.endswith("blocked") else _("merged")
     revs_cols = 2 if has_eligible else None
     reponame = context.resource.parent.id
     target_path = context.resource.id
     repos = RepositoryManager(self.env).get_repository(reponame)
     target_rev = context.resource.version
     if has_eligible:
         node = repos.get_node(target_path, target_rev)
         branch_starts = {}
         for path, rev in node.get_copy_ancestry():
             if path not in branch_starts:
                 branch_starts[path] = rev + 1
     rows = []
     if name.startswith("svnmerge-"):
         sources = props[name].split()
     else:
         sources = props[name].splitlines()
     for line in sources:
         path, revs = line.split(":", 1)
         spath = _path_within_scope(repos.scope, path)
         if spath is None:
             continue
         revs = revs.strip()
         inheritable, non_inheritable = _partition_inheritable(revs)
         revs = ",".join(inheritable)
         deleted = False
         try:
             node = repos.get_node(spath, target_rev)
             resource = context.resource.parent.child("source", spath)
             if "LOG_VIEW" in context.perm(resource):
                 row = [_get_source_link(spath, context), _get_revs_link(revs_label, context, spath, revs)]
                 if non_inheritable:
                     non_inheritable = ",".join(non_inheritable)
                     row.append(
                         _get_revs_link(
                             _("non-inheritable"),
                             context,
                             spath,
                             non_inheritable,
                             _("merged on the directory " "itself but not below"),
                         )
                     )
                 if has_eligible:
                     first_rev = branch_starts.get(spath)
                     if not first_rev:
                         first_rev = node.get_branch_origin()
                     eligible = set(xrange(first_rev or 1, target_rev + 1))
                     eligible -= set(Ranges(revs))
                     blocked = _get_blocked_revs(props, name, spath)
                     if blocked:
                         eligible -= set(Ranges(blocked))
                     if eligible:
                         nrevs = repos._get_node_revs(spath, max(eligible), min(eligible))
                         eligible &= set(nrevs)
                     eligible = to_ranges(eligible)
                     row.append(_get_revs_link(_("eligible"), context, spath, eligible))
                 rows.append((False, spath, [tag.td(each) for each in row]))
                 continue
         except NoSuchNode:
             deleted = True
         revs = revs.replace(",", u",\u200b")
         rows.append((deleted, spath, [tag.td("/" + spath), tag.td(revs, colspan=revs_cols)]))
     if not rows:
         return None
     rows.sort()
     has_deleted = rows[-1][0] if rows else None
     return tag(
         has_deleted and tag.a(_("(toggle deleted branches)"), class_="trac-toggledeleted", href="#"),
         tag.table(
             tag.tbody([tag.tr(row, class_="trac-deleted" if deleted else None) for deleted, spath, row in rows]),
             class_="props",
         ),
     )