Patchwork D738: directaccess: add support to export and tests to demonstrate things

login
register
mail settings
Submitter phabricator
Date Oct. 11, 2017, 7:11 p.m.
Message ID <2fd365ee8dc52f8c35c2a862305b52fd@localhost.localdomain>
Download mbox | patch
Permalink /patch/24756/
State Not Applicable
Headers show

Comments

phabricator - Oct. 11, 2017, 7:11 p.m.
pulkit updated this revision to Diff 2598.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D738?vs=1906&id=2598

REVISION DETAIL
  https://phab.mercurial-scm.org/D738

AFFECTED FILES
  mercurial/commands.py
  tests/test-directaccess.t

CHANGE DETAILS




To: pulkit, #hg-reviewers, durham
Cc: durham, mercurial-devel

Patch

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,92 @@ 
+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]
+  > uncommit =
+  > amend =
+  > rebase =
+  > EOF
+
+  $ hg init repo
+  $ cd repo
+  $ for ch in {a..h}; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done
+
+  $ hg log -G -T '{rev}:{node} {desc}' --hidden
+  @  7:ec2426147f0e39dbc9cef599b066be6035ce691d Added h
+  |
+  o  6:87d6d66763085b629e6d7ed56778c79827273022 Added g
+  |
+  o  5:825660c69f0cd8d9542c1fea6e5d444c666f063b Added f
+  |
+  o  4:aa98ab95a9284d289c73a270d70c37914795a842 Added e
+  |
+  o  3:62615734edd52f06b6fb9c2beb429e4fe30d57b8 Added d
+  |
+  o  2:28ad74487de9599d00d81085be739c61fc340652 Added c
+  |
+  o  1:29becc82797a4bc11ec8880b58eaecd2ab3e7760 Added b
+  |
+  o  0:18d04c59bb5d2d4090ad9a5b59bd6274adb63add Added a
+  
+  $ echo "bar" >> h
+  $ hg amend
+
+  $ hg log -G -T '{rev}:{node} {desc}' --hidden
+  @  8:c9fa1a715c1b7661c0fafb362a9f30bd75878d7d Added h
+  |
+  | x  7:ec2426147f0e39dbc9cef599b066be6035ce691d Added h
+  |/
+  o  6:87d6d66763085b629e6d7ed56778c79827273022 Added g
+  |
+  o  5:825660c69f0cd8d9542c1fea6e5d444c666f063b Added f
+  |
+  o  4:aa98ab95a9284d289c73a270d70c37914795a842 Added e
+  |
+  o  3:62615734edd52f06b6fb9c2beb429e4fe30d57b8 Added d
+  |
+  o  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 7
+  abort: hidden revision '7'!
+  (use --hidden to access hidden revisions)
+  [255]
+
+Testing with hash
+
+  $ hg exp ec2426
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID ec2426147f0e39dbc9cef599b066be6035ce691d
+  # Parent  87d6d66763085b629e6d7ed56778c79827273022
+  Added h
+  
+  diff -r 87d6d6676308 -r ec2426147f0e h
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/h	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 rebase -s ec2426 -d .
+  abort: hidden revision 'ec2426'!
+  (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