Ejemplo n.º 1
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.º 2
0
  def itemlog(self, path_parts, rev, sortby, first, limit, options):
    """see vclib.Repository.itemlog docstring

    rev parameter can be a revision number, a branch number, a tag name,
    or None. If None, will return information about all revisions, otherwise,
    will only return information about the specified revision or branch.

    Option values returned by this implementation:

      cvs_tags
        dictionary of Tag objects for all tags encountered
    """
    if self.itemtype(path_parts, rev) != vclib.FILE:  # does auth-check
      raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))

    path = self.rcsfile(path_parts, 1)
    sink = TreeSink()
    rcsparse.parse(open(path, 'rb'), sink)
    filtered_revs = _file_log(sink.revs.values(), sink.tags, sink.lockinfo,
                              sink.default_branch, rev)
    for rev in filtered_revs:
      if rev.prev and len(rev.number) == 2:
        rev.changed = rev.prev.next_changed
    options['cvs_tags'] = sink.tags

    if sortby == vclib.SORTBY_DATE:
      filtered_revs.sort(_logsort_date_cmp)
    elif sortby == vclib.SORTBY_REV:
      filtered_revs.sort(_logsort_rev_cmp)
      
    if len(filtered_revs) < first:
      return []
    if limit:
      return filtered_revs[first:first+limit]
    return filtered_revs
Ejemplo n.º 3
0
  def itemlog(self, path_parts, rev, sortby, first, limit, options):
    """see vclib.Repository.itemlog docstring

    rev parameter can be a revision number, a branch number, a tag name,
    or None. If None, will return information about all revisions, otherwise,
    will only return information about the specified revision or branch.

    Option values returned by this implementation:

      cvs_tags
        dictionary of Tag objects for all tags encountered
    """
    if self.itemtype(path_parts, rev) != vclib.FILE:  # does auth-check
      raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))

    path = self.rcsfile(path_parts, 1)
    sink = TreeSink()
    rcsparse.parse(open(path, 'rb'), sink)
    filtered_revs = _file_log(sink.revs.values(), sink.tags, sink.lockinfo,
                              sink.default_branch, rev)
    for rev in filtered_revs:
      if rev.prev and len(rev.number) == 2:
        rev.changed = rev.prev.next_changed
    options['cvs_tags'] = sink.tags

    if sortby == vclib.SORTBY_DATE:
      filtered_revs.sort(_logsort_date_cmp)
    elif sortby == vclib.SORTBY_REV:
      filtered_revs.sort(_logsort_rev_cmp)

    if len(filtered_revs) < first:
      return []
    if limit:
      return filtered_revs[first:first+limit]
    return filtered_revs
Ejemplo n.º 4
0
 def annotate(self, path_parts, rev=None, include_text=False):
     if self.itemtype(path_parts, rev) != vclib.FILE:  # does auth-check
         raise vclib.Error("Path '%s' is not a file." %
                           (_path_join(path_parts)))
     source = blame.BlameSource(self.rcsfile(path_parts, 1), rev,
                                include_text)
     return source, source.revision
Ejemplo n.º 5
0
 def openfile(self, path_parts, rev, options):
   if self.itemtype(path_parts, rev) != vclib.FILE:  # does auth-check
     raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))
   path = self.rcsfile(path_parts, 1)
   sink = COSink(rev)
   rcsparse.parse(open(path, 'rb'), sink)
   revision = sink.last and sink.last.string
   return cStringIO.StringIO('\n'.join(sink.sstext.text)), revision
Ejemplo n.º 6
0
 def openfile(self, path_parts, rev, options):
   if self.itemtype(path_parts, rev) != vclib.FILE:  # does auth-check
     raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))
   path = self.rcsfile(path_parts, 1)
   sink = COSink(rev)
   rcsparse.parse(open(path, 'rb'), sink)
   revision = sink.last and sink.last.string
   return cStringIO.StringIO('\n'.join(sink.sstext.text)), revision
Ejemplo n.º 7
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." % (_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)))

    fd1, temp1 = tempfile.mkstemp()
    os.fdopen(fd1, 'wb').write(self.openfile(path_parts1, rev1, {})[0].getvalue())
    fd2, temp2 = tempfile.mkstemp()
    os.fdopen(fd2, '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.º 8
0
 def annotate(self, path_parts, rev=None, include_text=False):
   if self.itemtype(path_parts, rev) != vclib.FILE:  # does auth-check
     raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))
   source = blame.BlameSource(self.rcsfile(path_parts, 1), rev, include_text)
   return source, source.revision