user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 12/11] edit|purge: improve output on rewrites
  @ 2019-06-10 17:56 14%     ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2019-06-10 17:56 UTC (permalink / raw)
  To: meta; +Cc: Konstantin Ryabitsev

Eric Wong <e@80x24.org> wrote:
> I just noticed, the status message triggers a perl uninitialized
> warning with multiple epochs, but it's harmless.   Will fix in a
> bit.

Pushed as 6e507c8cb41b0d48963503a88034348d74506211
------------------8<-------------
Subject: [PATCH] edit|purge: improve output on rewrites

Fill in undef as "(unchanged)" when displaying commits
and prefix the epoch name.
---
 lib/PublicInbox/AdminEdit.pm | 17 +++++++++++++++++
 script/public-inbox-edit     |  9 ++-------
 script/public-inbox-purge    |  7 +------
 t/purge.t                    |  4 ++--
 4 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/lib/PublicInbox/AdminEdit.pm b/lib/PublicInbox/AdminEdit.pm
index b27c831..169feba 100644
--- a/lib/PublicInbox/AdminEdit.pm
+++ b/lib/PublicInbox/AdminEdit.pm
@@ -47,4 +47,21 @@ sub check_editable ($) {
 	}
 }
 
+# takes the output of V2Writable::purge and V2Writable::replace
+# $rewrites = [ array commits keyed by epoch ]
+sub show_rewrites ($$$) {
+	my ($fh, $ibx, $rewrites) = @_;
+	print $fh "$ibx->{mainrepo}:";
+	if (scalar @$rewrites) {
+		my $epoch = -1;
+		my @out = map {;
+			++$epoch;
+			"$epoch.git: ".(defined($_) ? $_ : '(unchanged)')
+		} @$rewrites;
+		print $fh join("\n\t", '', @out), "\n";
+	} else {
+		print $fh " NONE\n";
+	}
+}
+
 1;
diff --git a/script/public-inbox-edit b/script/public-inbox-edit
index ff0351a..7a534cc 100755
--- a/script/public-inbox-edit
+++ b/script/public-inbox-edit
@@ -207,7 +207,7 @@ W: possible message boundary splitting error
 
 		next unless $opt->{verbose};
 		# should we consider this machine-parseable?
-		print "$ibx->{mainrepo}:\n\tNONE\n";
+		PublicInbox::AdminEdit::show_rewrites(\*STDOUT, $ibx, []);
 		next;
 	}
 
@@ -223,11 +223,6 @@ W: possible message boundary splitting error
 		}
 		next unless $opt->{verbose};
 		# should we consider this machine-parseable?
-		print "$ibx->{mainrepo}:";
-		if (scalar @$commits) {
-			print join("\n\t", '', @$commits), "\n";
-		} else {
-			print "\tNONE\n";
-		}
+		PublicInbox::AdminEdit::show_rewrites(\*STDOUT, $ibx, $commits);
 	}
 }
diff --git a/script/public-inbox-purge b/script/public-inbox-purge
index 846557c..0705d17 100755
--- a/script/public-inbox-purge
+++ b/script/public-inbox-purge
@@ -45,12 +45,7 @@ foreach my $ibx (@ibxs) {
 	$v2w->done;
 
 	if ($opt->{verbose}) { # should we consider this machine-parseable?
-		print "$ibx->{mainrepo}:";
-		if (scalar @$commits) {
-			print join("\n\t", '', @$commits), "\n";
-		} else {
-			print " NONE\n";
-		}
+		PublicInbox::AdminEdit::show_rewrites(\*STDOUT, $ibx, $commits);
 	}
 	$n_purged += scalar @$commits;
 }
diff --git a/t/purge.t b/t/purge.t
index c1e0e9a..384f32a 100644
--- a/t/purge.t
+++ b/t/purge.t
@@ -57,7 +57,7 @@ is($? >> 8, 1, 'missed purge exits with 1');
 
 # a successful case:
 ok(IPC::Run::run([$purge, $mainrepo], \$raw, \$out, \$err), 'match OK');
-like($out, qr/^\t[a-f0-9]{40,}/m, 'removed commit noted');
+like($out, qr/\b[a-f0-9]{40,}/m, 'removed commit noted');
 
 # add (old) vger filter to config file
 print $cfg_fh <<EOF or die "print $!";
@@ -85,7 +85,7 @@ $out = $err = '';
 ok(chdir('/'), "chdir / OK for --all test");
 ok(IPC::Run::run([$purge, '--all'], \$pre_scrub, \$out, \$err),
 	'scrub purge OK');
-like($out, qr/^\t[a-f0-9]{40,}/m, 'removed commit noted');
+like($out, qr/\b[a-f0-9]{40,}/m, 'removed commit noted');
 # diag "out: $out"; diag "err: $err";
 
 $out = $err = '';
-- 
EW

^ permalink raw reply related	[relevance 14%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2019-06-09  2:51     [PATCH 00/11] v2: implement message editing Eric Wong (Contractor, The Linux Foundation)
2019-06-10 15:06     ` Konstantin Ryabitsev
2019-06-10 15:40       ` Eric Wong
2019-06-10 17:56 14%     ` [PATCH 12/11] edit|purge: improve output on rewrites Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).