Alien-SVN

 view release on metacpan or  search on metacpan

src/subversion/tools/dist/backport.pl  view on Meta::CPAN

  $header = "$branch branch" if $branch;
  warn "No header for [@lines]" unless $header;

  return (
    revisions => [@revisions],
    logsummary => [@logsummary],
    branch => $branch,
    header => $header,
    votes => [@votes],
    entry => [@lines],
  );
}

sub handle_entry {
  my %entry = parse_entry @_;
  my @vetoes = grep { /^  -1:/ } @{$entry{votes}};

  if ($YES) {
    merge %entry unless @vetoes;
  } else {
    print "";
    print "\n>>> The $entry{header}:";
    print join ", ", map { "r$_" } @{$entry{revisions}};
    print "$BRANCHES/$entry{branch}" if $entry{branch};
    print "";
    print for @{$entry{logsummary}};
    print "";
    print for @{$entry{votes}};
    print "";
    print "Vetoes found!" if @vetoes;

    merge %entry if prompt;
  }

  # TODO: merge() changes ./STATUS, which we're reading below, but
  #       on my system the loop in main() doesn't seem to care.

  1;
}

sub main {
  usage, exit 0 if @ARGV;

  open STATUS, "<", $STATUS or (usage, exit 1);

  # Because we use the ':normal' command in Vim...
  die "A vim with the +ex_extra feature is required"
      if `${VIM} --version` !~ /[+]ex_extra/;

  # ### TODO: need to run 'revert' here
  # ### TODO: both here and in merge(), unlink files that previous merges added
  die "Local mods to STATUS file $STATUS" if `$SVN status -q $STATUS`;

  # Skip most of the file
  while (<STATUS>) {
    last if /^Approved changes/;
  }
  while (<STATUS>) {
    last unless /^=+$/;
  }
  $/ = ""; # paragraph mode

  while (<STATUS>) {
    my @lines = split /\n/;

    given ($lines[0]) {
      # Section header
      when (/^[A-Z].*:$/i) {
        print "\n\n=== $lines[0]" unless $YES;
      }
      # Separator after section header
      when (/^=+$/i) {
        break;
      }
      # Backport entry?
      when (/^ \*/) {
        warn "Too many bullets in $lines[0]" and next
          if grep /^ \*/, @lines[1..$#lines];
        handle_entry @lines;
      }
      default {
        warn "Unknown entry '$lines[0]' at $ARGV:$.\n";
      }
    }
  }
}

&main

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 6.719 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )