* [PATCH] mid: mid_compressed => mid_compress
@ 2015-08-25 2:03 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-08-25 2:03 UTC (permalink / raw)
To: meta
Consistently name mid_* functions as verbs.
---
lib/PublicInbox/Feed.pm | 4 ++--
lib/PublicInbox/Hval.pm | 4 ++--
lib/PublicInbox/MID.pm | 4 ++--
lib/PublicInbox/Mbox.pm | 4 ++--
lib/PublicInbox/Search.pm | 14 +++++++-------
lib/PublicInbox/SearchIdx.pm | 16 ++++++++--------
lib/PublicInbox/SearchMsg.pm | 4 ++--
lib/PublicInbox/View.pm | 8 ++++----
t/view.t | 6 +++---
9 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 969fc11..69ce59b 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -9,7 +9,7 @@ use Date::Parse qw(strptime);
use PublicInbox::Hval;
use PublicInbox::GitCatFile;
use PublicInbox::View;
-use PublicInbox::MID qw/mid_clean mid_compressed/;
+use PublicInbox::MID qw/mid_clean mid_compress/;
use constant {
DATEFMT => '%Y-%m-%dT%H:%M:%SZ', # atom standard
MAX_PER_PAGE => 25, # this needs to be tunable
@@ -339,7 +339,7 @@ sub add_topic {
$header_obj = $mime->header_obj;
}
my $mid = $header_obj->header('Message-ID');
- $mid = mid_compressed(mid_clean($mid));
+ $mid = mid_compress(mid_clean($mid));
$u = $enc_utf8->decode($u);
push @$order, [ $mid, $ts, $u, $subj ];
return 1;
diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index d8b31c8..21efe40 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -8,7 +8,7 @@ use warnings;
use fields qw(raw href);
use Encode qw(find_encoding);
use URI::Escape qw(uri_escape_utf8);
-use PublicInbox::MID qw/mid_clean mid_compressed/;
+use PublicInbox::MID qw/mid_clean mid_compress/;
my $enc_ascii = find_encoding('us-ascii');
@@ -27,7 +27,7 @@ sub new {
sub new_msgid {
my ($class, $msgid) = @_;
$msgid = mid_clean($msgid);
- $class->new($msgid, mid_compressed($msgid));
+ $class->new($msgid, mid_compress($msgid));
}
sub new_oneline {
diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm
index 2f0c09f..02ac709 100644
--- a/lib/PublicInbox/MID.pm
+++ b/lib/PublicInbox/MID.pm
@@ -4,7 +4,7 @@ package PublicInbox::MID;
use strict;
use warnings;
use base qw/Exporter/;
-our @EXPORT_OK = qw/mid_clean mid_compressed mid2path/;
+our @EXPORT_OK = qw/mid_clean mid_compress mid2path/;
use Digest::SHA qw/sha1_hex/;
use constant MID_MAX => 40; # SHA-1 hex length
@@ -18,7 +18,7 @@ sub mid_clean {
}
# this is idempotent
-sub mid_compressed {
+sub mid_compress {
my ($mid, $force) = @_;
# XXX dirty hack! FIXME!
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index 719398f..38ea5d8 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -4,7 +4,7 @@
package PublicInbox::Mbox;
use strict;
use warnings;
-use PublicInbox::MID qw/mid_compressed mid2path/;
+use PublicInbox::MID qw/mid_compress mid2path/;
require Email::Simple;
sub thread_mbox {
@@ -68,7 +68,7 @@ sub emit_mbox {
$fh = PublicInbox::MboxGz->new($fh) if $sfx;
require PublicInbox::GitCatFile;
- my $mid = mid_compressed($ctx->{mid});
+ my $mid = mid_compress($ctx->{mid});
my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
my %opts = (offset => 0);
my $nr;
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index d780878..bcc5312 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -7,7 +7,7 @@ use warnings;
use PublicInbox::SearchMsg;
use Search::Xapian qw/:standard/;
use Email::MIME;
-use PublicInbox::MID qw/mid_clean mid_compressed/;
+use PublicInbox::MID qw/mid_clean mid_compress/;
# This is English-only, everything else is non-standard and may be confused as
# a prefix common in patch emails
@@ -19,7 +19,7 @@ use constant {
# SCHEMA_VERSION history
# 0 - initial
# 1 - subject_path is lower-cased
- # 2 - subject_path is mid_compressed in the index, only
+ # 2 - subject_path is mid_compress in the index, only
# 3 - message-ID is compressed if it includes '%' (hack!)
# 4 - change "Re: " normalization, avoid circular Reference ghosts
# 5 - subject_path drops trailing '.'
@@ -31,7 +31,7 @@ use constant {
# setup prefixes
my %bool_pfx_internal = (
type => 'T', # "mail" or "ghost"
- mid => 'Q', # uniQue id (Message-ID or mid_compressed)
+ mid => 'Q', # uniQue id (Message-ID or mid_compress)
);
my %bool_pfx_external = (
@@ -83,7 +83,7 @@ sub query {
sub get_subject_path {
my ($self, $path, $opts) = @_;
- my $query = $self->qp->parse_query("path:".mid_compressed($path), 0);
+ my $query = $self->qp->parse_query("path:".mid_compress($path), 0);
$self->do_enquire($query, $opts);
}
@@ -91,7 +91,7 @@ sub get_subject_path {
sub get_followups {
my ($self, $mid, $opts) = @_;
$mid = mid_clean($mid);
- $mid = mid_compressed($mid);
+ $mid = mid_compress($mid);
my $qp = $self->qp;
my $irt = $qp->parse_query("inreplyto:$mid", 0);
my $ref = $qp->parse_query("references:$mid", 0);
@@ -106,7 +106,7 @@ sub get_thread {
return { total => 0, msgs => [] } unless $smsg;
my $qp = $self->qp;
my $qtid = $qp->parse_query('thread:'.$smsg->thread_id, 0);
- my $qsub = $qp->parse_query('path:'.mid_compressed($smsg->path), 0);
+ my $qsub = $qp->parse_query('path:'.mid_compress($smsg->path), 0);
my $query = Search::Xapian::Query->new(OP_OR, $qtid, $qsub);
$self->do_enquire($query, $opts);
}
@@ -176,7 +176,7 @@ sub date_range_processor {
sub lookup_message {
my ($self, $mid) = @_;
$mid = mid_clean($mid);
- $mid = mid_compressed($mid);
+ $mid = mid_compress($mid);
my $doc_id = $self->find_unique_doc_id('mid', $mid);
my $smsg;
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 05bf346..292419e 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -5,7 +5,7 @@ package PublicInbox::SearchIdx;
use strict;
use warnings;
use base qw(PublicInbox::Search);
-use PublicInbox::MID qw/mid_clean mid_compressed/;
+use PublicInbox::MID qw/mid_clean mid_compress/;
*xpfx = *PublicInbox::Search::xpfx;
use constant {
@@ -42,7 +42,7 @@ sub add_message {
my $doc_id;
my $mid_orig = mid_clean($mime->header('Message-ID'));
- my $mid = mid_compressed($mid_orig);
+ my $mid = mid_compress($mid_orig);
my $was_ghost = 0;
my $ct_msg = $mime->header('Content-Type') || 'text/plain';
@@ -78,7 +78,7 @@ sub add_message {
$doc->add_term(xpfx('subject') . $subj);
my $path = $self->subject_path($subj);
- $doc->add_term(xpfx('path') . mid_compressed($path));
+ $doc->add_term(xpfx('path') . mid_compress($path));
}
my $from = $smsg->from_name;
@@ -153,7 +153,7 @@ sub remove_message {
my $db = $self->{xdb};
my $doc_id;
$mid_orig = mid_clean($mid_orig);
- my $mid = mid_compressed($mid_orig);
+ my $mid = mid_compress($mid_orig);
eval {
$doc_id = $self->find_unique_doc_id('mid', $mid);
@@ -206,13 +206,13 @@ sub link_message {
sub link_message_to_parents {
my ($self, $smsg) = @_;
my $doc = $smsg->{doc};
- my $mid = mid_compressed($smsg->mid);
+ my $mid = mid_compress($smsg->mid);
my $mime = $smsg->mime;
my $refs = $mime->header('References');
my @refs = $refs ? ($refs =~ /<([^>]+)>/g) : ();
my $irt = $mime->header('In-Reply-To');
if ($irt) {
- $irt = mid_compressed(mid_clean($irt));
+ $irt = mid_compress(mid_clean($irt));
# maybe some crazies will try to make a circular reference:
if ($irt eq $mid) {
@@ -226,7 +226,7 @@ sub link_message_to_parents {
my $tid;
if (@refs) {
- my @crefs = map { mid_compressed($_) } @refs;
+ my @crefs = map { mid_compress($_) } @refs;
my %uniq = ($mid => 1);
# prevent circular references via References: here:
@@ -349,7 +349,7 @@ sub _resolve_mid_to_tid {
sub create_ghost {
my ($self, $mid, $tid) = @_;
- $mid = mid_compressed($mid);
+ $mid = mid_compress($mid);
$tid = $self->next_thread_id unless defined $tid;
my $doc = Search::Xapian::Document->new;
diff --git a/lib/PublicInbox/SearchMsg.pm b/lib/PublicInbox/SearchMsg.pm
index 03df7ab..a8f99bd 100644
--- a/lib/PublicInbox/SearchMsg.pm
+++ b/lib/PublicInbox/SearchMsg.pm
@@ -9,7 +9,7 @@ use Email::Address qw//;
use Email::Simple qw//;
use POSIX qw//;
use Date::Parse qw/str2time/;
-use PublicInbox::MID qw/mid_clean mid_compressed/;
+use PublicInbox::MID qw/mid_clean mid_compress/;
use Encode qw/find_encoding/;
my $enc_utf8 = find_encoding('UTF-8');
our $PFX2TERM_RE = undef;
@@ -162,7 +162,7 @@ sub _extract_mid {
my ($self) = @_;
my $mid = $self->mime->header('Message-ID');
- $mid ? mid_compressed(mid_clean($mid)) : $mid;
+ $mid ? mid_compress(mid_clean($mid)) : $mid;
}
sub mime {
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 64a2086..7412ccf 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -9,7 +9,7 @@ use Encode qw/find_encoding/;
use Encode::MIME::Header;
use Email::MIME::ContentType qw/parse_content_type/;
use PublicInbox::Hval;
-use PublicInbox::MID qw/mid_clean mid_compressed mid2path/;
+use PublicInbox::MID qw/mid_clean mid_compress mid2path/;
use Digest::SHA;
require POSIX;
@@ -152,7 +152,7 @@ sub thread_html {
sub emit_thread_html {
my ($cb, $ctx, $foot, $srch) = @_;
- my $mid = mid_compressed($ctx->{mid});
+ my $mid = mid_compress($ctx->{mid});
my $res = $srch->get_thread($mid);
my $msgs = load_results($res);
my $nr = scalar @$msgs;
@@ -440,7 +440,7 @@ sub html_footer {
my $idx = $standalone ? " <a\nhref=\"../\">index</a>" : '';
if ($idx && $srch) {
$irt = $mime->header('In-Reply-To') || '';
- $mid = mid_compressed(mid_clean($mid));
+ $mid = mid_compress(mid_clean($mid));
my $t_anchor = length $irt ? T_ANCHOR : '';
$idx = " <a\nhref=\"../t/$mid.html$t_anchor\">".
"threadlink</a>$idx";
@@ -483,7 +483,7 @@ sub anchor_for {
my ($msgid) = @_;
my $id = $msgid;
if ($id !~ /\A[a-f0-9]{40}\z/) {
- $id = mid_compressed(mid_clean($id), 1);
+ $id = mid_compress(mid_clean($id), 1);
}
'm' . $id;
}
diff --git a/t/view.t b/t/view.t
index fd3c75b..151fa77 100644
--- a/t/view.t
+++ b/t/view.t
@@ -146,10 +146,10 @@ EOF
{ # XXX dirty hack
- use PublicInbox::MID qw/mid_compressed/;
- like(mid_compressed('foo%bar@wtf'), qr/\A[a-f0-9]{40}\z/,
+ use PublicInbox::MID qw/mid_compress/;
+ like(mid_compress('foo%bar@wtf'), qr/\A[a-f0-9]{40}\z/,
"percent always converted to sha1 to workaround buggy httpds");
- is(mid_compressed('foobar@wtf'), 'foobar@wtf',
+ is(mid_compress('foobar@wtf'), 'foobar@wtf',
'regular MID not compressed');
}
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-08-25 2:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-25 2:03 [PATCH] mid: mid_compressed => mid_compress Eric Wong
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).