Mercurial > hg
comparison mercurial/commands.py @ 9603:220d39af2e57
Introduce summary command
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 18 Oct 2009 22:31:05 -0500 |
parents | 17da88da1abd |
children | fcc85abc762e 8e0e0d854b60 |
comparison
equal
deleted
inserted
replaced
9602:fc493cb90bb1 | 9603:220d39af2e57 |
---|---|
2874 | 2874 |
2875 for f in files: | 2875 for f in files: |
2876 ui.write(format % repo.pathto(f, cwd)) | 2876 ui.write(format % repo.pathto(f, cwd)) |
2877 if f in copy: | 2877 if f in copy: |
2878 ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end)) | 2878 ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end)) |
2879 | |
2880 def summary(ui, repo): | |
2881 """summarize working directory state | |
2882 | |
2883 This generates a brief summary of the working directory state, | |
2884 including parents, branch, commit status, and available updates. | |
2885 """ | |
2886 | |
2887 ctx = repo[None] | |
2888 parents = ctx.parents() | |
2889 pnode = parents[0].node() | |
2890 tags = repo.tags() | |
2891 | |
2892 for p in parents: | |
2893 t = ' '.join([t for t in tags if tags[t] == p.node()]) | |
2894 ui.write(_('parent: %d:%s %s\n') % (p.rev(), str(p), t)) | |
2895 ui.status(' ' + p.description().splitlines()[0].strip() + '\n') | |
2896 | |
2897 branch = ctx.branch() | |
2898 bheads = repo.branchheads(branch) | |
2899 ui.status(_('branch: %s\n') % branch) | |
2900 | |
2901 st = list(repo.status(unknown=True))[:7] | |
2902 ms = merge_.mergestate(repo) | |
2903 st.append([f for f in ms if f == 'u']) | |
2904 labels = _('modified added removed deleted unknown ignored unresolved') | |
2905 t = [] | |
2906 for i,l in enumerate(labels.split()): | |
2907 if st[i]: | |
2908 t.append('%d %s' % (len(st[i]), l)) | |
2909 | |
2910 t = ', '.join(t) | |
2911 | |
2912 if len(parents) > 1: | |
2913 t += _(' (merge)') | |
2914 elif branch != parents[0].branch(): | |
2915 t += _(' (new branch)') | |
2916 elif (not st[0] and not st[1] and not st[2]): | |
2917 t += _(' (clean)') | |
2918 elif pnode not in bheads: | |
2919 t += _(' (new branch head)') | |
2920 | |
2921 ui.write(_('commit: %s\n') % t.strip()) | |
2922 | |
2923 # all ancestors of branch heads - all ancestors of parent = new csets | |
2924 new = [0] * len(repo) | |
2925 cl = repo.changelog | |
2926 for a in cl.ancestors(*[cl.rev(n) for n in bheads]): | |
2927 new[a] = 1 | |
2928 for a in cl.ancestors(*[p.rev() for p in parents]): | |
2929 new[a] = 0 | |
2930 new = sum(new) | |
2931 | |
2932 if new == 0: | |
2933 ui.write(_('update: (current)\n')) | |
2934 elif pnode not in bheads: | |
2935 ui.write(_('update: %d new changesets (update)\n') % new) | |
2936 else: | |
2937 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') % | |
2938 (new, len(bheads))) | |
2879 | 2939 |
2880 def tag(ui, repo, name1, *names, **opts): | 2940 def tag(ui, repo, name1, *names, **opts): |
2881 """add one or more tags for the current or given revision | 2941 """add one or more tags for the current or given revision |
2882 | 2942 |
2883 Name a particular revision using <name>. | 2943 Name a particular revision using <name>. |
3506 _('[OPTION]...')), | 3566 _('[OPTION]...')), |
3507 "showconfig|debugconfig": | 3567 "showconfig|debugconfig": |
3508 (showconfig, | 3568 (showconfig, |
3509 [('u', 'untrusted', None, _('show untrusted configuration options'))], | 3569 [('u', 'untrusted', None, _('show untrusted configuration options'))], |
3510 _('[-u] [NAME]...')), | 3570 _('[-u] [NAME]...')), |
3571 "^summary|sum": | |
3572 (summary, []), | |
3511 "^status|st": | 3573 "^status|st": |
3512 (status, | 3574 (status, |
3513 [('A', 'all', None, _('show status of all files')), | 3575 [('A', 'all', None, _('show status of all files')), |
3514 ('m', 'modified', None, _('show only modified files')), | 3576 ('m', 'modified', None, _('show only modified files')), |
3515 ('a', 'added', None, _('show only added files')), | 3577 ('a', 'added', None, _('show only added files')), |