source: subversion/applications/utils/revert/revert.pl @ 17917

Last change on this file since 17917 was 17430, checked in by frederik, 11 years ago

fix parameter number bug

File size: 1.5 KB
Line 
1#!/usr/bin/perl
2
3# Adapter script for Revert.pm module
4# exports Revert.pm functionality for command line use.
5
6use strict;
7use warnings;
8use Revert;
9use Changeset;
10
11my $revert_creation = 1;
12
13if (scalar(@ARGV) < 1 || scalar(@ARGV) > 2)
14{
15    print <<EOF;
16usage: $0 <changeset_to_undo> [ <current_changeset> | <comment>]
17
18where
19  changeset_to_undo : is the id of the changeset you want to revert
20  current_changeset : is the id of a currently open changeset under
21     which this action will run.
22     If this is given, the changeset will not be closed in order
23     to allow you to run multiple operations on the same changeset.
24     If unset, a new changeset will be created and closed afterwards.
25  comment : the comment to use when closing the changeset (must not
26     be numeric lest it would be interpreted as a changeset id).
27EOF
28    exit;
29}
30
31my ($undo_cs, $current_cs_or_comment) = @ARGV;
32my $do_close = 0;
33
34my $current_cs;
35my $comment; 
36
37# what have we got, changeset or comment?
38if ($current_cs_or_comment =~ /^\d+$/)
39{
40    $current_cs = $current_cs_or_comment;
41}
42else
43{
44    $comment = $current_cs_or_comment;
45    $comment = "reverting changeset $undo_cs" if ($comment eq "");
46    $current_cs = Changeset::create($comment);
47    $do_close = 1;
48}
49
50if (defined($current_cs))
51{
52    if (Revert::revert($undo_cs, $current_cs, $revert_creation)) 
53    {
54        if ($do_close)
55        {
56            $comment = "reverted changeset $undo_cs" if ($comment eq "");
57            Changeset::close($current_cs, $comment);
58        }
59    }
60}
61
Note: See TracBrowser for help on using the repository browser.