D1144: directaccess: add support to export and tests to demonstrate things
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Tue Oct 17 12:20:01 UTC 2017
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This patch adds the cmdtype attribute to export command which is a read only
command and adds test for accessing hidden commits using the same command.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D1144
AFFECTED FILES
mercurial/commands.py
tests/test-directaccess.t
CHANGE DETAILS
diff --git a/tests/test-directaccess.t b/tests/test-directaccess.t
new file mode 100644
--- /dev/null
+++ b/tests/test-directaccess.t
@@ -0,0 +1,68 @@
+Tests for access level on hidden commits by various commands on based of their
+type.
+
+Setting the required config to start this
+
+ $ cat >> $HGRCPATH <<EOF
+ > [experimental]
+ > evolution=createmarkers, allowunstable
+ > directaccess=True
+ > [extensions]
+ > amend =
+ > EOF
+
+ $ hg init repo
+ $ cd repo
+ $ for ch in {a..c}; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done
+
+ $ hg log -G -T '{rev}:{node} {desc}' --hidden
+ @ 2:28ad74487de9599d00d81085be739c61fc340652 Added c
+ |
+ o 1:29becc82797a4bc11ec8880b58eaecd2ab3e7760 Added b
+ |
+ o 0:18d04c59bb5d2d4090ad9a5b59bd6274adb63add Added a
+
+ $ echo "bar" >> c
+ $ hg amend
+
+ $ hg log -G -T '{rev}:{node} {desc}' --hidden
+ @ 3:2443a0e664694756d8b435d06b6ad84f941b6fc0 Added c
+ |
+ | x 2:28ad74487de9599d00d81085be739c61fc340652 Added c
+ |/
+ o 1:29becc82797a4bc11ec8880b58eaecd2ab3e7760 Added b
+ |
+ o 0:18d04c59bb5d2d4090ad9a5b59bd6274adb63add Added a
+
+Testing read only commands on the hidden revision
+
+Testing with rev number
+
+ $ hg exp 2
+ abort: hidden revision '2'!
+ (use --hidden to access hidden revisions)
+ [255]
+
+Testing with hash
+
+ $ hg exp 28ad74
+ # HG changeset patch
+ # User test
+ # Date 0 0
+ # Thu Jan 01 00:00:00 1970 +0000
+ # Node ID 28ad74487de9599d00d81085be739c61fc340652
+ # Parent 29becc82797a4bc11ec8880b58eaecd2ab3e7760
+ Added c
+
+ diff -r 29becc82797a -r 28ad74487de9 c
+ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+ +++ b/c Thu Jan 01 00:00:00 1970 +0000
+ @@ -0,0 +1,1 @@
+ +foo
+
+Make sure things with cmdtype undefined dont work with hidden commits
+
+ $ hg log -r 28ad74
+ abort: hidden revision '28ad74'!
+ (use --hidden to access hidden revisions)
+ [255]
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -61,6 +61,8 @@
release = lockmod.release
+readonly = registrar.command.readonly
+
table = {}
table.update(debugcommandsmod.command._table)
@@ -1863,7 +1865,8 @@
('', 'switch-parent', None, _('diff against the second parent')),
('r', 'rev', [], _('revisions to export'), _('REV')),
] + diffopts,
- _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
+ _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'),
+ cmdtype=readonly)
def export(ui, repo, *changesets, **opts):
"""dump the header and diffs for one or more changesets
To: pulkit, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list