[Rt-commit] rt branch, 4.2-trunk, updated. rt-4.2.12-155-g564b9de

Jim Brandt jbrandt at bestpractical.com
Tue Jun 28 16:01:53 EDT 2016


The branch, 4.2-trunk has been updated
       via  564b9de7f3d9610fcdb3d0a46e63044623bc05d7 (commit)
       via  8e6309999c44313baafc0472e6cc6889976d5412 (commit)
       via  ac152958c6475fdbb067a031e13fe7efeec37bad (commit)
       via  5d01baa9207ac93e02a7078c5da777f3d7805389 (commit)
       via  fce4f0831afd4ea8c7f82bfed105db876407675e (commit)
       via  0a408adb24ada26229bea91f6b08a13258e0d2dc (commit)
       via  7d6f9d6b408efa4c767fecf3418c04e267db0acf (commit)
       via  1e9287ae1dd235b9426524c00cebe7898251db46 (commit)
       via  037839bc7e05a3fcaa9bd9bf9e8efb0d06f9549b (commit)
       via  aea531f3f5383a53b3ef8114b501b75c7fa7e84e (commit)
       via  a8b281e18e04197f2ac7206129d7fba26e44ae8a (commit)
       via  a8bf0f391208c8429feb66fad34dcd71f16d47a5 (commit)
       via  1cac7d3a64b1b3513610069f7b3895e359585475 (commit)
       via  3b8ae5b6697ffd26734c9db46b30002af9460193 (commit)
       via  50dea853e373a5c3d3fafe3f201d8b726fda1099 (commit)
      from  5cb918e1eefe00f76cc3cddc45955e07aad77dfd (commit)

Summary of changes:
 lib/RT/Attribute.pm             | 270 +++++++++++++++++++++++++++++++++++++++-
 lib/RT/Group.pm                 |   5 +-
 lib/RT/Migrate/Importer.pm      |  25 ++--
 lib/RT/Migrate/Importer/File.pm |   2 +-
 lib/RT/ObjectClass.pm           |  12 ++
 lib/RT/ObjectScrip.pm           |  13 ++
 lib/RT/ObjectTopic.pm           |  13 ++
 lib/RT/Transaction.pm           |   3 +
 sbin/rt-importer.in             |  26 +++-
 9 files changed, 352 insertions(+), 17 deletions(-)

- Log -----------------------------------------------------------------
commit ac152958c6475fdbb067a031e13fe7efeec37bad
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Mar 25 01:29:47 2016 +0000

    --exclude-organization option for rt-importer
    
        When records are already known to be unique this is unwanted noise.
    
    Fixes: I#31813
    Fixes: I#31812

diff --git a/lib/RT/Migrate/Importer.pm b/lib/RT/Migrate/Importer.pm
index 0e6456a..5c25d9a 100644
--- a/lib/RT/Migrate/Importer.pm
+++ b/lib/RT/Migrate/Importer.pm
@@ -65,17 +65,20 @@ sub new {
 sub Init {
     my $self = shift;
     my %args = (
-        OriginalId  => undef,
-        Progress    => undef,
-        Statefile   => undef,
-        DumpObjects => undef,
-        HandleError => undef,
+        OriginalId          => undef,
+        Progress            => undef,
+        Statefile           => undef,
+        DumpObjects         => undef,
+        HandleError         => undef,
+        ExcludeOrganization => undef,
         @_,
     );
 
     # Should we attempt to preserve record IDs as they are created?
     $self->{OriginalId} = $args{OriginalId};
 
+    $self->{ExcludeOrganization} = $args{ExcludeOrganization};
+
     $self->{Progress} = $args{Progress};
 
     $self->{HandleError} = sub { 0 };
@@ -294,6 +297,7 @@ sub Qualify {
     my ($string) = @_;
     return $string if $self->{Clone};
     return $string if not defined $self->{Organization};
+    return $string if $self->{ExcludeOrganization};
     return $string if $self->{Organization} eq $RT::Organization;
     return $self->{Organization}.": $string";
 }
@@ -402,9 +406,13 @@ sub ReadStream {
     # If it's a ticket, we might need to create a
     # TicketCustomField for the previous ID
     if ($class eq "RT::Ticket" and $self->{OriginalId}) {
+        my $value = $self->{ExcludeOrganization}
+                  ? $origid
+                  : $self->Organization . ":$origid";
+
         my ($id, $msg) = $obj->AddCustomFieldValue(
             Field             => $self->{OriginalId},
-            Value             => $self->Organization . ":$origid",
+            Value             => $value,
             RecordTransaction => 0,
         );
         warn "Failed to add custom field to $uid: $msg"
diff --git a/lib/RT/Migrate/Importer/File.pm b/lib/RT/Migrate/Importer/File.pm
index cfad9ae..3d36f3d 100644
--- a/lib/RT/Migrate/Importer/File.pm
+++ b/lib/RT/Migrate/Importer/File.pm
@@ -192,7 +192,7 @@ sub SaveState {
            NewQueues NewCFs
            SkipTransactions Pending Invalid
            UIDs
-           OriginalId Clone
+           OriginalId ExcludeOrganization Clone
           /;
     Storable::nstore(\%data, $self->{Statefile});
 
diff --git a/sbin/rt-importer.in b/sbin/rt-importer.in
index 6d3cda5..387128e 100644
--- a/sbin/rt-importer.in
+++ b/sbin/rt-importer.in
@@ -95,6 +95,7 @@ GetOptions(
 
     "resume!",
     "originalid|i=s",
+    "exclude-organization",
 
     "ask",
     "ignore-errors",
@@ -142,11 +143,12 @@ elsif ($OPT{'ignore-errors'}) {
 }
 
 my $import = RT::Migrate::Importer::File->new(
-    Directory   => $dir,
-    OriginalId  => $OPT{originalid},
-    DumpObjects => $OPT{dump},
-    Resume      => $OPT{resume},
-    HandleError => $error_handler,
+    Directory           => $dir,
+    OriginalId          => $OPT{originalid},
+    ExcludeOrganization => $OPT{'exclude-organization'},
+    DumpObjects         => $OPT{dump},
+    Resume              => $OPT{resume},
+    HandleError         => $error_handler,
 );
 
 if ($import->Metadata and -t STDOUT and not $OPT{quiet}) {
@@ -222,6 +224,14 @@ current database; this may include users, queues, and tickets.
 It is possible to stop the import process with ^C; it can be later
 resumed by re-running the importer.
 
+Certain records (notably queues and groups) will have their original
+Organization name prepended to them on import. This is primarily to avoid
+duplicate names (for example importing a General queue into an RT that
+already has one would otherwise cause a name collision error). If you are
+confident you won't have any name collisions in queues or groups, you may
+suppress this behavior by passing the B<--exclude-organization> flag to
+C<rt-importer>.
+
 =head2 OPTIONS
 
 =over
@@ -236,6 +246,12 @@ Places the original ticket organization and ID into a global custom
 field with the given name.  If no global ticket custom field with that
 name is found in the current database, it will create one.
 
+=item B<--exclude-organization>
+
+Ordinarily certain records (groups, queues, the B<--originalid> custom field)
+include the organization name of the original RT instance. Use this option to
+suppress that behavior and use the original name directly.
+
 =item B<--ask>
 
 Prompt for action when an error occurs inserting a record into the

commit 8e6309999c44313baafc0472e6cc6889976d5412
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Sun May 1 16:17:14 2016 -0400

    Serialize Transaction OldReference and NewReference using indirection
    
        Otherwise each transaction which records a custom field update would
        point to the wrong ObjectCustomFieldValue records, causing RT to
        display incorrect old and new values in, especially, ticket history.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index d73bf38..907d1d8 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -2041,6 +2041,9 @@ sub Serialize {
         my $cf = RT::CustomField->new( RT->SystemUser );
         $cf->Load( $store{Field} );
         $store{Field} = \($cf->UID);
+
+        $store{OldReference} = \($self->OldReferenceObject->UID) if $self->OldReference;
+        $store{NewReference} = \($self->NewReferenceObject->UID) if $self->NewReference;
     } elsif ($type =~ /^(Take|Untake|Force|Steal|Give)$/) {
         for my $field (qw/OldValue NewValue/) {
             my $user = RT::User->new( RT->SystemUser );

commit 564b9de7f3d9610fcdb3d0a46e63044623bc05d7
Merge: 5cb918e 8e63099
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Jun 28 16:00:45 2016 -0400

    Merge branch '4.2/migrator-fixes' into 4.2-trunk


-----------------------------------------------------------------------


More information about the rt-commit mailing list