title: Pip install --upgrade results in unexpected version
body: <p>I am trying to install external Python program to virtual environment using <code>Pip</code> version <code>21.0.1</code> on Ubuntu.</p>
  <p>I use command <code>pip install --upgrade hg+https://example.com/app1/@CHANGESET#egg=app1</code>. This seems to work when I install <code>app1</code> to clean virtual environment. But if I try to change version off <code>app1</code> Pip does not install version I expect. I am using the <code>--upgrade</code> flag so I belive it should be possible to change version without uninstalling previous version first.</p>
  <p>I install version <code>1.0</code> of <code>app1</code> using Mercurial tags. Pip reports correct version after installation.</p>
  <pre><code>pip install --upgrade hg+https://example.com/app1/@1.0#egg=app1
  pip freeze
  app1==1.0
  </code></pre>
  <p>Then I try to upgrade to newer changeset.</p>
  <pre><code>pip install --upgrade hg+https://example.com/app1/@CHANGESET#egg=app1
  Collecting app1
    Cloning hg https://example.com/app1/ (to revision CHANGESET) to /tmp/pip-install-4398yh34/app1_...
    Running command hg clone --noupdate -q https://example.com/app1/ /tmp/pip-install-4398yh34/app1_...
    Running command hg update -q CHANGESET
  </code></pre>
  <p>The command completes succesfully but <code>pip freeze</code> still reports version as <code>1.0</code> instead of requested changeset. Checking files in <code>virtualenv/lib/python3.8/site-packages/app1</code> shows that they are of version 1.0 and not from requested changeset.</p>
  <p>Same problem happens if try to upgrade to older changeset.</p>
  <p>If add flag <code>-e</code> to Pip command I am able to change package version without this problem.
  But why <code>--upgrade</code> is no enough and why command completes without errors while results are not what they should be?</p>