p4ed #1

  • //
  • guest/
  • richard_geiger/
  • utils/
  • p4ed
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!/usr/local/bin/perl
# -*-Fundamental-*-

## Notice: this script is not presently considered "done" for public
## distribution; if you do find this, and use it, bear that in mind!
##   - rmg 11/5/2002. (I Voted!)
##

use strict;
use Carp;
use File::Basename;

$| = 1;

my $Myname;
($Myname = $0) =~ s%^.*/%%;
$Myname = "${Myname}";
my $Mydir = &dirname($0);
my $Here = `/bin/pwd`; chop $Here;
chdir $Mydir || die; $Mydir = `/bin/pwd`; chop $Mydir; chdir $Here || die;

sub usage
{
  print <<EOF;
$Myname: usage: $Myname <p4-options-command-args> <description>
EOF
  exit 1;
}

my $desc;

if ($desc = $ENV{"P4EDEDIT"})
  {
    if ($#ARGV != 0) { die "P4EDEDIT and \$#ARGV != 0"; }

    my $Oname = $ARGV[0];
    my $Nname = "$Oname.new";

    open(O, $Oname) || die "open O";
    open(N, ">$Nname") || die "open N";

    while (<O>)
      {
        $_ =~ s/<enter description here>/$desc/;
        print N;
      }

    close O;
    close N;

    rename($Nname, $Oname) || die "rename";

    exit 0;
  }

if (! ($ENV{"P4EDEDIT"} = pop @ARGV)) { &usage; }

$ENV{"P4EDITOR"} = "$Mydir/$Myname";

exec "p4", @ARGV;
# Change User Description Committed
#1 2292 Richard Geiger Simple script to allow programmatic submits with one-liner
descriptions. Handy for test scripts, and so forth.