user-1: During the multiple issues with Bitcoin this year with soft and hard forks, and Segwit, I have read as much as I can about how all these changes are "deployed", eg BIP9, BIP91, BIP148, BIP's 141-146.
However I am still not clear about some of the terminology, such as "locking in", "signalling", "activation", "deployment".
I understand Segwit was implemented in v0.13.1 (and above) of Bitcoin Core which was released on 27/10/2016.
So all the Segwit changes have been in the Bitcoin Core software since that date ?
So when "activation" of Segwit occurred - did that mean a flag within the Bitcoin client, say "ACTIVATION_FLAG", became true and then the Segwit functionality thus started to run - because it is contained inside an "if" block :-
if (ACTIVATION_FLAG) {
    do Segwit stuff
}

However Segwit is a complex upgrade to Bitcoin so there must be many places where changes are made to Bitcoin for Segwit - so how many such "if" blocks are there ?
Can someone give me some links to where these "if" blocks are located in the Bitcoin source code?

user2306: 
However Segwit is a complex upgrade to Bitcoin so there must be many places where changes are made to Bitcoin for Segwit - so how many such "if" blocks are there ?

As of writing, there are 23 to 34 places where behavior changes based on whether segwit is active, depending on how you count. (e.g. if you pass a boolean to a function, and that function contains an if, and the function return value is passed to another if, is that 1 or 2 if statements?)
If you have a copy of the repository you can find them with the following commands:

grep -RI "SEGWIT" * | grep THRESHOLD_ACTIVE
grep -RI "fPreSegWit" *
grep -RI "IsWitnessEnabled" *
grep -RI "fWitnessEnabled" *
grep -RI "witnessEnabled" *


-1: <p>During the multiple issues with Bitcoin this year with soft and hard forks, and Segwit, I have read as much as I can about how all these changes are "deployed", eg BIP9, BIP91, BIP148, BIP's 141-146.</p>

<p>However I am still not clear about some of the terminology, such as "locking in", "signalling", "activation", "deployment".</p>

<p>I understand Segwit was implemented in v0.13.1 (and above) of Bitcoin Core which was released on 27/10/2016.</p>

<p>So all the Segwit changes have been in the Bitcoin Core software since that date ?</p>

<p>So when "activation" of Segwit occurred - did that mean a flag within the Bitcoin client, say "<code>ACTIVATION_FLAG</code>", became true and then the Segwit functionality thus started to run - because it is contained inside an "if" block :-</p>

<pre><code>if (ACTIVATION_FLAG) {
    do Segwit stuff
}
</code></pre>

<p>However Segwit is a complex upgrade to Bitcoin so there must be many places where changes are made to Bitcoin for Segwit - so how many such "if" blocks are there ?</p>

<p>Can someone give me some links to where these "if" blocks are located in the Bitcoin source code?</p>
 2306: <blockquote>
  <p>However Segwit is a complex upgrade to Bitcoin so there must be many places where changes are made to Bitcoin for Segwit - so how many such "if" blocks are there ?</p>
</blockquote>

<p>As of writing, there are 23 to 34 places where behavior changes based on whether segwit is active, depending on how you count. (e.g. if you pass a boolean to a function, and that function contains an if, and the function return value is passed to another if, is that 1 or 2 if statements?)</p>

<p>If you have a copy of the repository you can find them with the following commands:</p>

<ol>
<li><code>grep -RI "SEGWIT" * | grep THRESHOLD_ACTIVE</code></li>
<li><code>grep -RI "fPreSegWit" *</code></li>
<li><code>grep -RI "IsWitnessEnabled" *</code></li>
<li><code>grep -RI "fWitnessEnabled" *</code></li>
<li><code>grep -RI "witnessEnabled" *</code></li>
</ol>
