示例#1
0
def generate_diff(output, cfg, repos, date, change, group, params, pool):
    if change.item_kind == svn.core.svn_node_dir:
        # all changes were printed in the summary. nothing to do.
        return

    gen_diffs = cfg.get('generate_diffs', group, params)

    ### Do a little dance for deprecated options.  Note that even if you
    ### don't have an option anywhere in your configuration file, it
    ### still gets returned as non-None.
    if len(gen_diffs):
        diff_add = False
        diff_copy = False
        diff_delete = False
        diff_modify = False
        list = string.split(gen_diffs, " ")
        for item in list:
            if item == 'add':
                diff_add = True
            if item == 'copy':
                diff_copy = True
            if item == 'delete':
                diff_delete = True
            if item == 'modify':
                diff_modify = True
    else:
        diff_add = True
        diff_copy = True
        diff_delete = True
        diff_modify = True
        ### These options are deprecated
        suppress = cfg.get('suppress_deletes', group, params)
        if suppress == 'yes':
            diff_delete = False
        suppress = cfg.get('suppress_adds', group, params)
        if suppress == 'yes':
            diff_add = False

    if not change.path:
        ### params is a bit silly here
        if diff_delete == False:
            # a record of the deletion is in the summary. no need to write
            # anything further here.
            return

        output.write('\nDeleted: %s\n' % change.base_path)
        diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                               change.base_path, None, None, pool)

        label1 = '%s\t%s' % (change.base_path, date)
        label2 = '(empty file)'
        singular = True
    elif change.added:
        if change.base_path and (change.base_rev != -1):
            # this file was copied.

            if not change.text_changed:
                # copies with no changes are reported in the header, so we can just
                # skip them here.
                return

            if diff_copy == False:
                # a record of the copy is in the summary, no need to write
                # anything further here.
                return

            # note that we strip the leading slash from the base (copyfrom) path
            output.write('\nCopied: %s (from r%d, %s)\n' %
                         (change.path, change.base_rev, change.base_path[1:]))
            diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                                   change.base_path[1:], repos.root_this,
                                   change.path, pool)
            label1 = change.base_path[1:] + '\t(original)'
            label2 = '%s\t%s' % (change.path, date)
            singular = False
        else:
            if diff_add == False:
                # a record of the addition is in the summary. no need to write
                # anything further here.
                return

            output.write('\nAdded: %s\n' % change.path)
            diff = svn.fs.FileDiff(None, None, repos.root_this, change.path,
                                   pool)
            label1 = '(empty file)'
            label2 = '%s\t%s' % (change.path, date)
            singular = True
    elif not change.text_changed:
        # don't bother to show an empty diff. prolly just a prop change.
        return
    else:
        if diff_modify == False:
            # a record of the modification is in the summary, no need to write
            # anything further here.
            return

        output.write('\nModified: %s\n' % change.path)
        diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                               change.base_path[1:], repos.root_this,
                               change.path, pool)
        label1 = change.base_path[1:] + '\t(original)'
        label2 = '%s\t%s' % (change.path, date)
        singular = False

    output.write(SEPARATOR + '\n')

    if diff.either_binary():
        if singular:
            output.write('Binary file. No diff available.\n')
        else:
            output.write('Binary files. No diff available.\n')
        return

    ### do something with change.prop_changes

    src_fname, dst_fname = diff.get_files()

    output.run(
        cfg.get_diff_cmd({
            'label_from': label1,
            'label_to': label2,
            'from': src_fname,
            'to': dst_fname,
        }))
def generate_diff(output, cfg, repos, date, change, group, params, pool):
  if change.item_kind == svn.core.svn_node_dir:
    # all changes were printed in the summary. nothing to do.
    return

  gen_diffs = cfg.get('generate_diffs', group, params)

  ### Do a little dance for deprecated options.  Note that even if you
  ### don't have an option anywhere in your configuration file, it
  ### still gets returned as non-None.
  if len(gen_diffs):
    diff_add = False
    diff_copy = False
    diff_delete = False
    diff_modify = False
    list = string.split(gen_diffs, " ")
    for item in list:
      if item == 'add':
        diff_add = True
      if item == 'copy':
        diff_copy = True
      if item == 'delete':
        diff_delete = True
      if item == 'modify':
        diff_modify = True
  else:
    diff_add = True
    diff_copy = True
    diff_delete = True
    diff_modify = True
    ### These options are deprecated
    suppress = cfg.get('suppress_deletes', group, params)
    if suppress == 'yes':
      diff_delete = False
    suppress = cfg.get('suppress_adds', group, params)
    if suppress == 'yes':
      diff_add = False

  if not change.path:
    ### params is a bit silly here
    if diff_delete == False:
      # a record of the deletion is in the summary. no need to write
      # anything further here.
      return

    output.write('\nDeleted: %s\n' % change.base_path)
    diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                           change.base_path, None, None, pool)

    label1 = '%s\t%s' % (change.base_path, date)
    label2 = '(empty file)'
    singular = True
  elif change.added:
    if change.base_path and (change.base_rev != -1):
      # this file was copied.

      if not change.text_changed:
        # copies with no changes are reported in the header, so we can just
        # skip them here.
        return

      if diff_copy == False:
        # a record of the copy is in the summary, no need to write
        # anything further here.
	return

      # note that we strip the leading slash from the base (copyfrom) path
      output.write('\nCopied: %s (from r%d, %s)\n'
                   % (change.path, change.base_rev, change.base_path[1:]))
      diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                             change.base_path[1:],
                             repos.root_this, change.path,
                             pool)
      label1 = change.base_path[1:] + '\t(original)'
      label2 = '%s\t%s' % (change.path, date)
      singular = False
    else:
      if diff_add == False:
        # a record of the addition is in the summary. no need to write
        # anything further here.
        return

      output.write('\nAdded: %s\n' % change.path)
      diff = svn.fs.FileDiff(None, None, repos.root_this, change.path, pool)
      label1 = '(empty file)'
      label2 = '%s\t%s' % (change.path, date)
      singular = True
  elif not change.text_changed:
    # don't bother to show an empty diff. prolly just a prop change.
    return
  else:
    if diff_modify == False:
      # a record of the modification is in the summary, no need to write
      # anything further here.
      return

    output.write('\nModified: %s\n' % change.path)
    diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                           change.base_path[1:],
                           repos.root_this, change.path,
                           pool)
    label1 = change.base_path[1:] + '\t(original)'
    label2 = '%s\t%s' % (change.path, date)
    singular = False

  output.write(SEPARATOR + '\n')

  if diff.either_binary():
    if singular:
      output.write('Binary file. No diff available.\n')
    else:
      output.write('Binary files. No diff available.\n')
    return

  ### do something with change.prop_changes

  src_fname, dst_fname = diff.get_files()

  output.run(cfg.get_diff_cmd({
    'label_from' : label1,
    'label_to' : label2,
    'from' : src_fname,
    'to' : dst_fname,
    }))
示例#3
0
def generate_diff(output, cfg, repos, date, change, group, params, pool):
    if change.item_kind == svn.core.svn_node_dir:
        # all changes were printed in the summary. nothing to do.
        return

    gen_diffs = cfg.get('generate_diffs', group, params)
    viewcvs_base_url = cfg.get('viewcvs_base_url', group, params)

    ### Do a little dance for deprecated options.  Note that even if you
    ### don't have an option anywhere in your configuration file, it
    ### still gets returned as non-None.
    if len(gen_diffs):
        diff_add = False
        diff_copy = False
        diff_delete = False
        diff_modify = False
        list = string.split(gen_diffs, " ")
        for item in list:
            if item == 'add':
                diff_add = True
            if item == 'copy':
                diff_copy = True
            if item == 'delete':
                diff_delete = True
            if item == 'modify':
                diff_modify = True
    else:
        diff_add = True
        diff_copy = True
        diff_delete = True
        diff_modify = True
        ### These options are deprecated
        suppress = cfg.get('suppress_deletes', group, params)
        if suppress == 'yes':
            diff_delete = False
        suppress = cfg.get('suppress_adds', group, params)
        if suppress == 'yes':
            diff_add = False

    # Figure out if we're supposed to show ViewCVS URLs
    if len(viewcvs_base_url):
        show_urls = True
    else:
        show_urls = False

    diff = None
    diff_url = None
    header = None

    if not change.path:
        ### params is a bit silly here

        header = 'Deleted: %s' % change.base_path
        if show_urls:
            diff_url = '%s/%s?view=auto&rev=%d' \
                       % (viewcvs_base_url,
                          urllib.quote(change.base_path[1:]), change.base_rev)
        if diff_delete:
            diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                                   change.base_path, None, None, pool)
            label1 = '%s\t%s' % (change.base_path, date)
            label2 = '(empty file)'
            singular = True

    elif change.added:
        if change.base_path and (change.base_rev !=
                                 -1):  # this file was copied.
            # note that we strip the leading slash from the base (copyfrom) path
            header = 'Copied: %s (from r%d, %s)' \
                     % (change.path, change.base_rev, change.base_path[1:])
            if show_urls:
                diff_url = '%s/%s?view=diff&rev=%d&p1=%s&r1=%d&p2=%s&r2=%d' \
                           % (viewcvs_base_url,
                              urllib.quote(change.path), repos.rev,
                              urllib.quote(change.base_path[1:]), change.base_rev,
                              urllib.quote(change.path), repos.rev)
            if change.text_changed and diff_copy:
                diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                                       change.base_path[1:], repos.root_this,
                                       change.path, pool)
                label1 = change.base_path[1:] + '\t(original)'
                label2 = '%s\t%s' % (change.path, date)
                singular = False
        else:
            header = 'Added: %s' % change.path
            if show_urls:
                diff_url = '%s/%s?view=auto&rev=%d' \
                           % (viewcvs_base_url,
                              urllib.quote(change.path), repos.rev)
            if diff_add:
                diff = svn.fs.FileDiff(None, None, repos.root_this,
                                       change.path, pool)
                label1 = '(empty file)'
                label2 = '%s\t%s' % (change.path, date)
                singular = True
    elif not change.text_changed:
        # don't bother to show an empty diff. prolly just a prop change.
        return
    else:
        header = 'Modified: %s' % change.path
        if show_urls:
            diff_url = '%s/%s?view=diff&rev=%d&p1=%s&r1=%d&p2=%s&r2=%d' \
                       % (viewcvs_base_url,
                          urllib.quote(change.path), repos.rev,
                          urllib.quote(change.base_path[1:]), change.base_rev,
                          urllib.quote(change.path), repos.rev)
        if diff_modify:
            diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                                   change.base_path[1:], repos.root_this,
                                   change.path, pool)
            label1 = change.base_path[1:] + '\t(original)'
            label2 = '%s\t%s' % (change.path, date)
            singular = False

    if not (show_urls or diff):
        return

    output.write('\n' + header + '\n')
    if diff_url:
        output.write('Url: ' + diff_url + '\n')
    output.write(SEPARATOR + '\n')
    if not diff:
        return

    if diff.either_binary():
        if singular:
            output.write('Binary file. No diff available.\n')
        else:
            output.write('Binary files. No diff available.\n')
        return

    ### do something with change.prop_changes

    src_fname, dst_fname = diff.get_files()

    output.run(
        cfg.get_diff_cmd({
            'label_from': label1,
            'label_to': label2,
            'from': src_fname,
            'to': dst_fname,
        }))
def generate_diff(output, cfg, repos, date, change, group, params, pool):
  if change.item_kind == svn.core.svn_node_dir:
    # all changes were printed in the summary. nothing to do.
    return

  gen_diffs = cfg.get('generate_diffs', group, params)
  viewcvs_base_url = cfg.get('viewcvs_base_url', group, params)

  ### Do a little dance for deprecated options.  Note that even if you
  ### don't have an option anywhere in your configuration file, it
  ### still gets returned as non-None.
  if len(gen_diffs):
    diff_add = False
    diff_copy = False
    diff_delete = False
    diff_modify = False
    list = string.split(gen_diffs, " ")
    for item in list:
      if item == 'add':
        diff_add = True
      if item == 'copy':
        diff_copy = True
      if item == 'delete':
        diff_delete = True
      if item == 'modify':
        diff_modify = True
  else:
    diff_add = True
    diff_copy = True
    diff_delete = True
    diff_modify = True
    ### These options are deprecated
    suppress = cfg.get('suppress_deletes', group, params)
    if suppress == 'yes':
      diff_delete = False
    suppress = cfg.get('suppress_adds', group, params)
    if suppress == 'yes':
      diff_add = False

  # Figure out if we're supposed to show ViewCVS URLs
  if len(viewcvs_base_url):
    show_urls = True
  else:
    show_urls = False
    
  diff = None
  diff_url = None
  header = None
  
  if not change.path:
    ### params is a bit silly here

    header = 'Deleted: %s' % change.base_path
    if show_urls:
      diff_url = '%s/%s?view=auto&rev=%d' \
                 % (viewcvs_base_url,
                    urllib.quote(change.base_path[1:]), change.base_rev)
    if diff_delete:
      diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                             change.base_path, None, None, pool)
      label1 = '%s\t%s' % (change.base_path, date)
      label2 = '(empty file)'
      singular = True

  elif change.added:
    if change.base_path and (change.base_rev != -1): # this file was copied.
      # note that we strip the leading slash from the base (copyfrom) path
      header = 'Copied: %s (from r%d, %s)' \
               % (change.path, change.base_rev, change.base_path[1:])
      if show_urls:
        diff_url = '%s/%s?view=diff&rev=%d&p1=%s&r1=%d&p2=%s&r2=%d' \
                   % (viewcvs_base_url,
                      urllib.quote(change.path), repos.rev,
                      urllib.quote(change.base_path[1:]), change.base_rev,
                      urllib.quote(change.path), repos.rev)
      if change.text_changed and diff_copy:
        diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                               change.base_path[1:],
                               repos.root_this, change.path,
                               pool)
        label1 = change.base_path[1:] + '\t(original)'
        label2 = '%s\t%s' % (change.path, date)
        singular = False
    else:
      header = 'Added: %s' % change.path
      if show_urls:
        diff_url = '%s/%s?view=auto&rev=%d' \
                   % (viewcvs_base_url,
                      urllib.quote(change.path), repos.rev)
      if diff_add:
        diff = svn.fs.FileDiff(None, None, repos.root_this, change.path, pool)
        label1 = '(empty file)'
        label2 = '%s\t%s' % (change.path, date)
        singular = True
  elif not change.text_changed:
    # don't bother to show an empty diff. prolly just a prop change.
    return
  else:
    header = 'Modified: %s' % change.path
    if show_urls:
      diff_url = '%s/%s?view=diff&rev=%d&p1=%s&r1=%d&p2=%s&r2=%d' \
                 % (viewcvs_base_url,
                    urllib.quote(change.path), repos.rev,
                    urllib.quote(change.base_path[1:]), change.base_rev,
                    urllib.quote(change.path), repos.rev)
    if diff_modify:
      diff = svn.fs.FileDiff(repos.get_root(change.base_rev),
                             change.base_path[1:],
                             repos.root_this, change.path,
                             pool)
      label1 = change.base_path[1:] + '\t(original)'
      label2 = '%s\t%s' % (change.path, date)
      singular = False

  if not (show_urls or diff):
    return
  
  output.write('\n' + header + '\n')
  if diff_url:
    output.write('Url: ' + diff_url + '\n')
  output.write(SEPARATOR + '\n')
  if not diff:
    return
  
  if diff.either_binary():
    if singular:
      output.write('Binary file. No diff available.\n')
    else:
      output.write('Binary files. No diff available.\n')
    return

  ### do something with change.prop_changes

  src_fname, dst_fname = diff.get_files()

  output.run(cfg.get_diff_cmd({
    'label_from' : label1,
    'label_to' : label2,
    'from' : src_fname,
    'to' : dst_fname,
    }))