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.
yuja |
hg-reviewers |
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.
Lint Skipped |
Unit Tests Skipped |
I'm skeptical if the generic write message will be actually used, so let's
revisit this later.
Path | Packages | |||
---|---|---|---|---|
M | tests/test-directaccess.t (103 lines) |
Status | Author | Revision | |
---|---|---|---|
Abandoned | lothiraldan | ||
Abandoned | lothiraldan | ||
Closed | lothiraldan | ||
Closed | lothiraldan |
Tests for access level on hidden commits by various commands on based of their | Tests for access level on hidden commits by various commands on based of their | ||||
type. | 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 | Setting the required config to start this | ||||
$ cat >> $HGRCPATH <<EOF | $ cat >> $HGRCPATH <<EOF | ||||
> [experimental] | > [experimental] | ||||
> evolution=createmarkers, allowunstable | > evolution=createmarkers, allowunstable | ||||
> directaccess=True | > directaccess=True | ||||
> directaccess.revnums=True | > directaccess.revnums=True | ||||
> [extensions] | > [extensions] | ||||
> amend = | > amend = | ||||
> directaccessfakewritecommand = $TESTTMP/directaccessfakewritecommand.py | |||||
> EOF | > EOF | ||||
$ hg init repo | $ hg init repo | ||||
$ cd repo | $ cd repo | ||||
$ for ch in a b c; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done | $ for ch in a b c; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done | ||||
$ hg log -G -T '{rev}:{node} {desc}' --hidden | $ hg log -G -T '{rev}:{node} {desc}' --hidden | ||||
@ 2:28ad74487de9599d00d81085be739c61fc340652 Added c | @ 2:28ad74487de9599d00d81085be739c61fc340652 Added c | ||||
(use --hidden to access hidden revisions) | (use --hidden to access hidden revisions) | ||||
[255] | [255] | ||||
$ hg phase -r 2 | $ hg phase -r 2 | ||||
abort: hidden revision '2' was rewritten as: 2443a0e66469! | abort: hidden revision '2' was rewritten as: 2443a0e66469! | ||||
(use --hidden to access hidden revisions) | (use --hidden to access hidden revisions) | ||||
[255] | [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 | Setting a bookmark will make that changeset unhidden, so this should come in end | ||||
$ hg bookmarks -r 28ad74 book | $ hg bookmarks -r 28ad74 book | ||||
bookmarking hidden changeset 28ad74487de9 | bookmarking hidden changeset 28ad74487de9 | ||||
(hidden revision '28ad74487de9' was rewritten as: 2443a0e66469) | (hidden revision '28ad74487de9' was rewritten as: d716de383093) | ||||
$ hg bookmarks | $ hg bookmarks | ||||
book 2:28ad74487de9 | book 2:28ad74487de9 |