diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2877,6 +2877,66 @@ def status(ui, repo, *pats, **opts): 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 @@ table = { (showconfig, [('u', 'untrusted', None, _('show untrusted configuration options'))], _('[-u] [NAME]...')), + "^summary|sum": + (summary, []), "^status|st": (status, [('A', 'all', None, _('show status of all files')), diff --git a/tests/test-debugcomplete.out b/tests/test-debugcomplete.out --- a/tests/test-debugcomplete.out +++ b/tests/test-debugcomplete.out @@ -41,6 +41,7 @@ root serve showconfig status +summary tag tags tip @@ -159,7 +160,7 @@ root % 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 @@ push: force, rev, ssh, remotecmd 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 diff --git a/tests/test-globalopts.out b/tests/test-globalopts.out --- a/tests/test-globalopts.out +++ b/tests/test-globalopts.out @@ -191,6 +191,7 @@ list of commands: 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 @@ list of commands: 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 diff --git a/tests/test-help.out b/tests/test-help.out --- a/tests/test-help.out +++ b/tests/test-help.out @@ -18,6 +18,7 @@ basic commands: 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 @@ use "hg help" for the full list of comma 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 @@ list of commands: 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 @@ use "hg -v help" to show aliases and glo 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 @@ basic commands: 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 @@ basic commands: 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 diff --git a/tests/test-qrecord.out b/tests/test-qrecord.out --- a/tests/test-qrecord.out +++ b/tests/test-qrecord.out @@ -20,6 +20,7 @@ basic commands: 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 diff --git a/tests/test-strict.out b/tests/test-strict.out --- a/tests/test-strict.out +++ b/tests/test-strict.out @@ -21,6 +21,7 @@ basic commands: 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