Mercurial > hg
changeset 609:2acf1f5df2e6
[PATCH] hg tag: local tag support in file .hg/localtags
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[PATCH] hg tag: local tag support in file .hg/localtags
From: Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl>
Support local tags in .hg/localtags
Also minor cleanups in related functions
manifest hash: 553b2e896fed3c9055ed18482ce15cfaa4fc41ce
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCyYdJywK+sNU5EO8RAhohAKC2I3U44EXi+k4ofo5AWHBOg+94bgCfcbzs
VQ2yWkPPHZycjtswOBmepa8=
=v5AX
-----END PGP SIGNATURE-----
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 04 Jul 2005 11:00:25 -0800 |
parents | d2994b5298fb |
children | 4c02464cb9f0 |
files | mercurial/commands.py mercurial/hg.py |
diffstat | 2 files changed, 30 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Jul 03 21:51:09 2005 -0800 +++ b/mercurial/commands.py Mon Jul 04 11:00:25 2005 -0800 @@ -649,6 +649,7 @@ b = revs.pop(0) off = a > b and -1 or 1 revlist.extend(range(a, b + off, off)) + for i in revlist or range(log.count() - 1, -1, -1): show_changeset(ui, repo, filelog=filelog, rev=i) @@ -851,10 +852,19 @@ if name == "tip": ui.warn("abort: 'tip' is a reserved name!\n") return -1 + if rev: + r = hg.hex(repo.lookup(rev)) + else: + r = hg.hex(repo.changelog.tip()) + if name.find(revrangesep) >= 0: ui.warn("abort: '%s' cannot be used in a tag name\n" % revrangesep) return -1 + if opts['local']: + repo.opener("localtags", "a").write("%s %s\n" % (r, name)) + return + (c, a, d, u) = repo.changes(None, None) for x in (c, a, d, u): if ".hgtags" in x: @@ -862,11 +872,6 @@ ui.status("(please commit .hgtags manually)\n") return -1 - if rev: - r = hg.hex(repo.lookup(rev)) - else: - r = hg.hex(repo.changelog.tip()) - add = 0 if not os.path.exists(repo.wjoin(".hgtags")): add = 1 repo.wfile(".hgtags", "a").write("%s %s\n" % (r, name)) @@ -1000,7 +1005,8 @@ ('t', 'templates', "", 'template map')], "hg serve [options]"), "^status": (status, [], 'hg status'), - "tag": (tag, [('t', 'text', "", 'commit text'), + "tag": (tag, [('l', 'local', None, 'make the tag local'), + ('t', 'text', "", 'commit text'), ('d', 'date', "", 'date code'), ('u', 'user', "", 'user')], 'hg tag [options] <name> [rev]'),
--- a/mercurial/hg.py Sun Jul 03 21:51:09 2005 -0800 +++ b/mercurial/hg.py Mon Jul 04 11:00:25 2005 -0800 @@ -438,6 +438,13 @@ '''return a mapping of tag to node''' if not self.tagscache: self.tagscache = {} + def addtag(self, k, n): + try: + bin_n = bin(n) + except TypeError: + bin_n = '' + self.tagscache[k.strip()] = bin_n + try: # read each head of the tags file, ending with the tip # and add each tag found to the map, with "newer" ones @@ -449,22 +456,20 @@ for l in fl.revision(r).splitlines(): if l: n, k = l.split(" ", 1) - try: - bin_n = bin(n) - except TypeError: - bin_n = '' - self.tagscache[k.strip()] = bin_n + addtag(self, k, n) except KeyError: pass - for k, n in self.ui.configitems("tags"): - try: - bin_n = bin(n) - except TypeError: - bin_n = '' - self.tagscache[k] = bin_n - + + try: + f = self.opener("localtags") + for l in f: + n, k = l.split(" ", 1) + addtag(self, k, n) + except IOError: + pass + self.tagscache['tip'] = self.changelog.tip() - + return self.tagscache def tagslist(self):