New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
fcm_graphic_merge in branches/UKMO/dev_r5518_CICE_coupling_GSI7_GSI8/NEMOGCM/EXTERNAL/fcm/bin – NEMO

source: branches/UKMO/dev_r5518_CICE_coupling_GSI7_GSI8/NEMOGCM/EXTERNAL/fcm/bin/fcm_graphic_merge @ 5662

Last change on this file since 5662 was 5662, checked in by dancopsey, 9 years ago

Removed SVN keywords.

File size: 2.0 KB
Line 
1#!/usr/bin/env perl
2#-------------------------------------------------------------------------------
3# (C) Crown copyright Met Office. All rights reserved.
4# For further details please refer to the file COPYRIGHT.txt
5# which you should have received as part of this distribution.
6#-------------------------------------------------------------------------------
7
8use strict;
9use warnings;
10
11my ($base, $mine, $older, $yours) = @ARGV;
12
13# FCM_GRAPHIC_MERGE is the graphical merge tool command
14my $cmd = (exists $ENV{FCM_GRAPHIC_MERGE} ? $ENV{FCM_GRAPHIC_MERGE} : 'xxdiff');
15
16my $rc  = 2;
17my $out = '';
18if ($cmd eq 'xxdiff') {
19  # Launch xxdiff
20  my @command   = ($cmd, qw/-m -M/, $base, qw/-O -X/, $mine, $older, $yours);
21  my ($cmd_out) = qx(@command);
22  my $cmd_rc    = $?;
23
24  # Parse output from xxdiff
25  if ($cmd_out) {
26    chomp $cmd_out;
27    if ($cmd_out eq 'NODECISION') {
28      $out = 'made no decision';
29      $rc  = 1;
30
31    } elsif ($cmd_out eq 'MERGED' and $cmd_rc) {
32      $out = 'not resolved all the conflicts';
33      $rc  = 1;
34
35    } else {
36      $out = lc ($cmd_out);
37      $rc  = 0;
38    }
39
40  } else {
41    print STDERR $cmd, ': failed, abort.', "\n";
42  }
43
44} else {
45  # Throw error for unknown/undefined graphic merge tool
46  print STDERR ($cmd ? $cmd . ': ' : ''),
47               'unknown/undefined graphic merge tool, abort.', "\n";
48}
49
50if ($rc == 1) {
51  # Merge unresolved
52  print 'You have ', $out, '.', "\n";
53
54} elsif ($rc == 0) {
55  # Merge resolved
56  print 'You ', $out, ' all the changes.', "\n";
57}
58
59exit $rc;
60
61__END__
62
63=head1 NAME
64
65fcm_graphic_merge
66
67=head1 SYNOPSIS
68
69    fcm_graphic_merge BASE MINE OLDER YOURS
70
71=head1 DESCRIPTION
72
73Wrapper script which invokes a graphical merge tool. It returns 0 on
74success, 1 if conflicts not resolved or 2 on failure. (This is similar to
75GNU diff3.) BASE is the file you want to save the merge result into. MINE
76is the original file. YOURS is the file you want MINE to merge with. OLDER
77is the common ancestor of MINE and YOURS.
78
79=head1 COPYRIGHT
80
81(C) Crown copyright Met Office. All rights reserved.
82
83=cut
Note: See TracBrowser for help on using the repository browser.