GNU logs - #38334, boring messages


Message sent to bug-vc-dwim@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#38334: adding --dry-run option to vc-dwim [patch]
Resent-From: Karl Berry <karl@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-vc-dwim@HIDDEN
Resent-Date: Fri, 22 Nov 2019 22:52:05 +0000
Resent-Message-ID: <handler.38334.B.157446310425724 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 38334
X-GNU-PR-Package: vc-dwim
X-GNU-PR-Keywords: patch
To: 38334 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-vc-dwim@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.157446310425724
          (code B ref -1); Fri, 22 Nov 2019 22:52:05 +0000
Received: (at submit) by debbugs.gnu.org; 22 Nov 2019 22:51:44 +0000
Received: from localhost ([127.0.0.1]:55681 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iYHmB-0006gk-Mo
	for submit <at> debbugs.gnu.org; Fri, 22 Nov 2019 17:51:44 -0500
Received: from lists.gnu.org ([209.51.188.17]:48819)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <karl@HIDDEN>) id 1iYHlu-0006gA-2f
 for submit <at> debbugs.gnu.org; Fri, 22 Nov 2019 17:51:33 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:45905)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <karl@HIDDEN>) id 1iYHlq-0003hu-Q0
 for bug-vc-dwim@HIDDEN; Fri, 22 Nov 2019 17:51:25 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_MED,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <karl@HIDDEN>) id 1iYHlo-00063g-QZ
 for bug-vc-dwim@HIDDEN; Fri, 22 Nov 2019 17:51:22 -0500
Received: from freefriends.org ([96.88.95.60]:56020)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <karl@HIDDEN>)
 id 1iYHlo-00062F-F1
 for bug-vc-dwim@HIDDEN; Fri, 22 Nov 2019 17:51:20 -0500
X-Envelope-From: karl@HIDDEN
X-Envelope-To: <bug-vc-dwim@HIDDEN>
Received: from freefriends.org (freefriends.org [96.88.95.60])
 by freefriends.org (8.14.7/8.14.7) with ESMTP id xAMMpHHQ004484
 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)
 for <bug-vc-dwim@HIDDEN>; Fri, 22 Nov 2019 15:51:17 -0700
Received: (from apache@localhost)
 by freefriends.org (8.14.7/8.14.7/Submit) id xAMMpH9u004483;
 Fri, 22 Nov 2019 15:51:17 -0700
Date: Fri, 22 Nov 2019 15:51:17 -0700
Message-Id: <201911222251.xAMMpH9u004483@HIDDEN>
From: Karl Berry <karl@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 96.88.95.60
X-Spam-Score: -1.4 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

Possible NEWS entry, under "New features":

  vc-dwim accepts a new option: --dry-run (-n)

Several of the changes are just replacing
  <code>
with
  if ($dry_run) {
    print "msg";
 } else {
   <code>
 }
hence they look longer than they actually are.

2019-11-14  Karl Berry  <karl@HIDDEN>

	vc-dwim: New option vc-dwim --dry-run (aka -n).

	* vc-dwim.pl ($dry_run): new variable.
	(GetOptions): set it.
	(run_command): conditionalize system call and INHIBIT_STDOUT.
	(main): conditionalize initialize operations, rename, symlink.
	* doc/vc-dwim.texi (vc-dwim Invocation): document it.

--- doc/vc-dwim.texi	2019-11-13 17:36:14.920575492 -0800
+++ n.texi	2019-11-17 18:23:06.972699737 -0800
@@ -252,4 +252,8 @@
 Perform the commit, too.
 
+@item -n
+@itemx --dry-run
+Print the commands that would be run instead of running them.
+
 @item --diff
 Determine which version control system manages the first
--- vc-dwim.pl	2019-11-17 18:43:44.673256552 -0800
+++ n.pl	2019-11-21 18:14:13.250781876 -0800
@@ -61,4 +61,5 @@
 my $verbose = 0;
 my $debug = 0;
+my $dry_run = 0;
 
 sub usage ($)
@@ -248,5 +249,5 @@
      DIE_UPON_FAILURE => 1,
      INHIBIT_STDERR => 0,
-     INHIBIT_STDOUT => 1,
+     INHIBIT_STDOUT => ! $dry_run, # keep stdout if just printing
     );
 
@@ -292,5 +293,11 @@
 
   my $fail = 1;
-  my $rc = 0xffff & system @cmd;
+  my $rc;
+  if ($dry_run) {
+    print "$ME: would run: @cmd\n";
+    $rc = 0;
+  } else {
+    $rc = 0xffff & system @cmd;
+  }
 
   # Restore stdout.
@@ -734,4 +741,6 @@
      'print-vc-list' =>
        sub { print join (' ', VC::supported_vc_names()), "\n"; exit },
+     n => \$dry_run,
+     'dry-run' => \$dry_run,
      debug => \$debug,
      verbose => \$verbose,
@@ -757,13 +766,21 @@
       do_at ($adm, sub
       {
-        ! (mkdir ('c') || $! == EEXIST)
-          and die "$ME: failed to create $adm/c: $!\n";
-        chdir 'c' or die "$ME: failed to chdir to $adm/c: $!\n";
+        if ($dry_run) {
+          print "$ME: would mkdir 'c' in $adm\n";
+        } else {
+          ! (mkdir ('c') || $! == EEXIST)
+            and die "$ME: failed to create $adm/c: $!\n";
+          chdir 'c' or die "$ME: failed to chdir to $adm/c: $!\n";
+        }
 
         # touch ChangeLog || die
-        open FH, '>>', $cl
-          or die "$ME: failed to open '$cl' for writing: $!\n";
-        close FH
-          or die "$ME: failed to write '$cl': $!\n";
+        if ($dry_run) {
+          print "$ME: would touch $cl in $adm\n";
+        } else {
+          open FH, '>>', $cl
+            or die "$ME: failed to open '$cl' for writing: $!\n";
+          close FH
+            or die "$ME: failed to write '$cl': $!\n";
+        }
 
         # Initialize the git repo, add ChangeLog and commit it.
@@ -775,11 +792,21 @@
 
       # If a ChangeLog file exists in the current directory, rename it
-      # to ChangeLog~, deliberately ignoring any rename failure.
-      rename $cl, "$cl~";
+      # deliberately ignoring any rename failure. (But only report the
+      # rename for dry runs if it does exist.)
+      my $cl_top = "../../$cl";
+      if ($dry_run && -e $cl_top) {
+        print "$ME: would rename($cl_top, $cl_top~)\n";
+      } else {
+        rename $cl_top, "$cl_top~";
+      }
 
       # Create the top-level ChangeLog symlink into $adm/c:
       my $cl_sub = "$adm/c/$cl";
-      symlink $cl_sub, $cl
-        or die "$ME: failed to create symlink, $cl, to $cl_sub: $!\n";
+      if ($dry_run) {
+        print "$ME: would symlink($cl_sub, $cl_top)\n";
+      } else {
+        symlink $cl_sub, $cl_top
+          or die "$ME: failed to create symlink, $cl, to $cl_sub: $!\n";
+      }
 
       exit 0;
@@ -799,5 +826,10 @@
         and verbose_cmd \@cmd;
 
-      exec @cmd;
+      if ($dry_run) {
+        print "$ME: would run: @cmd\n";
+        exit 0;
+      } else {
+        exec @cmd;
+      }
       exit 1;
     }




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Karl Berry <karl@HIDDEN>
Subject: bug#38334: Acknowledgement (adding --dry-run option to vc-dwim
 [patch])
Message-ID: <handler.38334.B.157446310425724.ack <at> debbugs.gnu.org>
References: <201911222251.xAMMpH9u004483@HIDDEN>
X-Gnu-PR-Message: ack 38334
X-Gnu-PR-Package: vc-dwim
X-Gnu-PR-Keywords: patch
Reply-To: 38334 <at> debbugs.gnu.org
Date: Fri, 22 Nov 2019 22:52:05 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-vc-dwim@HIDDEN

If you wish to submit further information on this problem, please
send it to 38334 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
38334: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D38334
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems



Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.