Mercurial > hg
annotate tests/fakemergerecord.py @ 31975:76169296e52f
obsolescence: add test for the "branch replacement" logic during push, case A2
Mercurial checks for the introduction of new heads on push. Evolution comes
into play to detect if existing branches on the server are being replaced by
some of the new one we push.
The current code for this logic is very basic (eg: issue4354) and was poorly
tested. We have a better implementation coming in the evolve extension fixing
these issues and with more serious tests coverage. In the process of upstreaming
this improved logic, we start with adding the test case that are already passing
with the current implementation. Once they are all in, we'll upstream the better
implementation and the extra test case.
See inline documentation for details about the test case added in this
changeset.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 13 Apr 2017 16:23:01 +0200 |
parents | b303b3817d0e |
children | 46ba2cdda476 |
rev | line source |
---|---|
27027
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
1 # Extension to write out fake unsupported records into the merge state |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
2 # |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
3 # |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
4 |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
5 from __future__ import absolute_import |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
6 |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
7 from mercurial import ( |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
8 cmdutil, |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
9 merge, |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
10 ) |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
11 |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
12 cmdtable = {} |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
13 command = cmdutil.command(cmdtable) |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
14 |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
15 @command('fakemergerecord', |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
16 [('X', 'mandatory', None, 'add a fake mandatory record'), |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
17 ('x', 'advisory', None, 'add a fake advisory record')], '') |
a01ecbcfaf84
mergestate: handle additional record types specially
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
18 def fakemergerecord(ui, repo, *pats, **opts): |
29754
b303b3817d0e
fakemergerecord: take wlock to write the merge state
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
27027
diff
changeset
|
19 with repo.wlock(): |
b303b3817d0e
fakemergerecord: take wlock to write the merge state
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
27027
diff
changeset
|
20 ms = merge.mergestate.read(repo) |
b303b3817d0e
fakemergerecord: take wlock to write the merge state
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
27027
diff
changeset
|
21 records = ms._makerecords() |
b303b3817d0e
fakemergerecord: take wlock to write the merge state
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
27027
diff
changeset
|
22 if opts.get('mandatory'): |
b303b3817d0e
fakemergerecord: take wlock to write the merge state
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
27027
diff
changeset
|
23 records.append(('X', 'mandatory record')) |
b303b3817d0e
fakemergerecord: take wlock to write the merge state
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
27027
diff
changeset
|
24 if opts.get('advisory'): |
b303b3817d0e
fakemergerecord: take wlock to write the merge state
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
27027
diff
changeset
|
25 records.append(('x', 'advisory record')) |
b303b3817d0e
fakemergerecord: take wlock to write the merge state
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
27027
diff
changeset
|
26 ms._writerecords(records) |