--- a/mercurial/commands.py Fri Oct 16 11:19:39 2009 +0200
+++ b/mercurial/commands.py Sun Oct 18 22:31:05 2009 -0500
@@ -2877,6 +2877,66 @@
if f in copy:
ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end))
+def summary(ui, repo):
+ """summarize working directory state
+
+ This generates a brief summary of the working directory state,
+ including parents, branch, commit status, and available updates.
+ """
+
+ ctx = repo[None]
+ parents = ctx.parents()
+ pnode = parents[0].node()
+ tags = repo.tags()
+
+ for p in parents:
+ t = ' '.join([t for t in tags if tags[t] == p.node()])
+ ui.write(_('parent: %d:%s %s\n') % (p.rev(), str(p), t))
+ ui.status(' ' + p.description().splitlines()[0].strip() + '\n')
+
+ branch = ctx.branch()
+ bheads = repo.branchheads(branch)
+ ui.status(_('branch: %s\n') % branch)
+
+ st = list(repo.status(unknown=True))[:7]
+ ms = merge_.mergestate(repo)
+ st.append([f for f in ms if f == 'u'])
+ labels = _('modified added removed deleted unknown ignored unresolved')
+ t = []
+ for i,l in enumerate(labels.split()):
+ if st[i]:
+ t.append('%d %s' % (len(st[i]), l))
+
+ t = ', '.join(t)
+
+ if len(parents) > 1:
+ t += _(' (merge)')
+ elif branch != parents[0].branch():
+ t += _(' (new branch)')
+ elif (not st[0] and not st[1] and not st[2]):
+ t += _(' (clean)')
+ elif pnode not in bheads:
+ t += _(' (new branch head)')
+
+ ui.write(_('commit: %s\n') % t.strip())
+
+ # all ancestors of branch heads - all ancestors of parent = new csets
+ new = [0] * len(repo)
+ cl = repo.changelog
+ for a in cl.ancestors(*[cl.rev(n) for n in bheads]):
+ new[a] = 1
+ for a in cl.ancestors(*[p.rev() for p in parents]):
+ new[a] = 0
+ new = sum(new)
+
+ if new == 0:
+ ui.write(_('update: (current)\n'))
+ elif pnode not in bheads:
+ ui.write(_('update: %d new changesets (update)\n') % new)
+ else:
+ ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
+ (new, len(bheads)))
+
def tag(ui, repo, name1, *names, **opts):
"""add one or more tags for the current or given revision
@@ -3508,6 +3568,8 @@
(showconfig,
[('u', 'untrusted', None, _('show untrusted configuration options'))],
_('[-u] [NAME]...')),
+ "^summary|sum":
+ (summary, []),
"^status|st":
(status,
[('A', 'all', None, _('show status of all files')),
--- a/tests/test-debugcomplete.out Fri Oct 16 11:19:39 2009 +0200
+++ b/tests/test-debugcomplete.out Sun Oct 18 22:31:05 2009 -0500
@@ -41,6 +41,7 @@
serve
showconfig
status
+summary
tag
tags
tip
@@ -159,7 +160,7 @@
% Show an error if we use --options with an ambiguous abbreviation
hg: command 's' is ambiguous:
- serve showconfig status
+ serve showconfig status summary
% Show all commands + options
add: include, exclude, dry-run
@@ -178,6 +179,7 @@
remove: after, force, include, exclude
serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, webdir-conf, pid-file, stdio, templates, style, ipv6, certificate
status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, include, exclude
+summary:
update: clean, check, date, rev
addremove: similarity, include, exclude, dry-run
archive: no-decode, prefix, rev, type, include, exclude
--- a/tests/test-globalopts.out Fri Oct 16 11:19:39 2009 +0200
+++ b/tests/test-globalopts.out Sun Oct 18 22:31:05 2009 -0500
@@ -191,6 +191,7 @@
serve export the repository via HTTP
showconfig show combined config settings from all hgrc files
status show changed files in the working directory
+ summary summarize working directory state
tag add one or more tags for the current or given revision
tags list repository tags
tip show the tip revision
@@ -258,6 +259,7 @@
serve export the repository via HTTP
showconfig show combined config settings from all hgrc files
status show changed files in the working directory
+ summary summarize working directory state
tag add one or more tags for the current or given revision
tags list repository tags
tip show the tip revision
--- a/tests/test-help.out Fri Oct 16 11:19:39 2009 +0200
+++ b/tests/test-help.out Sun Oct 18 22:31:05 2009 -0500
@@ -18,6 +18,7 @@
remove remove the specified files on the next commit
serve export the repository via HTTP
status show changed files in the working directory
+ summary summarize working directory state
update update working directory
use "hg help" for the full list of commands or "hg -v" for details
@@ -37,6 +38,7 @@
remove remove the specified files on the next commit
serve export the repository via HTTP
status show changed files in the working directory
+ summary summarize working directory state
update update working directory
Mercurial Distributed SCM
@@ -84,6 +86,7 @@
serve export the repository via HTTP
showconfig show combined config settings from all hgrc files
status show changed files in the working directory
+ summary summarize working directory state
tag add one or more tags for the current or given revision
tags list repository tags
tip show the tip revision
@@ -147,6 +150,7 @@
serve export the repository via HTTP
showconfig show combined config settings from all hgrc files
status show changed files in the working directory
+ summary summarize working directory state
tag add one or more tags for the current or given revision
tags list repository tags
tip show the tip revision
@@ -319,6 +323,7 @@
remove remove the specified files on the next commit
serve export the repository via HTTP
status show changed files in the working directory
+ summary summarize working directory state
update update working directory
use "hg help" for the full list of commands or "hg -v" for details
@@ -343,6 +348,7 @@
remove remove the specified files on the next commit
serve export the repository via HTTP
status show changed files in the working directory
+ summary summarize working directory state
update update working directory
use "hg help" for the full list of commands or "hg -v" for details
--- a/tests/test-qrecord.out Fri Oct 16 11:19:39 2009 +0200
+++ b/tests/test-qrecord.out Sun Oct 18 22:31:05 2009 -0500
@@ -20,6 +20,7 @@
remove remove the specified files on the next commit
serve export the repository via HTTP
status show changed files in the working directory
+ summary summarize working directory state
update update working directory
use "hg help" for the full list of commands or "hg -v" for details
--- a/tests/test-strict.out Fri Oct 16 11:19:39 2009 +0200
+++ b/tests/test-strict.out Sun Oct 18 22:31:05 2009 -0500
@@ -21,6 +21,7 @@
remove remove the specified files on the next commit
serve export the repository via HTTP
status show changed files in the working directory
+ summary summarize working directory state
update update working directory
use "hg help" for the full list of commands or "hg -v" for details