Mercurial > hg
changeset 339:a76fc9c4b67b
added hg identify|id (based on a patch from Andrew Thompson)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
added hg identify|id (based on a patch from Andrew Thompson)
manifest hash: b8f801efb6cf14a6d754fed2cf47149f4e77b3cc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFCr8BLW7P1GVgWeRoRAj3+AJ4jIvfBnu6vbF+SOS2ybVTboXe7pACfZkkT
2G2bbxYowVnrytOXVg6BhlU=
=wNpZ
-----END PGP SIGNATURE-----
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Wed, 15 Jun 2005 06:44:43 +0100 |
parents | 1e091b3293d5 |
children | 97a897d32dfc |
files | mercurial/commands.py |
diffstat | 1 files changed, 30 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Jun 14 18:37:53 2005 -0800 +++ b/mercurial/commands.py Wed Jun 15 06:44:43 2005 +0100 @@ -126,6 +126,18 @@ ui.status("summary: %s\n" % description[0]) ui.status("\n") +def tags_load(repo): + repo.lookup(0) # prime the cache + i = repo.tags.items() + n = [] + for e in i: + try: + l = repo.changelog.rev(e[1]) + except KeyError: + l = -2 + n.append((l, e)) + return n + def help(ui, cmd=None): '''show help for a given command or all commands''' if cmd: @@ -312,6 +324,22 @@ for i in range(repo.changelog.count() - 1, -1, -1): show_changeset(ui, repo, rev=i) +def identify(ui, repo): + """print information about the working copy""" + (c, a, d, u) = repo.diffdir(repo.root) + mflag = (c or a or d or u) and "+" or "" + parents = [parent for parent in repo.dirstate.parents() + if parent != hg.nullid] + tstring = '' + if not ui.quiet: + taglist = [e[1] for e in tags_load(repo)] + tstring = " %s" % ' + '.join([e[0] for e in taglist + if e[0] != 'tip' and e[1] in parents]) + + hexfunc = ui.verbose and hg.hex or hg.short + pstring = '+'.join([hexfunc(parent) for parent in parents]) + ui.write("%s%s%s\n" % (pstring, mflag, tstring)) + def init(ui, source=None): """create a new repository or copy an existing one""" @@ -512,15 +540,7 @@ def tags(ui, repo): """list repository tags""" - repo.lookup(0) # prime the cache - i = repo.tags.items() - n = [] - for e in i: - try: - l = repo.changelog.rev(e[1]) - except KeyError: - l = -2 - n.append((l, e)) + n = tags_load(repo) n.sort() n.reverse() @@ -590,6 +610,7 @@ "heads": (heads, [], 'hg heads'), "history": (history, [], 'hg history'), "help": (help, [], 'hg help [command]'), + "identify|id": (identify, [], 'hg identify'), "init": (init, [], 'hg init [url]'), "log": (log, [], 'hg log <file>'), "manifest|dumpmanifest": (manifest, [], 'hg manifest [rev]'),