Ejemplo n.º 1
0
    def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
        if self.itemtype(path_parts1, rev1) != vclib.FILE:  # does auth-check
            raise vclib.Error("Path '%s' is not a file." %
                              (string.join(path_parts1, "/")))
        if self.itemtype(path_parts2, rev2) != vclib.FILE:  # does auth-check
            raise vclib.Error("Path '%s' is not a file." %
                              (string.join(path_parts2, "/")))

        temp1 = tempfile.mktemp()
        open(temp1,
             'wb').write(self.openfile(path_parts1, rev1, {})[0].getvalue())
        temp2 = tempfile.mktemp()
        open(temp2,
             'wb').write(self.openfile(path_parts2, rev2, {})[0].getvalue())

        r1 = self.itemlog(path_parts1, rev1, vclib.SORTBY_DEFAULT, 0, 0,
                          {})[-1]
        r2 = self.itemlog(path_parts2, rev2, vclib.SORTBY_DEFAULT, 0, 0,
                          {})[-1]

        info1 = (self.rcsfile(path_parts1, root=1, v=0), r1.date, r1.string)
        info2 = (self.rcsfile(path_parts2, root=1, v=0), r2.date, r2.string)

        diff_args = vclib._diff_args(type, options)

        return vclib._diff_fp(temp1, temp2, info1, info2, self.utilities.diff
                              or 'diff', diff_args)
Ejemplo n.º 2
0
    def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
        p1 = self._getpath(path_parts1)
        p2 = self._getpath(path_parts2)
        r1 = self._getrev(rev1)
        r2 = self._getrev(rev2)
        if not vclib.check_path_access(self, path_parts1, vclib.FILE, rev1):
            raise vclib.ItemNotFound(path_parts1)
        if not vclib.check_path_access(self, path_parts2, vclib.FILE, rev2):
            raise vclib.ItemNotFound(path_parts2)

        args = vclib._diff_args(type, options)

        def _date_from_rev(rev):
            date, author, msg, revprops, changes = self._revinfo(rev)
            return date

        try:
            temp1 = cat_to_tempfile(self, p1, r1)
            temp2 = cat_to_tempfile(self, p2, r2)
            info1 = p1, _date_from_rev(r1), r1
            info2 = p2, _date_from_rev(r2), r2
            return vclib._diff_fp(temp1, temp2, info1, info2, self.diff_cmd,
                                  args)
        except core.SubversionException, e:
            _fix_subversion_exception(e)
            if e.apr_err == vclib.svn.core.SVN_ERR_FS_NOT_FOUND:
                raise vclib.InvalidRevision
            raise
  def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
    p1 = self._getpath(path_parts1)
    p2 = self._getpath(path_parts2)
    r1 = self._getrev(rev1)
    r2 = self._getrev(rev2)
    if not vclib.check_path_access(self, path_parts1, vclib.FILE, rev1):
      raise vclib.ItemNotFound(path_parts1)
    if not vclib.check_path_access(self, path_parts2, vclib.FILE, rev2):
      raise vclib.ItemNotFound(path_parts2)

    args = vclib._diff_args(type, options)

    def _date_from_rev(rev):
      date, author, msg, changes = self.revinfo(rev)
      return date
    
    try:
      temp1 = temp_checkout(self, p1, r1)
      temp2 = temp_checkout(self, p2, r2)
      info1 = p1, _date_from_rev(r1), r1
      info2 = p2, _date_from_rev(r2), r2
      return vclib._diff_fp(temp1, temp2, info1, info2, self.diff_cmd, args)
    except core.SubversionException, e:
      _fix_subversion_exception(e)
      if e.apr_err == vclib.svn.core.SVN_ERR_FS_NOT_FOUND:
        raise vclib.InvalidRevision
      raise
Ejemplo n.º 4
0
  def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
    """see vclib.Repository.rawdiff docstring

    Option values recognized by this implementation:

      ignore_keyword_subst - boolean, ignore keyword substitution
    """
    if self.itemtype(path_parts1, rev1) != vclib.FILE:  # does auth-check
      raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts1)))
    if self.itemtype(path_parts2, rev2) != vclib.FILE:  # does auth-check
      raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts2)))
    
    args = vclib._diff_args(type, options)
    if options.get('ignore_keyword_subst', 0):
      args.append('-kk')

    rcsfile = self.rcsfile(path_parts1, 1)
    if path_parts1 != path_parts2:
      raise NotImplementedError, "cannot diff across paths in cvs"
    args.extend(['-r' + rev1, '-r' + rev2, rcsfile])
    
    fp = self.rcs_popen('rcsdiff', args, 'rt')

    # Eat up the non-GNU-diff-y headers.
    while 1:
      line = fp.readline()
      if not line or line[0:5] == 'diff ':
        break
    return fp
Ejemplo n.º 5
0
  def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
    """see vclib.Repository.rawdiff docstring

    Option values recognized by this implementation:

      ignore_keyword_subst - boolean, ignore keyword substitution
    """
    if self.itemtype(path_parts1, rev1) != vclib.FILE:  # does auth-check
      raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts1)))
    if self.itemtype(path_parts2, rev2) != vclib.FILE:  # does auth-check
      raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts2)))

    args = vclib._diff_args(type, options)
    if options.get('ignore_keyword_subst', 0):
      args.append('-kk')

    rcsfile = self.rcsfile(path_parts1, 1)
    if path_parts1 != path_parts2:
      raise NotImplementedError("cannot diff across paths in cvs")
    args.extend(['-r' + rev1, '-r' + rev2, rcsfile])
    
    fp = self.rcs_popen('rcsdiff', args, True)

    # Eat up the non-GNU-diff-y headers.
    while 1:
      line = fp.readline()
      if not line or line[0:5] == 'diff ':
        break
    return fp
Ejemplo n.º 6
0
  def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
    if path_parts1 and self.itemtype(path_parts1, rev1) != vclib.FILE:  # does auth-check
      raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts1)))
    if path_parts2 and self.itemtype(path_parts2, rev2) != vclib.FILE:  # does auth-check
      raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts2)))
    if not path_parts1 and not path_parts2:
      raise vclib.Error("Nothing to diff.")
    
    if path_parts1:
      temp1 = tempfile.mktemp()
      open(temp1, 'wb').write(self.openfile(path_parts1, rev1, {})[0].getvalue())
      r1 = self.itemlog(path_parts1, rev1, vclib.SORTBY_DEFAULT, 0, 0, {})[-1]
      info1 = (self.rcsfile(path_parts1, root=1, v=0), r1.date, r1.string)
    else:
      temp1 = '/dev/null'
      info1 = ('/dev/null', '', '')

    if path_parts2:
      temp2 = tempfile.mktemp()
      open(temp2, 'wb').write(self.openfile(path_parts2, rev2, {})[0].getvalue())
      r2 = self.itemlog(path_parts2, rev2, vclib.SORTBY_DEFAULT, 0, 0, {})[-1]
      info2 = (self.rcsfile(path_parts2, root=1, v=0), r2.date, r2.string)
    else:
      temp2 = '/dev/null'
      info2 = ('/dev/null', '', '')

    diff_args = vclib._diff_args(type, options)

    return vclib._diff_fp(temp1, temp2, info1, info2,
                          self.utilities.diff or 'diff', diff_args)
Ejemplo n.º 7
0
  def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
    temp1 = tempfile.mktemp()
    open(temp1, 'wb').write(self.openfile(path_parts1, rev1)[0].getvalue())
    temp2 = tempfile.mktemp()
    open(temp2, 'wb').write(self.openfile(path_parts2, rev2)[0].getvalue())

    r1 = self.itemlog(path_parts1, rev1, {})[-1]
    r2 = self.itemlog(path_parts2, rev2, {})[-1]

    info1 = (self.rcsfile(path_parts1, root=1, v=0), r1.date, r1.string)
    info2 = (self.rcsfile(path_parts2, root=1, v=0), r2.date, r2.string)

    diff_args = vclib._diff_args(type, options)

    return vclib._diff_fp(temp1, temp2, info1, info2, diff_args)
Ejemplo n.º 8
0
    def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
        temp1 = tempfile.mktemp()
        open(temp1, 'wb').write(self.openfile(path_parts1, rev1)[0].getvalue())
        temp2 = tempfile.mktemp()
        open(temp2, 'wb').write(self.openfile(path_parts2, rev2)[0].getvalue())

        r1 = self.itemlog(path_parts1, rev1, {})[-1]
        r2 = self.itemlog(path_parts2, rev2, {})[-1]

        info1 = (self.rcsfile(path_parts1, root=1, v=0), r1.date, r1.string)
        info2 = (self.rcsfile(path_parts2, root=1, v=0), r2.date, r2.string)

        diff_args = vclib._diff_args(type, options)

        return vclib._diff_fp(temp1, temp2, info1, info2, diff_args)
Ejemplo n.º 9
0
    def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
        p1 = self._getpath(path_parts1)
        p2 = self._getpath(path_parts2)
        r1 = self._getrev(rev1)
        r2 = self._getrev(rev2)
        args = vclib._diff_args(type, options)

        try:
            temp1 = temp_checkout(self, p1, r1, self.pool)
            temp2 = temp_checkout(self, p2, r2, self.pool)
            info1 = p1, date_from_rev(self, r1), r1
            info2 = p2, date_from_rev(self, r2), r2
            return vclib._diff_fp(temp1, temp2, info1, info2, args)
        except vclib.svn.core.SubversionException, e:
            if e.apr_err == vclib.svn.core.SVN_ERR_FS_NOT_FOUND:
                raise vclib.InvalidRevision
            raise
Ejemplo n.º 10
0
  def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
    p1 = self._getpath(path_parts1)
    p2 = self._getpath(path_parts2)
    r1 = self._getrev(rev1)
    r2 = self._getrev(rev2)
    args = vclib._diff_args(type, options)

    try:
      temp1 = temp_checkout(self, p1, r1, self.pool)
      temp2 = temp_checkout(self, p2, r2, self.pool)
      info1 = p1, date_from_rev(self, r1), r1
      info2 = p2, date_from_rev(self, r2), r2
      return vclib._diff_fp(temp1, temp2, info1, info2, args)
    except vclib.svn.core.SubversionException, e:
      if e.apr_err == vclib.svn.core.SVN_ERR_FS_NOT_FOUND:
        raise vclib.InvalidRevision
      raise
Ejemplo n.º 11
0
  def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
    if path_parts1:
      p1 = self._getpath(path_parts1)
      r1 = self._getrev(rev1)
      if not vclib.check_path_access(self, path_parts1, vclib.FILE, rev1):
        raise vclib.ItemNotFound(path_parts1)
    else:
      p1 = None

    if path_parts2:
      p2 = self._getpath(path_parts2)
      r2 = self._getrev(rev2)
      if not vclib.check_path_access(self, path_parts2, vclib.FILE, rev2):
        raise vclib.ItemNotFound(path_parts2)
    else:
      if not p1:
        raise vclib.ItemNotFound(path_parts2)
      p2 = None

    args = vclib._diff_args(type, options)

    def _date_from_rev(rev):
      date, author, msg, revprops, changes = self._revinfo(rev)
      return date

    try:
      if p1:
        temp1 = temp_checkout(self, p1, r1)
        info1 = p1, _date_from_rev(r1), r1
      else:
        temp1 = '/dev/null'
        info1 = '/dev/null', _date_from_rev(rev1), rev1
      if p2:
        temp2 = temp_checkout(self, p2, r2)
        info2 = p2, _date_from_rev(r2), r2
      else:
        temp2 = '/dev/null'
        info2 = '/dev/null', _date_from_rev(rev2), rev2
      return vclib._diff_fp(temp1, temp2, info1, info2, self.diff_cmd, args)
    except core.SubversionException, e:
      _fix_subversion_exception(e)
      if e.apr_err == core.SVN_ERR_FS_NOT_FOUND:
        raise vclib.InvalidRevision
      if e.apr_err != _SVN_ERR_CEASE_INVOCATION:
        raise
Ejemplo n.º 12
0
    def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
        if self.itemtype(path_parts1, rev1) != vclib.FILE:  # does auth-check
            raise vclib.Error("Path '%s' is not a file." % (string.join(path_parts1, "/")))
        if self.itemtype(path_parts2, rev2) != vclib.FILE:  # does auth-check
            raise vclib.Error("Path '%s' is not a file." % (string.join(path_parts2, "/")))

        temp1 = tempfile.mktemp()
        open(temp1, "wb").write(self.openfile(path_parts1, rev1, {})[0].getvalue())
        temp2 = tempfile.mktemp()
        open(temp2, "wb").write(self.openfile(path_parts2, rev2, {})[0].getvalue())

        r1 = self.itemlog(path_parts1, rev1, vclib.SORTBY_DEFAULT, 0, 0, {})[-1]
        r2 = self.itemlog(path_parts2, rev2, vclib.SORTBY_DEFAULT, 0, 0, {})[-1]

        info1 = (self.rcsfile(path_parts1, root=1, v=0), r1.date, r1.string)
        info2 = (self.rcsfile(path_parts2, root=1, v=0), r2.date, r2.string)

        diff_args = vclib._diff_args(type, options)

        return vclib._diff_fp(temp1, temp2, info1, info2, self.utilities.diff or "diff", diff_args)