Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 4118:35b39097c3e6
Break core of repo.tag into dirstate/hook-free repo._tag for convert-repo
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Tue, 27 Feb 2007 12:58:40 -0800 |
parents | 961ccb615cf7 |
children | 9dc64c8414ca |
comparison
equal
deleted
inserted
replaced
4117:eb0967c6e77b | 4118:35b39097c3e6 |
---|---|
215 r = runhook(hname, cmd) or r | 215 r = runhook(hname, cmd) or r |
216 return r | 216 return r |
217 | 217 |
218 tag_disallowed = ':\r\n' | 218 tag_disallowed = ':\r\n' |
219 | 219 |
220 def tag(self, name, node, message, local, user, date): | 220 def _tag(self, name, node, message, local, user, date, parent=None): |
221 '''tag a revision with a symbolic name. | 221 use_dirstate = parent is None |
222 | |
223 if local is True, the tag is stored in a per-repository file. | |
224 otherwise, it is stored in the .hgtags file, and a new | |
225 changeset is committed with the change. | |
226 | |
227 keyword arguments: | |
228 | |
229 local: whether to store tag in non-version-controlled file | |
230 (default False) | |
231 | |
232 message: commit message to use if committing | |
233 | |
234 user: name of user to use if committing | |
235 | |
236 date: date tuple to use if committing''' | |
237 | 222 |
238 for c in self.tag_disallowed: | 223 for c in self.tag_disallowed: |
239 if c in name: | 224 if c in name: |
240 raise util.Abort(_('%r cannot be used in a tag name') % c) | 225 raise util.Abort(_('%r cannot be used in a tag name') % c) |
241 | 226 |
245 # local tags are stored in the current charset | 230 # local tags are stored in the current charset |
246 self.opener('localtags', 'a').write('%s %s\n' % (hex(node), name)) | 231 self.opener('localtags', 'a').write('%s %s\n' % (hex(node), name)) |
247 self.hook('tag', node=hex(node), tag=name, local=local) | 232 self.hook('tag', node=hex(node), tag=name, local=local) |
248 return | 233 return |
249 | 234 |
235 # committed tags are stored in UTF-8 | |
236 line = '%s %s\n' % (hex(node), util.fromlocal(name)) | |
237 if use_dirstate: | |
238 self.wfile('.hgtags', 'ab').write(line) | |
239 else: | |
240 ntags = self.filectx('.hgtags', parent).data() | |
241 self.wfile('.hgtags', 'ab').write(ntags + line) | |
242 if use_dirstate and self.dirstate.state('.hgtags') == '?': | |
243 self.add(['.hgtags']) | |
244 | |
245 tagnode = self.commit(['.hgtags'], message, user, date, p1=parent) | |
246 | |
247 self.hook('tag', node=hex(node), tag=name, local=local) | |
248 | |
249 return tagnode | |
250 | |
251 def tag(self, name, node, message, local, user, date): | |
252 '''tag a revision with a symbolic name. | |
253 | |
254 if local is True, the tag is stored in a per-repository file. | |
255 otherwise, it is stored in the .hgtags file, and a new | |
256 changeset is committed with the change. | |
257 | |
258 keyword arguments: | |
259 | |
260 local: whether to store tag in non-version-controlled file | |
261 (default False) | |
262 | |
263 message: commit message to use if committing | |
264 | |
265 user: name of user to use if committing | |
266 | |
267 date: date tuple to use if committing''' | |
268 | |
250 for x in self.status()[:5]: | 269 for x in self.status()[:5]: |
251 if '.hgtags' in x: | 270 if '.hgtags' in x: |
252 raise util.Abort(_('working copy of .hgtags is changed ' | 271 raise util.Abort(_('working copy of .hgtags is changed ' |
253 '(please commit .hgtags manually)')) | 272 '(please commit .hgtags manually)')) |
254 | 273 |
255 # committed tags are stored in UTF-8 | 274 |
256 line = '%s %s\n' % (hex(node), util.fromlocal(name)) | 275 self._tag(name, node, message, local, user, date) |
257 self.wfile('.hgtags', 'ab').write(line) | |
258 if self.dirstate.state('.hgtags') == '?': | |
259 self.add(['.hgtags']) | |
260 | |
261 self.commit(['.hgtags'], message, user, date) | |
262 self.hook('tag', node=hex(node), tag=name, local=local) | |
263 | 276 |
264 def tags(self): | 277 def tags(self): |
265 '''return a mapping of tag to node''' | 278 '''return a mapping of tag to node''' |
266 if not self.tagscache: | 279 if not self.tagscache: |
267 self.tagscache = {} | 280 self.tagscache = {} |