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

Last change on this file since 30254 was 17935, checked in by frederik, 10 years ago

bugfix for "seen" mechanism, and capability to read change files from stdin

File size: 1.6 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     or the minus sign (-) if you want to read a .osc file from stdin
21  current_changeset : is the id of a currently open changeset under
22     which this action will run.
23     If this is given, the changeset will not be closed in order
24     to allow you to run multiple operations on the same changeset.
25     If unset, a new changeset will be created and closed afterwards.
26  comment : the comment to use when closing the changeset (must not
27     be numeric lest it would be interpreted as a changeset id).
28EOF
29    exit;
30}
31
32my ($undo_cs, $current_cs_or_comment) = @ARGV;
33my $do_close = 0;
34
35my $current_cs;
36my $comment; 
37
38if ($undo_cs eq "-")
39{
40    $undo_cs = "";
41    $undo_cs .= $_ while(<>);
42}
43
44# what have we got, changeset or comment?
45if ($current_cs_or_comment =~ /^\d+$/)
46{
47    $current_cs = $current_cs_or_comment;
48}
49else
50{
51    $comment = $current_cs_or_comment;
52    $comment = "reverting changeset $undo_cs" if ($comment eq "");
53    $current_cs = Changeset::create($comment);
54    $do_close = 1;
55}
56
57if (defined($current_cs))
58{
59    if (Revert::revert($undo_cs, $current_cs, $revert_creation)) 
60    {
61        if ($do_close)
62        {
63            $comment = "reverted changeset $undo_cs" if ($comment eq "");
64            Changeset::close($current_cs, $comment);
65        }
66    }
67}
68
Note: See TracBrowser for help on using the repository browser.