Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/localrepo.py @ 3773:73860ffbe798
Handle transcoding of tags
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 03 Dec 2006 16:16:33 -0600 |
parents | 9433bdcaa9ae |
children | b1eeaeb936ae |
comparison
equal
deleted
inserted
replaced
3772:29d91e57d055 | 3773:73860ffbe798 |
---|---|
196 raise util.Abort(_('%r cannot be used in a tag name') % c) | 196 raise util.Abort(_('%r cannot be used in a tag name') % c) |
197 | 197 |
198 self.hook('pretag', throw=True, node=hex(node), tag=name, local=local) | 198 self.hook('pretag', throw=True, node=hex(node), tag=name, local=local) |
199 | 199 |
200 if local: | 200 if local: |
201 # local tags are stored in the current charset | |
201 self.opener('localtags', 'a').write('%s %s\n' % (hex(node), name)) | 202 self.opener('localtags', 'a').write('%s %s\n' % (hex(node), name)) |
202 self.hook('tag', node=hex(node), tag=name, local=local) | 203 self.hook('tag', node=hex(node), tag=name, local=local) |
203 return | 204 return |
204 | 205 |
205 for x in self.status()[:5]: | 206 for x in self.status()[:5]: |
206 if '.hgtags' in x: | 207 if '.hgtags' in x: |
207 raise util.Abort(_('working copy of .hgtags is changed ' | 208 raise util.Abort(_('working copy of .hgtags is changed ' |
208 '(please commit .hgtags manually)')) | 209 '(please commit .hgtags manually)')) |
209 | 210 |
210 self.wfile('.hgtags', 'ab').write('%s %s\n' % (hex(node), name)) | 211 # committed tags are stored in UTF-8 |
212 line = '%s %s\n' % (hex(node), util.fromlocal(name)) | |
213 self.wfile('.hgtags', 'ab').write(line) | |
211 if self.dirstate.state('.hgtags') == '?': | 214 if self.dirstate.state('.hgtags') == '?': |
212 self.add(['.hgtags']) | 215 self.add(['.hgtags']) |
213 | 216 |
214 self.commit(['.hgtags'], message, user, date) | 217 self.commit(['.hgtags'], message, user, date) |
215 self.hook('tag', node=hex(node), tag=name, local=local) | 218 self.hook('tag', node=hex(node), tag=name, local=local) |
225 s = l.split(" ", 1) | 228 s = l.split(" ", 1) |
226 if len(s) != 2: | 229 if len(s) != 2: |
227 self.ui.warn(_("%s: cannot parse entry\n") % context) | 230 self.ui.warn(_("%s: cannot parse entry\n") % context) |
228 return | 231 return |
229 node, key = s | 232 node, key = s |
230 key = key.strip() | 233 key = util.tolocal(key.strip()) # stored in UTF-8 |
231 try: | 234 try: |
232 bin_n = bin(node) | 235 bin_n = bin(node) |
233 except TypeError: | 236 except TypeError: |
234 self.ui.warn(_("%s: node '%s' is not well formed\n") % | 237 self.ui.warn(_("%s: node '%s' is not well formed\n") % |
235 (context, node)) | 238 (context, node)) |
254 | 257 |
255 try: | 258 try: |
256 f = self.opener("localtags") | 259 f = self.opener("localtags") |
257 count = 0 | 260 count = 0 |
258 for l in f: | 261 for l in f: |
262 # localtags are stored in the local character set | |
263 # while the internal tag table is stored in UTF-8 | |
264 l = util.fromlocal(l) | |
259 count += 1 | 265 count += 1 |
260 parsetag(l, _("localtags, line %d") % count) | 266 parsetag(l, _("localtags, line %d") % count) |
261 except IOError: | 267 except IOError: |
262 pass | 268 pass |
263 | 269 |