Ejemplo n.º 1
0
 def add_log(self, log_entry, pool):
   if self.done:
     return
   paths = log_entry.changed_paths
   revision = log_entry.revision
   msg, author, date, revprops = _split_revprops(log_entry.revprops)
   
   # Changed paths have leading slashes
   changed_paths = paths.keys()
   changed_paths.sort(lambda a, b: _compare_paths(a, b))
   this_path = None
   if self.path in changed_paths:
     this_path = self.path
     change = paths[self.path]
     if change.copyfrom_path:
       this_path = change.copyfrom_path
   for changed_path in changed_paths:
     if changed_path != self.path:
       # If a parent of our path was copied, our "next previous"
       # (huh?) path will exist elsewhere (under the copy source).
       if (self.path.rfind(changed_path) == 0) and \
              self.path[len(changed_path)] == '/':
         change = paths[changed_path]
         if change.copyfrom_path:
           this_path = change.copyfrom_path + self.path[len(changed_path):]
   if self.show_all_logs or this_path:
     if self.access_check_func is None \
        or self.access_check_func(self.path[1:], revision):
       entry = Revision(revision, date, author, msg, None, self.lockinfo,
                        self.path[1:], None, None)
       self.logs.append(entry)
     else:
       self.done = True
   if this_path:
     self.path = this_path
Ejemplo n.º 2
0
    def add_log(self, log_entry, pool):
        if self.done:
            return
        paths = log_entry.changed_paths
        revision = log_entry.revision
        msg, author, date, revprops = _split_revprops(log_entry.revprops)

        # Changed paths have leading slashes
        changed_paths = paths.keys()
        changed_paths.sort(lambda a, b: _compare_paths(a, b))
        this_path = None
        if self.path in changed_paths:
            this_path = self.path
            change = paths[self.path]
            if change.copyfrom_path:
                this_path = change.copyfrom_path
        for changed_path in changed_paths:
            if changed_path != self.path:
                # If a parent of our path was copied, our "next previous"
                # (huh?) path will exist elsewhere (under the copy source).
                if (string.rfind(self.path, changed_path) == 0) and \
                       self.path[len(changed_path)] == '/':
                    change = paths[changed_path]
                    if change.copyfrom_path:
                        this_path = change.copyfrom_path + self.path[
                            len(changed_path):]
        if self.show_all_logs or this_path:
            if self.access_check_func is None \
               or self.access_check_func(self.path[1:], revision):
                entry = Revision(revision, date, author, msg, None,
                                 self.lockinfo, self.path[1:], None, None)
                self.logs.append(entry)
            else:
                self.done = True
        if this_path:
            self.path = this_path
Ejemplo n.º 3
0
        def _log_cb(log_entry, pool, retval=revs):
            # If Subversion happens to call us more than once, we choose not
            # to care.
            if retval:
                return

            revision = log_entry.revision
            msg, author, date, revprops = _split_revprops(log_entry.revprops)
            action_map = {
                'D': vclib.DELETED,
                'A': vclib.ADDED,
                'R': vclib.REPLACED,
                'M': vclib.MODIFIED,
            }

            # Easy out: if we won't use the changed-path info, just return a
            # changes-less tuple.
            if not need_changes:
                return revs.append([date, author, msg, revprops, None])

            # Subversion 1.5 and earlier didn't offer the 'changed_paths2'
            # hash, and in Subversion 1.6, it's offered but broken.
            try:
                changed_paths = log_entry.changed_paths2
                paths = (changed_paths or {}).keys()
            except:
                changed_paths = log_entry.changed_paths
                paths = (changed_paths or {}).keys()
            paths.sort(lambda a, b: _compare_paths(a, b))

            # If we get this far, our caller needs changed-paths, or we need
            # them for authz-related sanitization.
            changes = []
            found_readable = found_unreadable = 0
            for path in paths:
                change = changed_paths[path]

                # svn_log_changed_path_t (which we might get instead of the
                # svn_log_changed_path2_t we'd prefer) doesn't have the
                # 'node_kind' member.
                pathtype = None
                if hasattr(change, 'node_kind'):
                    if change.node_kind == core.svn_node_dir:
                        pathtype = vclib.DIR
                    elif change.node_kind == core.svn_node_file:
                        pathtype = vclib.FILE

                # svn_log_changed_path2_t only has the 'text_modified' and
                # 'props_modified' bits in Subversion 1.7 and beyond.  And
                # svn_log_changed_path_t is without.
                text_modified = props_modified = 0
                if hasattr(change, 'text_modified'):
                    if change.text_modified == core.svn_tristate_true:
                        text_modified = 1
                if hasattr(change, 'props_modified'):
                    if change.props_modified == core.svn_tristate_true:
                        props_modified = 1

                # Wrong, diddily wrong wrong wrong.  Can you say,
                # "Manufacturing data left and right because it hurts to
                # figure out the right stuff?"
                action = action_map.get(change.action, vclib.MODIFIED)
                if change.copyfrom_path and change.copyfrom_rev:
                    is_copy = 1
                    base_path = change.copyfrom_path
                    base_rev = change.copyfrom_rev
                elif action == vclib.ADDED or action == vclib.REPLACED:
                    is_copy = 0
                    base_path = base_rev = None
                else:
                    is_copy = 0
                    base_path = path
                    base_rev = revision - 1

                # Check authz rules (sadly, we have to lie about the path type)
                parts = _path_parts(path)
                if vclib.check_path_access(self, parts, vclib.FILE, revision):
                    if is_copy and base_path and (base_path != path):
                        parts = _path_parts(base_path)
                        if not vclib.check_path_access(self, parts, vclib.FILE,
                                                       base_rev):
                            is_copy = 0
                            base_path = None
                            base_rev = None
                            found_unreadable = 1
                    changes.append(
                        SVNChangedPath(path, revision, pathtype, base_path,
                                       base_rev, action, is_copy,
                                       text_modified, props_modified))
                    found_readable = 1
                else:
                    found_unreadable = 1

                # If our caller doesn't want changed-path stuff, and we have
                # the info we need to make an authz determination already,
                # quit this loop and get on with it.
                if (not include_changed_paths
                    ) and found_unreadable and found_readable:
                    break

            # Filter unreadable information.
            if found_unreadable:
                msg = None
                if not found_readable:
                    author = None
                    date = None

            # Drop unrequested changes.
            if not include_changed_paths:
                changes = None

            # Add this revision information to the "return" array.
            retval.append([date, author, msg, revprops, changes])
Ejemplo n.º 4
0
    def _log_cb(log_entry, pool, retval=revs):
      # If Subversion happens to call us more than once, we choose not
      # to care.
      if retval:
        return
      
      revision = log_entry.revision
      msg, author, date, revprops = _split_revprops(log_entry.revprops)
      action_map = { 'D' : vclib.DELETED,
                     'A' : vclib.ADDED,
                     'R' : vclib.REPLACED,
                     'M' : vclib.MODIFIED,
                     }

      # Easy out: if we won't use the changed-path info, just return a
      # changes-less tuple.
      if not need_changes:
        return revs.append([date, author, msg, revprops, None])

      # Subversion 1.5 and earlier didn't offer the 'changed_paths2'
      # hash, and in Subversion 1.6, it's offered but broken.
      try: 
        changed_paths = log_entry.changed_paths2
        paths = (changed_paths or {}).keys()
      except:
        changed_paths = log_entry.changed_paths
        paths = (changed_paths or {}).keys()
      paths.sort(lambda a, b: _compare_paths(a, b))

      # If we get this far, our caller needs changed-paths, or we need
      # them for authz-related sanitization.
      changes = []
      found_readable = found_unreadable = 0
      for path in paths:
        change = changed_paths[path]

        # svn_log_changed_path_t (which we might get instead of the
        # svn_log_changed_path2_t we'd prefer) doesn't have the
        # 'node_kind' member.        
        pathtype = None
        if hasattr(change, 'node_kind'):
          if change.node_kind == core.svn_node_dir:
            pathtype = vclib.DIR
          elif change.node_kind == core.svn_node_file:
            pathtype = vclib.FILE
            
        # svn_log_changed_path2_t only has the 'text_modified' and
        # 'props_modified' bits in Subversion 1.7 and beyond.  And
        # svn_log_changed_path_t is without.
        text_modified = props_modified = 0
        if hasattr(change, 'text_modified'):
          if change.text_modified == core.svn_tristate_true:
            text_modified = 1
        if hasattr(change, 'props_modified'):
          if change.props_modified == core.svn_tristate_true:
            props_modified = 1
            
        # Wrong, diddily wrong wrong wrong.  Can you say,
        # "Manufacturing data left and right because it hurts to
        # figure out the right stuff?"
        action = action_map.get(change.action, vclib.MODIFIED)
        if change.copyfrom_path and change.copyfrom_rev:
          is_copy = 1
          base_path = change.copyfrom_path
          base_rev = change.copyfrom_rev
        elif action == vclib.ADDED or action == vclib.REPLACED:
          is_copy = 0
          base_path = base_rev = None
        else:
          is_copy = 0
          base_path = path
          base_rev = revision - 1

        # Check authz rules (sadly, we have to lie about the path type)
        parts = _path_parts(path)
        if vclib.check_path_access(self, parts, vclib.FILE, revision):
          if is_copy and base_path and (base_path != path):
            parts = _path_parts(base_path)
            if not vclib.check_path_access(self, parts, vclib.FILE, base_rev):
              is_copy = 0
              base_path = None
              base_rev = None
              found_unreadable = 1
          changes.append(SVNChangedPath(path, revision, pathtype, base_path,
                                        base_rev, action, is_copy,
                                        text_modified, props_modified))
          found_readable = 1
        else:
          found_unreadable = 1

        # If our caller doesn't want changed-path stuff, and we have
        # the info we need to make an authz determination already,
        # quit this loop and get on with it.
        if (not include_changed_paths) and found_unreadable and found_readable:
          break

      # Filter unreadable information.
      if found_unreadable:
        msg = None
        if not found_readable:
          author = None
          date = None

      # Drop unrequested changes.
      if not include_changed_paths:
        changes = None

      # Add this revision information to the "return" array.
      retval.append([date, author, msg, revprops, changes])
Ejemplo n.º 5
0
        def _log_cb(log_entry, pool, retval=revs):
            ### Subversion 1.5 and earlier didn't offer the 'changed_paths2'
            ### hash, and in Subversion 1.6, it's offered but broken.
            try:
                changed_paths = log_entry.changed_paths2
                paths = (changed_paths or {}).keys()
            except:
                changed_paths = log_entry.changed_paths
                paths = (changed_paths or {}).keys()
            paths.sort(lambda a, b: _compare_paths(a, b))
            revision = log_entry.revision
            msg, author, date, revprops = _split_revprops(log_entry.revprops)
            action_map = {
                'D': vclib.DELETED,
                'A': vclib.ADDED,
                'R': vclib.REPLACED,
                'M': vclib.MODIFIED,
            }
            changes = []
            found_readable = found_unreadable = 0
            for path in paths:
                change = changed_paths[path]
                ### svn_log_changed_path_t (which we might get instead of the
                ### svn_log_changed_path2_t we'd prefer) doesn't have the
                ### 'node_kind' member.
                pathtype = None
                if hasattr(change, 'node_kind'):
                    if change.node_kind == core.svn_node_dir:
                        pathtype = vclib.DIR
                    elif change.node_kind == core.svn_node_file:
                        pathtype = vclib.FILE
                ### svn_log_changed_path2_t only has the 'text_modified' and
                ### 'props_modified' bits in Subversion 1.7 and beyond.  And
                ### svn_log_changed_path_t is without.
                text_modified = props_modified = 0
                if hasattr(change, 'text_modified'):
                    if change.text_modified == core.svn_tristate_true:
                        text_modified = 1
                if hasattr(change, 'props_modified'):
                    if change.props_modified == core.svn_tristate_true:
                        props_modified = 1
                ### Wrong, diddily wrong wrong wrong.  Can you say,
                ### "Manufacturing data left and right because it hurts to
                ### figure out the right stuff?"
                action = action_map.get(change.action, vclib.MODIFIED)
                if change.copyfrom_path and change.copyfrom_rev:
                    is_copy = 1
                    base_path = change.copyfrom_path
                    base_rev = change.copyfrom_rev
                elif action == vclib.ADDED or action == vclib.REPLACED:
                    is_copy = 0
                    base_path = base_rev = None
                else:
                    is_copy = 0
                    base_path = path
                    base_rev = revision - 1

                ### Check authz rules (we lie about the path type)
                parts = _path_parts(path)
                if vclib.check_path_access(self, parts, vclib.FILE, revision):
                    if is_copy and base_path and (base_path != path):
                        parts = _path_parts(base_path)
                        if vclib.check_path_access(self, parts, vclib.FILE,
                                                   base_rev):
                            is_copy = 0
                            base_path = None
                            base_rev = None
                    changes.append(
                        SVNChangedPath(path, revision, pathtype, base_path,
                                       base_rev, action, is_copy,
                                       text_modified, props_modified))
                    found_readable = 1
                else:
                    found_unreadable = 1

            if found_unreadable:
                msg = None
                if not found_readable:
                    author = None
                    date = None
            revs.append([date, author, msg, revprops, changes])
Ejemplo n.º 6
0
    def _log_cb(log_entry, pool, retval=revs):
      ### Subversion 1.5 and earlier didn't offer the 'changed_paths2'
      ### hash, and in Subversion 1.6, it's offered but broken.
      try: 
        changed_paths = log_entry.changed_paths2
        paths = (changed_paths or {}).keys()
      except:
        changed_paths = log_entry.changed_paths
        paths = (changed_paths or {}).keys()
      paths.sort(lambda a, b: _compare_paths(a, b))
      revision = log_entry.revision
      msg, author, date, revprops = _split_revprops(log_entry.revprops)
      action_map = { 'D' : vclib.DELETED,
                     'A' : vclib.ADDED,
                     'R' : vclib.REPLACED,
                     'M' : vclib.MODIFIED,
                     }
      changes = []
      found_readable = found_unreadable = 0
      for path in paths:
        change = changed_paths[path]
        ### svn_log_changed_path_t (which we might get instead of the
        ### svn_log_changed_path2_t we'd prefer) doesn't have the
        ### 'node_kind' member.        
        pathtype = None
        if hasattr(change, 'node_kind'):
          if change.node_kind == core.svn_node_dir:
            pathtype = vclib.DIR
          elif change.node_kind == core.svn_node_file:
            pathtype = vclib.FILE
        ### svn_log_changed_path2_t only has the 'text_modified' and
        ### 'props_modified' bits in Subversion 1.7 and beyond.  And
        ### svn_log_changed_path_t is without.
        text_modified = props_modified = 0
        if hasattr(change, 'text_modified'):
          if change.text_modified == core.svn_tristate_true:
            text_modified = 1
        if hasattr(change, 'props_modified'):
          if change.props_modified == core.svn_tristate_true:
            props_modified = 1
        ### Wrong, diddily wrong wrong wrong.  Can you say,
        ### "Manufacturing data left and right because it hurts to
        ### figure out the right stuff?"
        action = action_map.get(change.action, vclib.MODIFIED)
        if change.copyfrom_path and change.copyfrom_rev:
          is_copy = 1
          base_path = change.copyfrom_path
          base_rev = change.copyfrom_rev
        elif action == vclib.ADDED or action == vclib.REPLACED:
          is_copy = 0
          base_path = base_rev = None
        else:
          is_copy = 0
          base_path = path
          base_rev = revision - 1

        ### Check authz rules (we lie about the path type)
        parts = _path_parts(path)
        if vclib.check_path_access(self, parts, vclib.FILE, revision):
          if is_copy and base_path and (base_path != path):
            parts = _path_parts(base_path)
            if vclib.check_path_access(self, parts, vclib.FILE, base_rev):
              is_copy = 0
              base_path = None
              base_rev = None
          changes.append(SVNChangedPath(path, revision, pathtype, base_path,
                                        base_rev, action, is_copy,
                                        text_modified, props_modified))
          found_readable = 1
        else:
          found_unreadable = 1

      if found_unreadable:
        msg = None
        if not found_readable:
          author = None
          date = None
      revs.append([date, author, msg, revprops, changes])