mirror of
https://github.com/facebook/sapling.git
synced 2024-12-26 22:47:26 +03:00
bookmarks: reload changelog if unknown node is seen
Summary: This mitigates loading order issues demonstrated by the previous diff. Reviewed By: DurhamG Differential Revision: D21148446 fbshipit-source-id: 40e4861055822b4676f3ac38d0f004b365efe86d
This commit is contained in:
parent
b4ff907c2a
commit
73c5cb89de
@ -96,9 +96,6 @@ class bmstore(dict):
|
||||
try:
|
||||
sha, refspec = line.split(" ", 1)
|
||||
node = tonode(sha)
|
||||
if node in nm:
|
||||
refspec = encoding.tolocal(refspec)
|
||||
setitem(self, refspec, node)
|
||||
except (TypeError, ValueError):
|
||||
# TypeError:
|
||||
# - bin(...)
|
||||
@ -106,6 +103,35 @@ class bmstore(dict):
|
||||
# - node in nm, for non-20-bytes entry
|
||||
# - split(...), for string without ' '
|
||||
repo.ui.warn(_("malformed line in .hg/bookmarks: %r\n") % line)
|
||||
else:
|
||||
if node in nm:
|
||||
refspec = encoding.tolocal(refspec)
|
||||
setitem(self, refspec, node)
|
||||
else:
|
||||
# This might happen if:
|
||||
# - changelog was loaded, bookmarks are not loaded
|
||||
# - bookmarks was changed to point to unknown nodes
|
||||
# - bookmarks are loaded
|
||||
#
|
||||
# Try to mitigate by reloading changelog.
|
||||
repo.invalidate(clearfilecache=True)
|
||||
nm = repo.changelog.nodemap
|
||||
if node in nm:
|
||||
refspec = encoding.tolocal(refspec)
|
||||
setitem(self, refspec, node)
|
||||
repo.ui.log(
|
||||
"features", feature="fix-bookmark-changelog-order"
|
||||
)
|
||||
else:
|
||||
repo.ui.log(
|
||||
"features",
|
||||
feature="fix-bookmark-changelog-order-failed",
|
||||
)
|
||||
repo.ui.warn(
|
||||
_("unknown reference in .hg/bookmarks: %s %s\n")
|
||||
% (refspec, sha)
|
||||
)
|
||||
|
||||
except IOError as inst:
|
||||
if inst.errno != errno.ENOENT:
|
||||
raise
|
||||
|
@ -20,10 +20,8 @@ With metalog it works fine:
|
||||
$ hg log -r A -T '{desc}\n' --config hooks.pre-bookmark-load='hg commit -m A3'
|
||||
A2
|
||||
|
||||
Without metalog it causes errors:
|
||||
Without metalog:
|
||||
|
||||
$ setconfig experimental.metalog=false
|
||||
$ hg log -r A -T '{desc}\n' --config hooks.pre-bookmark-load='hg commit -m A4'
|
||||
abort: unknown revision 'A'!
|
||||
(if A is a remote bookmark or commit, try to 'hg pull' it first)
|
||||
[255]
|
||||
A4
|
||||
|
Loading…
Reference in New Issue
Block a user