Mercurial > hg
view tests/test-commit-multiple.t @ 37295:45b39c69fae0
wireproto: separate commands tables for version 1 and 2 commands
We can't easily reuse existing command handlers for version 2
commands because the response types will be different. e.g. many
commands return nodes encoded as hex. Our new wire protocol is
binary safe, so we'll wish to encode nodes as binary.
We /could/ teach each command handler to look at the protocol
handler and change behavior based on the version in use. However,
this would make logic a bit unwieldy over time and would make
it harder to design a unified protocol handler interface. I think
it's better to create a clean break between version 1 and version 2
of commands on the server.
What I imagine happening is we will have separate @wireprotocommand
functions for each protocol generation. Those functions will parse the
request, dispatch to a common function to process it, then generate
the response in its own, transport-specific manner.
This commit establishes a separate table for tracking version 1
commands from version 2 commands. The HTTP server pieces have been
updated to use this new table.
Most commands are marked as both version 1 and version 2, so there is
little practical impact to this change.
A side-effect of this change is we now rely on transport registration
in wireprototypes.TRANSPORTS and certain properties of the protocol
interface. So a test had to be updated to conform.
Differential Revision: https://phab.mercurial-scm.org/D2982
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 28 Mar 2018 10:40:41 -0700 |
parents | e2c0c0884b1f |
children | 5abc47d4ca6b |
line wrap: on
line source
# reproduce issue2264, issue2516 create test repo $ cat <<EOF >> $HGRCPATH > [extensions] > transplant = > EOF $ hg init repo $ cd repo $ template="{rev} {desc|firstline} [{branch}]\n" # we need to start out with two changesets on the default branch # in order to avoid the cute little optimization where transplant # pulls rather than transplants add initial changesets $ echo feature1 > file1 $ hg ci -Am"feature 1" adding file1 $ echo feature2 >> file2 $ hg ci -Am"feature 2" adding file2 # The changes to 'bugfix' are enough to show the bug: in fact, with only # those changes, it's a very noisy crash ("RuntimeError: nothing # committed after transplant"). But if we modify a second file in the # transplanted changesets, the bug is much more subtle: transplant # silently drops the second change to 'bugfix' on the floor, and we only # see it when we run 'hg status' after transplanting. Subtle data loss # bugs are worse than crashes, so reproduce the subtle case here. commit bug fixes on bug fix branch $ hg branch fixes marked working directory as branch fixes (branches are permanent and global, did you want a bookmark?) $ echo fix1 > bugfix $ echo fix1 >> file1 $ hg ci -Am"fix 1" adding bugfix $ echo fix2 > bugfix $ echo fix2 >> file1 $ hg ci -Am"fix 2" $ hg log -G --template="$template" @ 3 fix 2 [fixes] | o 2 fix 1 [fixes] | o 1 feature 2 [default] | o 0 feature 1 [default] transplant bug fixes onto release branch $ hg update 0 1 files updated, 0 files merged, 2 files removed, 0 files unresolved $ hg branch release marked working directory as branch release $ hg transplant 2 3 applying [0-9a-f]{12} (re) [0-9a-f]{12} transplanted to [0-9a-f]{12} (re) applying [0-9a-f]{12} (re) [0-9a-f]{12} transplanted to [0-9a-f]{12} (re) $ hg log -G --template="$template" @ 5 fix 2 [release] | o 4 fix 1 [release] | | o 3 fix 2 [fixes] | | | o 2 fix 1 [fixes] | | | o 1 feature 2 [default] |/ o 0 feature 1 [default] $ hg status $ hg status --rev 0:4 M file1 A bugfix $ hg status --rev 4:5 M bugfix M file1 now test that we fixed the bug for all scripts/extensions $ cat > $TESTTMP/committwice.py <<__EOF__ > from mercurial import ui, hg, match, node > from time import sleep > > def replacebyte(fn, b): > f = open(fn, "rb+") > f.seek(0, 0) > f.write(b) > f.close() > > def printfiles(repo, rev): > repo.ui.status(b"revision %d files: [%s]\n" > % (rev, b', '.join(b"'%s'" % f > for f in repo[rev].files()))) > > repo = hg.repository(ui.ui.load(), b'.') > assert len(repo) == 6, \ > "initial: len(repo): %d, expected: 6" % len(repo) > > replacebyte(b"bugfix", b"u") > sleep(2) > try: > repo.ui.status(b"PRE: len(repo): %d\n" % len(repo)) > wlock = repo.wlock() > lock = repo.lock() > replacebyte(b"file1", b"x") > repo.commit(text=b"x", user=b"test", date=(0, 0)) > replacebyte(b"file1", b"y") > repo.commit(text=b"y", user=b"test", date=(0, 0)) > repo.ui.status(b"POST: len(repo): %d\n" % len(repo)) > finally: > lock.release() > wlock.release() > printfiles(repo, 6) > printfiles(repo, 7) > __EOF__ $ $PYTHON $TESTTMP/committwice.py PRE: len(repo): 6 POST: len(repo): 8 revision 6 files: ['bugfix', 'file1'] revision 7 files: ['file1'] Do a size-preserving modification outside of that process $ echo abcd > bugfix $ hg status M bugfix $ hg log --template "{rev} {desc} {files}\n" -r5: 5 fix 2 bugfix file1 6 x bugfix file1 7 y file1 $ cd ..