Why "Updated upstream" block is so small?
diff mbox series

Message ID 1936584831.20190629130545@yandex.ru
State New
Headers show
Series
  • Why "Updated upstream" block is so small?
Related show

Commit Message

Eugen Konkov June 29, 2019, 10:05 a.m. UTC
Hello

I want to apply this patch from stage:

+++ b/lib/App/Schema/Result/Invoice.pm
@@@ -211,33 -204,34 +211,87 @@@ sub new_package 
     }
  
     ## Create radius account
 +   eval{
         my $radius_dbh =  $self->result_source->storage->schema->{ _radius_dbh };
 -   if( !$radius_dbh->FETCH('AutoCommit') ) {
 +       $radius_dbh->begin_work;
 +       my $sth =  $radius_dbh->prepare(
 +           "INSERT INTO radusergroup ( username, groupname, priority ) values (?,'static',1)"
 +       );
 +       $sth->execute( $package->login );
 +
 +       $sth =  $radius_dbh->prepare(
 +           "INSERT INTO radcheck ( username, attribute, op, value ) values ( ?, ?, ?, ? )"
 +       );
 +       # my $package_type =  $package->Invoice->Order->Tariff->type;
 +       my $pass =  $package->password;
 +       ($pass) =  (`smbencrypt $pass` =~ /([^\s]+)$/s);
 +       $sth->execute( $package->login, 'NT-Password', ':=', $pass //'' );
 +       $sth->execute( $package->login, 'NAS-Identifier', '=~', 'ppp' );
 +
 +       $sth =  $radius_dbh->prepare(
 +           "INSERT INTO radreply ( username, attribute, op, value, nasip) values ( ?, 'Framed-IP-Address', '=', ?, ? )"
 +       );
 +       my $ip =  $package->Ips->first;
 +       $sth->execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
 +
         $radius_dbh->commit;
++<<<<<<< Updated upstream
 +       # NOTICE: This is a bit inconsistent
 +       # if whole payment failed we will have radius account without payment
 +   };
++||||||| merged common ancestors
++   }
++   $radius_dbh->begin_work;
++   my $sth =  $radius_dbh->prepare(
++       "INSERT INTO radusergroup ( username, groupname, priority ) values (?,'static',1)"
++   );
++   $sth->execute( $package->login );
++
++   $sth =  $radius_dbh->prepare(
++       "INSERT INTO radcheck ( username, attribute, op, value ) values ( ?, ?, ?, ? )"
++   );
++   # my $package_type =  $package->Invoice->Order->Tariff->type;
++   my $pass =  $package->password;
++   ($pass) =  (`smbencrypt $pass` =~ /([^\s]+)$/s);
++   $sth->execute( $package->login, 'NT-Password', ':=', $pass );
++   $sth->execute( $package->login, 'NAS-Identifier', '=~', 'ppp' );
++
++   $sth =  $radius_dbh->prepare(
++       "INSERT INTO radreply ( username, attribute, op, value, nasip) values ( ?, 'Framed-IP-Address', '=', ?, ? )"
++   );
++   my $ip =  $package->Ips->first;
++   $sth->execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
++
++   $radius_dbh->commit;
++   # NOTICE: This is a bit inconsistent
++   # if whole payment failed we will have radius account without payment
++=======
+    }
+    $radius_dbh->begin_work;
+    my $sth =  $radius_dbh->prepare(
+        "INSERT INTO radusergroup ( username, groupname, priority ) values (?,'static',1)"
+    );
+    $sth->execute( $package->login );
+ 
+    $sth =  $radius_dbh->prepare(
+        "INSERT INTO radcheck ( username, attribute, op, value ) values ( ?, ?, ?, ? )"
+    );
+    # my $package_type =  $package->Invoice->Order->Tariff->type;
+    my $pass =  $package->password;
+    ($pass) =  (`smbencrypt $pass` =~ /([^\s]+)$/s);
+    $sth->execute( $package->login, 'NT-Password', ':=', $pass //'');
+    $sth->execute( $package->login, 'NAS-Identifier', '=~', 'ppp' );
+ 
+    $sth =  $radius_dbh->prepare(
+        "INSERT INTO radreply ( username, attribute, op, value, nasip) values ( ?, 'Framed-IP-Address', '=', ?, ? )"
+    );
+    my $ip =  $package->Ips->first;
+    # $sth->execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
+ 
+    $radius_dbh->commit;
+    # NOTICE: This is a bit inconsistent
+    # if whole payment failed we will have radius account without payment
++>>>>>>> Stashed changes
  
  
     return $package;



Why updated upstream block is so small?

++<<<<<<< Updated upstream
 +       # NOTICE: This is a bit inconsistent
 +       # if whole payment failed we will have radius account without payment
 +   };
++||||||| merged common ancestors

 
I suppose it should start from to line line:

     +       $radius_dbh->begin_work;
     ...
    +    # if whole payment failed we will have radius account without payment

Comments

Eugen Konkov June 29, 2019, 10:23 a.m. UTC | #1
Hello Eugen,

If I do space changes to lines as next:

        ## Create radius account
        eval{
        my $radius_dbh =  $self->result_source->storage->schema->{ _radius_dbh };
        $radius_dbh->begin_work;
        my $sth =  $radius_dbh->prepare(
                "INSERT INTO radusergroup ( username, groupname, priority ) values (?,'static',1)"
        );
        $sth->execute( $package->login );

        $sth =  $radius_dbh->prepare(
                "INSERT INTO radcheck ( username, attribute, op, value ) values ( ?, ?, ?, ? )"
        );
        # my $package_type =  $package->Invoice->Order->Tariff->type;
        my $pass =  $package->password;
        ($pass) =  (`smbencrypt $pass` =~ /([^\s]+)$/s);
        $sth->execute( $package->login, 'NT-Password', ':=', $pass //'' );
        $sth->execute( $package->login, 'NAS-Identifier', '=~', 'ppp' );

        $sth =  $radius_dbh->prepare(
                "INSERT INTO radreply ( username, attribute, op, value, nasip) values ( ?, 'Framed-IP-Address', '=', ?, ? )"
        );
        my $ip =  $package->Ips->first;
        $sth->execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );

        $radius_dbh->commit;
        # NOTICE: This is a bit inconsistent
        # if whole payment failed we will have radius account without payment
        };


and `git stash apply` then I get expected result:

diff --cc lib/App/Schema/Result/Invoice.pm
index 07e1b373,0ce2d698..00000000
--- a/lib/App/Schema/Result/Invoice.pm
+++ b/lib/App/Schema/Result/Invoice.pm
@@@ -223,23 -217,22 +223,29 @@@ sub new_package 
         "INSERT INTO radcheck ( username, attribute, op, value ) values ( ?, ?, ?, ? )"
     );
     # my $package_type =  $package->Invoice->Order->Tariff->type;
     my $pass =  $package->password;
     ($pass) =  (`smbencrypt $pass` =~ /([^\s]+)$/s);
++<<<<<<< Updated upstream
     $sth->execute( $package->login, 'NT-Password', ':=', $pass //'' );
++||||||| merged common ancestors
++   $sth->execute( $package->login, 'NT-Password', ':=', $pass );
++=======
++   $sth->execute( $package->login, 'NT-Password', ':=', $pass //'');
++>>>>>>> Stashed changes
     $sth->execute( $package->login, 'NAS-Identifier', '=~', 'ppp' );
  
     $sth =  $radius_dbh->prepare(
         "INSERT INTO radreply ( username, attribute, op, value, nasip) values ( ?, 'Frame
     );
     my $ip =  $package->Ips->first;
-    $sth->execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
+    # $sth->execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
  
     $radius_dbh->commit;
     # NOTICE: This is a bit inconsistent
     # if whole payment failed we will have radius account without payment
 +   };
  
  
     return $package;
  }


Why before space change I get broken result?



Saturday, June 29, 2019, 1:05:45 PM, you wrote:

> Hello

> I want to apply this patch from stage:

> diff --git a/lib/App/Schema/Result/Invoice.pm
> b/lib/App/Schema/Result/Invoice.pm
> index 0176916f..0ce2d698 100644
> --- a/lib/App/Schema/Result/Invoice.pm
> +++ b/lib/App/Schema/Result/Invoice.pm
> @@ -219,14 +219,14 @@ sub new_package {
>      # my $package_type =  $package->Invoice->Order->Tariff->type;
>      my $pass =  $package->password;
>      ($pass) =  (`smbencrypt $pass` =~ /([^\s]+)$/s);
-    $sth->>execute( $package->login, 'NT-Password', ':=', $pass );
+    $sth->>execute( $package->login, 'NT-Password', ':=', $pass //'');
>      $sth->execute( $package->login, 'NAS-Identifier', '=~', 'ppp' );
>  
>      $sth =  $radius_dbh->prepare(
>          "INSERT INTO radreply ( username, attribute, op, value,
> nasip) values ( ?, 'Framed-IP-Address', '=', ?, ? )"
>      );
>      my $ip =  $package->Ips->first;
-    $sth->>execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
+    # $sth->>execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
>  
>      $radius_dbh->commit;
>      # NOTICE: This is a bit inconsistent


> after applying I get merge conflict:


> diff --cc lib/App/Schema/Result/Invoice.pm
> index e3f55654,0ce2d698..00000000
> --- a/lib/App/Schema/Result/Invoice.pm
> +++ b/lib/App/Schema/Result/Invoice.pm
> @@@ -211,33 -204,34 +211,87 @@@ sub new_package 
>      }
>   
>      ## Create radius account
>  +   eval{
>          my $radius_dbh =  $self->result_source->storage->schema->{ _radius_dbh };
>  -   if( !$radius_dbh->FETCH('AutoCommit') ) {
>  +       $radius_dbh->begin_work;
>  +       my $sth =  $radius_dbh->prepare(
>  +           "INSERT INTO radusergroup ( username, groupname, priority ) values (?,'static',1)"
>  +       );
>  +       $sth->execute( $package->login );
>  +
>  +       $sth =  $radius_dbh->prepare(
>  +           "INSERT INTO radcheck ( username, attribute, op, value ) values ( ?, ?, ?, ? )"
>  +       );
>  +       # my $package_type =  $package->Invoice->Order->Tariff->type;
>  +       my $pass =  $package->password;
>  +       ($pass) =  (`smbencrypt $pass` =~ /([^\s]+)$/s);
>  +       $sth->execute( $package->login, 'NT-Password', ':=', $pass //'' );
>  +       $sth->execute( $package->login, 'NAS-Identifier', '=~', 'ppp' );
>  +
>  +       $sth =  $radius_dbh->prepare(
>  +           "INSERT INTO radreply ( username, attribute, op,
> value, nasip) values ( ?, 'Framed-IP-Address', '=', ?, ? )"
>  +       );
>  +       my $ip =  $package->Ips->first;
>  +       $sth->execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
>  +
>          $radius_dbh->commit;
> ++<<<<<<< Updated upstream
>  +       # NOTICE: This is a bit inconsistent
>  +       # if whole payment failed we will have radius account without payment
>  +   };
> ++||||||| merged common ancestors
> ++   }
++   $radius_dbh->>begin_work;
> ++   my $sth =  $radius_dbh->prepare(
> ++       "INSERT INTO radusergroup ( username, groupname, priority ) values (?,'static',1)"
> ++   );
++   $sth->>execute( $package->login );
> ++
> ++   $sth =  $radius_dbh->prepare(
> ++       "INSERT INTO radcheck ( username, attribute, op, value ) values ( ?, ?, ?, ? )"
> ++   );
> ++   # my $package_type =  $package->Invoice->Order->Tariff->type;
> ++   my $pass =  $package->password;
> ++   ($pass) =  (`smbencrypt $pass` =~ /([^\s]+)$/s);
++   $sth->>execute( $package->login, 'NT-Password', ':=', $pass );
++   $sth->>execute( $package->login, 'NAS-Identifier', '=~', 'ppp' );
> ++
> ++   $sth =  $radius_dbh->prepare(
> ++       "INSERT INTO radreply ( username, attribute, op, value,
> nasip) values ( ?, 'Framed-IP-Address', '=', ?, ? )"
> ++   );
> ++   my $ip =  $package->Ips->first;
++   $sth->>execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
> ++
++   $radius_dbh->>commit;
> ++   # NOTICE: This is a bit inconsistent
> ++   # if whole payment failed we will have radius account without payment
> ++=======
> +    }
+    $radius_dbh->>begin_work;
> +    my $sth =  $radius_dbh->prepare(
> +        "INSERT INTO radusergroup ( username, groupname, priority ) values (?,'static',1)"
> +    );
+    $sth->>execute( $package->login );
> + 
> +    $sth =  $radius_dbh->prepare(
> +        "INSERT INTO radcheck ( username, attribute, op, value ) values ( ?, ?, ?, ? )"
> +    );
> +    # my $package_type =  $package->Invoice->Order->Tariff->type;
> +    my $pass =  $package->password;
> +    ($pass) =  (`smbencrypt $pass` =~ /([^\s]+)$/s);
+    $sth->>execute( $package->login, 'NT-Password', ':=', $pass //'');
+    $sth->>execute( $package->login, 'NAS-Identifier', '=~', 'ppp' );
> + 
> +    $sth =  $radius_dbh->prepare(
> +        "INSERT INTO radreply ( username, attribute, op, value,
> nasip) values ( ?, 'Framed-IP-Address', '=', ?, ? )"
> +    );
> +    my $ip =  $package->Ips->first;
+    # $sth->>execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
> + 
+    $radius_dbh->>commit;
> +    # NOTICE: This is a bit inconsistent
> +    # if whole payment failed we will have radius account without payment
++>>>>>>>> Stashed changes
>   
>   
>      return $package;



> Why updated upstream block is so small?

> ++<<<<<<< Updated upstream
>  +       # NOTICE: This is a bit inconsistent
>  +       # if whole payment failed we will have radius account without payment
>  +   };
> ++||||||| merged common ancestors

>  
> I suppose it should start from to line line:

>      +       $radius_dbh->begin_work;
>      ...
>     +    # if whole payment failed we will have radius account without payment

Patch
diff mbox series

diff --git a/lib/App/Schema/Result/Invoice.pm b/lib/App/Schema/Result/Invoice.pm
index 0176916f..0ce2d698 100644
--- a/lib/App/Schema/Result/Invoice.pm
+++ b/lib/App/Schema/Result/Invoice.pm
@@ -219,14 +219,14 @@  sub new_package {
     # my $package_type =  $package->Invoice->Order->Tariff->type;
     my $pass =  $package->password;
     ($pass) =  (`smbencrypt $pass` =~ /([^\s]+)$/s);
-    $sth->execute( $package->login, 'NT-Password', ':=', $pass );
+    $sth->execute( $package->login, 'NT-Password', ':=', $pass //'');
     $sth->execute( $package->login, 'NAS-Identifier', '=~', 'ppp' );
 
     $sth =  $radius_dbh->prepare(
         "INSERT INTO radreply ( username, attribute, op, value, nasip) values ( ?, 'Framed-IP-Address', '=', ?, ? )"
     );
     my $ip =  $package->Ips->first;
-    $sth->execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
+    # $sth->execute( $package->login, $ip->ip, $ip->Listener->first->nas_ip );
 
     $radius_dbh->commit;
     # NOTICE: This is a bit inconsistent


after applying I get merge conflict:


diff --cc lib/App/Schema/Result/Invoice.pm
index e3f55654,0ce2d698..00000000
--- a/lib/App/Schema/Result/Invoice.pm