diff --git a/mercurial/tags.py b/mercurial/tags.py --- a/mercurial/tags.py +++ b/mercurial/tags.py @@ -72,6 +72,15 @@ def readlocaltags(ui, repo, alltags, tag filetags = _readtags( ui, repo, data.splitlines(), "localtags", recode=encoding.fromlocal) + + # remove tags pointing to invalid nodes + cl = repo.changelog + for t in filetags.keys(): + try: + cl.rev(filetags[t][0]) + except (LookupError, ValueError): + del filetags[t] + _updatetags(filetags, "local", alltags, tagtypes) def _readtags(ui, repo, lines, fn, recode=None): diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t --- a/tests/test-obsolete.t +++ b/tests/test-obsolete.t @@ -907,3 +907,15 @@ Test that a local tag blocks a changeset date: Thu Jan 01 00:00:00 1970 +0000 summary: A +Test that removing a local tag does not cause some commands to fail + + $ hg tag -l -r tip tiptag + $ hg tags + tiptag 2:3816541e5485 + tip 2:3816541e5485 + visible 0:193e9254ce7e + $ hg --config extensions.strip= strip -r tip --no-backup + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ hg tags + visible 0:193e9254ce7e + tip 0:193e9254ce7e