Show More
@@ -0,0 +1,156 b'' | |||||
|
1 | Tests for access level on hidden commits by various commands on based of their | |||
|
2 | type. | |||
|
3 | ||||
|
4 | Setting the required config to start this | |||
|
5 | ||||
|
6 | $ cat >> $HGRCPATH <<EOF | |||
|
7 | > [experimental] | |||
|
8 | > evolution=createmarkers, allowunstable | |||
|
9 | > directaccess=True | |||
|
10 | > directaccess.revnums=True | |||
|
11 | > [extensions] | |||
|
12 | > amend = | |||
|
13 | > EOF | |||
|
14 | ||||
|
15 | $ hg init repo | |||
|
16 | $ cd repo | |||
|
17 | $ for ch in a b c; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done | |||
|
18 | ||||
|
19 | $ hg log -G -T '{rev}:{node} {desc}' --hidden | |||
|
20 | @ 2:28ad74487de9599d00d81085be739c61fc340652 Added c | |||
|
21 | | | |||
|
22 | o 1:29becc82797a4bc11ec8880b58eaecd2ab3e7760 Added b | |||
|
23 | | | |||
|
24 | o 0:18d04c59bb5d2d4090ad9a5b59bd6274adb63add Added a | |||
|
25 | ||||
|
26 | $ echo "bar" >> c | |||
|
27 | $ hg amend | |||
|
28 | ||||
|
29 | $ hg log -G -T '{rev}:{node} {desc}' --hidden | |||
|
30 | @ 3:2443a0e664694756d8b435d06b6ad84f941b6fc0 Added c | |||
|
31 | | | |||
|
32 | | x 2:28ad74487de9599d00d81085be739c61fc340652 Added c | |||
|
33 | |/ | |||
|
34 | o 1:29becc82797a4bc11ec8880b58eaecd2ab3e7760 Added b | |||
|
35 | | | |||
|
36 | o 0:18d04c59bb5d2d4090ad9a5b59bd6274adb63add Added a | |||
|
37 | ||||
|
38 | Testing read only commands on the hidden revision | |||
|
39 | ||||
|
40 | Testing with rev number | |||
|
41 | ||||
|
42 | $ hg exp 2 --config experimental.directaccess.revnums=False | |||
|
43 | abort: hidden revision '2'! | |||
|
44 | (use --hidden to access hidden revisions) | |||
|
45 | [255] | |||
|
46 | ||||
|
47 | $ hg exp 2 | |||
|
48 | # HG changeset patch | |||
|
49 | # User test | |||
|
50 | # Date 0 0 | |||
|
51 | # Thu Jan 01 00:00:00 1970 +0000 | |||
|
52 | # Node ID 28ad74487de9599d00d81085be739c61fc340652 | |||
|
53 | # Parent 29becc82797a4bc11ec8880b58eaecd2ab3e7760 | |||
|
54 | Added c | |||
|
55 | ||||
|
56 | diff -r 29becc82797a -r 28ad74487de9 c | |||
|
57 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |||
|
58 | +++ b/c Thu Jan 01 00:00:00 1970 +0000 | |||
|
59 | @@ -0,0 +1,1 @@ | |||
|
60 | +foo | |||
|
61 | ||||
|
62 | $ hg log -r 2 | |||
|
63 | changeset: 2:28ad74487de9 | |||
|
64 | user: test | |||
|
65 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
66 | obsolete: rewritten using amend as 3:2443a0e66469 | |||
|
67 | summary: Added c | |||
|
68 | ||||
|
69 | $ hg identify -r 2 | |||
|
70 | 28ad74487de9 | |||
|
71 | ||||
|
72 | $ hg status --change 2 | |||
|
73 | A c | |||
|
74 | ||||
|
75 | $ hg status --change 2 --config experimental.directaccess.revnums=False | |||
|
76 | abort: hidden revision '2'! | |||
|
77 | (use --hidden to access hidden revisions) | |||
|
78 | [255] | |||
|
79 | ||||
|
80 | $ hg diff -c 2 | |||
|
81 | diff -r 29becc82797a -r 28ad74487de9 c | |||
|
82 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |||
|
83 | +++ b/c Thu Jan 01 00:00:00 1970 +0000 | |||
|
84 | @@ -0,0 +1,1 @@ | |||
|
85 | +foo | |||
|
86 | ||||
|
87 | Testing with hash | |||
|
88 | ||||
|
89 | `hg export` | |||
|
90 | ||||
|
91 | $ hg exp 28ad74 | |||
|
92 | # HG changeset patch | |||
|
93 | # User test | |||
|
94 | # Date 0 0 | |||
|
95 | # Thu Jan 01 00:00:00 1970 +0000 | |||
|
96 | # Node ID 28ad74487de9599d00d81085be739c61fc340652 | |||
|
97 | # Parent 29becc82797a4bc11ec8880b58eaecd2ab3e7760 | |||
|
98 | Added c | |||
|
99 | ||||
|
100 | diff -r 29becc82797a -r 28ad74487de9 c | |||
|
101 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |||
|
102 | +++ b/c Thu Jan 01 00:00:00 1970 +0000 | |||
|
103 | @@ -0,0 +1,1 @@ | |||
|
104 | +foo | |||
|
105 | ||||
|
106 | `hg log` | |||
|
107 | ||||
|
108 | $ hg log -r 28ad74 | |||
|
109 | changeset: 2:28ad74487de9 | |||
|
110 | user: test | |||
|
111 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
112 | obsolete: rewritten using amend as 3:2443a0e66469 | |||
|
113 | summary: Added c | |||
|
114 | ||||
|
115 | `hg cat` | |||
|
116 | ||||
|
117 | $ hg cat -r 28ad74 c | |||
|
118 | foo | |||
|
119 | ||||
|
120 | `hg diff` | |||
|
121 | ||||
|
122 | $ hg diff -c 28ad74 | |||
|
123 | diff -r 29becc82797a -r 28ad74487de9 c | |||
|
124 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |||
|
125 | +++ b/c Thu Jan 01 00:00:00 1970 +0000 | |||
|
126 | @@ -0,0 +1,1 @@ | |||
|
127 | +foo | |||
|
128 | ||||
|
129 | `hg files` | |||
|
130 | ||||
|
131 | $ hg files -r 28ad74 | |||
|
132 | a | |||
|
133 | b | |||
|
134 | c | |||
|
135 | ||||
|
136 | `hg identify` | |||
|
137 | ||||
|
138 | $ hg identify -r 28ad74 | |||
|
139 | 28ad74487de9 | |||
|
140 | ||||
|
141 | `hg status` | |||
|
142 | ||||
|
143 | $ hg status --change 28ad74 | |||
|
144 | A c | |||
|
145 | ||||
|
146 | Commands with undefined cmdtype should not work right now | |||
|
147 | ||||
|
148 | $ hg phase -r 28ad74 | |||
|
149 | abort: hidden revision '28ad74'! | |||
|
150 | (use --hidden to access hidden revisions) | |||
|
151 | [255] | |||
|
152 | ||||
|
153 | $ hg phase -r 2 | |||
|
154 | abort: hidden revision '2'! | |||
|
155 | (use --hidden to access hidden revisions) | |||
|
156 | [255] |
@@ -1279,7 +1279,9 b' def cat(ui, repo, file1, *pats, **opts):' | |||||
1279 | Returns 0 on success. |
|
1279 | Returns 0 on success. | |
1280 | """ |
|
1280 | """ | |
1281 | opts = pycompat.byteskwargs(opts) |
|
1281 | opts = pycompat.byteskwargs(opts) | |
1282 |
|
|
1282 | rev = opts.get('rev') | |
|
1283 | repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn') | |||
|
1284 | ctx = scmutil.revsingle(repo, rev) | |||
1283 | m = scmutil.match(ctx, (file1,) + pats, opts) |
|
1285 | m = scmutil.match(ctx, (file1,) + pats, opts) | |
1284 | fntemplate = opts.pop('output', '') |
|
1286 | fntemplate = opts.pop('output', '') | |
1285 | if cmdutil.isstdiofilename(fntemplate): |
|
1287 | if cmdutil.isstdiofilename(fntemplate): | |
@@ -1840,9 +1842,11 b' def diff(ui, repo, *pats, **opts):' | |||||
1840 | msg = _('cannot specify --rev and --change at the same time') |
|
1842 | msg = _('cannot specify --rev and --change at the same time') | |
1841 | raise error.Abort(msg) |
|
1843 | raise error.Abort(msg) | |
1842 | elif change: |
|
1844 | elif change: | |
|
1845 | repo = scmutil.unhidehashlikerevs(repo, [change], 'nowarn') | |||
1843 | node2 = scmutil.revsingle(repo, change, None).node() |
|
1846 | node2 = scmutil.revsingle(repo, change, None).node() | |
1844 | node1 = repo[node2].p1().node() |
|
1847 | node1 = repo[node2].p1().node() | |
1845 | else: |
|
1848 | else: | |
|
1849 | repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn') | |||
1846 | node1, node2 = scmutil.revpair(repo, revs) |
|
1850 | node1, node2 = scmutil.revpair(repo, revs) | |
1847 |
|
1851 | |||
1848 | if reverse: |
|
1852 | if reverse: | |
@@ -1926,6 +1930,7 b' def export(ui, repo, *changesets, **opts' | |||||
1926 | changesets += tuple(opts.get('rev', [])) |
|
1930 | changesets += tuple(opts.get('rev', [])) | |
1927 | if not changesets: |
|
1931 | if not changesets: | |
1928 | changesets = ['.'] |
|
1932 | changesets = ['.'] | |
|
1933 | repo = scmutil.unhidehashlikerevs(repo, changesets, 'nowarn') | |||
1929 | revs = scmutil.revrange(repo, changesets) |
|
1934 | revs = scmutil.revrange(repo, changesets) | |
1930 | if not revs: |
|
1935 | if not revs: | |
1931 | raise error.Abort(_("export requires at least one changeset")) |
|
1936 | raise error.Abort(_("export requires at least one changeset")) | |
@@ -1989,7 +1994,9 b' def files(ui, repo, *pats, **opts):' | |||||
1989 | """ |
|
1994 | """ | |
1990 |
|
1995 | |||
1991 | opts = pycompat.byteskwargs(opts) |
|
1996 | opts = pycompat.byteskwargs(opts) | |
1992 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
|
1997 | rev = opts.get('rev') | |
|
1998 | repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn') | |||
|
1999 | ctx = scmutil.revsingle(repo, rev, None) | |||
1993 |
|
2000 | |||
1994 | end = '\n' |
|
2001 | end = '\n' | |
1995 | if opts.get('print0'): |
|
2002 | if opts.get('print0'): | |
@@ -2586,8 +2593,10 b' def heads(ui, repo, *branchrevs, **opts)' | |||||
2586 |
|
2593 | |||
2587 | opts = pycompat.byteskwargs(opts) |
|
2594 | opts = pycompat.byteskwargs(opts) | |
2588 | start = None |
|
2595 | start = None | |
2589 | if 'rev' in opts: |
|
2596 | rev = opts.get('rev') | |
2590 | start = scmutil.revsingle(repo, opts['rev'], None).node() |
|
2597 | if rev: | |
|
2598 | repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn') | |||
|
2599 | start = scmutil.revsingle(repo, rev, None).node() | |||
2591 |
|
2600 | |||
2592 | if opts.get('topo'): |
|
2601 | if opts.get('topo'): | |
2593 | heads = [repo[h] for h in repo.heads(start)] |
|
2602 | heads = [repo[h] for h in repo.heads(start)] | |
@@ -2770,6 +2779,7 b' def identify(ui, repo, source=None, rev=' | |||||
2770 | fm.data(node=hex(remoterev)) |
|
2779 | fm.data(node=hex(remoterev)) | |
2771 | fm.data(bookmarks=fm.formatlist(bms, name='bookmark')) |
|
2780 | fm.data(bookmarks=fm.formatlist(bms, name='bookmark')) | |
2772 | else: |
|
2781 | else: | |
|
2782 | repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn') | |||
2773 | ctx = scmutil.revsingle(repo, rev, None) |
|
2783 | ctx = scmutil.revsingle(repo, rev, None) | |
2774 |
|
2784 | |||
2775 | if ctx.rev() is None: |
|
2785 | if ctx.rev() is None: | |
@@ -3395,6 +3405,7 b' def log(ui, repo, *pats, **opts):' | |||||
3395 | raise error.Abort(_('graph not supported with line range patterns')) |
|
3405 | raise error.Abort(_('graph not supported with line range patterns')) | |
3396 | return cmdutil.graphlog(ui, repo, pats, opts) |
|
3406 | return cmdutil.graphlog(ui, repo, pats, opts) | |
3397 |
|
3407 | |||
|
3408 | repo = scmutil.unhidehashlikerevs(repo, opts.get('rev'), 'nowarn') | |||
3398 | revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts) |
|
3409 | revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts) | |
3399 | hunksfilter = None |
|
3410 | hunksfilter = None | |
3400 |
|
3411 | |||
@@ -3502,6 +3513,7 b' def manifest(ui, repo, node=None, rev=No' | |||||
3502 |
|
3513 | |||
3503 | char = {'l': '@', 'x': '*', '': ''} |
|
3514 | char = {'l': '@', 'x': '*', '': ''} | |
3504 | mode = {'l': '644', 'x': '755', '': '644'} |
|
3515 | mode = {'l': '644', 'x': '755', '': '644'} | |
|
3516 | repo = scmutil.unhidehashlikerevs(repo, [node], 'nowarn') | |||
3505 | ctx = scmutil.revsingle(repo, node) |
|
3517 | ctx = scmutil.revsingle(repo, node) | |
3506 | mf = ctx.manifest() |
|
3518 | mf = ctx.manifest() | |
3507 | ui.pager('manifest') |
|
3519 | ui.pager('manifest') | |
@@ -3689,7 +3701,9 b' def parents(ui, repo, file_=None, **opts' | |||||
3689 | """ |
|
3701 | """ | |
3690 |
|
3702 | |||
3691 | opts = pycompat.byteskwargs(opts) |
|
3703 | opts = pycompat.byteskwargs(opts) | |
3692 | ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
|
3704 | rev = opts.get('rev') | |
|
3705 | repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn') | |||
|
3706 | ctx = scmutil.revsingle(repo, rev, None) | |||
3693 |
|
3707 | |||
3694 | if file_: |
|
3708 | if file_: | |
3695 | m = scmutil.match(ctx, (file_,), opts) |
|
3709 | m = scmutil.match(ctx, (file_,), opts) | |
@@ -4841,9 +4855,11 b' def status(ui, repo, *pats, **opts):' | |||||
4841 | msg = _('cannot use --terse with --rev') |
|
4855 | msg = _('cannot use --terse with --rev') | |
4842 | raise error.Abort(msg) |
|
4856 | raise error.Abort(msg) | |
4843 | elif change: |
|
4857 | elif change: | |
|
4858 | repo = scmutil.unhidehashlikerevs(repo, [change], 'nowarn') | |||
4844 | node2 = scmutil.revsingle(repo, change, None).node() |
|
4859 | node2 = scmutil.revsingle(repo, change, None).node() | |
4845 | node1 = repo[node2].p1().node() |
|
4860 | node1 = repo[node2].p1().node() | |
4846 | else: |
|
4861 | else: | |
|
4862 | repo = scmutil.unhidehashlikerevs(repo, revs, 'nowarn') | |||
4847 | node1, node2 = scmutil.revpair(repo, revs) |
|
4863 | node1, node2 = scmutil.revpair(repo, revs) | |
4848 |
|
4864 | |||
4849 | if pats or ui.configbool('commands', 'status.relative'): |
|
4865 | if pats or ui.configbool('commands', 'status.relative'): |
General Comments 0
You need to be logged in to leave comments.
Login now