#!/usr/bin/perl -w =head1 NAME savemerge.pl =head1 SYNOPSIS SHOULD CHANGE ------------- *You need to change the path to your perl interpreter *You need to change the path to your p4perl installation *Make sure you have File::Basename and File::Basename modules and the path is correct *Change port number and client name =head1 DESCRIPTION I had a chat with Randall and during one of the training session on how to get the merged result without marking file as marked. It was a very fruitful discussion and got a solution using P4MERGE or p4* API's. As a result Randall wrote this blog and gave the solution using Python API's This is from the extract of blog by Randall DeFauw http://blog.perforce.com/blog/?p=2770 A way to automatically save the merge output files with conflict markers while running p4 resolve. In this scenario, we’re running a big integration, potentially merging hundreds of files at once. We rely on the automatic merge action (p4 resolve -am) where possible, but some of the files have conflicts. When we run into a merge conflict, we need to grab the person who knows that file and can determine how to manually address the conflict. Rather than having that person walk over to our desk, we’d like to send her the file with conflict markers. She can manually edit the file and send it back to us, and we’ll use the edited file to finish the resolve. Here I am trying to port this to perl using P4Perl API's Contact: thanvk@gmail.com =head1 SEE ALSO http://blog.perforce.com/blog/?p=2770 =cut use lib ( '/path/to/your/P4.pm/installation'); use P4; package MyResolver; use File::Basename qw( basename dirname ); use File::Copy qw( copy ); our @ISA = qw( P4::Resolver ); sub Resolve( $ ) { my $self = shift; my $mergeData = shift; my $your_name = $mergeData->YourName(); my $result_path = $mergeData->ResultPath(); my $dst = dirname( $result_path ) ."/". basename( $your_name ) ."\.merge_result"; print"Merge result for $your_name is being copied to $dst\n"; copy( $result_path, $dst ); return "s"; } 1; package main; my $port = "localhost:1666"; my $client_name = "bruno_ws"; my $p4 = P4->new(); $p4->SetPort( "$port" ); $p4->SetClient( "$client_name" ); $p4->Connect(); $resolver = new MyResolver; $p4->RunResolve( $resolver ); $p4->Disconnect();