Mercurial > hg
comparison hgext/bookmarks.py @ 13103:6e79a3bb8c79 stable
bookmarks: create undo.bookmarks using repo.opener instead of util.copyfile
This more closely matches how the other undo files are created, and we
don't care about settings permissions or times on the file, which can
fail if the user running hg doesn't own the file.
author | Brodie Rao <brodie@bitheap.org> |
---|---|
date | Tue, 07 Dec 2010 20:03:04 +1100 |
parents | 161fe4879bfc |
children | 5dac0d04b838 146bad852ede |
comparison
equal
deleted
inserted
replaced
13102:2956945c3bee | 13103:6e79a3bb8c79 |
---|---|
42 | 42 |
43 We also store a backup of the previous state in undo.bookmarks that | 43 We also store a backup of the previous state in undo.bookmarks that |
44 can be copied back on rollback. | 44 can be copied back on rollback. |
45 ''' | 45 ''' |
46 refs = repo._bookmarks | 46 refs = repo._bookmarks |
47 if os.path.exists(repo.join('bookmarks')): | 47 |
48 util.copyfile(repo.join('bookmarks'), repo.join('undo.bookmarks')) | 48 try: |
49 bms = repo.opener('bookmarks').read() | |
50 except IOError: | |
51 bms = None | |
52 if bms is not None: | |
53 repo.opener('undo.bookmarks', 'w').write(bms) | |
54 | |
49 if repo._bookmarkcurrent not in refs: | 55 if repo._bookmarkcurrent not in refs: |
50 setcurrent(repo, None) | 56 setcurrent(repo, None) |
51 wlock = repo.wlock() | 57 wlock = repo.wlock() |
52 try: | 58 try: |
53 file = repo.opener('bookmarks', 'w', atomictemp=True) | 59 file = repo.opener('bookmarks', 'w', atomictemp=True) |