Пример #1
0
 def add_history(self, path, revision, pool):
     # If filtering, only add the path and revision to the histories
     # list if they were actually changed in this revision (where
     # change means the path itself was changed, or one of its parents
     # was copied).  This is useful for omitting bubble-up directory
     # changes.
     if not self.show_all_logs:
         rev_root = fs.revision_root(self.fs_ptr, revision, pool)
         changed_paths = fs.paths_changed(rev_root, pool)
         paths = changed_paths.keys()
         if path not in paths:
             # Look for a copied parent
             test_path = path
             found = 0
             subpool = core.svn_pool_create(pool)
             while 1:
                 core.svn_pool_clear(subpool)
                 off = string.rfind(test_path, '/')
                 if off < 0:
                     break
                 test_path = test_path[0:off]
                 if test_path in paths:
                     copyfrom_rev, copyfrom_path = \
                                   fs.copied_from(rev_root, test_path, subpool)
                     if copyfrom_rev >= 0 and copyfrom_path:
                         found = 1
                         break
             core.svn_pool_destroy(subpool)
             if not found:
                 return
     self.histories[revision] = _cleanup_path(path)
Пример #2
0
 def add_history(self, path, revision, pool):
   # If filtering, only add the path and revision to the histories
   # list if they were actually changed in this revision (where
   # change means the path itself was changed, or one of its parents
   # was copied).  This is useful for omitting bubble-up directory
   # changes.
   if not self.show_all_logs:
     rev_root = fs.revision_root(self.fs_ptr, revision, pool)
     changed_paths = fs.paths_changed(rev_root, pool)
     paths = changed_paths.keys()
     if path not in paths:
       # Look for a copied parent
       test_path = path
       found = 0
       subpool = core.svn_pool_create(pool)
       while 1:
         core.svn_pool_clear(subpool)
         off = string.rfind(test_path, '/')
         if off < 0:
           break
         test_path = test_path[0:off]
         if test_path in paths:
           copyfrom_rev, copyfrom_path = \
                         fs.copied_from(rev_root, test_path, subpool)
           if copyfrom_rev >= 0 and copyfrom_path:
             found = 1
             break
       core.svn_pool_destroy(subpool)
       if not found:
         return
   self.histories[revision] = _cleanup_path(path)
Пример #3
0
def get_logs(svnrepos, full_name, rev, files):
    fsroot = svnrepos._getroot(rev)
    subpool = core.svn_pool_create(svnrepos.pool)
    for file in files:
        core.svn_pool_clear(subpool)
        path = _fs_path_join(full_name, file.name)
        rev = _get_last_history_rev(fsroot, path, subpool)
        datestr, author, msg = _fs_rev_props(svnrepos.fs_ptr, rev, subpool)
        date = _datestr_to_date(datestr, subpool)
        file.rev = str(rev)
        file.date = date
        file.author = author
        file.log = msg
        if file.kind == vclib.FILE:
            file.size = fs.file_length(fsroot, path, subpool)
    core.svn_pool_destroy(subpool)
Пример #4
0
def get_logs(svnrepos, full_name, rev, files):
  fsroot = svnrepos._getroot(rev)
  subpool = core.svn_pool_create(svnrepos.pool)
  for file in files:
    core.svn_pool_clear(subpool)
    path = _fs_path_join(full_name, file.name)
    rev = _get_last_history_rev(fsroot, path, subpool)
    datestr, author, msg = _fs_rev_props(svnrepos.fs_ptr, rev, subpool)
    date = _datestr_to_date(datestr, subpool)
    file.rev = str(rev)
    file.date = date
    file.author = author
    file.log = msg
    if file.kind == vclib.FILE:
      file.size = fs.file_length(fsroot, path, subpool)
  core.svn_pool_destroy(subpool)
Пример #5
0
def get_logs(svnrepos, full_name, rev, files):
    dirents = svnrepos._get_dirents(full_name, rev)
    subpool = core.svn_pool_create(svnrepos.pool)
    rev_info_cache = {}
    for file in files:
        core.svn_pool_clear(subpool)
        entry = dirents[file.name]
        if rev_info_cache.has_key(entry.created_rev):
            rev, author, date, log = rev_info_cache[entry.created_rev]
        else:
            ### i think this needs some get_last_history action to be accurate
            rev, author, date, log, changes = \
                 _get_rev_details(svnrepos, entry.created_rev, subpool)
            rev_info_cache[entry.created_rev] = rev, author, date, log
        file.rev = rev
        file.author = author
        file.date = _datestr_to_date(date, subpool)
        file.log = log
        file.size = entry.size
    core.svn_pool_destroy(subpool)
Пример #6
0
def get_logs(svnrepos, full_name, rev, files):
  dirents = svnrepos._get_dirents(full_name, rev)
  subpool = core.svn_pool_create(svnrepos.pool)
  rev_info_cache = { }
  for file in files:
    core.svn_pool_clear(subpool)
    entry = dirents[file.name]
    if rev_info_cache.has_key(entry.created_rev):
      rev, author, date, log = rev_info_cache[entry.created_rev]
    else:
      ### i think this needs some get_last_history action to be accurate
      rev, author, date, log, changes = \
           _get_rev_details(svnrepos, entry.created_rev, subpool)
      rev_info_cache[entry.created_rev] = rev, author, date, log
    file.rev = rev
    file.author = author
    file.date = _datestr_to_date(date, subpool)
    file.log = log
    file.size = entry.size
  core.svn_pool_destroy(subpool)    
Пример #7
0
def _fetch_log(svnrepos, full_name, which_rev, options, pool):
    revs = []

    if options.get('svn_latest_log', 0):
        rev = _log_helper(svnrepos, which_rev, full_name, pool)
        if rev:
            revs.append(rev)
    else:
        history_set = _get_history(svnrepos, full_name, which_rev, options)
        history_revs = history_set.keys()
        history_revs.sort()
        history_revs.reverse()
        subpool = core.svn_pool_create(pool)
        for history_rev in history_revs:
            core.svn_pool_clear(subpool)
            rev = _log_helper(svnrepos, history_rev, history_set[history_rev],
                              subpool)
            if rev:
                revs.append(rev)
        core.svn_pool_destroy(subpool)
    return revs
Пример #8
0
def _fetch_log(svnrepos, full_name, which_rev, options, pool):
  revs = []

  if options.get('svn_latest_log', 0):
    rev = _log_helper(svnrepos, which_rev, full_name, pool)
    if rev:
      revs.append(rev)
  else:
    history_set = _get_history(svnrepos, full_name, which_rev, options)
    history_revs = history_set.keys()
    history_revs.sort()
    history_revs.reverse()
    subpool = core.svn_pool_create(pool)
    for history_rev in history_revs:
      core.svn_pool_clear(subpool)
      rev = _log_helper(svnrepos, history_rev, history_set[history_rev],
                        subpool)
      if rev:
        revs.append(rev)
    core.svn_pool_destroy(subpool)
  return revs
Пример #9
0
def sync(db, repos, fs_ptr, pool):
    """
    updates the revision and node_change tables to be in sync with
    the repository.
    """

    if core.SVN_VER_MAJOR < 1:
        raise EnvironmentError, \
              "Subversion >= 1.0 required: Found %d.%d.%d" % \
              (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO)

    cursor = db.cursor()
    cursor.execute('SELECT ifnull(max(rev), 0) FROM revision')
    youngest_stored = int(cursor.fetchone()[0])
    max_rev = fs.youngest_rev(fs_ptr, pool)
    num = max_rev - youngest_stored
    offset = youngest_stored + 1

    subpool = core.svn_pool_create(pool)
    for rev in range(num):
        message = fs.revision_prop(fs_ptr, rev + offset,
                                   core.SVN_PROP_REVISION_LOG, subpool)
        author = fs.revision_prop(fs_ptr, rev + offset,
                                  core.SVN_PROP_REVISION_AUTHOR, subpool)
        date = fs.revision_prop(fs_ptr, rev + offset,
                                core.SVN_PROP_REVISION_DATE, subpool)

        date = core.svn_time_from_cstring(date, subpool) / 1000000

        cursor.execute(
            'INSERT INTO revision (rev, time, author, message) '
            'VALUES (%s, %s, %s, %s)', rev + offset, date, author, message)
        insert_change(subpool, fs_ptr, rev + offset, cursor)
        core.svn_pool_clear(subpool)

    core.svn_pool_destroy(subpool)
    db.commit()
Пример #10
0
def export_revision(rev, repo, fs, pool):
    sys.stderr.write("Exporting revision %s... " % rev)

    revpool = svn_pool_create(pool)
    svn_pool_clear(revpool)

    # Open a root object representing the youngest (HEAD) revision.
    root = svn_fs_revision_root(fs, rev, revpool)

    # And the list of what changed in this revision.
    changes = svn_fs_paths_changed(root, revpool)

    i = 1
    marks = {}
    file_changes = []

    for path, change_type in changes.iteritems():
        c_t = ct_short[change_type.change_kind]
        if svn_fs_is_dir(root, path, revpool):
            continue

        if not path.startswith(trunk_path):
            # We don't handle branches. Or tags. Yet.
            pass
        else:
            if c_t == 'D':
                file_changes.append("D %s" % path.replace(trunk_path, ''))
            else:
                marks[i] = path.replace(trunk_path, '')
                file_changes.append("M 644 :%s %s" % (i, marks[i]))
                sys.stdout.write("blob\nmark :%s\n" % i)
                dump_file_blob(root, path, revpool)
                i += 1

    # Get the commit author and message
    props = svn_fs_revision_proplist(fs, rev, revpool)

    # Do the recursive crawl.
    if props.has_key('svn:author'):
        author = "%s <%s@localhost>" % (props['svn:author'],
                                        props['svn:author'])
    else:
        author = 'nobody <nobody@localhost>'

    if len(file_changes) == 0:
        svn_pool_destroy(revpool)
        sys.stderr.write("skipping.\n")
        return

    svndate = props['svn:date'][0:-8]
    commit_time = mktime(strptime(svndate, '%Y-%m-%dT%H:%M:%S'))
    sys.stdout.write("commit refs/heads/master\n")
    sys.stdout.write("committer %s %s -0000\n" % (author, int(commit_time)))
    sys.stdout.write("data %s\n" % len(props['svn:log']))
    sys.stdout.write(props['svn:log'])
    sys.stdout.write("\n")
    sys.stdout.write('\n'.join(file_changes))
    sys.stdout.write("\n\n")

    svn_pool_destroy(revpool)

    sys.stderr.write("done!\n")
Пример #11
0
  repos_path = args[0]
  print 'Accessing repository at [%s]' % repos_path

  repository = Repository(repos_path, pool)
  sub = repository.subpool()

  try:
    txn = repository.begin(username, log_msg)

    # Read commands from STDIN
    lineno = 0
    for line in sys.stdin:
      lineno += 1

      core.svn_pool_clear(sub)
      try:
        if COMMENT_RE.search(line):
          continue

        match = RCOPY_RE.search(line)
        if match:
          src = match.group(1)
          dest = match.group(2)
          txn.copy(src, dest, sub)
          continue

        match = RMOVE_RE.search(line)
        if match:
          src = match.group(1)
          dest = match.group(2)
Пример #12
0
def export_revision(rev, repo, fs, pool):
    sys.stderr.write("Exporting revision %s... " % rev)

    revpool = svn_pool_create(pool)
    svn_pool_clear(revpool)

    # Open a root object representing the youngest (HEAD) revision.
    root = svn_fs_revision_root(fs, rev, revpool)

    # And the list of what changed in this revision.
    changes = svn_fs_paths_changed(root, revpool)

    i = 1
    marks = {}
    file_changes = []

    for path, change_type in changes.iteritems():
        c_t = ct_short[change_type.change_kind]
        if svn_fs_is_dir(root, path, revpool):
            continue

        if not path.startswith(trunk_path):
            # We don't handle branches. Or tags. Yet.
            pass
        else:
            if c_t == "D":
                file_changes.append("D %s" % path.replace(trunk_path, ""))
            else:
                marks[i] = path.replace(trunk_path, "")
                file_changes.append("M 644 :%s %s" % (i, marks[i]))
                sys.stdout.write("blob\nmark :%s\n" % i)
                dump_file_blob(root, path, revpool)
                i += 1

    # Get the commit author and message
    props = svn_fs_revision_proplist(fs, rev, revpool)

    # Do the recursive crawl.
    if props.has_key("svn:author"):
        author = "%s <%s@localhost>" % (props["svn:author"], props["svn:author"])
    else:
        author = "nobody <nobody@localhost>"

    if len(file_changes) == 0:
        svn_pool_destroy(revpool)
        sys.stderr.write("skipping.\n")
        return

    svndate = props["svn:date"][0:-8]
    commit_time = mktime(strptime(svndate, "%Y-%m-%dT%H:%M:%S"))
    sys.stdout.write("commit refs/heads/master\n")
    sys.stdout.write("committer %s %s -0000\n" % (author, int(commit_time)))
    sys.stdout.write("data %s\n" % len(props["svn:log"]))
    sys.stdout.write(props["svn:log"])
    sys.stdout.write("\n")
    sys.stdout.write("\n".join(file_changes))
    sys.stdout.write("\n\n")

    svn_pool_destroy(revpool)

    sys.stderr.write("done!\n")
Пример #13
0
 def _scratch_clear(self):
     core.svn_pool_clear(self.scratch_pool)
Пример #14
0
 def _scratch_clear(self):
   core.svn_pool_clear(self.scratch_pool)