diff --git a/hgext/bookmarks.py b/hgext/bookmarks.py --- a/hgext/bookmarks.py +++ b/hgext/bookmarks.py @@ -44,8 +44,14 @@ def write(repo): can be copied back on rollback. ''' refs = repo._bookmarks - if os.path.exists(repo.join('bookmarks')): - util.copyfile(repo.join('bookmarks'), repo.join('undo.bookmarks')) + + try: + bms = repo.opener('bookmarks').read() + except IOError: + bms = None + if bms is not None: + repo.opener('undo.bookmarks', 'w').write(bms) + if repo._bookmarkcurrent not in refs: setcurrent(repo, None) wlock = repo.wlock()