Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 349:b2293093b89e
Merged with mercurial-identify (which includes upstream's current tip)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Merged with mercurial-identify (which includes upstream's current tip)
manifest hash: b135d201757b84bbe7f14a446d2b001fd0cc1aa2
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFCr9mNW7P1GVgWeRoRAmTjAJ919wnvZXbKI27N0cDJCrumR3z4rQCcD6PO
yZTmrT6p+gt6GBO+j5FVBn0=
=HWn8
-----END PGP SIGNATURE-----
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Wed, 15 Jun 2005 08:32:29 +0100 |
parents | a0b2758edee7 97a897d32dfc |
children | b4e0e20646bb |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Jun 14 08:49:52 2005 +0100 +++ b/mercurial/commands.py Wed Jun 15 08:32:29 2005 +0100 @@ -126,6 +126,18 @@ ui.status("summary: %s\n" % description.splitlines()[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,26 @@ 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] + if not parents: + ui.note("unknown\n") + return + + 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""" @@ -334,13 +366,20 @@ try: os.remove(".hg/dirstate") except: pass + + repo = hg.repository(ui, ".") + else: repo = hg.repository(ui, ".", create=1) other = hg.repository(ui, source) cg = repo.getchangegroup(other) repo.addchangegroup(cg) else: - hg.repository(ui, ".", create=1) + repo = hg.repository(ui, ".", create=1) + + f = repo.opener("hgrc", "w") + f.write("[paths]\n") + f.write("default = %s\n" % source) def log(ui, repo, f): """show the revision history of a single file""" @@ -409,7 +448,7 @@ raise "patch failed!" repo.commit(files, text) -def pull(ui, repo, source): +def pull(ui, repo, source="default"): """pull changes from the specified source""" paths = {} for name, path in ui.configitems("paths"): @@ -457,7 +496,7 @@ os.kill(child, signal.SIGTERM) return r -def rawcommit(ui, repo, files, **rc): +def rawcommit(ui, repo, flist, **rc): "raw commit interface" text = rc['text'] @@ -468,7 +507,7 @@ print "missing commit text" return 1 - files = relpath(repo, files) + files = relpath(repo, flist) if rc['files']: files += open(rc['files']).read().splitlines() @@ -505,15 +544,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() @@ -583,6 +614,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]'), @@ -627,7 +659,7 @@ def find(cmd): i = None for e in table.keys(): - if re.match(e + "$", cmd): + if re.match("(%s)$" % e, cmd): return table[e] raise UnknownCommand(cmd)