Mercurial > hg
comparison hgext/bookmarks.py @ 13048:e298cca2d53a
bookmarks: use UTF-8 storage
This uses tolocal/fromlocal to translate bookmark metadata to UTF-8
for storage. Existing bookmarks in ASCII, UTF-8 or Latin1 will
continue to work, others may need to set HGENCODINGFALLBACK to
transition.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 24 Nov 2010 16:04:33 -0600 |
parents | e41e2b79883d |
children | 3790452d499b |
comparison
equal
deleted
inserted
replaced
13047:6c375e07d673 | 13048:e298cca2d53a |
---|---|
29 ''' | 29 ''' |
30 | 30 |
31 from mercurial.i18n import _ | 31 from mercurial.i18n import _ |
32 from mercurial.node import nullid, nullrev, bin, hex, short | 32 from mercurial.node import nullid, nullrev, bin, hex, short |
33 from mercurial import util, commands, repair, extensions, pushkey, hg, url | 33 from mercurial import util, commands, repair, extensions, pushkey, hg, url |
34 from mercurial import revset | 34 from mercurial import revset, encoding |
35 import os | 35 import os |
36 | 36 |
37 def write(repo): | 37 def write(repo): |
38 '''Write bookmarks | 38 '''Write bookmarks |
39 | 39 |
50 setcurrent(repo, None) | 50 setcurrent(repo, None) |
51 wlock = repo.wlock() | 51 wlock = repo.wlock() |
52 try: | 52 try: |
53 file = repo.opener('bookmarks', 'w', atomictemp=True) | 53 file = repo.opener('bookmarks', 'w', atomictemp=True) |
54 for refspec, node in refs.iteritems(): | 54 for refspec, node in refs.iteritems(): |
55 file.write("%s %s\n" % (hex(node), refspec)) | 55 file.write("%s %s\n" % (hex(node), encoding.fromlocal(refspec))) |
56 file.rename() | 56 file.rename() |
57 | 57 |
58 # touch 00changelog.i so hgweb reloads bookmarks (no lock needed) | 58 # touch 00changelog.i so hgweb reloads bookmarks (no lock needed) |
59 try: | 59 try: |
60 os.utime(repo.sjoin('00changelog.i'), None) | 60 os.utime(repo.sjoin('00changelog.i'), None) |
231 ''' | 231 ''' |
232 try: | 232 try: |
233 bookmarks = {} | 233 bookmarks = {} |
234 for line in self.opener('bookmarks'): | 234 for line in self.opener('bookmarks'): |
235 sha, refspec = line.strip().split(' ', 1) | 235 sha, refspec = line.strip().split(' ', 1) |
236 refspec = encoding.tolocal(refspec) | |
236 bookmarks[refspec] = self.changelog.lookup(sha) | 237 bookmarks[refspec] = self.changelog.lookup(sha) |
237 except: | 238 except: |
238 pass | 239 pass |
239 return bookmarks | 240 return bookmarks |
240 | 241 |