# HG changeset patch # User Matt Mackall # Date 1182444851 18000 # Node ID 091c9e54d306bc178b364d33f0efb1f8975ec7f4 # Parent dedb8abfd0e1c809628fc260498bbb46366741cf identify: accept a revision argument diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1432,32 +1432,36 @@ def help_(ui, name=None, with_version=Fa else: ui.write("%s\n" % first) -def identify(ui, repo): - """print information about the working copy - - Print a short summary of the current state of the repo. +def identify(ui, repo, rev=None): + """identify the working copy or specified revision + + With no argument, print a summary of the current state of the repo. This summary identifies the repository state using one or two parent hash identifiers, followed by a "+" if there are uncommitted changes - in the working directory, followed by a list of tags for this revision. + in the working directory, a list of tags for this revision and a branch + name for non-default branches. """ hexfunc = ui.debugflag and hex or short - wctx = repo.workingctx() - parents = wctx.parents() - changed = wctx.files() + wctx.deleted() - - output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]), - (changed) and "+" or "")] + if not rev: + ctx = repo.workingctx() + parents = ctx.parents() + changed = ctx.files() + ctx.deleted() + output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]), + (changed) and "+" or "")] + else: + ctx = repo.changectx(rev) + output = [hexfunc(ctx.node())] if not ui.quiet: - branch = util.tolocal(wctx.branch()) + branch = util.tolocal(ctx.branch()) if branch != 'default': output.append("(%s)" % branch) # multiple tags for a single parent separated by '/' - tags = "/".join(wctx.tags()) + tags = "/".join(ctx.tags()) if tags: output.append(tags) @@ -2821,7 +2825,10 @@ table = { ('', 'template', '', _('display with template'))], _('hg heads [-r REV] [REV]...')), "help": (help_, [], _('hg help [COMMAND]')), - "identify|id": (identify, [], _('hg identify')), + "identify|id": + (identify, + [('r', 'rev', '', _('identify the specified rev'))], + _('hg identify [-r REV]')), "import|patch": (import_, [('p', 'strip', 1, diff --git a/tests/test-globalopts.out b/tests/test-globalopts.out --- a/tests/test-globalopts.out +++ b/tests/test-globalopts.out @@ -136,7 +136,7 @@ list of commands: grep search for a pattern in specified files and revisions heads show current repository heads or show branch heads help show help for a command, extension, or list of commands - identify print information about the working copy + identify identify the working copy or specified revision import import an ordered set of patches incoming show new changesets found in source init create a new repository in the given directory @@ -188,7 +188,7 @@ list of commands: grep search for a pattern in specified files and revisions heads show current repository heads or show branch heads help show help for a command, extension, or list of commands - identify print information about the working copy + identify identify the working copy or specified revision import import an ordered set of patches incoming show new changesets found in source init create a new repository in the given directory diff --git a/tests/test-help.out b/tests/test-help.out --- a/tests/test-help.out +++ b/tests/test-help.out @@ -59,7 +59,7 @@ list of commands: grep search for a pattern in specified files and revisions heads show current repository heads or show branch heads help show help for a command, extension, or list of commands - identify print information about the working copy + identify identify the working copy or specified revision import import an ordered set of patches incoming show new changesets found in source init create a new repository in the given directory @@ -107,7 +107,7 @@ use "hg -v help" to show aliases and glo grep search for a pattern in specified files and revisions heads show current repository heads or show branch heads help show help for a command, extension, or list of commands - identify print information about the working copy + identify identify the working copy or specified revision import import an ordered set of patches incoming show new changesets found in source init create a new repository in the given directory