- # TODO. Invent a better, non-conflicting name.
- rename("$config{srcdir}/$file", "$config{srcdir}/$file.save") or
- error("failed to rename $file to $file.save: $!");
-
- # Roll the repository back to $rcstoken.
-
- # TODO. Can we be sure that no changes are lost? I think that
- # we can, if we make sure that the 'darcs push' below will always
- # succeed.
-
- # We need to revert everything as 'darcs obliterate' might choke
- # otherwise.
- # TODO: 'yes | ...' needed? Doesn't seem so.
- silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") and
- error("'darcs revert' failed");
- # Remove all patches starting at $rcstoken.
- my $child = open(DARCS_OBLITERATE, "|-");
- if (! $child) {
- open(STDOUT, ">/dev/null");
- exec('darcs', "obliterate", "--repodir", $config{srcdir},
- "--match", "hash " . $rcstoken) and
- error("'darcs obliterate' failed");
- }
- while (print DARCS_OBLITERATE "y") {
- ;
- }
- close(DARCS_OBLITERATE);
- # Restore the $rcstoken one.
- silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir},
- "--match", "hash " . $rcstoken, "--all") and
- error("'darcs pull' failed");
-
- # We're back at $rcstoken. Re-install the modified file.
- rename("$config{srcdir}/$file.save", "$config{srcdir}/$file") or
- error("failed to rename $file.save to $file: $!");
+ # TODO. Invent a better, non-conflicting name.
+ rename("$config{srcdir}/$file", "$config{srcdir}/$file.save") or
+ error("failed to rename $file to $file.save: $!");
+
+ # Roll the repository back to $rcstoken.
+
+ # TODO. Can we be sure that no changes are lost? I think that
+ # we can, if we make sure that the 'darcs push' below will always
+ # succeed.
+
+ # We need to revert everything as 'darcs obliterate' might choke
+ # otherwise.
+ # TODO: 'yes | ...' needed? Doesn't seem so.
+ silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") == 0 ||
+ error("'darcs revert' failed");
+ # Remove all patches starting at $rcstoken.
+ my $child = open(DARCS_OBLITERATE, "|-");
+ if (! $child) {
+ open(STDOUT, ">/dev/null");
+ exec('darcs', "obliterate", "--repodir", $config{srcdir},
+ "--match", "hash " . $rcstoken) and
+ error("'darcs obliterate' failed");
+ }
+ 1 while print DARCS_OBLITERATE "y";
+ close(DARCS_OBLITERATE);
+ # Restore the $rcstoken one.
+ silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir},
+ "--match", "hash " . $rcstoken, "--all") == 0 ||
+ error("'darcs pull' failed");
+
+ # We're back at $rcstoken. Re-install the modified file.
+ rename("$config{srcdir}/$file.save", "$config{srcdir}/$file") or
+ error("failed to rename $file.save to $file: $!");