Patchwork D1871: test: add a test for directacces generic write message

login
register
mail settings
Submitter phabricator
Date Jan. 17, 2018, 11:41 a.m.
Message ID <differential-rev-PHID-DREV-xdlfurg3xjxjy4pxgcul-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26809/
State Superseded
Headers show

Comments

phabricator - Jan. 17, 2018, 11:41 a.m.
lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Even if no write command is using it right now, add a fake extension that
  simulate one in order to test the message and logic.
  
  We will add the obsfate message at the same place but before, we make sure
  it's tested.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-directaccess.t

CHANGE DETAILS




To: lothiraldan, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 18, 2018, 1:23 p.m.
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  I'm skeptical if the generic write message will be actually used, so let's
  revisit this later.

REPOSITORY
  rHG Mercurial

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

To: lothiraldan, #hg-reviewers, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/tests/test-directaccess.t b/tests/test-directaccess.t
--- a/tests/test-directaccess.t
+++ b/tests/test-directaccess.t
@@ -1,6 +1,23 @@ 
 Tests for access level on hidden commits by various commands on based of their
 type.
 
+  $ cat << EOF > directaccessfakewritecommand.py
+  > """A small extension that simulate a write command for directaccess
+  > """
+  > 
+  > from mercurial import error, registrar, repair, util, scmutil
+  > 
+  > cmdtable = {}
+  > command = registrar.command(cmdtable)
+  > 
+  > @command(b'writedirectaccess', [('r', 'rev', [], 'revision', 'REV')], '')
+  > def write(ui, repo, *pats, **opts):
+  >     revs = opts.get('rev')
+  >     repo = scmutil.unhidehashlikerevs(repo, revs, 'warn')
+  >     range = scmutil.revrange(repo, revs)
+  >     repo.ui.write("RANGE %s\n" % list(range))
+  > EOF
+
 Setting the required config to start this
 
   $ cat >> $HGRCPATH <<EOF
@@ -10,6 +27,7 @@ 
   > directaccess.revnums=True
   > [extensions]
   > amend =
+  > directaccessfakewritecommand = $TESTTMP/directaccessfakewritecommand.py
   > EOF
 
   $ hg init repo
@@ -188,11 +206,94 @@ 
   (use --hidden to access hidden revisions)
   [255]
 
+Test a fake write command to validate the message
+
+  $ hg log -G --hidden
+  @  changeset:   3:2443a0e66469
+  |  tag:         tip
+  |  parent:      1:29becc82797a
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Added c
+  |
+  | x  changeset:   2:28ad74487de9
+  |/   user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    obsolete:    rewritten using amend as 3:2443a0e66469
+  |    summary:     Added c
+  |
+  o  changeset:   1:29becc82797a
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Added b
+  |
+  o  changeset:   0:18d04c59bb5d
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     Added a
+  
+
+Amend a second time to test the write message on several hidden changesets
+  $ echo "babar" >> c
+  $ hg amend
+  $ hg log -G --hidden
+  @  changeset:   4:d716de383093
+  |  tag:         tip
+  |  parent:      1:29becc82797a
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Added c
+  |
+  | x  changeset:   3:2443a0e66469
+  |/   parent:      1:29becc82797a
+  |    user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    obsolete:    rewritten using amend as 4:d716de383093
+  |    summary:     Added c
+  |
+  | x  changeset:   2:28ad74487de9
+  |/   user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    obsolete:    rewritten using amend as 3:2443a0e66469
+  |    summary:     Added c
+  |
+  o  changeset:   1:29becc82797a
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     Added b
+  |
+  o  changeset:   0:18d04c59bb5d
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     Added a
+  
+
+  $ hg writedirectaccess -r 28ad74
+  warning: accessing hidden changesets for write operation: 28ad74487de9
+  RANGE [2]
+
+  $ hg writedirectaccess -r 2443a0
+  warning: accessing hidden changesets for write operation: 2443a0e66469
+  RANGE [3]
+
+  $ hg writedirectaccess -r "28ad74:2443a0"
+  warning: accessing hidden changesets for write operation: 28ad74487de9, 2443a0e66469
+  RANGE [2, 3]
+
+  $ hg writedirectaccess -r "28ad74 + 2443a0"
+  abort: hidden revision '28ad74' was rewritten as: d716de383093!
+  (use --hidden to access hidden revisions)
+  [255]
+
+  $ hg writedirectaccess -r "28ad74:d716de"
+  warning: accessing hidden changesets for write operation: 28ad74487de9
+  RANGE [2, 3, 4]
+
 Setting a bookmark will make that changeset unhidden, so this should come in end
 
   $ hg bookmarks -r 28ad74 book
   bookmarking hidden changeset 28ad74487de9
-  (hidden revision '28ad74487de9' was rewritten as: 2443a0e66469)
+  (hidden revision '28ad74487de9' was rewritten as: d716de383093)
 
   $ hg bookmarks
      book                      2:28ad74487de9