Show More
@@ -2667,7 +2667,7 b' def help_(ui, name=None, **opts):' | |||||
2667 | ('b', 'branch', None, _('show branch')), |
|
2667 | ('b', 'branch', None, _('show branch')), | |
2668 | ('t', 'tags', None, _('show tags')), |
|
2668 | ('t', 'tags', None, _('show tags')), | |
2669 | ('B', 'bookmarks', None, _('show bookmarks')), |
|
2669 | ('B', 'bookmarks', None, _('show bookmarks')), | |
2670 | ] + remoteopts, |
|
2670 | ] + remoteopts + formatteropts, | |
2671 | _('[-nibtB] [-r REV] [SOURCE]'), |
|
2671 | _('[-nibtB] [-r REV] [SOURCE]'), | |
2672 | optionalrepo=True) |
|
2672 | optionalrepo=True) | |
2673 | def identify(ui, repo, source=None, rev=None, |
|
2673 | def identify(ui, repo, source=None, rev=None, | |
@@ -2726,6 +2726,9 b' def identify(ui, repo, source=None, rev=' | |||||
2726 | repo = peer.local() |
|
2726 | repo = peer.local() | |
2727 | revs, checkout = hg.addbranchrevs(repo, peer, branches, None) |
|
2727 | revs, checkout = hg.addbranchrevs(repo, peer, branches, None) | |
2728 |
|
2728 | |||
|
2729 | fm = ui.formatter('identify', opts) | |||
|
2730 | fm.startitem() | |||
|
2731 | ||||
2729 | if not repo: |
|
2732 | if not repo: | |
2730 | if num or branch or tags: |
|
2733 | if num or branch or tags: | |
2731 | raise error.Abort( |
|
2734 | raise error.Abort( | |
@@ -2736,8 +2739,10 b' def identify(ui, repo, source=None, rev=' | |||||
2736 | rev = "tip" |
|
2739 | rev = "tip" | |
2737 |
|
2740 | |||
2738 | remoterev = peer.lookup(rev) |
|
2741 | remoterev = peer.lookup(rev) | |
|
2742 | hexrev = hexfunc(remoterev) | |||
2739 | if default or id: |
|
2743 | if default or id: | |
2740 |
output = [hex |
|
2744 | output = [hexrev] | |
|
2745 | fm.data(id=hexrev) | |||
2741 |
|
2746 | |||
2742 | def getbms(): |
|
2747 | def getbms(): | |
2743 | bms = [] |
|
2748 | bms = [] | |
@@ -2749,13 +2754,17 b' def identify(ui, repo, source=None, rev=' | |||||
2749 |
|
2754 | |||
2750 | return sorted(bms) |
|
2755 | return sorted(bms) | |
2751 |
|
2756 | |||
|
2757 | bms = getbms() | |||
2752 | if bookmarks: |
|
2758 | if bookmarks: | |
2753 |
output.extend( |
|
2759 | output.extend(bms) | |
2754 | elif default and not ui.quiet: |
|
2760 | elif default and not ui.quiet: | |
2755 | # multiple bookmarks for a single parent separated by '/' |
|
2761 | # multiple bookmarks for a single parent separated by '/' | |
2756 |
bm = '/'.join( |
|
2762 | bm = '/'.join(bms) | |
2757 | if bm: |
|
2763 | if bm: | |
2758 | output.append(bm) |
|
2764 | output.append(bm) | |
|
2765 | ||||
|
2766 | fm.data(node=hex(remoterev)) | |||
|
2767 | fm.data(bookmarks=fm.formatlist(bms, name='bookmark')) | |||
2759 | else: |
|
2768 | else: | |
2760 | ctx = scmutil.revsingle(repo, rev, None) |
|
2769 | ctx = scmutil.revsingle(repo, rev, None) | |
2761 |
|
2770 | |||
@@ -2767,19 +2776,32 b' def identify(ui, repo, source=None, rev=' | |||||
2767 | taglist.extend(p.tags()) |
|
2776 | taglist.extend(p.tags()) | |
2768 |
|
2777 | |||
2769 | changed = "" |
|
2778 | changed = "" | |
2770 | if default or id or num: |
|
2779 | if (any(repo.status()) | |
2771 | if (any(repo.status()) |
|
2780 | or any(ctx.sub(s).dirty() for s in ctx.substate)): | |
2772 | or any(ctx.sub(s).dirty() for s in ctx.substate)): |
|
2781 | changed = '+' | |
2773 | changed = '+' |
|
2782 | fm.data(changed=changed) | |
|
2783 | ||||
|
2784 | hexoutput = [hexfunc(p.node()) for p in parents] | |||
2774 | if default or id: |
|
2785 | if default or id: | |
2775 | output = ["%s%s" % |
|
2786 | output = ["%s%s" % ('+'.join(hexoutput), changed)] | |
2776 | ('+'.join([hexfunc(p.node()) for p in parents]), changed)] |
|
2787 | fm.data(id="%s%s" % ('+'.join(hexoutput), changed)) | |
|
2788 | ||||
2777 | if num: |
|
2789 | if num: | |
2778 | output.append("%s%s" % |
|
2790 | numoutput = ["%d" % p.rev() for p in parents] | |
2779 | ('+'.join(["%d" % p.rev() for p in parents]), changed)) |
|
2791 | output.append("%s%s" % ('+'.join(numoutput), changed)) | |
|
2792 | ||||
|
2793 | for i, p in enumerate(parents): | |||
|
2794 | fn = fm.nested('p%d' % (i + 1)) | |||
|
2795 | fn.startitem() | |||
|
2796 | fn.data(rev=p.rev()) | |||
|
2797 | fn.data(node=p.hex()) | |||
|
2798 | fn.end() | |||
2780 | else: |
|
2799 | else: | |
|
2800 | hexoutput = hexfunc(ctx.node()) | |||
2781 | if default or id: |
|
2801 | if default or id: | |
2782 |
output = [hex |
|
2802 | output = [hexoutput] | |
|
2803 | fm.data(id=hexoutput) | |||
|
2804 | ||||
2783 | if num: |
|
2805 | if num: | |
2784 | output.append(pycompat.bytestr(ctx.rev())) |
|
2806 | output.append(pycompat.bytestr(ctx.rev())) | |
2785 | taglist = ctx.tags() |
|
2807 | taglist = ctx.tags() | |
@@ -2808,7 +2830,13 b' def identify(ui, repo, source=None, rev=' | |||||
2808 | if bookmarks: |
|
2830 | if bookmarks: | |
2809 | output.extend(ctx.bookmarks()) |
|
2831 | output.extend(ctx.bookmarks()) | |
2810 |
|
2832 | |||
2811 | ui.write("%s\n" % ' '.join(output)) |
|
2833 | fm.data(node=ctx.hex()) | |
|
2834 | fm.data(branch=ctx.branch()) | |||
|
2835 | fm.data(tags=fm.formatlist(taglist, name='tag', sep=':')) | |||
|
2836 | fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name='bookmark')) | |||
|
2837 | ||||
|
2838 | fm.plain("%s\n" % ' '.join(output)) | |||
|
2839 | fm.end() | |||
2812 |
|
2840 | |||
2813 | @command('import|patch', |
|
2841 | @command('import|patch', | |
2814 | [('p', 'strip', 1, |
|
2842 | [('p', 'strip', 1, |
@@ -295,7 +295,7 b' Show all commands + options' | |||||
295 | grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, template, include, exclude |
|
295 | grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, template, include, exclude | |
296 | heads: rev, topo, active, closed, style, template |
|
296 | heads: rev, topo, active, closed, style, template | |
297 | help: extension, command, keyword, system |
|
297 | help: extension, command, keyword, system | |
298 | identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure |
|
298 | identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template | |
299 | import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity |
|
299 | import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity | |
300 | incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos |
|
300 | incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos | |
301 | locate: rev, print0, fullpath, include, exclude |
|
301 | locate: rev, print0, fullpath, include, exclude |
@@ -95,7 +95,7 b' pretxncommit and commit hooks can see bo' | |||||
95 | test generic hooks |
|
95 | test generic hooks | |
96 |
|
96 | |||
97 | $ hg id |
|
97 | $ hg id | |
98 | pre-identify hook: HG_ARGS=id HG_HOOKNAME=pre-identify HG_HOOKTYPE=pre-identify HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None} HG_PATS=[] |
|
98 | pre-identify hook: HG_ARGS=id HG_HOOKNAME=pre-identify HG_HOOKTYPE=pre-identify HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None, 'template': ''} HG_PATS=[] | |
99 | abort: pre-identify hook exited with status 1 |
|
99 | abort: pre-identify hook exited with status 1 | |
100 | [255] |
|
100 | [255] | |
101 | $ hg cat b |
|
101 | $ hg cat b |
@@ -43,12 +43,36 b' with options' | |||||
43 | cb9a9f314b8b |
|
43 | cb9a9f314b8b | |
44 | $ hg id -n -t -b -i |
|
44 | $ hg id -n -t -b -i | |
45 | cb9a9f314b8b 0 default tip |
|
45 | cb9a9f314b8b 0 default tip | |
|
46 | $ hg id -Tjson | |||
|
47 | [ | |||
|
48 | { | |||
|
49 | "bookmarks": [], | |||
|
50 | "branch": "default", | |||
|
51 | "changed": "", | |||
|
52 | "id": "cb9a9f314b8b", | |||
|
53 | "node": "ffffffffffffffffffffffffffffffffffffffff", | |||
|
54 | "p1": [{"node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b", "rev": 0}], | |||
|
55 | "tags": ["tip"] | |||
|
56 | } | |||
|
57 | ] | |||
46 |
|
58 | |||
47 | with modifications |
|
59 | with modifications | |
48 |
|
60 | |||
49 | $ echo b > a |
|
61 | $ echo b > a | |
50 | $ hg id -n -t -b -i |
|
62 | $ hg id -n -t -b -i | |
51 | cb9a9f314b8b+ 0+ default tip |
|
63 | cb9a9f314b8b+ 0+ default tip | |
|
64 | $ hg id -Tjson | |||
|
65 | [ | |||
|
66 | { | |||
|
67 | "bookmarks": [], | |||
|
68 | "branch": "default", | |||
|
69 | "changed": "+", | |||
|
70 | "id": "cb9a9f314b8b+", | |||
|
71 | "node": "ffffffffffffffffffffffffffffffffffffffff", | |||
|
72 | "p1": [{"node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b", "rev": 0}], | |||
|
73 | "tags": ["tip"] | |||
|
74 | } | |||
|
75 | ] | |||
52 |
|
76 | |||
53 | other local repo |
|
77 | other local repo | |
54 |
|
78 |
@@ -49,6 +49,19 b' Should succeed:' | |||||
49 | $ hg merge 2 |
|
49 | $ hg merge 2 | |
50 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
50 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
51 | (branch merge, don't forget to commit) |
|
51 | (branch merge, don't forget to commit) | |
|
52 | $ hg id -Tjson | |||
|
53 | [ | |||
|
54 | { | |||
|
55 | "bookmarks": [], | |||
|
56 | "branch": "default", | |||
|
57 | "changed": "+", | |||
|
58 | "id": "f25cbe84d8b3+2d95304fed5d+", | |||
|
59 | "node": "ffffffffffffffffffffffffffffffffffffffff", | |||
|
60 | "p1": [{"node": "f25cbe84d8b320e298e7703f18a25a3959518c23", "rev": 4}], | |||
|
61 | "p2": [{"node": "2d95304fed5d89bc9d70b2a0d02f0d567469c3ab", "rev": 2}], | |||
|
62 | "tags": ["tip"] | |||
|
63 | } | |||
|
64 | ] | |||
52 | $ hg commit -mm1 |
|
65 | $ hg commit -mm1 | |
53 |
|
66 | |||
54 | Should succeed - 2 heads: |
|
67 | Should succeed - 2 heads: | |
@@ -65,6 +78,17 b' Should succeed - 2 heads:' | |||||
65 | (branch merge, don't forget to commit) |
|
78 | (branch merge, don't forget to commit) | |
66 | $ hg commit -mm2 |
|
79 | $ hg commit -mm2 | |
67 |
|
80 | |||
|
81 | $ hg id -r 1 -Tjson | |||
|
82 | [ | |||
|
83 | { | |||
|
84 | "bookmarks": [], | |||
|
85 | "branch": "default", | |||
|
86 | "id": "1846eede8b68", | |||
|
87 | "node": "1846eede8b6886d8cc8a88c96a687b7fe8f3b9d1", | |||
|
88 | "tags": [] | |||
|
89 | } | |||
|
90 | ] | |||
|
91 | ||||
68 | Should fail because at tip: |
|
92 | Should fail because at tip: | |
69 |
|
93 | |||
70 | $ hg merge |
|
94 | $ hg merge |
General Comments 0
You need to be logged in to leave comments.
Login now