user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 04/20] rename reference to git epochs as "partitions"
Date: Sat, 15 Jun 2019 08:47:00 +0000	[thread overview]
Message-ID: <20190615084716.3075-5-e@80x24.org> (raw)
In-Reply-To: <20190615084716.3075-1-e@80x24.org>

Try to remain consistent with our own documentation regarding
v2 git "epochs", first.
---
 lib/PublicInbox/Inbox.pm      | 18 +++++++++---------
 lib/PublicInbox/WWW.pm        | 12 ++++++------
 lib/PublicInbox/WwwListing.pm |  2 +-
 lib/PublicInbox/WwwStream.pm  | 12 ++++++------
 t/view.t                      |  2 +-
 5 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 10f716c..c0eb640 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -125,11 +125,11 @@ sub new {
 	bless $opts, $class;
 }
 
-sub git_part {
-	my ($self, $part) = @_;
+sub git_epoch {
+	my ($self, $epoch) = @_;
 	($self->{version} || 1) == 2 or return;
-	$self->{"$part.git"} ||= eval {
-		my $git_dir = "$self->{mainrepo}/git/$part.git";
+	$self->{"$epoch.git"} ||= eval {
+		my $git_dir = "$self->{mainrepo}/git/$epoch.git";
 		my $g = PublicInbox::Git->new($git_dir);
 		$g->{-httpbackend_limiter} = $self->{-httpbackend_limiter};
 		# no cleanup needed, we never cat-file off this, only clone
@@ -149,13 +149,13 @@ sub git {
 	};
 }
 
-sub max_git_part {
+sub max_git_epoch {
 	my ($self) = @_;
 	my $v = $self->{version};
 	return unless defined($v) && $v == 2;
-	my $part = $self->{-max_git_part};
+	my $cur = $self->{-max_git_epoch};
 	my $changed = git($self)->alternates_changed;
-	if (!defined($part) || $changed) {
+	if (!defined($cur) || $changed) {
 		$self->git->cleanup if $changed;
 		my $gits = "$self->{mainrepo}/git";
 		if (opendir my $dh, $gits) {
@@ -164,12 +164,12 @@ sub max_git_part {
 				$git_dir =~ m!\A([0-9]+)\.git\z! or next;
 				$max = $1 if $1 > $max;
 			}
-			$part = $self->{-max_git_part} = $max if $max >= 0;
+			$cur = $self->{-max_git_epoch} = $max if $max >= 0;
 		} else {
 			warn "opendir $gits failed: $!\n";
 		}
 	}
-	$part;
+	$cur;
 }
 
 sub mm {
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index e468263..9021cb5 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -76,9 +76,9 @@ sub call {
 	if ($method eq 'POST') {
 		if ($path_info =~ m!$INBOX_RE/(?:(?:git/)?([0-9]+)(?:\.git)?/)?
 					(git-upload-pack)\z!x) {
-			my ($part, $path) = ($2, $3);
+			my ($epoch, $path) = ($2, $3);
 			return invalid_inbox($ctx, $1) ||
-				serve_git($ctx, $part, $path);
+				serve_git($ctx, $epoch, $path);
 		} elsif ($path_info =~ m!$INBOX_RE/!o) {
 			return invalid_inbox($ctx, $1) || mbox_results($ctx);
 		}
@@ -100,8 +100,8 @@ sub call {
 		invalid_inbox($ctx, $1) || get_new($ctx);
 	} elsif ($path_info =~ m!$INBOX_RE/(?:(?:git/)?([0-9]+)(?:\.git)?/)?
 				($PublicInbox::GitHTTPBackend::ANY)\z!ox) {
-		my ($part, $path) = ($2, $3);
-		invalid_inbox($ctx, $1) || serve_git($ctx, $part, $path);
+		my ($epoch, $path) = ($2, $3);
+		invalid_inbox($ctx, $1) || serve_git($ctx, $epoch, $path);
 	} elsif ($path_info =~ m!$INBOX_RE/([a-zA-Z0-9_\-]+).mbox\.gz\z!o) {
 		serve_mbox_range($ctx, $1, $2);
 	} elsif ($path_info =~ m!$INBOX_RE/$MID_RE/$END_RE\z!o) {
@@ -437,10 +437,10 @@ sub msg_page {
 }
 
 sub serve_git {
-	my ($ctx, $part, $path) = @_;
+	my ($ctx, $epoch, $path) = @_;
 	my $env = $ctx->{env};
 	my $ibx = $ctx->{-inbox};
-	my $git = defined $part ? $ibx->git_part($part) : $ibx->git;
+	my $git = defined $epoch ? $ibx->git_epoch($epoch) : $ibx->git;
 	$git ? PublicInbox::GitHTTPBackend::serve($env, $git, $path) : r404();
 }
 
diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm
index e2724cc..e052bbf 100644
--- a/lib/PublicInbox/WwwListing.pm
+++ b/lib/PublicInbox/WwwListing.pm
@@ -190,7 +190,7 @@ sub js ($$) {
 
 	my $manifest = { -abs2urlpath => {}, -mtime => 0 };
 	for my $ibx (@$list) {
-		if (defined(my $max = $ibx->max_git_part)) {
+		if (defined(my $max = $ibx->max_git_epoch)) {
 			for my $epoch (0..$max) {
 				manifest_add($manifest, $ibx, $epoch);
 			}
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index f6c5049..082e5ec 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -85,11 +85,11 @@ sub _html_end {
 	my (%seen, @urls);
 	my $http = $ibx->base_url($ctx->{env});
 	chop $http; # no trailing slash for clone
-	my $part = $ibx->max_git_part;
+	my $max = $ibx->max_git_epoch;
 	my $dir = (split(m!/!, $http))[-1];
-	if (defined($part)) { # v2
+	if (defined($max)) { # v2
 		$seen{$http} = 1;
-		for my $i (0..$part) {
+		for my $i (0..$max) {
 			# old parts my be deleted:
 			-d "$ibx->{mainrepo}/git/$i.git" or next;
 			my $url = "$http/$i";
@@ -101,7 +101,7 @@ sub _html_end {
 		push @urls, $http;
 	}
 
-	# FIXME: partitioning in can be different in other repositories,
+	# FIXME: epoch splits can be different in other repositories,
 	# use the "cloneurl" file as-is for now:
 	foreach my $u (@{$ibx->cloneurl}) {
 		next if $seen{$u};
@@ -109,13 +109,13 @@ sub _html_end {
 		push @urls, $u =~ /\Ahttps?:/ ? qq(<a\nhref="$u">$u</a>) : $u;
 	}
 
-	if (defined($part) || scalar(@urls) > 1) {
+	if (defined($max) || scalar(@urls) > 1) {
 		$urls .= "\n" .
 			join("\n", map { "\tgit clone --mirror $_" } @urls);
 	} else {
 		$urls .= " git clone --mirror $urls[0]";
 	}
-	if (defined $part) {
+	if (defined $max) {
 		my $addrs = $ibx->{address};
 		$addrs = join(' ', @$addrs) if ref($addrs) eq 'ARRAY';
 		$urls .=  <<EOF
diff --git a/t/view.t b/t/view.t
index 0782954..d93be6f 100644
--- a/t/view.t
+++ b/t/view.t
@@ -18,7 +18,7 @@ my $ctx = {
 		base_url => sub { 'http://example.com/' },
 		cloneurl => sub {[]},
 		nntp_url => sub {[]},
-		max_git_part => sub { undef },
+		max_git_epoch => sub { undef },
 		description => sub { '' }),
 	www => Plack::Util::inline_object(style => sub { '' }),
 };
-- 
EW


  parent reply	other threads:[~2019-06-15  8:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-15  8:46 [PATCH 00/20] v2: use consistent terminology Eric Wong
2019-06-15  8:46 ` [PATCH 01/20] doc: rename our Xapian "partitions" to "shards" Eric Wong
2019-06-15  8:46 ` [PATCH 02/20] v2writable: update comments regarding xcpdb --reshard Eric Wong
2019-06-15  8:46 ` [PATCH 03/20] admin|xapcmd: user-facing messages say "shard" Eric Wong
2019-06-15  8:47 ` Eric Wong [this message]
2019-06-15  8:47 ` [PATCH 05/20] searchidxpart: start using "shard" in user-visible places Eric Wong
2019-06-15  8:47 ` [PATCH 06/20] v2writable: count_partitions => count_shards Eric Wong
2019-06-15  8:47 ` [PATCH 07/20] v2writable: rename {partitions} field to {shards} Eric Wong
2019-06-15  8:47 ` [PATCH 08/20] tests: change messages to use "shard" instead of partition Eric Wong
2019-06-15  8:47 ` [PATCH 09/20] inboxwritable: s/partitions/shards/ in local var Eric Wong
2019-06-15  8:47 ` [PATCH 10/20] v2: rename SearchIdxPart => SearchIdxShard Eric Wong
2019-06-15  8:47 ` [PATCH 11/20] xapcmd: update comments referencing "partitions" Eric Wong
2019-06-15  8:47 ` [PATCH 12/20] search*: rename {partition} => {shard} Eric Wong
2019-06-15  8:47 ` [PATCH 13/20] v2writable: avoid "part" in internal subs and fields Eric Wong
2019-06-15  8:47 ` [PATCH 14/20] v2writable: rename local vars to match Xapian terminology Eric Wong
2019-06-15  8:47 ` [PATCH 15/20] adminedit: "part" => "shard" for local variables Eric Wong
2019-06-15  8:47 ` [PATCH 16/20] v2writable: use "epoch" consistently when referring to git repos Eric Wong
2019-06-15  8:47 ` [PATCH 17/20] search: use "shard" for local variable Eric Wong
2019-06-15  8:47 ` [PATCH 18/20] xapcmd: favor 'shard' over 'part' in local variables Eric Wong
2019-06-15  8:47 ` [PATCH 19/20] t/xcpdb-reshard: use 'shard' term " Eric Wong
2019-06-15  8:47 ` [PATCH 20/20] comments: replace "partition" with "shard" Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190615084716.3075-5-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).