prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  experiments: show table includes all staged/stashed experiments instead of only the currently applicable ones
  ```
  example-get-started git:executor-tree  py:dvc ❯ dvc exp show --no-pager --include-params=featurize
  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
  ┃ Experiment                         ┃     auc ┃ featurize.max_features ┃ featurize.ngrams ┃
  ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩
  │ workspace                          │ 0.54175 │ 500                    │ 5                │
  │ bbdfa81 (2020-08-21 11:27:38)      │ 0.54175 │ 500                    │ 5                │
  │ ├── ebbf40d (2020-08-21 11:28:42)  │ 0.50822 │ 1500                   │ 4                │
  │ └── *32c3875 (2020-08-21 12:05:16) │       - │ 1500                   │ 7                │
  │ ├── *8cb834d (2020-08-21 12:04:59) │       - │ 1500                   │ 2                │
  │ ├── *32d107b (2020-08-21 12:05:01) │       - │ 1500                   │ 5                │
  │ └── *4f2c53c (2020-08-21 12:05:04) │       - │ 1500                   │ 6                │
  └────────────────────────────────────┴─────────┴────────────────────────┴──────────────────┘
  ```
  
  the last 3 stashed experiments are derived from a different baseline commit and should be excluded by default (unless `--all-commit`/etc are used)
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `dvc/repo/experiments/show.py`
  Content:
  ```
  1 import logging
  2 import re
  3 from collections import OrderedDict, defaultdict
  4 from datetime import datetime
  5 
  6 from dvc.repo import locked
  7 from dvc.repo.metrics.show import _collect_metrics, _read_metrics
  8 from dvc.repo.params.show import _collect_configs, _read_params
  9 
  10 logger = logging.getLogger(__name__)
  11 
  12 
  13 EXP_RE = re.compile(r"(?P<rev_sha>[a-f0-9]{7})-(?P<exp_sha>[a-f0-9]+)")
  14 
  15 
  16 def _collect_experiment(repo, branch, stash=False):
  17     res = defaultdict(dict)
  18     for rev in repo.brancher(revs=[branch]):
  19         if rev == "workspace":
  20             res["timestamp"] = None
  21         else:
  22             commit = repo.scm.repo.rev_parse(rev)
  23             res["timestamp"] = datetime.fromtimestamp(commit.committed_date)
  24 
  25         configs = _collect_configs(repo)
  26         params = _read_params(repo, configs, rev)
  27         if params:
  28             res["params"] = params
  29 
  30         res["queued"] = stash
  31         if not stash:
  32             metrics = _collect_metrics(repo, None, False)
  33             vals = _read_metrics(repo, metrics, rev)
  34             res["metrics"] = vals
  35 
  36     return res
  37 
  38 
  39 @locked
  40 def show(
  41     repo, all_branches=False, all_tags=False, revs=None, all_commits=False
  42 ):
  43     res = defaultdict(OrderedDict)
  44 
  45     if revs is None:
  46         revs = [repo.scm.get_rev()]
  47 
  48     revs = OrderedDict(
  49         (rev, None)
  50         for rev in repo.brancher(
  51             revs=revs,
  52             all_branches=all_branches,
  53             all_tags=all_tags,
  54             all_commits=all_commits,
  55         )
  56     )
  57 
  58     for rev in revs:
  59         res[rev]["baseline"] = _collect_experiment(repo, rev)
  60 
  61     # collect reproduced experiments
  62     for exp_branch in repo.experiments.scm.list_branches():
  63         m = re.match(EXP_RE, exp_branch)
  64         if m:
  65             rev = repo.scm.resolve_rev(m.group("rev_sha"))
  66             if rev in revs:
  67                 exp_rev = repo.experiments.scm.resolve_rev(exp_branch)
  68                 with repo.experiments.chdir():
  69                     experiment = _collect_experiment(
  70                         repo.experiments.exp_dvc, exp_branch
  71                     )
  72                 res[rev][exp_rev] = experiment
  73 
  74     # collect queued (not yet reproduced) experiments
  75     for stash_rev, (_, baseline_rev) in repo.experiments.stash_revs.items():
  76         with repo.experiments.chdir():
  77             experiment = _collect_experiment(
  78                 repo.experiments.exp_dvc, stash_rev, stash=True
  79             )
  80         res[baseline_rev][stash_rev] = experiment
  81 
  82     return res
  83
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/dvc/repo/experiments/show.py b/dvc/repo/experiments/show.py
  --- a/dvc/repo/experiments/show.py
  +++ b/dvc/repo/experiments/show.py
  @@ -73,10 +73,11 @@
   
       # collect queued (not yet reproduced) experiments
       for stash_rev, (_, baseline_rev) in repo.experiments.stash_revs.items():
  -        with repo.experiments.chdir():
  -            experiment = _collect_experiment(
  -                repo.experiments.exp_dvc, stash_rev, stash=True
  -            )
  -        res[baseline_rev][stash_rev] = experiment
  +        if baseline_rev in revs:
  +            with repo.experiments.chdir():
  +                experiment = _collect_experiment(
  +                    repo.experiments.exp_dvc, stash_rev, stash=True
  +                )
  +            res[baseline_rev][stash_rev] = experiment
   
       return res
  
verification_info: {"golden_diff": "diff --git a/dvc/repo/experiments/show.py b/dvc/repo/experiments/show.py\n--- a/dvc/repo/experiments/show.py\n+++ b/dvc/repo/experiments/show.py\n@@ -73,10 +73,11 @@\n \n     # collect queued (not yet reproduced) experiments\n     for stash_rev, (_, baseline_rev) in repo.experiments.stash_revs.items():\n-        with repo.experiments.chdir():\n-            experiment = _collect_experiment(\n-                repo.experiments.exp_dvc, stash_rev, stash=True\n-            )\n-        res[baseline_rev][stash_rev] = experiment\n+        if baseline_rev in revs:\n+            with repo.experiments.chdir():\n+                experiment = _collect_experiment(\n+                    repo.experiments.exp_dvc, stash_rev, stash=True\n+                )\n+            res[baseline_rev][stash_rev] = experiment\n \n     return res\n", "issue": "experiments: show table includes all staged/stashed experiments instead of only the currently applicable ones\n```\r\nexample-get-started git:executor-tree  py:dvc \u276f dvc exp show --no-pager --include-params=featurize\r\n\u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\r\n\u2503 Experiment                         \u2503     auc \u2503 featurize.max_features \u2503 featurize.ngrams \u2503\r\n\u2521\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2529\r\n\u2502 workspace                          \u2502 0.54175 \u2502 500                    \u2502 5                \u2502\r\n\u2502 bbdfa81 (2020-08-21 11:27:38)      \u2502 0.54175 \u2502 500                    \u2502 5                \u2502\r\n\u2502 \u251c\u2500\u2500 ebbf40d (2020-08-21 11:28:42)  \u2502 0.50822 \u2502 1500                   \u2502 4                \u2502\r\n\u2502 \u2514\u2500\u2500 *32c3875 (2020-08-21 12:05:16) \u2502       - \u2502 1500                   \u2502 7                \u2502\r\n\u2502 \u251c\u2500\u2500 *8cb834d (2020-08-21 12:04:59) \u2502       - \u2502 1500                   \u2502 2                \u2502\r\n\u2502 \u251c\u2500\u2500 *32d107b (2020-08-21 12:05:01) \u2502       - \u2502 1500                   \u2502 5                \u2502\r\n\u2502 \u2514\u2500\u2500 *4f2c53c (2020-08-21 12:05:04) \u2502       - \u2502 1500                   \u2502 6                \u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n```\r\n\r\nthe last 3 stashed experiments are derived from a different baseline commit and should be excluded by default (unless `--all-commit`/etc are used)\n", "before_files": [{"content": "import logging\nimport re\nfrom collections import OrderedDict, defaultdict\nfrom datetime import datetime\n\nfrom dvc.repo import locked\nfrom dvc.repo.metrics.show import _collect_metrics, _read_metrics\nfrom dvc.repo.params.show import _collect_configs, _read_params\n\nlogger = logging.getLogger(__name__)\n\n\nEXP_RE = re.compile(r\"(?P<rev_sha>[a-f0-9]{7})-(?P<exp_sha>[a-f0-9]+)\")\n\n\ndef _collect_experiment(repo, branch, stash=False):\n    res = defaultdict(dict)\n    for rev in repo.brancher(revs=[branch]):\n        if rev == \"workspace\":\n            res[\"timestamp\"] = None\n        else:\n            commit = repo.scm.repo.rev_parse(rev)\n            res[\"timestamp\"] = datetime.fromtimestamp(commit.committed_date)\n\n        configs = _collect_configs(repo)\n        params = _read_params(repo, configs, rev)\n        if params:\n            res[\"params\"] = params\n\n        res[\"queued\"] = stash\n        if not stash:\n            metrics = _collect_metrics(repo, None, False)\n            vals = _read_metrics(repo, metrics, rev)\n            res[\"metrics\"] = vals\n\n    return res\n\n\n@locked\ndef show(\n    repo, all_branches=False, all_tags=False, revs=None, all_commits=False\n):\n    res = defaultdict(OrderedDict)\n\n    if revs is None:\n        revs = [repo.scm.get_rev()]\n\n    revs = OrderedDict(\n        (rev, None)\n        for rev in repo.brancher(\n            revs=revs,\n            all_branches=all_branches,\n            all_tags=all_tags,\n            all_commits=all_commits,\n        )\n    )\n\n    for rev in revs:\n        res[rev][\"baseline\"] = _collect_experiment(repo, rev)\n\n    # collect reproduced experiments\n    for exp_branch in repo.experiments.scm.list_branches():\n        m = re.match(EXP_RE, exp_branch)\n        if m:\n            rev = repo.scm.resolve_rev(m.group(\"rev_sha\"))\n            if rev in revs:\n                exp_rev = repo.experiments.scm.resolve_rev(exp_branch)\n                with repo.experiments.chdir():\n                    experiment = _collect_experiment(\n                        repo.experiments.exp_dvc, exp_branch\n                    )\n                res[rev][exp_rev] = experiment\n\n    # collect queued (not yet reproduced) experiments\n    for stash_rev, (_, baseline_rev) in repo.experiments.stash_revs.items():\n        with repo.experiments.chdir():\n            experiment = _collect_experiment(\n                repo.experiments.exp_dvc, stash_rev, stash=True\n            )\n        res[baseline_rev][stash_rev] = experiment\n\n    return res\n", "path": "dvc/repo/experiments/show.py"}], "after_files": [{"content": "import logging\nimport re\nfrom collections import OrderedDict, defaultdict\nfrom datetime import datetime\n\nfrom dvc.repo import locked\nfrom dvc.repo.metrics.show import _collect_metrics, _read_metrics\nfrom dvc.repo.params.show import _collect_configs, _read_params\n\nlogger = logging.getLogger(__name__)\n\n\nEXP_RE = re.compile(r\"(?P<rev_sha>[a-f0-9]{7})-(?P<exp_sha>[a-f0-9]+)\")\n\n\ndef _collect_experiment(repo, branch, stash=False):\n    res = defaultdict(dict)\n    for rev in repo.brancher(revs=[branch]):\n        if rev == \"workspace\":\n            res[\"timestamp\"] = None\n        else:\n            commit = repo.scm.repo.rev_parse(rev)\n            res[\"timestamp\"] = datetime.fromtimestamp(commit.committed_date)\n\n        configs = _collect_configs(repo)\n        params = _read_params(repo, configs, rev)\n        if params:\n            res[\"params\"] = params\n\n        res[\"queued\"] = stash\n        if not stash:\n            metrics = _collect_metrics(repo, None, False)\n            vals = _read_metrics(repo, metrics, rev)\n            res[\"metrics\"] = vals\n\n    return res\n\n\n@locked\ndef show(\n    repo, all_branches=False, all_tags=False, revs=None, all_commits=False\n):\n    res = defaultdict(OrderedDict)\n\n    if revs is None:\n        revs = [repo.scm.get_rev()]\n\n    revs = OrderedDict(\n        (rev, None)\n        for rev in repo.brancher(\n            revs=revs,\n            all_branches=all_branches,\n            all_tags=all_tags,\n            all_commits=all_commits,\n        )\n    )\n\n    for rev in revs:\n        res[rev][\"baseline\"] = _collect_experiment(repo, rev)\n\n    # collect reproduced experiments\n    for exp_branch in repo.experiments.scm.list_branches():\n        m = re.match(EXP_RE, exp_branch)\n        if m:\n            rev = repo.scm.resolve_rev(m.group(\"rev_sha\"))\n            if rev in revs:\n                exp_rev = repo.experiments.scm.resolve_rev(exp_branch)\n                with repo.experiments.chdir():\n                    experiment = _collect_experiment(\n                        repo.experiments.exp_dvc, exp_branch\n                    )\n                res[rev][exp_rev] = experiment\n\n    # collect queued (not yet reproduced) experiments\n    for stash_rev, (_, baseline_rev) in repo.experiments.stash_revs.items():\n        if baseline_rev in revs:\n            with repo.experiments.chdir():\n                experiment = _collect_experiment(\n                    repo.experiments.exp_dvc, stash_rev, stash=True\n                )\n            res[baseline_rev][stash_rev] = experiment\n\n    return res\n", "path": "dvc/repo/experiments/show.py"}]}