Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 2601:00fc88b0b256
move most of tag code to localrepository class.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Wed, 12 Jul 2006 08:59:20 -0700 |
parents | 54b152379589 |
children | ffb895f16925 e196aa1df169 |
comparison
equal
deleted
inserted
replaced
2600:c4325f0a9b91 | 2601:00fc88b0b256 |
---|---|
159 if cmd.startswith('python:'): | 159 if cmd.startswith('python:'): |
160 r = callhook(hname, cmd[7:].strip()) or r | 160 r = callhook(hname, cmd[7:].strip()) or r |
161 else: | 161 else: |
162 r = runhook(hname, cmd) or r | 162 r = runhook(hname, cmd) or r |
163 return r | 163 return r |
164 | |
165 tag_disallowed = ':\r\n' | |
166 | |
167 def tag(self, name, node, local=False, message=None, user=None, date=None): | |
168 '''tag a revision with a symbolic name. | |
169 | |
170 if local is True, the tag is stored in a per-repository file. | |
171 otherwise, it is stored in the .hgtags file, and a new | |
172 changeset is committed with the change. | |
173 | |
174 keyword arguments: | |
175 | |
176 local: whether to store tag in non-version-controlled file | |
177 (default False) | |
178 | |
179 message: commit message to use if committing | |
180 | |
181 user: name of user to use if committing | |
182 | |
183 date: date tuple to use if committing''' | |
184 | |
185 for c in self.tag_disallowed: | |
186 if c in name: | |
187 raise util.Abort(_('%r cannot be used in a tag name') % c) | |
188 | |
189 self.hook('pretag', throw=True, node=node, tag=name, local=local) | |
190 | |
191 if local: | |
192 self.opener('localtags', 'a').write('%s %s\n' % (node, name)) | |
193 self.hook('tag', node=node, tag=name, local=local) | |
194 return | |
195 | |
196 for x in self.changes(): | |
197 if '.hgtags' in x: | |
198 raise util.Abort(_('working copy of .hgtags is changed ' | |
199 '(please commit .hgtags manually)')) | |
200 | |
201 self.wfile('.hgtags', 'ab').write('%s %s\n' % (node, name)) | |
202 if self.dirstate.state('.hgtags') == '?': | |
203 self.add(['.hgtags']) | |
204 | |
205 if not message: | |
206 message = _('Added tag %s for changeset %s') % (name, node) | |
207 | |
208 self.commit(['.hgtags'], message, user, date) | |
209 self.hook('tag', node=node, tag=name, local=local) | |
164 | 210 |
165 def tags(self): | 211 def tags(self): |
166 '''return a mapping of tag to node''' | 212 '''return a mapping of tag to node''' |
167 if not self.tagscache: | 213 if not self.tagscache: |
168 self.tagscache = {} | 214 self.tagscache = {} |