mirror of
https://github.com/facebook/sapling.git
synced 2025-01-01 01:25:49 +03:00
Add tag support
This commit is contained in:
parent
d9094f35ef
commit
7c6f4b49c8
2
README
2
README
@ -37,6 +37,7 @@ Mercurial commands:
|
||||
$ hg add foo # add a new file for the next commit
|
||||
$ hg remove bar # mark a file as removed
|
||||
$ hg verify # check repo integrity
|
||||
$ hg tags # show current tags
|
||||
|
||||
Branching and merging:
|
||||
|
||||
@ -93,7 +94,6 @@ Network support:
|
||||
# merge changes from a remote machine
|
||||
bar$ hg merge hg://foo/~user/hg-linux
|
||||
|
||||
|
||||
Another approach which does perform well right now is to use rsync.
|
||||
Simply rsync the remote repo to a read-only local copy and then do a
|
||||
local pull.
|
||||
|
22
hg
22
hg
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# mercurial - a minimal scalable distributed SCM
|
||||
# v0.4e "sabina"
|
||||
# v0.4f "jane dark"
|
||||
#
|
||||
# Copyright 2005 Matt Mackall <mpm@selenic.com>
|
||||
#
|
||||
@ -37,6 +37,7 @@ def help():
|
||||
dump <file> [rev] dump the latest or given revision of a file
|
||||
dumpmanifest [rev] dump the latest or given revision of the manifest
|
||||
diff [files...] diff working directory (or selected files)
|
||||
tags show current changeset tags
|
||||
"""
|
||||
|
||||
def filterfiles(list, files):
|
||||
@ -118,7 +119,7 @@ else:
|
||||
if cmd == "checkout" or cmd == "co":
|
||||
node = repo.changelog.tip()
|
||||
if args:
|
||||
node = repo.changelog.lookup(args[0])
|
||||
node = repo.lookup(args[0])
|
||||
repo.checkout(node)
|
||||
|
||||
elif cmd == "add":
|
||||
@ -177,7 +178,7 @@ elif cmd == "diff":
|
||||
opts = [('r', 'revision', [], 'revision')]
|
||||
args = fancyopts.fancyopts(args, opts, doptions,
|
||||
'hg diff [options] [files]')
|
||||
revs = map(lambda x: repo.changelog.lookup(x), doptions['revision'])
|
||||
revs = map(lambda x: repo.lookup(x), doptions['revision'])
|
||||
|
||||
if len(revs) > 2:
|
||||
print "too many revisions to diff"
|
||||
@ -191,12 +192,12 @@ elif cmd == "diff":
|
||||
diff(args, *revs)
|
||||
|
||||
elif cmd == "export":
|
||||
node = repo.changelog.lookup(args[0])
|
||||
node = repo.lookup(args[0])
|
||||
prev = repo.changelog.parents(node)[0]
|
||||
diff(None, prev, node)
|
||||
|
||||
elif cmd == "debugchangegroup":
|
||||
newer = repo.newer(map(repo.changelog.lookup, args))
|
||||
newer = repo.newer(map(repo.lookup, args))
|
||||
for chunk in repo.changegroup(newer):
|
||||
sys.stdout.write(chunk)
|
||||
|
||||
@ -288,6 +289,17 @@ elif cmd == "merge":
|
||||
else:
|
||||
print "missing source repository"
|
||||
|
||||
elif cmd == "tags":
|
||||
repo.lookup(0) # prime the cache
|
||||
i = repo.tags.items()
|
||||
i.sort()
|
||||
for k, n in i:
|
||||
try:
|
||||
r = repo.changelog.rev(n)
|
||||
except KeyError:
|
||||
r = "?"
|
||||
print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n))
|
||||
|
||||
elif cmd == "debugoldmerge":
|
||||
if args:
|
||||
other = hg.repository(ui, args[0])
|
||||
|
@ -258,6 +258,7 @@ class localrepository:
|
||||
self.manifest = manifest(self.opener)
|
||||
self.changelog = changelog(self.opener)
|
||||
self.ignorelist = None
|
||||
self.tags = None
|
||||
|
||||
if not self.remote:
|
||||
self.dircache = dircache(self.opener, ui)
|
||||
@ -274,7 +275,7 @@ class localrepository:
|
||||
if self.ignorelist is None:
|
||||
self.ignorelist = []
|
||||
try:
|
||||
l = open(os.path.join(self.root, ".hgignore")).readlines()
|
||||
l = open(os.path.join(self.root, ".hgignore"))
|
||||
for pat in l:
|
||||
if pat != "\n":
|
||||
self.ignorelist.append(re.compile(pat[:-1]))
|
||||
@ -283,6 +284,21 @@ class localrepository:
|
||||
if pat.search(f): return True
|
||||
return False
|
||||
|
||||
def lookup(self, key):
|
||||
if self.tags is None:
|
||||
self.tags = {}
|
||||
try:
|
||||
fl = self.file(".hgtags")
|
||||
for l in fl.revision(fl.tip()).splitlines():
|
||||
if l:
|
||||
n, k = l.split(" ")
|
||||
self.tags[k] = bin(n)
|
||||
except KeyError: pass
|
||||
try:
|
||||
return self.tags[key]
|
||||
except KeyError:
|
||||
return self.changelog.lookup(key)
|
||||
|
||||
def join(self, f):
|
||||
return os.path.join(self.path, f)
|
||||
|
||||
|
@ -73,7 +73,7 @@ class revlog:
|
||||
if id in hex(n):
|
||||
c.append(n)
|
||||
if len(c) > 1: raise KeyError("Ambiguous identifier")
|
||||
if len(c) < 1: raise KeyError
|
||||
if len(c) < 1: raise KeyError("No match found")
|
||||
return c[0]
|
||||
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user