-
Notifications
You must be signed in to change notification settings - Fork 13
/
undo.pl
55 lines (44 loc) · 1.12 KB
/
undo.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl
# Adapter script for Undo.pm module
# exports Undo.pm functionality for command line use.
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Undo;
use Getopt::Long;
my $force = 0;
usage() unless GetOptions("force" => \$force);
usage() unless (scalar(@ARGV) == 4 && $ARGV[0] =~ /^(node|way|relation)$/);
sub usage
{
print <<EOF;
usage: $0 [--force] <node|way|relation> <id> <username|changeset> <changeset>
where
id : OSM id of the object to revert
username, changeset : username (alphanumeric) or changeset (numeric)
of the change to revert
changeset : id of changeset to use for revert action
when --force is given, overrides subsequent changes
EOF
exit;
}
my ($what, $id, $undo_what, $changeset) = @ARGV;
my $undo_user;
my $undo_changeset;
if ($undo_what =~ /^[0-9]+(,[0-9]+)*$/)
{
foreach (split(/,/, $undo_what))
{
$undo_changeset->{$_} = 1;
}
}
else
{
foreach (split(/,/, $undo_what))
{
$undo_user->{$_} = 1;
}
}
exit 1 if (!defined(Undo::undo($what, $id, $undo_user, $undo_changeset, undef, $changeset, $force)));
exit 0