annotate hgext3rd/evolve/__init__.py @ 3705:bd236590d127

wrapping: fix a silly error were we checking on module and wrapping the other ...
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 23 Apr 2018 11:44:05 +0100
parents 67d6cc7e0979
children 648552969e88
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1 # Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
2 # Logilab SA <contact@logilab.fr>
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
3 # Pierre-Yves David <pierre-yves.david@ens-lyon.org>
519
9825c7da5b54 ensure all file have a copyright notice
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 517
diff changeset
4 # Patrick Mezard <patrick@mezard.eu>
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
5 #
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
6 # This software may be used and distributed according to the terms of the
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
7 # GNU General Public License version 2 or any later version.
2032
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
8 """extends Mercurial feature related to Changeset Evolution
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
9
2292
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
10 This extension:
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
11
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
12 - provides several commands to mutate history and deal with resulting issues,
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
13 - enable the changeset-evolution feature for Mercurial,
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
14 - improves some aspect of the early implementation in Mercurial core,
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
15
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
16 Note that a version dedicated to server usage only (no local working copy) is
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
17 available as 'evolve.serveronly'.
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
18
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
19 While many feature related to changeset evolution are directly handled by core
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
20 this extensions contains significant additions recommended to any user of
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
21 changeset evolution.
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
22
2678
da2b3e5e4f69 docs: some fixes to the help text
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2667
diff changeset
23 With the extension various evolution events will display warning (new unstable
2292
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
24 changesets, obsolete working copy parent, improved error when accessing hidden
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
25 revision, etc).
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
26
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
27 In addition, the extension contains better discovery protocol for obsolescence
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
28 markers. This means less obs-markers will have to be pushed and pulled around,
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
29 speeding up such operation.
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
30
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
31 Some improvement and bug fixes available in newer version of Mercurial are also
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
32 backported to older version of Mercurial by this extension. Some older
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
33 experimental protocol are also supported for a longer time in the extensions to
f026e85bd0b2 evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2290
diff changeset
34 help people transitioning. (The extensions is currently compatible down to
3691
96cb98989d57 evolve: use in code filtered error for 4.6
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3690
diff changeset
35 Mercurial version 4.3).
2311
26d638e419df auto-push: move config help in the extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2294
diff changeset
36
2923
8c2d3c474fc6 doc: make paragraphs before example code end with "::" for reST syntax
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2895
diff changeset
37 New Config::
2311
26d638e419df auto-push: move config help in the extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2294
diff changeset
38
26d638e419df auto-push: move config help in the extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2294
diff changeset
39 [experimental]
26d638e419df auto-push: move config help in the extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2294
diff changeset
40 # Set to control the behavior when pushing draft changesets to a publishing
26d638e419df auto-push: move config help in the extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2294
diff changeset
41 # repository. Possible value:
26d638e419df auto-push: move config help in the extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2294
diff changeset
42 # * ignore: current core behavior (default)
26d638e419df auto-push: move config help in the extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2294
diff changeset
43 # * warn: proceed with the push, but issue a warning
26d638e419df auto-push: move config help in the extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2294
diff changeset
44 # * abort: abort the push
26d638e419df auto-push: move config help in the extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2294
diff changeset
45 auto-publish = ignore
26d638e419df auto-push: move config help in the extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2294
diff changeset
46
2521
29fc90b0e59c obsdiscovery: add an option to disable all obsdiscovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2504
diff changeset
47 # For some large repository with few markers, the current for obsolescence
29fc90b0e59c obsdiscovery: add an option to disable all obsdiscovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2504
diff changeset
48 # markers discovery can get in the way. You can disable it with the
29fc90b0e59c obsdiscovery: add an option to disable all obsdiscovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2504
diff changeset
49 # configuration option below. This means all pushes and pulls will
29fc90b0e59c obsdiscovery: add an option to disable all obsdiscovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2504
diff changeset
50 # re-exchange all markers every time.
29fc90b0e59c obsdiscovery: add an option to disable all obsdiscovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2504
diff changeset
51 evolution.obsdiscovery = yes
29fc90b0e59c obsdiscovery: add an option to disable all obsdiscovery
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2504
diff changeset
52
2460
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
53 Obsolescence Markers Discovery Experiment
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
54 =========================================
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
55
2550
d8a48234efad obshashrange: basic proof reading of the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2549
diff changeset
56 We are experimenting with a new protocol to discover common markers between
d8a48234efad obshashrange: basic proof reading of the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2549
diff changeset
57 local and remote repositories. This experiment is still at an early stage but
d8a48234efad obshashrange: basic proof reading of the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2549
diff changeset
58 is already raising better results than the previous version (when usable).
d8a48234efad obshashrange: basic proof reading of the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2549
diff changeset
59
d8a48234efad obshashrange: basic proof reading of the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2549
diff changeset
60 "Large" repositories (hundreds of thousand) are currently unsupported. Some key
3225
28fb347a5bf8 typos: fix typos in several locations
Kyle Lippincott <spectral@google.com>
parents: 3198
diff changeset
61 algorithm has a naive implementation with too aggressive caching, creating
2460
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
62 memory consumption issue (this will get fixed).
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
63
3225
28fb347a5bf8 typos: fix typos in several locations
Kyle Lippincott <spectral@google.com>
parents: 3198
diff changeset
64 Medium sized repositories works fine, but be prepared for a noticeable initial
2460
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
65 cache filling. for the Mercurial repository, this is around 20 seconds
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
66
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
67 The following config control the experiment::
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
68
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
69 [experimental]
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
70
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
71 # enable new discovery protocol
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
72 # (needed on both client and server)
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
73 obshashrange = yes
64cc0b059073 obshashrange: document the experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2443
diff changeset
74
3368
7310f3ef6dee caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3365
diff changeset
75 # control cache warming at the end of transaction
7310f3ef6dee caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3365
diff changeset
76 # yes: warm all caches at the end of each transaction,
7310f3ef6dee caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3365
diff changeset
77 # off: warm no caches at the end of transaction,
3369
c7fbb79cd366 caches: switch to 'auto' warming by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3368
diff changeset
78 # auto: warm cache at the end of server side transaction (default).
3368
7310f3ef6dee caches: add a 'auto' option for obshashrange cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3365
diff changeset
79 obshashrange.warm-cache = 'auto'
2475
84982b441e82 documentation: recomment using blackbox with the obshashrange experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2465
diff changeset
80
3690
44580b7e288b documentation: refer to 4.3 in the help text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3673
diff changeset
81 $ hg debugupdatecache
2715
61e73c8fe169 obshashrange: add cache warming instruction to the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2714
diff changeset
82
3690
44580b7e288b documentation: refer to 4.3 in the help text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3673
diff changeset
83 It is recommended to enable the blackbox extension. It gathers useful data about
44580b7e288b documentation: refer to 4.3 in the help text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3673
diff changeset
84 the experiment. It is shipped with Mercurial so no extra install is needed::
3691
96cb98989d57 evolve: use in code filtered error for 4.6
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3690
diff changeset
85 $ hg debugupdatecache
2715
61e73c8fe169 obshashrange: add cache warming instruction to the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2714
diff changeset
86
2678
da2b3e5e4f69 docs: some fixes to the help text
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2667
diff changeset
87 It is recommended to enable the blackbox extension. It gathers useful data about
2687
4a02781d90ce evolve: fix documentation formatting
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2678
diff changeset
88 the experiment. It is shipped with Mercurial so no extra install is needed::
2475
84982b441e82 documentation: recomment using blackbox with the obshashrange experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2465
diff changeset
89
84982b441e82 documentation: recomment using blackbox with the obshashrange experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2465
diff changeset
90 [extensions]
84982b441e82 documentation: recomment using blackbox with the obshashrange experiment
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2465
diff changeset
91 blackbox =
2493
3ee8e9a12f41 doc: add documentation about effectflag experiment
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
92
2550
d8a48234efad obshashrange: basic proof reading of the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2549
diff changeset
93 Finally some extra options are available to help tame the experimental
2687
4a02781d90ce evolve: fix documentation formatting
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2678
diff changeset
94 implementation of some of the algorithms::
2504
d95006fe4dd0 stablerange: use last recently used caching for revisions associated to ranges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2493
diff changeset
95
d95006fe4dd0 stablerange: use last recently used caching for revisions associated to ranges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2493
diff changeset
96 [experimental]
d95006fe4dd0 stablerange: use last recently used caching for revisions associated to ranges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2493
diff changeset
97 # restrict cache size to reduce memory consumption
d95006fe4dd0 stablerange: use last recently used caching for revisions associated to ranges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2493
diff changeset
98 obshashrange.lru-size = 2000 # default is 2000
d95006fe4dd0 stablerange: use last recently used caching for revisions associated to ranges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2493
diff changeset
99
2551
ecd47c63b6de obshashrange: add an option to protect from accidental activation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2550
diff changeset
100 # automatically disable obshashrange related computation and capabilities
ecd47c63b6de obshashrange: add an option to protect from accidental activation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2550
diff changeset
101 # if the repository has more than N revisions. This is meant to help large
3225
28fb347a5bf8 typos: fix typos in several locations
Kyle Lippincott <spectral@google.com>
parents: 3198
diff changeset
102 # server deployment to enable the feature on smaller repositories while
2551
ecd47c63b6de obshashrange: add an option to protect from accidental activation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2550
diff changeset
103 # ensuring no large repository will get affected.
ecd47c63b6de obshashrange: add an option to protect from accidental activation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2550
diff changeset
104 obshashrange.max-revs = 100000 # default is None
ecd47c63b6de obshashrange: add an option to protect from accidental activation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2550
diff changeset
105
2714
7eff426f999b evolve: explain how to disable markers discovery in the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2699
diff changeset
106 For very large repositories. it is currently recommended to disable obsmarkers
7eff426f999b evolve: explain how to disable markers discovery in the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2699
diff changeset
107 discovery (Make sure you follow release announcement to know when you can turn
2923
8c2d3c474fc6 doc: make paragraphs before example code end with "::" for reST syntax
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2895
diff changeset
108 it back on)::
2714
7eff426f999b evolve: explain how to disable markers discovery in the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2699
diff changeset
109
7eff426f999b evolve: explain how to disable markers discovery in the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2699
diff changeset
110 [experimental]
7eff426f999b evolve: explain how to disable markers discovery in the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2699
diff changeset
111 evolution.obsdiscovery = no
7eff426f999b evolve: explain how to disable markers discovery in the documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2699
diff changeset
112
2493
3ee8e9a12f41 doc: add documentation about effectflag experiment
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
113 Effect Flag Experiment
3ee8e9a12f41 doc: add documentation about effectflag experiment
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
114 ======================
3ee8e9a12f41 doc: add documentation about effectflag experiment
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
115
2689
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
116 Evolve also records what changed between two evolutions of a changeset. For
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
117 example, having this information is helpful to understand what changed between
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
118 an obsolete changeset and its tipmost successors.
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
119
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
120 Evolve currently records:
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
121
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
122 - Meta changes, user, date
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
123 - Tree movement, branch and parent, did the changeset moved?
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
124 - Description, was the commit description edited
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
125 - Diff, was there apart from potential diff change due to rebase a change in the diff?
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
126
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
127 These flags are lightweight and can be combined, so it's easy to see if 4
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
128 evolutions of the same changeset has just updated the description or if the
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
129 content changed and you need to review again the diff.
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
130
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
131 The effect flag recording is enabled by default in Evolve 6.4.0 so you have
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
132 nothing to do to enjoy it. Now every new evolution that you create will have
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
133 the effect flag attached.
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
134
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
135 The following config control the effect flag recording::
2493
3ee8e9a12f41 doc: add documentation about effectflag experiment
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
136
3ee8e9a12f41 doc: add documentation about effectflag experiment
Boris Feld <boris.feld@octobus.net>
parents: 2488
diff changeset
137 [experimental]
2689
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
138 # uncomment to deactivate the registration of effect flags in obs markers
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
139 # evolution.effect-flags = false
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
140
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
141 You can display the effect flags with the command obslog, so if you have a
2923
8c2d3c474fc6 doc: make paragraphs before example code end with "::" for reST syntax
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2895
diff changeset
142 changeset and you update only the message, you will see::
2689
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
143
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
144 $ hg commit -m "WIP
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
145 $ hg commit -m "A better commit message!"
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
146 $ hg obslog .
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
147 @ 8e9045855628 (3133) A better commit message!
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
148 |
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
149 x 7863a5bb5763 (3132) WIP
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
150 rewritten(description) by Boris Feld <boris.feld@octobus.net> (Fri Jun 02 12:00:24 2017 +0200) as 8e9045855628
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
151
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
152 Servers does not need to activate the effect flag recording. Effect flags that
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
153 you create will not cause interference with other clients or servers without
9e84b407fde5 doc: update effect flag documentation
Boris Feld <boris.feld@octobus.net>
parents: 2687
diff changeset
154 the effect flag recording.
2556
d5b97b5dec5b doc: document the evolve templates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2551
diff changeset
155
d5b97b5dec5b doc: document the evolve templates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2551
diff changeset
156 Templates
d5b97b5dec5b doc: document the evolve templates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2551
diff changeset
157 =========
d5b97b5dec5b doc: document the evolve templates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2551
diff changeset
158
d5b97b5dec5b doc: document the evolve templates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2551
diff changeset
159 Evolve ship several templates that you can use to have a better visibility
d5b97b5dec5b doc: document the evolve templates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2551
diff changeset
160 about your obs history:
d5b97b5dec5b doc: document the evolve templates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2551
diff changeset
161
d5b97b5dec5b doc: document the evolve templates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2551
diff changeset
162 - precursors, for each obsolete changeset show the closest visible
d5b97b5dec5b doc: document the evolve templates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2551
diff changeset
163 precursors.
3225
28fb347a5bf8 typos: fix typos in several locations
Kyle Lippincott <spectral@google.com>
parents: 3198
diff changeset
164 - successors, for each obsolete changeset show the closest visible
2556
d5b97b5dec5b doc: document the evolve templates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2551
diff changeset
165 successors. It is useful when your working directory is obsolete to see
2678
da2b3e5e4f69 docs: some fixes to the help text
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2667
diff changeset
166 what are its successors. This information can also be retrieved with the
2556
d5b97b5dec5b doc: document the evolve templates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2551
diff changeset
167 obslog command and the --all option.
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
168 - obsfate, for each obsolete changeset display a line summarizing what
3225
28fb347a5bf8 typos: fix typos in several locations
Kyle Lippincott <spectral@google.com>
parents: 3198
diff changeset
169 changed between the changeset and its successors. Depending on the
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
170 verbosity level (-q and -v) it display the changeset successors, the users
2678
da2b3e5e4f69 docs: some fixes to the help text
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2667
diff changeset
171 that created the obsmarkers and the date range of these changes.
2591
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
172
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
173 The template itself is not complex, the data are basically a list of
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
174 successortset. Each successorset is a dict with these fields:
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
175
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
176 - "verb", how did the revision changed, pruned or rewritten for the moment
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
177 - "users" a sorted list of users that have create obs marker between current
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
178 changeset and one of its successor
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
179 - "min_date" the tiniest date of the first obs marker between current
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
180 changeset and one of its successor
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
181 - "max_date" the biggest date between current changeset and one of its
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
182 successor
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
183 - "successors" a sorted list of locally know successors node ids
1991935fb603 obsfate: add a new obsfate template
Boris Feld <boris.feld@octobus.net>
parents: 2586
diff changeset
184 - "markers" the raw list of changesets.
2032
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
185 """
2049
b81d3775006b evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2048
diff changeset
186
1414
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
187 evolutionhelptext = """
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
188 Obsolescence markers make it possible to mark changesets that have been
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
189 deleted or superset in a new version of the changeset.
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
190
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
191 Unlike the previous way of handling such changes, by stripping the old
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
192 changesets from the repository, obsolescence markers can be propagated
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
193 between repositories. This allows for a safe and simple way of exchanging
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
194 mutable history and altering it after the fact. Changeset phases are
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
195 respected, such that only draft and secret changesets can be altered (see
1709
989ed2f30d41 help: fix evolution hg phases reference
timeless@gmail.com
parents: 1702
diff changeset
196 :hg:`help phases` for details).
1414
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
197
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
198 Obsolescence is tracked using "obsolete markers", a piece of metadata
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
199 tracking which changesets have been made obsolete, potential successors for
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
200 a given changeset, the moment the changeset was marked as obsolete, and the
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
201 user who performed the rewriting operation. The markers are stored
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
202 separately from standard changeset data can be exchanged without any of the
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
203 precursor changesets, preventing unnecessary exchange of obsolescence data.
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
204
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
205 The complete set of obsolescence markers describes a history of changeset
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
206 modifications that is orthogonal to the repository history of file
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
207 modifications. This changeset history allows for detection and automatic
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
208 resolution of edge cases arising from multiple users rewriting the same part
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
209 of history concurrently.
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
210
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
211 Current feature status
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
212 ======================
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
213
1710
aec233d3cafd help: fix evolution help grammar
timeless@gmail.com
parents: 1709
diff changeset
214 This feature is still in development. If you see this help, you have enabled an
1414
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
215 extension that turned this feature on.
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
216
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
217 Obsolescence markers will be exchanged between repositories that explicitly
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
218 assert support for the obsolescence feature (this can currently only be done
2782
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
219 via an extension).
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
220
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
221 Instability
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
222 ==========
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
223
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
224 (note: the vocabulary is in the process of being updated)
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
225
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
226 Rewriting changesets might introduce instability (currently 'trouble').
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
227
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
228 There are two main kinds of instability: orphaning and diverging.
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
229
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
230 Orphans are changesets left behind when their ancestors are rewritten, (currently: 'unstable').
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
231 Divergence has two variants:
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
232
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
233 * Content-divergence occurs when independent rewrites of the same changesets
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
234 lead to different results. (currently: 'divergent')
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
235
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
236 * Phase-divergence occurs when the old (obsolete) version of a changeset
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
237 becomes public. (currently: 'bumped')
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
238
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
239 If it possible to prevent local creation of orphans by using the following config::
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
240
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
241 [experimental]
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
242 evolution=createmarkers,allnewcommands,exchange
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
243
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
244 You can also enable that option explicitly::
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
245
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
246 [experimental]
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
247 evolution=createmarkers,allnewcommands,allowunstable,exchange
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
248
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
249 or simply::
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
250
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
251 [experimental]
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
252 evolution=all
2bd0b0996cfb evolve: document the various instability/troubles
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2772
diff changeset
253 """.strip()
1414
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
254
2032
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
255 import sys
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
256 import struct
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
257
1678
1247d87a738d py3: tolerate io/StringIO divergence
timeless@gmail.com
parents: 1677
diff changeset
258 try:
1247d87a738d py3: tolerate io/StringIO divergence
timeless@gmail.com
parents: 1677
diff changeset
259 import StringIO as io
1247d87a738d py3: tolerate io/StringIO divergence
timeless@gmail.com
parents: 1677
diff changeset
260 StringIO = io.StringIO
1247d87a738d py3: tolerate io/StringIO divergence
timeless@gmail.com
parents: 1677
diff changeset
261 except ImportError:
1247d87a738d py3: tolerate io/StringIO divergence
timeless@gmail.com
parents: 1677
diff changeset
262 import io
1247d87a738d py3: tolerate io/StringIO divergence
timeless@gmail.com
parents: 1677
diff changeset
263 StringIO = io.StringIO
2032
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
264
481
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
265
1825
377d94d6c889 evolve: proactively detect bad version early
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1824
diff changeset
266 try:
377d94d6c889 evolve: proactively detect bad version early
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1824
diff changeset
267 from mercurial import registrar
377d94d6c889 evolve: proactively detect bad version early
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1824
diff changeset
268 registrar.templatekeyword # new in hg-3.8
377d94d6c889 evolve: proactively detect bad version early
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1824
diff changeset
269 except ImportError:
2049
b81d3775006b evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2048
diff changeset
270 from . import metadata
2895
e4ee0b6170e9 compat: make it more clear that evolve need Mercurial >= minversion
Philippe Pepiot <phil@philpep.org>
parents: 2859
diff changeset
271 raise ImportError('evolve needs Mercurial version %s or above' %
2049
b81d3775006b evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2048
diff changeset
272 min(metadata.testedwith.split()))
1825
377d94d6c889 evolve: proactively detect bad version early
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1824
diff changeset
273
670
97ce1f801309 evolve: drop unused import
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 663
diff changeset
274 import mercurial
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
275 from mercurial import util
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
276
1834
f23a97d14895 compat: drop compat for older wireproto implementation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1833
diff changeset
277 from mercurial import obsolete
f23a97d14895 compat: drop compat for older wireproto implementation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1833
diff changeset
278 if not obsolete._enabled:
f23a97d14895 compat: drop compat for older wireproto implementation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1833
diff changeset
279 obsolete._enabled = True
617
469befc27b26 detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 616
diff changeset
280
1823
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
281 from mercurial import (
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
282 bookmarks as bookmarksmod,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
283 cmdutil,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
284 commands,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
285 context,
2465
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
286 dirstate,
1823
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
287 error,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
288 extensions,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
289 help,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
290 hg,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
291 lock as lockmod,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
292 node,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
293 patch,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
294 revset,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
295 scmutil,
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
296 )
649d7a574c3f evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1822
diff changeset
297
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
298 from mercurial.i18n import _
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
299 from mercurial.node import nullid
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
300
2041
3b6550261614 exthelper: extract into its own submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2032
diff changeset
301 from . import (
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents: 2524
diff changeset
302 compat,
2123
cf7b4ab31f0c split: move the debugcommand into a dedicated module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2122
diff changeset
303 debugcmd,
2772
394b836e475b commands: rewrite the 'evocommands' module to 'cmdrewrite'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2766
diff changeset
304 cmdrewrite,
3457
82e9f9603b1b evolvestate: rename the file to state.py and class name to cmdstate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3456
diff changeset
305 state,
3461
6475d2046f87 evolvecmd: introduce a new module to handle `hg evolve` related code
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3460
diff changeset
306 evolvecmd,
2041
3b6550261614 exthelper: extract into its own submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2032
diff changeset
307 exthelper,
2049
b81d3775006b evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2048
diff changeset
308 metadata,
2294
75996eafab43 perf: adds some cache key helper on the obsstore class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2293
diff changeset
309 obscache,
75996eafab43 perf: adds some cache key helper on the obsstore class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2293
diff changeset
310 obsexchange,
2524
d912380ec685 evolve: fix import order
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2521
diff changeset
311 obshistory,
2756
f4dd6e6d4c73 rewriteutil: create a rewriteutil module to host utility function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2755
diff changeset
312 rewriteutil,
2286
a4c5744a7b93 safeguard: add an option to disable automatic publishing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2275
diff changeset
313 safeguard,
2524
d912380ec685 evolve: fix import order
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2521
diff changeset
314 templatekw,
2047
ce39d0f9976d serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2044
diff changeset
315 utility,
2041
3b6550261614 exthelper: extract into its own submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2032
diff changeset
316 )
3b6550261614 exthelper: extract into its own submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2032
diff changeset
317
3373
3ff0da45d4c7 evolve: use compat.TROUBLES to show troubles in user interface
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3369
diff changeset
318 TROUBLES = compat.TROUBLES
2049
b81d3775006b evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2048
diff changeset
319 __version__ = metadata.__version__
b81d3775006b evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2048
diff changeset
320 testedwith = metadata.testedwith
b81d3775006b evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2048
diff changeset
321 minimumhgversion = metadata.minimumhgversion
b81d3775006b evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2048
diff changeset
322 buglink = metadata.buglink
1838
6942750831bb serveronly: deduplicate code with the main evolve extension
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1836
diff changeset
323
2032
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
324 # Flags for enabling optional parts of evolve
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
325 commandopt = 'allnewcommands'
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
326
2047
ce39d0f9976d serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2044
diff changeset
327 obsexcmsg = utility.obsexcmsg
2763
4a5b0c373e65 commands: move the touch to the 'evocommands' module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2762
diff changeset
328 shorttemplate = utility.shorttemplate
1838
6942750831bb serveronly: deduplicate code with the main evolve extension
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1836
diff changeset
329
2404
c07f752137f4 label: rename 'evolve.short_node' to 'evolve.node'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2403
diff changeset
330 colortable = {'evolve.node': 'yellow',
2337
c0ed4adf965e obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents: 2336
diff changeset
331 'evolve.user': 'green',
c0ed4adf965e obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents: 2336
diff changeset
332 'evolve.rev': 'blue',
c0ed4adf965e obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents: 2336
diff changeset
333 'evolve.short_description': '',
c0ed4adf965e obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents: 2336
diff changeset
334 'evolve.date': 'cyan',
c0ed4adf965e obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents: 2336
diff changeset
335 'evolve.current_rev': 'bold',
c0ed4adf965e obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents: 2336
diff changeset
336 'evolve.verb': '',
3501
7c8150697810 color: add some colors to evolve command itself
Boris Feld <boris.feld@octobus.net>
parents: 3484
diff changeset
337 'evolve.operation': 'bold'
2337
c0ed4adf965e obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents: 2336
diff changeset
338 }
c0ed4adf965e obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents: 2336
diff changeset
339
820
a9a66143e2ec exchange: actually use _pushkeyescape fallback
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 819
diff changeset
340 _pack = struct.pack
1597
7876ed4fceb7 evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1594
diff changeset
341 _unpack = struct.unpack
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
342
1296
23819e1d61fd evolve: add -i flag to amend command
Laurent Charignon <lcharignon@fb.com>
parents: 1281
diff changeset
343 aliases, entry = cmdutil.findcmd('commit', commands.table)
2772
394b836e475b commands: rewrite the 'evocommands' module to 'cmdrewrite'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2766
diff changeset
344 commitopts3 = cmdrewrite.commitopts3
394b836e475b commands: rewrite the 'evocommands' module to 'cmdrewrite'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2766
diff changeset
345 interactiveopt = cmdrewrite.interactiveopt
2759
3137185b1bfe rewriteutil: move the 'rewrite' function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2758
diff changeset
346 rewrite = rewriteutil.rewrite
2724
e6bc6eaa17c5 amend: extract into a 'evolve.evocommands' module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2716
diff changeset
347
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
348 # This extension contains the following code
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
349 #
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
350 # - Extension Helper code
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
351 # - Obsolescence cache
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
352 # - ...
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
353 # - Older format compat
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
354
2041
3b6550261614 exthelper: extract into its own submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2032
diff changeset
355 eh = exthelper.exthelper()
2123
cf7b4ab31f0c split: move the debugcommand into a dedicated module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2122
diff changeset
356 eh.merge(debugcmd.eh)
3470
ece5cd58147d evolve: move the evolve command to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3469
diff changeset
357 eh.merge(evolvecmd.eh)
2053
f3765c4a352a exchange: rename the module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2051
diff changeset
358 eh.merge(obsexchange.eh)
2286
a4c5744a7b93 safeguard: add an option to disable automatic publishing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2275
diff changeset
359 eh.merge(safeguard.eh)
2294
75996eafab43 perf: adds some cache key helper on the obsstore class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2293
diff changeset
360 eh.merge(obscache.eh)
2415
89a5dabbb43d obshistory: move the command into the obshistory module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2414
diff changeset
361 eh.merge(obshistory.eh)
2485
e6ecd35e99ec refactor: extract templates into a new file
Boris Feld <boris.feld@octobus.net>
parents: 2481
diff changeset
362 eh.merge(templatekw.eh)
2525
5adb8bdb935e compatibility: backport mercurial 176d1a0ce385
Boris Feld <boris.feld@octobus.net>
parents: 2524
diff changeset
363 eh.merge(compat.eh)
2772
394b836e475b commands: rewrite the 'evocommands' module to 'cmdrewrite'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2766
diff changeset
364 eh.merge(cmdrewrite.eh)
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
365 uisetup = eh.final_uisetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
366 extsetup = eh.final_extsetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
367 reposetup = eh.final_reposetup
2043
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
368 cmdtable = eh.cmdtable
3080
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3074
diff changeset
369 configtable = eh.configtable
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3074
diff changeset
370
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3074
diff changeset
371 # Configuration
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3074
diff changeset
372 eh.configitem('experimental', 'evolutioncommands')
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3074
diff changeset
373 eh.configitem('experimental', 'evolution.allnewcommands')
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3074
diff changeset
374 eh.configitem('experimental', 'prunestrip')
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3074
diff changeset
375
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3074
diff changeset
376 # hack around because we need an actual default there
3093
9c04bd928056 compat: conditionally access config item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
377 if configtable:
9c04bd928056 compat: conditionally access config item
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3080
diff changeset
378 configtable['experimental']['evolution.allnewcommands'].default = None
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
379
2465
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
380 # pre hg 4.0 compat
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
381
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
382 if not util.safehasattr(dirstate.dirstate, 'parentchange'):
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
383 import contextlib
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
384
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
385 @contextlib.contextmanager
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
386 def parentchange(self):
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
387 '''Context manager for handling dirstate parents.
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
388
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
389 If an exception occurs in the scope of the context manager,
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
390 the incoherent dirstate won't be written when wlock is
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
391 released.
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
392 '''
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
393 self._parentwriters += 1
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
394 yield
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
395 # Typically we want the "undo" step of a context manager in a
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
396 # finally block so it happens even when an exception
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
397 # occurs. In this case, however, we only want to decrement
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
398 # parentwriters if the code in the with statement exits
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
399 # normally, so we don't have a try/finally here on purpose.
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
400 self._parentwriters -= 1
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
401 dirstate.dirstate.parentchange = parentchange
479646a3873a deprecation: fix dirstate.beginparentchange deprecation warning
Boris Feld <boris.feld@octobus.net>
parents: 2460
diff changeset
402
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
403 #####################################################################
1213
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
404 ### Option configuration ###
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
405 #####################################################################
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
406
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
407 @eh.reposetup # must be the first of its kin.
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
408 def _configureoptions(ui, repo):
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
409 # If no capabilities are specified, enable everything.
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
410 # This is so existing evolve users don't need to change their config.
3185
0c64d0242ac2 config: clarify that config is only enabled on the repository is it setup for
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3155
diff changeset
411 evolveopts = repo.ui.configlist('experimental', 'evolution')
1213
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
412 if not evolveopts:
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
413 evolveopts = ['all']
3185
0c64d0242ac2 config: clarify that config is only enabled on the repository is it setup for
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3155
diff changeset
414 repo.ui.setconfig('experimental', 'evolution', evolveopts, 'evolve')
3149
79a926b557f1 compat: drop support for older exchange protocol
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3141
diff changeset
415 if obsolete.isenabled(repo, 'exchange'):
3510
3bd642f11313 legacy: respect explicit config for server.bundle1
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3483
diff changeset
416 # if no config explicitly set, disable bundle1
3bd642f11313 legacy: respect explicit config for server.bundle1
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3483
diff changeset
417 if not isinstance(repo.ui.config('server', 'bundle1'), str):
3bd642f11313 legacy: respect explicit config for server.bundle1
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3483
diff changeset
418 repo.ui.setconfig('server', 'bundle1', False)
1213
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
419
3365
911c91ce686f caches: record 'desc' attribute on transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
420 class trdescrepo(repo.__class__):
911c91ce686f caches: record 'desc' attribute on transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
421
911c91ce686f caches: record 'desc' attribute on transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
422 def transaction(self, desc, *args, **kwargs):
911c91ce686f caches: record 'desc' attribute on transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
423 tr = super(trdescrepo, self).transaction(desc, *args, **kwargs)
911c91ce686f caches: record 'desc' attribute on transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
424 tr.desc = desc
911c91ce686f caches: record 'desc' attribute on transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
425 return tr
911c91ce686f caches: record 'desc' attribute on transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
426
911c91ce686f caches: record 'desc' attribute on transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
427 repo.__class__ = trdescrepo
911c91ce686f caches: record 'desc' attribute on transaction
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3298
diff changeset
428
1226
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
429 @eh.uisetup
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
430 def _configurecmdoptions(ui):
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
431 # Unregister evolve commands if the command capability is not specified.
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
432 #
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
433 # This must be in the same function as the option configuration above to
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
434 # guarantee it happens after the above configuration, but before the
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
435 # extsetup functions.
3080
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3074
diff changeset
436 evolvecommands = ui.configlist('experimental', 'evolutioncommands', [])
1226
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
437 evolveopts = ui.configlist('experimental', 'evolution')
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
438 if evolveopts and (commandopt not in evolveopts and
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
439 'all' not in evolveopts):
1441
a4abe588d77f evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents: 1440
diff changeset
440 # We build whitelist containing the commands we want to enable
a4abe588d77f evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents: 1440
diff changeset
441 whitelist = set()
a4abe588d77f evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents: 1440
diff changeset
442 for cmd in evolvecommands:
a4abe588d77f evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents: 1440
diff changeset
443 matchingevolvecommands = [e for e in cmdtable.keys() if cmd in e]
a4abe588d77f evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents: 1440
diff changeset
444 if not matchingevolvecommands:
a4abe588d77f evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents: 1440
diff changeset
445 raise error.Abort(_('unknown command: %s') % cmd)
a4abe588d77f evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents: 1440
diff changeset
446 elif len(matchingevolvecommands) > 1:
1547
425c0700aabd check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1536
diff changeset
447 msg = _('ambiguous command specification: "%s" matches %r')
425c0700aabd check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1536
diff changeset
448 raise error.Abort(msg % (cmd, matchingevolvecommands))
1441
a4abe588d77f evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents: 1440
diff changeset
449 else:
a4abe588d77f evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents: 1440
diff changeset
450 whitelist.add(matchingevolvecommands[0])
a4abe588d77f evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents: 1440
diff changeset
451 for disabledcmd in set(cmdtable) - whitelist:
a4abe588d77f evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents: 1440
diff changeset
452 del cmdtable[disabledcmd]
1213
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
453
7118996bdf43 config: enable all obsolete options
Durham Goode <durham@fb.com>
parents: 1212
diff changeset
454 #####################################################################
805
66c02a2e8e2f prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 804
diff changeset
455 ### experimental behavior ###
66c02a2e8e2f prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 804
diff changeset
456 #####################################################################
66c02a2e8e2f prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 804
diff changeset
457
590
02cadd3dc9f4 evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 589
diff changeset
458 getrevs = obsolete.getrevs
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
459
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
460 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
461 ### Additional Utilities ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
462 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
463
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
464 # This section contains a lot of small utility function and method
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
465
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
466 # - Function to create markers
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
467 # - useful alias pstatus and pdiff (should probably go in evolve)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
468 # - "troubles" method on changectx
1661
48232457b704 Spelling: through
timeless@gmail.com
parents: 1659
diff changeset
469 # - function to travel through the obsolescence graph
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
470 # - function to find useful changeset to stabilize
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
471
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
472
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
473 ### Useful alias
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
474
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
475 @eh.uisetup
2953
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
476 def setupparentcommand(ui):
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
477
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
478 _alias, statuscmd = cmdutil.findcmd('status', commands.table)
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
479 pstatusopts = [o for o in statuscmd[1] if o[1] != 'rev']
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
480
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
481 @eh.command('pstatus', pstatusopts)
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
482 def pstatus(ui, repo, *args, **kwargs):
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
483 """show status combining committed and uncommited changes
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
484
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
485 This show the combined status of the current working copy parent commit and
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
486 the uncommitted change in the working copy itself. The status displayed
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
487 match the content of the commit that a bare :hg:`amend` will creates.
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
488
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
489 See :hg:`help status` for details."""
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
490 kwargs['rev'] = ['.^']
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
491 return statuscmd[0](ui, repo, *args, **kwargs)
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
492
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
493 _alias, diffcmd = cmdutil.findcmd('diff', commands.table)
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
494 pdiffopts = [o for o in diffcmd[1] if o[1] != 'rev']
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
495
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
496 @eh.command('pdiff', pdiffopts)
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
497 def pdiff(ui, repo, *args, **kwargs):
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
498 """show diff combining committed and uncommited changes
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
499
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
500 This show the combined diff of the current working copy parent commit and
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
501 the uncommitted change in the working copy itself. The diff displayed
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
502 match the content of the commit that a bare :hg:`amend` will creates.
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
503
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
504 See :hg:`help diff` for details."""
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
505 kwargs['rev'] = ['.^']
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
506 return diffcmd[0](ui, repo, *args, **kwargs)
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
507
b9aea9e48203 commands: upgrade pdiff and pstatus to full commands
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2952
diff changeset
508 @eh.uisetup
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
509 def _installalias(ui):
3615
1ff7ff53d81f compat: provide an explicit default value to the 'odiff' config
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3605
diff changeset
510 if ui.config('alias', 'odiff', None) is None:
949
2b2a4ab0eb68 evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents: 948
diff changeset
511 ui.setconfig('alias', 'odiff',
2032
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
512 "diff --hidden --rev 'limit(precursors(.),1)' --rev .",
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
513 'evolve')
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
514
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
515 ### Troubled revset symbol
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
516
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
517 @eh.revset('troubled()')
594
7f89b31fcb26 merge bumped rename
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 592 593
diff changeset
518 def revsettroubled(repo, subset, x):
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
519 """Changesets with troubles.
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
520 """
993
8a4a8fe50c26 evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 988
diff changeset
521 revset.getargs(x, 0, 0, 'troubled takes no arguments')
1381
61849d45d47e evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1380
diff changeset
522 troubled = set()
2845
9fc6a4615ae5 revset: unstable volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2844
diff changeset
523 troubled.update(getrevs(repo, 'orphan'))
2847
a1805a65ce21 revset: bumped volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2846
diff changeset
524 troubled.update(getrevs(repo, 'phasedivergent'))
2846
9c019996bce0 revset: divergent volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2845
diff changeset
525 troubled.update(getrevs(repo, 'contentdivergent'))
1381
61849d45d47e evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1380
diff changeset
526 troubled = revset.baseset(troubled)
61849d45d47e evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1380
diff changeset
527 troubled.sort() # set is non-ordered, enforce order
61849d45d47e evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1380
diff changeset
528 return subset & troubled
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
529
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
530 ### Obsolescence graph
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
531
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
532 # XXX SOME MAJOR CLEAN UP TO DO HERE XXX
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
533
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
534 def _precursors(repo, s):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
535 """Precursor of a changeset"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
536 cs = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
537 nm = repo.changelog.nodemap
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2838
diff changeset
538 markerbysubj = repo.obsstore.predecessors
1377
01bdeb847f81 evolve: avoid creating changectx object in _precursors
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1376
diff changeset
539 node = repo.changelog.node
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
540 for r in s:
1377
01bdeb847f81 evolve: avoid creating changectx object in _precursors
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1376
diff changeset
541 for p in markerbysubj.get(node(r), ()):
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
542 pr = nm.get(p[0])
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
543 if pr is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
544 cs.add(pr)
1383
cf62abb62941 evolve: move 'precursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1382
diff changeset
545 cs -= repo.changelog.filteredrevs # nodemap has no filtering
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
546 return cs
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
547
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
548 def _allprecursors(repo, s): # XXX we need a better naming
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
549 """transitive precursors of a subset"""
1378
a127f0f3bf5f evolve: avoid creating changectx object in _allprecursors
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1377
diff changeset
550 node = repo.changelog.node
a127f0f3bf5f evolve: avoid creating changectx object in _allprecursors
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1377
diff changeset
551 toproceed = [node(r) for r in s]
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
552 seen = set()
2840
dfad30be866c context: precursors was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2838
diff changeset
553 allsubjects = repo.obsstore.predecessors
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
554 while toproceed:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
555 nc = toproceed.pop()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
556 for mark in allsubjects.get(nc, ()):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
557 np = mark[0]
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
558 if np not in seen:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
559 seen.add(np)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
560 toproceed.append(np)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
561 nm = repo.changelog.nodemap
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
562 cs = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
563 for p in seen:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
564 pr = nm.get(p)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
565 if pr is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
566 cs.add(pr)
1384
64c8b8c27811 evolve: move 'allprecursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1383
diff changeset
567 cs -= repo.changelog.filteredrevs # nodemap has no filtering
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
568 return cs
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
569
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
570 def _successors(repo, s):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
571 """Successors of a changeset"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
572 cs = set()
1379
693cdcd809f2 evolve: avoid creating changectx object in _successors
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1378
diff changeset
573 node = repo.changelog.node
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
574 nm = repo.changelog.nodemap
590
02cadd3dc9f4 evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 589
diff changeset
575 markerbyobj = repo.obsstore.successors
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
576 for r in s:
1379
693cdcd809f2 evolve: avoid creating changectx object in _successors
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1378
diff changeset
577 for p in markerbyobj.get(node(r), ()):
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
578 for sub in p[1]:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
579 sr = nm.get(sub)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
580 if sr is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
581 cs.add(sr)
1385
c2584407afbf evolve: move 'successors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1384
diff changeset
582 cs -= repo.changelog.filteredrevs # nodemap has no filtering
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
583 return cs
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
584
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
585 def _allsuccessors(repo, s, haltonflags=0): # XXX we need a better naming
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
586 """transitive successors of a subset
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
587
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
588 haltonflags allows to provide flags which prevent the evaluation of a
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
589 marker. """
1380
43dcf62237be evolve: avoid creating changectx object in _allsuccessors
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1379
diff changeset
590 node = repo.changelog.node
43dcf62237be evolve: avoid creating changectx object in _allsuccessors
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1379
diff changeset
591 toproceed = [node(r) for r in s]
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
592 seen = set()
590
02cadd3dc9f4 evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 589
diff changeset
593 allobjects = repo.obsstore.successors
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
594 while toproceed:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
595 nc = toproceed.pop()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
596 for mark in allobjects.get(nc, ()):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
597 if mark[2] & haltonflags:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
598 continue
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
599 for sub in mark[1]:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
600 if sub == nullid:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
601 continue # should not be here!
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
602 if sub not in seen:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
603 seen.add(sub)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
604 toproceed.append(sub)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
605 nm = repo.changelog.nodemap
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
606 cs = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
607 for s in seen:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
608 sr = nm.get(s)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
609 if sr is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
610 cs.add(sr)
1386
b5eaec8a53d0 evolve: move 'allsuccessors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1385
diff changeset
611 cs -= repo.changelog.filteredrevs # nodemap has no filtering
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
612 return cs
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
613
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
614 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
615 ### Extending revset and template ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
616 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
617
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
618 # this section add several useful revset symbol not yet in core.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
619 # they are subject to changes
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
620
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
621
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
622 ### XXX I'm not sure this revset is useful
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
623 @eh.revset('suspended()')
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
624 def revsetsuspended(repo, subset, x):
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
625 """Obsolete changesets with non-obsolete descendants.
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
626 """
1307
677c5da57b9c evolve: remove unused variables
Laurent Charignon <lcharignon@fb.com>
parents: 1306
diff changeset
627 revset.getargs(x, 0, 0, 'suspended takes no arguments')
1382
c431f827f366 evolve: move 'suspended()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1381
diff changeset
628 suspended = revset.baseset(getrevs(repo, 'suspended'))
c431f827f366 evolve: move 'suspended()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1381
diff changeset
629 suspended.sort()
c431f827f366 evolve: move 'suspended()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1381
diff changeset
630 return subset & suspended
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
631
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
632
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
633 @eh.revset('precursors(set)')
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
634 def revsetprecursors(repo, subset, x):
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
635 """Immediate precursors of changesets in set.
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
636 """
1204
161b8f6e7402 evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents: 1203
diff changeset
637 s = revset.getset(repo, revset.fullreposet(repo), x)
1383
cf62abb62941 evolve: move 'precursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1382
diff changeset
638 s = revset.baseset(_precursors(repo, s))
cf62abb62941 evolve: move 'precursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1382
diff changeset
639 s.sort()
cf62abb62941 evolve: move 'precursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1382
diff changeset
640 return subset & s
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
641
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
642
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
643 @eh.revset('allprecursors(set)')
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
644 def revsetallprecursors(repo, subset, x):
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
645 """Transitive precursors of changesets in set.
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
646 """
1204
161b8f6e7402 evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents: 1203
diff changeset
647 s = revset.getset(repo, revset.fullreposet(repo), x)
1384
64c8b8c27811 evolve: move 'allprecursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1383
diff changeset
648 s = revset.baseset(_allprecursors(repo, s))
64c8b8c27811 evolve: move 'allprecursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1383
diff changeset
649 s.sort()
64c8b8c27811 evolve: move 'allprecursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1383
diff changeset
650 return subset & s
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
651
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
652
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
653 @eh.revset('successors(set)')
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
654 def revsetsuccessors(repo, subset, x):
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
655 """Immediate successors of changesets in set.
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
656 """
1204
161b8f6e7402 evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents: 1203
diff changeset
657 s = revset.getset(repo, revset.fullreposet(repo), x)
1385
c2584407afbf evolve: move 'successors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1384
diff changeset
658 s = revset.baseset(_successors(repo, s))
c2584407afbf evolve: move 'successors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1384
diff changeset
659 s.sort()
c2584407afbf evolve: move 'successors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1384
diff changeset
660 return subset & s
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
661
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
662 @eh.revset('allsuccessors(set)')
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
663 def revsetallsuccessors(repo, subset, x):
2925
9efedcedd9dd evolve: use registrar.revsetpredicate to register revset predicate functions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 2923
diff changeset
664 """Transitive successors of changesets in set.
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
665 """
1204
161b8f6e7402 evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents: 1203
diff changeset
666 s = revset.getset(repo, revset.fullreposet(repo), x)
1386
b5eaec8a53d0 evolve: move 'allsuccessors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1385
diff changeset
667 s = revset.baseset(_allsuccessors(repo, s))
b5eaec8a53d0 evolve: move 'allsuccessors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1385
diff changeset
668 s.sort()
b5eaec8a53d0 evolve: move 'allsuccessors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1385
diff changeset
669 return subset & s
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
670
1399
9ff6d9240f16 template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 949
diff changeset
671
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
672 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
673 ### Various trouble warning ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
674 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
675
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
676 # This section take care of issue warning to the user when troubles appear
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
677
3363
380fa6e8baf2 evolve: don't show working directory obsolete message if we were on it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3362
diff changeset
678 def _warnobsoletewc(ui, repo, prevnode=None, wasobs=None):
2289
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
679 rev = repo['.']
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
680
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
681 if not rev.obsolete():
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
682 return
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
683
3363
380fa6e8baf2 evolve: don't show working directory obsolete message if we were on it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3362
diff changeset
684 if rev.node() == prevnode and wasobs:
380fa6e8baf2 evolve: don't show working directory obsolete message if we were on it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3362
diff changeset
685 return
2289
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
686 msg = _("working directory parent is obsolete! (%s)\n")
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
687 shortnode = node.short(rev.node())
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
688
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
689 ui.warn(msg % shortnode)
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
690
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
691 # Check that evolve is activated for performance reasons
3455
f7ecb11d71bb update: show "use 'hg evolve' to..." hint iff evolve command enabled
Martin von Zweigbergk <martinvonz@google.com>
parents: 3427
diff changeset
692 evolvecommandenabled = any('evolve' in e for e in cmdtable)
f7ecb11d71bb update: show "use 'hg evolve' to..." hint iff evolve command enabled
Martin von Zweigbergk <martinvonz@google.com>
parents: 3427
diff changeset
693 if ui.quiet or not evolvecommandenabled:
2289
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
694 return
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
695
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
696 # Show a warning for helping the user to solve the issue
2488
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2485
diff changeset
697 reason, successors = obshistory._getobsfateandsuccs(repo, rev.node())
2289
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
698
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
699 if reason == 'pruned':
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
700 solvemsg = _("use 'hg evolve' to update to its parent successor")
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
701 elif reason == 'diverged':
3154
406992d0d611 evolve: rename --contentdivergent flag to --content-divergent
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3149
diff changeset
702 debugcommand = "hg evolve --list --content-divergent"
2289
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
703 basemsg = _("%s has diverged, use '%s' to resolve the issue")
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
704 solvemsg = basemsg % (shortnode, debugcommand)
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
705 elif reason == 'superseed':
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
706 msg = _("use 'hg evolve' to update to its successor: %s")
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
707 solvemsg = msg % successors[0]
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
708 elif reason == 'superseed_split':
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
709 msg = _("use 'hg evolve' to update to its tipmost successor: %s")
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
710
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
711 if len(successors) <= 2:
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
712 solvemsg = msg % ", ".join(successors)
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
713 else:
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
714 firstsuccessors = ", ".join(successors[:2])
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
715 remainingnumber = len(successors) - 2
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
716 successorsmsg = _("%s and %d more") % (firstsuccessors, remainingnumber)
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
717 solvemsg = msg % successorsmsg
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
718 else:
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
719 raise ValueError(reason)
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
720
61d073590fb7 ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents: 2286
diff changeset
721 ui.warn("(%s)\n" % solvemsg)
1527
e080d2ae2656 parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1519
diff changeset
722
3691
96cb98989d57 evolve: use in code filtered error for 4.6
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3690
diff changeset
723 if util.safehasattr(context, '_filterederror'): # <= hg-4.5
3705
bd236590d127 wrapping: fix a silly error were we checking on module and wrapping the other
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3699
diff changeset
724 @eh.wrapfunction(context, '_filterederror')
2293
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
725 def evolve_filtererror(original, repo, changeid):
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
726 """build an exception to be raised about a filtered changeid
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
727
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
728 This is extracted in a function to help extensions (eg: evolve) to
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
729 experiment with various message variants."""
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
730 if repo.filtername.startswith('visible'):
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
731
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
732 unfilteredrepo = repo.unfiltered()
3691
96cb98989d57 evolve: use in code filtered error for 4.6
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3690
diff changeset
733 rev = repo[scmutil.revsingle(unfilteredrepo, changeid)]
2488
1bdbe8f55339 refactor: extract obs fate algorithm from _getobsoletereason
Boris Feld <boris.feld@octobus.net>
parents: 2485
diff changeset
734 reason, successors = obshistory._getobsfateandsuccs(unfilteredrepo, rev.node())
2293
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
735
3691
96cb98989d57 evolve: use in code filtered error for 4.6
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3690
diff changeset
736 # Be more precise in case the revision is superseed
2293
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
737 if reason == 'superseed':
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
738 reason = _("successor: %s") % successors[0]
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
739 elif reason == 'superseed_split':
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
740 if len(successors) <= 2:
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
741 reason = _("successors: %s") % ", ".join(successors)
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
742 else:
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
743 firstsuccessors = ", ".join(successors[:2])
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
744 remainingnumber = len(successors) - 2
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
745 successorsmsg = _("%s and %d more") % (firstsuccessors, remainingnumber)
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
746 reason = _("successors: %s") % successorsmsg
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
747
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
748 msg = _("hidden revision '%s'") % changeid
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
749 hint = _('use --hidden to access hidden revisions; %s') % reason
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
750 return error.FilteredRepoLookupError(msg, hint=hint)
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
751 msg = _("filtered revision '%s' (not in '%s' subset)")
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
752 msg %= (changeid, repo.filtername)
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
753 return error.FilteredRepoLookupError(msg)
1659b42c28c2 compat: only install the better filtered message for mercurial 4.2 and above
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2292
diff changeset
754
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
755 @eh.wrapcommand("update")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
756 @eh.wrapcommand("pull")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
757 def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
758 """Warn that the working directory parent is an obsolete changeset"""
3363
380fa6e8baf2 evolve: don't show working directory obsolete message if we were on it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3362
diff changeset
759 ctx = repo['.']
380fa6e8baf2 evolve: don't show working directory obsolete message if we were on it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3362
diff changeset
760 node = ctx.node()
380fa6e8baf2 evolve: don't show working directory obsolete message if we were on it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3362
diff changeset
761 isobs = ctx.obsolete()
380fa6e8baf2 evolve: don't show working directory obsolete message if we were on it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3362
diff changeset
762
1452
1bcbd14cf159 merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1451
diff changeset
763 def warnobsolete():
3363
380fa6e8baf2 evolve: don't show working directory obsolete message if we were on it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3362
diff changeset
764 _warnobsoletewc(ui, repo, node, isobs)
1452
1bcbd14cf159 merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1451
diff changeset
765 wlock = None
1bcbd14cf159 merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1451
diff changeset
766 try:
1bcbd14cf159 merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1451
diff changeset
767 wlock = repo.wlock()
1bcbd14cf159 merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1451
diff changeset
768 repo._afterlock(warnobsolete)
1bcbd14cf159 merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1451
diff changeset
769 res = origfn(ui, repo, *args, **opts)
1bcbd14cf159 merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1451
diff changeset
770 finally:
1bcbd14cf159 merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1451
diff changeset
771 lockmod.release(wlock)
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
772 return res
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
773
1527
e080d2ae2656 parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1519
diff changeset
774 @eh.wrapcommand("parents")
e080d2ae2656 parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1519
diff changeset
775 def wrapparents(origfn, ui, repo, *args, **opts):
e080d2ae2656 parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1519
diff changeset
776 res = origfn(ui, repo, *args, **opts)
e080d2ae2656 parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1519
diff changeset
777 _warnobsoletewc(ui, repo)
e080d2ae2656 parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1519
diff changeset
778 return res
e080d2ae2656 parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1519
diff changeset
779
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
780 # XXX this could wrap transaction code
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
781 # XXX (but this is a bit a layer violation)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
782 @eh.wrapcommand("commit")
763
966e2659e989 import: warn about new unstable changesets
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 762
diff changeset
783 @eh.wrapcommand("import")
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
784 @eh.wrapcommand("push")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
785 @eh.wrapcommand("pull")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
786 @eh.wrapcommand("graft")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
787 @eh.wrapcommand("phase")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
788 @eh.wrapcommand("unbundle")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
789 def warnobserrors(orig, ui, repo, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
790 """display warning is the command resulted in more instable changeset"""
3427
cbeee8d31d58 trouble-reports: yield to in code reporting of new troubles
Martin von Zweigbergk <martinvonz@google.com>
parents: 3395
diff changeset
791 # hg < 4.4 does not have the feature built in. bail out otherwise.
cbeee8d31d58 trouble-reports: yield to in code reporting of new troubles
Martin von Zweigbergk <martinvonz@google.com>
parents: 3395
diff changeset
792 if util.safehasattr(scmutil, '_reportstroubledchangesets'):
cbeee8d31d58 trouble-reports: yield to in code reporting of new troubles
Martin von Zweigbergk <martinvonz@google.com>
parents: 3395
diff changeset
793 return orig(ui, repo, *args, **kwargs)
cbeee8d31d58 trouble-reports: yield to in code reporting of new troubles
Martin von Zweigbergk <martinvonz@google.com>
parents: 3395
diff changeset
794
658
2a2b8c95bb43 evolve: remove revset calls in warnobserror
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 657
diff changeset
795 # part of the troubled stuff may be filtered (stash ?)
2a2b8c95bb43 evolve: remove revset calls in warnobserror
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 657
diff changeset
796 # This needs a better implementation but will probably wait for core.
2a2b8c95bb43 evolve: remove revset calls in warnobserror
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 657
diff changeset
797 filtered = repo.changelog.filteredrevs
2845
9fc6a4615ae5 revset: unstable volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2844
diff changeset
798 priorunstables = len(set(getrevs(repo, 'orphan')) - filtered)
2847
a1805a65ce21 revset: bumped volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2846
diff changeset
799 priorbumpeds = len(set(getrevs(repo, 'phasedivergent')) - filtered)
2846
9c019996bce0 revset: divergent volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2845
diff changeset
800 priordivergents = len(set(getrevs(repo, 'contentdivergent')) - filtered)
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
801 ret = orig(ui, repo, *args, **kwargs)
658
2a2b8c95bb43 evolve: remove revset calls in warnobserror
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 657
diff changeset
802 filtered = repo.changelog.filteredrevs
949
2b2a4ab0eb68 evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents: 948
diff changeset
803 newunstables = \
2845
9fc6a4615ae5 revset: unstable volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2844
diff changeset
804 len(set(getrevs(repo, 'orphan')) - filtered) - priorunstables
949
2b2a4ab0eb68 evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents: 948
diff changeset
805 newbumpeds = \
2847
a1805a65ce21 revset: bumped volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2846
diff changeset
806 len(set(getrevs(repo, 'phasedivergent')) - filtered) - priorbumpeds
949
2b2a4ab0eb68 evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents: 948
diff changeset
807 newdivergents = \
2846
9c019996bce0 revset: divergent volatile set was deprecated
Boris Feld <boris.feld@octobus.net>
parents: 2845
diff changeset
808 len(set(getrevs(repo, 'contentdivergent')) - filtered) - priordivergents
2854
66796d7b5415 warning: rename unstable warning message
Boris Feld <boris.feld@octobus.net>
parents: 2847
diff changeset
809
66796d7b5415 warning: rename unstable warning message
Boris Feld <boris.feld@octobus.net>
parents: 2847
diff changeset
810 base_msg = _('%i new %s changesets\n')
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
811 if newunstables > 0:
2854
66796d7b5415 warning: rename unstable warning message
Boris Feld <boris.feld@octobus.net>
parents: 2847
diff changeset
812 ui.warn(base_msg % (newunstables, compat.TROUBLES['ORPHAN']))
593
26f76b38f879 evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 588
diff changeset
813 if newbumpeds > 0:
2855
1db0137297f4 warning: rename bumped warning message
Boris Feld <boris.feld@octobus.net>
parents: 2854
diff changeset
814 ui.warn(base_msg % (newbumpeds, compat.TROUBLES['PHASEDIVERGENT']))
586
f01721161532 evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 585
diff changeset
815 if newdivergents > 0:
2857
0c286d054bcd warning: use 'divergent', not 'contentdivergent' on old Mercurial
Martin von Zweigbergk <martinvonz@google.com>
parents: 2856
diff changeset
816 ui.warn(base_msg % (newdivergents, compat.TROUBLES['CONTENTDIVERGENT']))
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
817 return ret
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
818
1122
c8750f4388c8 evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents: 1120
diff changeset
819 @eh.wrapfunction(mercurial.exchange, 'push')
c8750f4388c8 evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents: 1120
diff changeset
820 def push(orig, repo, *args, **opts):
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
821 """Add a hint for "hg evolve" when troubles make push fails
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
822 """
1122
c8750f4388c8 evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents: 1120
diff changeset
823 try:
c8750f4388c8 evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents: 1120
diff changeset
824 return orig(repo, *args, **opts)
1547
425c0700aabd check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1536
diff changeset
825 except error.Abort as ex:
1122
c8750f4388c8 evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents: 1120
diff changeset
826 hint = _("use 'hg evolve' to get a stable history "
c8750f4388c8 evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents: 1120
diff changeset
827 "or --force to ignore warnings")
c8750f4388c8 evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents: 1120
diff changeset
828 if (len(ex.args) >= 1
c8750f4388c8 evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents: 1120
diff changeset
829 and ex.args[0].startswith('push includes ')
c8750f4388c8 evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents: 1120
diff changeset
830 and ex.hint is None):
c8750f4388c8 evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents: 1120
diff changeset
831 ex.hint = hint
c8750f4388c8 evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents: 1120
diff changeset
832 raise
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
833
788
e973dd5bf583 evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents: 776
diff changeset
834 def summaryhook(ui, repo):
3457
82e9f9603b1b evolvestate: rename the file to state.py and class name to cmdstate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3456
diff changeset
835 evolvestate = state.cmdstate(repo)
82e9f9603b1b evolvestate: rename the file to state.py and class name to cmdstate
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3456
diff changeset
836 if evolvestate:
1640
bbf897714e70 evolve: add --continue note to summary
timeless@gmail.com
parents: 1639
diff changeset
837 # i18n: column positioning for "hg summary"
3198
390c87f8c65d summaryhook: respect -q flag
Martin von Zweigbergk <martinvonz@google.com>
parents: 3197
diff changeset
838 ui.status(_('evolve: (evolve --continue)\n'))
788
e973dd5bf583 evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents: 776
diff changeset
839
e973dd5bf583 evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents: 776
diff changeset
840 @eh.extsetup
e973dd5bf583 evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents: 776
diff changeset
841 def obssummarysetup(ui):
e973dd5bf583 evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents: 776
diff changeset
842 cmdutil.summaryhooks.add('evolve', summaryhook)
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
843
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
844
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
845 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
846 ### Core Other extension compat ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
847 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
848
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
849
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
850 @eh.extsetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
851 def _rebasewrapping(ui):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
852 # warning about more obsolete
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
853 try:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
854 rebase = extensions.find('rebase')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
855 if rebase:
572
dc107acd0bd2 adapt to core rebase support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 571
diff changeset
856 extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors)
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
857 except KeyError:
1547
425c0700aabd check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1536
diff changeset
858 pass # rebase not found
678
718262019c6f evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 677
diff changeset
859 try:
718262019c6f evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 677
diff changeset
860 histedit = extensions.find('histedit')
718262019c6f evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 677
diff changeset
861 if histedit:
718262019c6f evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 677
diff changeset
862 extensions.wrapcommand(histedit.cmdtable, 'histedit', warnobserrors)
718262019c6f evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 677
diff changeset
863 except KeyError:
1575
0c8548df67fe merge with stable
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1568 1574
diff changeset
864 pass # histedit not found
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
865
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
866 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
867 ### Old Evolve extension content ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
868 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
869
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
870 ### new command
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
871 #############################
716
4c0f6d555032 prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents: 715
diff changeset
872
953
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
873 @eh.uisetup
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
874 def _installimportobsolete(ui):
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
875 entry = cmdutil.findcmd('import', commands.table)[1]
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
876 entry[1].append(('', 'obsolete', False,
1162
5c07f464981e help: fix typo in help for 'obsolete' option added to import command
Mike Edgar <adgar@google.com>
parents: 1160
diff changeset
877 _('mark the old node as obsoleted by '
953
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
878 'the created commit')))
930
cac35bef8aee import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 927
diff changeset
879
3672
f4d5ef9ba074 import: grab the expected node value on the fly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3671
diff changeset
880 def _getnodefrompatch(patch, dest):
f4d5ef9ba074 import: grab the expected node value on the fly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3671
diff changeset
881 patchnode = patch.get('nodeid')
f4d5ef9ba074 import: grab the expected node value on the fly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3671
diff changeset
882 if patchnode is not None:
f4d5ef9ba074 import: grab the expected node value on the fly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3671
diff changeset
883 dest['node'] = node.bin(patchnode)
f4d5ef9ba074 import: grab the expected node value on the fly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3671
diff changeset
884
953
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
885 @eh.wrapfunction(mercurial.cmdutil, 'tryimportone')
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
886 def tryimportone(orig, ui, repo, hunk, parents, opts, *args, **kwargs):
3671
c82f0d5740b4 import: use a less direct approach to store the expected node
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3662
diff changeset
887 expected = {'node': None}
3673
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
888 if not util.safehasattr(hunk, 'get'): # hg < 4.6
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
889 oldextract = patch.extract
3672
f4d5ef9ba074 import: grab the expected node value on the fly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3671
diff changeset
890
3673
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
891 def extract(*args, **kwargs):
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
892 ret = oldextract(*args, **kwargs)
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
893 _getnodefrompatch(ret, expected)
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
894 return ret
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
895 try:
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
896 patch.extract = extract
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
897 ret = orig(ui, repo, hunk, parents, opts, *args, **kwargs)
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
898 finally:
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
899 patch.extract = oldextract
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
900 else:
9c12b6520a20 import: adapt to fd1dd79cff20
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3672
diff changeset
901 _getnodefrompatch(hunk, expected)
953
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
902 ret = orig(ui, repo, hunk, parents, opts, *args, **kwargs)
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
903 created = ret[1]
3671
c82f0d5740b4 import: use a less direct approach to store the expected node
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3662
diff changeset
904 if (opts['obsolete'] and None not in (created, expected['node'])
c82f0d5740b4 import: use a less direct approach to store the expected node
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3662
diff changeset
905 and created != expected['node']):
953
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
906 tr = repo.transaction('import-obs')
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
907 try:
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
908 metadata = {'user': ui.username()}
3671
c82f0d5740b4 import: use a less direct approach to store the expected node
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3662
diff changeset
909 repo.obsstore.create(tr, expected['node'], (created,),
953
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
910 metadata=metadata)
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
911 tr.close()
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
912 finally:
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
913 tr.release()
a02e5916a7e3 import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 952
diff changeset
914 return ret
930
cac35bef8aee import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 927
diff changeset
915
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
916
894
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
917 def _deprecatealias(oldalias, newalias):
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
918 '''Deprecates an alias for a command in favour of another
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
919
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
920 Creates a new entry in the command table for the old alias. It creates a
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
921 wrapper that has its synopsis set to show that is has been deprecated.
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
922 The documentation will be replace with a pointer to the new alias.
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
923 If a user invokes the command a deprecation warning will be printed and
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
924 the command of the *new* alias will be invoked.
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
925
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
926 This function is loosely based on the extensions.wrapcommand function.
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
927 '''
1226
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
928 try:
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
929 aliases, entry = cmdutil.findcmd(newalias, cmdtable)
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
930 except error.UnknownCommand:
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
931 # Commands may be disabled
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
932 return
1680
7caa5f2040c5 py3: use items() instead of iteritems()
timeless@gmail.com
parents: 1679
diff changeset
933 for alias, e in cmdtable.items():
894
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
934 if e is entry:
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
935 break
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
936
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
937 synopsis = '(DEPRECATED)'
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
938 if len(entry) > 2:
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
939 fn, opts, _syn = entry
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
940 else:
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
941 fn, opts, = entry
1496
62aa11956a40 evolve: _() should not contain %
timeless@mozdev.org
parents: 1495
diff changeset
942 deprecationwarning = _('%s have been deprecated in favor of %s\n') % (
62aa11956a40 evolve: _() should not contain %
timeless@mozdev.org
parents: 1495
diff changeset
943 oldalias, newalias)
2032
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
944
894
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
945 def newfn(*args, **kwargs):
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
946 ui = args[0]
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
947 ui.warn(deprecationwarning)
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
948 util.checksignature(fn)(*args, **kwargs)
2952
f1bbc536602a gup/gdown: properly mark these commands as deprecated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2925
diff changeset
949 newfn.__doc__ = deprecationwarning + ' (DEPRECATED)'
2043
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
950 cmdwrapper = eh.command(oldalias, opts, synopsis)
894
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
951 cmdwrapper(newfn)
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
952
895
17ac69db9329 evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents: 894
diff changeset
953 @eh.extsetup
17ac69db9329 evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents: 894
diff changeset
954 def deprecatealiases(ui):
17ac69db9329 evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents: 894
diff changeset
955 _deprecatealias('gup', 'next')
17ac69db9329 evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents: 894
diff changeset
956 _deprecatealias('gdown', 'previous')
894
4f21a3279a60 evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents: 890
diff changeset
957
2745
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
958 def _gettopic(ctx):
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
959 """handle topic fetching with or without the extension"""
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
960 return getattr(ctx, 'topic', lambda: '')()
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
961
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
962 def _gettopicidx(ctx):
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
963 """handle topic fetching with or without the extension"""
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
964 return getattr(ctx, 'topicidx', lambda: None)()
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
965
2742
64fb1a082f58 prev: add '_getcurrenttopic' helper and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2741
diff changeset
966 def _getcurrenttopic(repo):
64fb1a082f58 prev: add '_getcurrenttopic' helper and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2741
diff changeset
967 return getattr(repo, 'currenttopic', '')
64fb1a082f58 prev: add '_getcurrenttopic' helper and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2741
diff changeset
968
2736
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
969 def _prevupdate(repo, displayer, target, bookmark, dryrun):
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
970 if dryrun:
3583
944a8c27d27b __init__: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3574
diff changeset
971 repo.ui.write(_('hg update %s;\n') % target)
2736
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
972 if bookmark is not None:
3583
944a8c27d27b __init__: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3574
diff changeset
973 repo.ui.write(_('hg bookmark %s -r %s;\n')
944a8c27d27b __init__: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3574
diff changeset
974 % (bookmark, target))
2736
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
975 else:
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
976 ret = hg.update(repo, target.rev())
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
977 if not ret:
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
978 tr = lock = None
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
979 try:
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
980 lock = repo.lock()
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
981 tr = repo.transaction('previous')
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
982 if bookmark is not None:
2752
4457aa1d81aa compat: add a compatibility layer for bookmark move
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2748
diff changeset
983 bmchanges = [(bookmark, target.node())]
3699
67d6cc7e0979 compat: drop compatibility layer for bookmark.applychanges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3694
diff changeset
984 repo._bookmarks.applychanges(repo, tr, bmchanges)
2736
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
985 else:
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
986 bookmarksmod.deactivate(repo)
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
987 tr.close()
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
988 finally:
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
989 lockmod.release(tr, lock)
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
990
3196
94e5235e95f5 evolve: make prev/next respect --quiet flag (issue5742)
Martin von Zweigbergk <martinvonz@google.com>
parents: 3185
diff changeset
991 if not repo.ui.quiet:
94e5235e95f5 evolve: make prev/next respect --quiet flag (issue5742)
Martin von Zweigbergk <martinvonz@google.com>
parents: 3185
diff changeset
992 displayer.show(target)
2739
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
993
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
994 def _findprevtarget(repo, displayer, movebookmark=False, topic=True):
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
995 target = bookmark = None
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
996 wkctx = repo[None]
2741
51d669b16fa8 prev: explicitly use 'p1' as a variable name
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2739
diff changeset
997 p1 = wkctx.parents()[0]
51d669b16fa8 prev: explicitly use 'p1' as a variable name
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2739
diff changeset
998 parents = p1.parents()
2742
64fb1a082f58 prev: add '_getcurrenttopic' helper and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2741
diff changeset
999 currenttopic = _getcurrenttopic(repo)
2745
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
1000
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
1001 # we do not filter in the 1 case to allow prev to t0
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
1002 if currenttopic and topic and _gettopicidx(p1) != 1:
3468
a3052824101d evolve: move builddependencies() and _singlesuccessor() to utility module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3467
diff changeset
1003 parents = [repo[utility._singlesuccessor(repo, ctx)] if ctx.mutable() else ctx
3362
92b414710d2e prev: jump to parent's successor if parent is obsolete and topic is involved
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3232
diff changeset
1004 for ctx in parents]
2739
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1005 parents = [ctx for ctx in parents if ctx.topic() == currenttopic]
2741
51d669b16fa8 prev: explicitly use 'p1' as a variable name
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2739
diff changeset
1006
51d669b16fa8 prev: explicitly use 'p1' as a variable name
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2739
diff changeset
1007 # issue message for the various case
51d669b16fa8 prev: explicitly use 'p1' as a variable name
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2739
diff changeset
1008 if p1.node() == node.nullid:
2739
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1009 repo.ui.warn(_('already at repository root\n'))
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1010 elif not parents and currenttopic:
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1011 repo.ui.warn(_('no parent in topic "%s"\n') % currenttopic)
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1012 repo.ui.warn(_('(do you want --no-topic)\n'))
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1013 elif len(parents) == 1:
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1014 target = parents[0]
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1015 bookmark = None
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1016 if movebookmark:
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1017 bookmark = repo._activebookmark
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1018 else:
3551
ce346c6165c6 prev: prompt user to choose parent in case of multiple parents
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3550
diff changeset
1019 header = _("multiple parents, choose one to update:")
ce346c6165c6 prev: prompt user to choose parent in case of multiple parents
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3550
diff changeset
1020 prevs = [p.rev() for p in parents]
ce346c6165c6 prev: prompt user to choose parent in case of multiple parents
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3550
diff changeset
1021 choosedrev = utility.revselectionprompt(repo.ui, repo, prevs, header)
ce346c6165c6 prev: prompt user to choose parent in case of multiple parents
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3550
diff changeset
1022 if choosedrev is None:
ce346c6165c6 prev: prompt user to choose parent in case of multiple parents
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3550
diff changeset
1023 for p in parents:
ce346c6165c6 prev: prompt user to choose parent in case of multiple parents
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3550
diff changeset
1024 displayer.show(p)
ce346c6165c6 prev: prompt user to choose parent in case of multiple parents
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3550
diff changeset
1025 repo.ui.warn(_('multiple parents, explicitly update to one\n'))
ce346c6165c6 prev: prompt user to choose parent in case of multiple parents
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3550
diff changeset
1026 else:
ce346c6165c6 prev: prompt user to choose parent in case of multiple parents
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3550
diff changeset
1027 target = repo[choosedrev]
2739
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1028 return target, bookmark
2736
3c87d5276394 prev: extract the function performing the update
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2735
diff changeset
1029
2043
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1030 @eh.command(
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1031 '^previous',
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1032 [('B', 'move-bookmark', False,
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1033 _('move active bookmark after update')),
3574
8aba29d8b133 previous/next: add -m short form for --merge
Martin von Zweigbergk <martinvonz@google.com>
parents: 3561
diff changeset
1034 ('m', 'merge', False, _('bring uncommitted change along')),
2043
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1035 ('', 'no-topic', False, _('ignore topic and move topologically')),
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1036 ('n', 'dry-run', False,
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1037 _('do not perform actions, just print what would be done'))],
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1038 '[OPTION]...')
1160
e29a813f6af5 Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents: 1157
diff changeset
1039 def cmdprevious(ui, repo, **opts):
1572
44e9c0a264de evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents: 1571
diff changeset
1040 """update to parent revision
44e9c0a264de evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents: 1571
diff changeset
1041
44e9c0a264de evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents: 1571
diff changeset
1042 Displays the summary line of the destination for clarity."""
1742
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1043 wlock = None
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1044 dryrunopt = opts['dry_run']
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1045 if not dryrunopt:
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1046 wlock = repo.wlock()
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1047 try:
1741
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1048 wkctx = repo[None]
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1049 wparents = wkctx.parents()
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1050 if len(wparents) != 1:
3583
944a8c27d27b __init__: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3574
diff changeset
1051 raise error.Abort(_('merge in progress'))
1741
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1052 if not opts['merge']:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1053 try:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1054 cmdutil.bailifchanged(repo)
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1055 except error.Abort as exc:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1056 exc.hint = _('do you want --merge?')
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1057 raise
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1058
3483
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3455
diff changeset
1059 displayer = compat.changesetdisplayer(ui, repo,
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3455
diff changeset
1060 {'template': shorttemplate})
2743
2fe562f94ead prev: retrieve the 'no-topic' result is a clear and reusable option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2742
diff changeset
1061 topic = not opts.get("no_topic", False)
2739
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1062
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1063 target, bookmark = _findprevtarget(repo, displayer,
2743
2fe562f94ead prev: retrieve the 'no-topic' result is a clear and reusable option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2742
diff changeset
1064 opts.get('move_bookmark'), topic)
2739
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1065 if target is not None:
2795
0dc119ed06b4 compat: avoid using configoveride
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2782
diff changeset
1066 backup = repo.ui.backupconfig('_internal', 'keep-topic')
0dc119ed06b4 compat: avoid using configoveride
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2782
diff changeset
1067 try:
0dc119ed06b4 compat: avoid using configoveride
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2782
diff changeset
1068 if topic and _getcurrenttopic(repo) != _gettopic(target):
0dc119ed06b4 compat: avoid using configoveride
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2782
diff changeset
1069 repo.ui.setconfig('_internal', 'keep-topic', 'yes',
0dc119ed06b4 compat: avoid using configoveride
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2782
diff changeset
1070 source='topic-extension')
2745
b38112b43a27 prev: allow to update to 't0' from 't1'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2743
diff changeset
1071 _prevupdate(repo, displayer, target, bookmark, dryrunopt)
2795
0dc119ed06b4 compat: avoid using configoveride
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2782
diff changeset
1072 finally:
0dc119ed06b4 compat: avoid using configoveride
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2782
diff changeset
1073 repo.ui.restoreconfig(backup)
2739
7d86594cb829 prev: extract the code computing the destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2738
diff changeset
1074 return 0
1500
b4dfafda72c2 next: add support for --dry-run
timeless@mozdev.org
parents: 1499
diff changeset
1075 else:
1741
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1076 return 1
1742
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1077 finally:
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1078 lockmod.release(wlock)
127
7e113963f2c8 Add gup and gdown command to mimic qpop and qpush command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 119
diff changeset
1079
2043
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1080 @eh.command(
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1081 '^next',
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1082 [('B', 'move-bookmark', False,
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1083 _('move active bookmark after update')),
3574
8aba29d8b133 previous/next: add -m short form for --merge
Martin von Zweigbergk <martinvonz@google.com>
parents: 3561
diff changeset
1084 ('m', 'merge', False, _('bring uncommitted change along')),
2043
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1085 ('', 'evolve', False, _('evolve the next changeset if necessary')),
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1086 ('', 'no-topic', False, _('ignore topic and move topologically')),
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1087 ('n', 'dry-run', False,
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1088 _('do not perform actions, just print what would be done'))],
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1089 '[OPTION]...')
1160
e29a813f6af5 Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents: 1157
diff changeset
1090 def cmdnext(ui, repo, **opts):
1572
44e9c0a264de evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents: 1571
diff changeset
1091 """update to next child revision
44e9c0a264de evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents: 1571
diff changeset
1092
44e9c0a264de evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents: 1571
diff changeset
1093 Use the ``--evolve`` flag to evolve unstable children on demand.
44e9c0a264de evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents: 1571
diff changeset
1094
44e9c0a264de evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents: 1571
diff changeset
1095 Displays the summary line of the destination for clarity.
44e9c0a264de evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents: 1571
diff changeset
1096 """
1742
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1097 wlock = None
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1098 dryrunopt = opts['dry_run']
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1099 if not dryrunopt:
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1100 wlock = repo.wlock()
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1101 try:
1741
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1102 wkctx = repo[None]
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1103 wparents = wkctx.parents()
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1104 if len(wparents) != 1:
3583
944a8c27d27b __init__: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3574
diff changeset
1105 raise error.Abort(_('merge in progress'))
1741
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1106 if not opts['merge']:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1107 try:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1108 cmdutil.bailifchanged(repo)
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1109 except error.Abort as exc:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1110 exc.hint = _('do you want --merge?')
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1111 raise
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1112
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1113 children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()]
2803
843311b8876e next: use the utility to retrieve the current topic
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2795
diff changeset
1114 topic = _getcurrenttopic(repo)
1741
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1115 filtered = []
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1116 if topic and not opts.get("no_topic", False):
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1117 filtered = [ctx for ctx in children if ctx.topic() != topic]
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1118 # XXX N-square membership on children
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1119 children = [ctx for ctx in children if ctx not in filtered]
3483
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3455
diff changeset
1120 displayer = compat.changesetdisplayer(ui, repo,
f03845bfd015 compat: add wrapper for logcmdutil functions
Yuya Nishihara <yuya@tcha.org>
parents: 3455
diff changeset
1121 {'template': shorttemplate})
1741
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1122 if len(children) == 1:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1123 c = children[0]
3550
78d3ba4e17ac next: cleanup logic around return by returning early
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3549
diff changeset
1124 return _updatetonext(ui, repo, c, displayer, opts)
1741
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1125 elif children:
3547
78abffad8626 next: prompt user to choose a children in case of ambiguity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3546
diff changeset
1126 cheader = _("ambiguous next changeset, choose one to update:")
78abffad8626 next: prompt user to choose a children in case of ambiguity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3546
diff changeset
1127 crevs = [c.rev() for c in children]
78abffad8626 next: prompt user to choose a children in case of ambiguity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3546
diff changeset
1128 choosedrev = utility.revselectionprompt(ui, repo, crevs, cheader)
78abffad8626 next: prompt user to choose a children in case of ambiguity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3546
diff changeset
1129 if choosedrev is None:
78abffad8626 next: prompt user to choose a children in case of ambiguity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3546
diff changeset
1130 ui.warn(_("ambiguous next changeset:\n"))
78abffad8626 next: prompt user to choose a children in case of ambiguity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3546
diff changeset
1131 for c in children:
78abffad8626 next: prompt user to choose a children in case of ambiguity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3546
diff changeset
1132 displayer.show(c)
78abffad8626 next: prompt user to choose a children in case of ambiguity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3546
diff changeset
1133 ui.warn(_("explicitly update to one of them\n"))
3550
78d3ba4e17ac next: cleanup logic around return by returning early
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3549
diff changeset
1134 return 1
3547
78abffad8626 next: prompt user to choose a children in case of ambiguity
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3546
diff changeset
1135 else:
3550
78d3ba4e17ac next: cleanup logic around return by returning early
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3549
diff changeset
1136 return _updatetonext(ui, repo, repo[choosedrev], displayer, opts)
1500
b4dfafda72c2 next: add support for --dry-run
timeless@mozdev.org
parents: 1499
diff changeset
1137 else:
3464
908d2b5dfa7e evolvecmd: move more code from __init__.py to evolvecmd.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3463
diff changeset
1138 aspchildren = evolvecmd._aspiringchildren(repo, [repo['.'].rev()])
1741
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1139 if topic:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1140 filtered.extend(repo[c] for c in children
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1141 if repo[c].topic() != topic)
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1142 # XXX N-square membership on children
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1143 aspchildren = [ctx for ctx in aspchildren if ctx not in filtered]
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1144 if not opts['evolve'] or not aspchildren:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1145 if filtered:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1146 ui.warn(_('no children on topic "%s"\n') % topic)
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1147 ui.warn(_('do you want --no-topic\n'))
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1148 else:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1149 ui.warn(_('no children\n'))
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1150 if aspchildren:
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1151 msg = _('(%i unstable changesets to be evolved here, '
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1152 'do you want --evolve?)\n')
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1153 ui.warn(msg % len(aspchildren))
3550
78d3ba4e17ac next: cleanup logic around return by returning early
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3549
diff changeset
1154 return 1
1741
8c05184672ae evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1739
diff changeset
1155 elif 1 < len(aspchildren):
3549
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1156 cheader = _("ambiguous next (unstable) changeset, choose one to"
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1157 " evolve and update:")
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1158 choosedrev = utility.revselectionprompt(ui, repo,
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1159 aspchildren, cheader)
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1160 if choosedrev is None:
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1161 ui.warn(_("ambiguous next (unstable) changeset:\n"))
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1162 for c in aspchildren:
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1163 displayer.show(repo[c])
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1164 ui.warn(_("(run 'hg evolve --rev REV' on one of them)\n"))
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1165 return 1
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1166 else:
802441114400 next: prompt user to choose child in ambiguity in `hg next --evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3548
diff changeset
1167 return _nextevolve(ui, repo, repo[choosedrev], opts)
1628
db19b1dc5c45 topic: restrict 'hg prev' to current topic unless --no-topic is passed
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1627
diff changeset
1168 else:
3548
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1169 return _nextevolve(ui, repo, aspchildren[0], opts)
1742
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1170 finally:
970a4c13ebc3 evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents: 1741
diff changeset
1171 lockmod.release(wlock)
87
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 82
diff changeset
1172
3548
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1173 def _nextevolve(ui, repo, aspchildren, opts):
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1174 """logic for hg next command to evolve and update to an aspiring children"""
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1175
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1176 cmdutil.bailifchanged(repo)
3653
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3641
diff changeset
1177 evolvestate = state.cmdstate(repo, opts={'command': 'next',
d9682c41ea2f evolve: restore bookmarks correctly after `hg evolve --abort`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3641
diff changeset
1178 'bookmarkchanges': []})
3548
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1179 result = evolvecmd._solveone(ui, repo, repo[aspchildren],
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1180 evolvestate, opts.get('dry_run'), False,
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1181 lambda: None, category='orphan')
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1182 # making sure a next commit is formed
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1183 if result[0] and result[1]:
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1184 ui.status(_('working directory now at %s\n')
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1185 % ui.label(str(repo['.']), 'evolve.node'))
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1186 return 0
79d995cb8152 next: move logic to evolve the children to it's own function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3547
diff changeset
1187
3539
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1188 def _updatetonext(ui, repo, children, displayer, opts):
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1189 """ logic for `hg next` command to update to children and move bookmarks if
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1190 required """
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1191 bm = repo._activebookmark
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1192 shouldmove = opts.get('move_bookmark') and bm is not None
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1193 if opts.get('dry_run'):
3583
944a8c27d27b __init__: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3574
diff changeset
1194 ui.write(_('hg update %s;\n') % children)
3539
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1195 if shouldmove:
3583
944a8c27d27b __init__: show some internationalization love
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3574
diff changeset
1196 ui.write(_('hg bookmark %s -r %s;\n') % (bm, children))
3539
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1197 else:
3546
d197e6f0d0e3 next: show changeset hash in `--dry-run` instead of rev numbers
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3539
diff changeset
1198 ret = hg.update(repo, children)
3539
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1199 if not ret:
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1200 lock = tr = None
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1201 try:
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1202 lock = repo.lock()
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1203 tr = repo.transaction('next')
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1204 if shouldmove:
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1205 bmchanges = [(bm, children.node())]
3699
67d6cc7e0979 compat: drop compatibility layer for bookmark.applychanges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3694
diff changeset
1206 repo._bookmarks.applychanges(repo, tr, bmchanges)
3539
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1207 else:
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1208 bookmarksmod.deactivate(repo)
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1209 tr.close()
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1210 finally:
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1211 lockmod.release(tr, lock)
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1212 if not ui.quiet:
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1213 displayer.show(children)
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1214 return 0
9bd64091e880 next: factor out the logic to update to changeset in another function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3535
diff changeset
1215
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1216 @eh.wrapcommand('commit')
116
64ca29eef349 Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 113
diff changeset
1217 def commitwrapper(orig, ui, repo, *arg, **kwargs):
1558
4706475e0c5d commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents: 1557
diff changeset
1218 tr = None
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1219 if kwargs.get('amend', False):
1255
a2d4901e211e commit: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1253
diff changeset
1220 wlock = lock = None
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1221 else:
1255
a2d4901e211e commit: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1253
diff changeset
1222 wlock = repo.wlock()
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1223 lock = repo.lock()
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1224 try:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1225 obsoleted = kwargs.get('obsolete', [])
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1226 if obsoleted:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1227 obsoleted = repo.set('%lr', obsoleted)
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1228 result = orig(ui, repo, *arg, **kwargs)
1659
c450d134aac4 Spelling: succeeded
timeless@gmail.com
parents: 1646
diff changeset
1229 if not result: # commit succeeded
3662
0caa27259800 evolve: don't pass stringified int to repo.__getitem__
Martin von Zweigbergk <martinvonz@google.com>
parents: 3653
diff changeset
1230 new = repo['tip']
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1231 oldbookmarks = []
444
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1232 markers = []
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1233 for old in obsoleted:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1234 oldbookmarks.extend(repo.nodebookmarks(old.node()))
444
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1235 markers.append((old, (new,)))
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1236 if markers:
3694
c0d5e0929f8b compat: from compatibility layer for createmarkers
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3691
diff changeset
1237 obsolete.createmarkers(repo, markers, operation="amend")
2752
4457aa1d81aa compat: add a compatibility layer for bookmark move
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2748
diff changeset
1238 bmchanges = []
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1239 for book in oldbookmarks:
2752
4457aa1d81aa compat: add a compatibility layer for bookmark move
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2748
diff changeset
1240 bmchanges.append((book, new.node()))
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1241 if oldbookmarks:
1558
4706475e0c5d commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents: 1557
diff changeset
1242 if not wlock:
4706475e0c5d commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents: 1557
diff changeset
1243 wlock = repo.wlock()
4706475e0c5d commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents: 1557
diff changeset
1244 if not lock:
4706475e0c5d commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents: 1557
diff changeset
1245 lock = repo.lock()
4706475e0c5d commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents: 1557
diff changeset
1246 tr = repo.transaction('commit')
3699
67d6cc7e0979 compat: drop compatibility layer for bookmark.applychanges
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3694
diff changeset
1247 repo._bookmarks.applychanges(repo, tr, bmchanges)
1558
4706475e0c5d commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents: 1557
diff changeset
1248 tr.close()
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1249 return result
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1250 finally:
1558
4706475e0c5d commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents: 1557
diff changeset
1251 lockmod.release(tr, lock, wlock)
116
64ca29eef349 Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 113
diff changeset
1252
1220
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1253 @eh.wrapcommand('strip', extension='strip', opts=[
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1254 ('', 'bundle', None, _("delete the commit entirely and move it to a "
2032
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
1255 "backup bundle")),
1220
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1256 ])
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1257 def stripwrapper(orig, ui, repo, *revs, **kwargs):
3080
461c9d940519 evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents: 3074
diff changeset
1258 if (not ui.configbool('experimental', 'prunestrip', False) or
1220
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1259 kwargs.get('bundle', False)):
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1260 return orig(ui, repo, *revs, **kwargs)
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1261
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1262 if kwargs.get('force'):
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1263 ui.warn(_("warning: --force has no effect during strip with evolve "
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1264 "enabled\n"))
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1265 if kwargs.get('no_backup', False):
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1266 ui.warn(_("warning: --no-backup has no effect during strips with "
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1267 "evolve enabled\n"))
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1268
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1269 revs = list(revs) + kwargs.pop('rev', [])
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1270 revs = set(scmutil.revrange(repo, revs))
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1271 revs = repo.revs("(%ld)::", revs)
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1272 kwargs['rev'] = []
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1273 kwargs['new'] = []
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1274 kwargs['succ'] = []
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1275 kwargs['biject'] = False
2772
394b836e475b commands: rewrite the 'evocommands' module to 'cmdrewrite'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2766
diff changeset
1276 return cmdrewrite.cmdprune(ui, repo, *revs, **kwargs)
1220
71240f696f26 strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents: 1219
diff changeset
1277
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1278 @eh.extsetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1279 def oldevolveextsetup(ui):
1631
7463f5880ce9 prune: remove the kill alias
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1630
diff changeset
1280 for cmd in ['prune', 'uncommit', 'touch', 'fold']:
1226
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
1281 try:
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
1282 entry = extensions.wrapcommand(cmdtable, cmd,
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
1283 warnobserrors)
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
1284 except error.UnknownCommand:
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
1285 # Commands may be disabled
901d2f4b21a9 config: allow disabling commands
Durham Goode <durham@fb.com>
parents: 1221
diff changeset
1286 continue
356
56d4c6207ef9 Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 355
diff changeset
1287
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1288 entry = cmdutil.findcmd('commit', commands.table)[1]
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1289 entry[1].append(('o', 'obsolete', [],
1008
a010ba5a0ffb evolve: deprecated --obsolete and --old-obsolete option on commit and graft
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1007
diff changeset
1290 _("make commit obsolete this revision (DEPRECATED)")))
211
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
1291
1302
ebcf23fe3032 evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1301
diff changeset
1292 @eh.wrapfunction(obsolete, '_checkinvalidmarkers')
ebcf23fe3032 evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1301
diff changeset
1293 def _checkinvalidmarkers(orig, markers):
ebcf23fe3032 evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1301
diff changeset
1294 """search for marker with invalid data and raise error if needed
ebcf23fe3032 evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1301
diff changeset
1295
ebcf23fe3032 evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1301
diff changeset
1296 Exist as a separated function to allow the evolve extension for a more
ebcf23fe3032 evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1301
diff changeset
1297 subtle handling.
ebcf23fe3032 evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1301
diff changeset
1298 """
ebcf23fe3032 evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1301
diff changeset
1299 if 'debugobsconvert' in sys.argv:
ebcf23fe3032 evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1301
diff changeset
1300 return
ebcf23fe3032 evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1301
diff changeset
1301 for mark in markers:
ebcf23fe3032 evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1301
diff changeset
1302 if node.nullid in mark[1]:
2032
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
1303 msg = _('bad obsolescence marker detected: invalid successors nullid')
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
1304 hint = _('You should run `hg debugobsconvert`')
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
1305 raise error.Abort(msg, hint=hint)
1202
4099b087f672 evolve: handle invalid obsmarkers in the `debugobsconvert`
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1198
diff changeset
1306
2043
c64300906a32 exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2041
diff changeset
1307 @eh.command(
1159
04bd66779a1f obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents: 1157
diff changeset
1308 'debugobsconvert',
2053
f3765c4a352a exchange: rename the module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2051
diff changeset
1309 [('', 'new-format', obsexchange._bestformat, _('Destination format for markers.'))],
1159
04bd66779a1f obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents: 1157
diff changeset
1310 '')
04bd66779a1f obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents: 1157
diff changeset
1311 def debugobsconvert(ui, repo, new_format):
1507
6f574c76c142 debugobsconvert: make sure obsstore is loaded before version comparison
Yuya Nishihara <yuya@tcha.org>
parents: 1506
diff changeset
1312 origmarkers = repo.obsstore._all # settle version
1159
04bd66779a1f obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents: 1157
diff changeset
1313 if new_format == repo.obsstore._version:
04bd66779a1f obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents: 1157
diff changeset
1314 msg = _('New format is the same as the old format, not upgrading!')
1547
425c0700aabd check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents: 1536
diff changeset
1315 raise error.Abort(msg)
2748
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1316 with repo.lock():
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1317 f = repo.svfs('obsstore', 'wb', atomictemp=True)
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1318 known = set()
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1319 markers = []
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1320 for m in origmarkers:
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1321 # filter out invalid markers
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1322 if nullid in m[1]:
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1323 m = list(m)
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1324 m[1] = tuple(s for s in m[1] if s != nullid)
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1325 m = tuple(m)
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1326 if m in known:
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1327 continue
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1328 known.add(m)
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1329 markers.append(m)
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1330 ui.write(_('Old store is version %d, will rewrite in version %d\n') % (
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1331 repo.obsstore._version, new_format))
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1332 map(f.write, obsolete.encodemarkers(markers, True, new_format))
723f5b505c48 debugobsconvert: take the lock when writing the obsstore file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2745
diff changeset
1333 f.close()
1159
04bd66779a1f obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents: 1157
diff changeset
1334 ui.write(_('Done!\n'))
04bd66779a1f obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents: 1157
diff changeset
1335
864
401da1b38cca discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 863
diff changeset
1336
1827
15ec53d46f44 compat: drop handling of ancestral 'helploader' caller
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1826
diff changeset
1337 def _helploader(ui):
1414
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
1338 return help.gettext(evolutionhelptext)
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
1339
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
1340 @eh.uisetup
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
1341 def _setuphelp(ui):
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
1342 for entry in help.helptable:
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
1343 if entry[0] == "evolution":
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
1344 break
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
1345 else:
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
1346 help.helptable.append((["evolution"], _("Safely Rewriting History"),
2032
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
1347 _helploader))
1414
4198e2fad6ba evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1413
diff changeset
1348 help.helptable.sort()
1567
536fdfa3c48b evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents: 1566
diff changeset
1349
1597
7876ed4fceb7 evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1594
diff changeset
1350 evolvestateversion = 0
7876ed4fceb7 evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1594
diff changeset
1351
7876ed4fceb7 evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1594
diff changeset
1352 @eh.uisetup
7876ed4fceb7 evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1594
diff changeset
1353 def setupevolveunfinished(ui):
3641
ed50f10aacbd evolve: don't allow updating or commiting when there is interrupted evolve
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3615
diff changeset
1354 data = ('evolvestate', False, False, _('evolve in progress'),
2032
dd7e092a854a flake8: update the code sources to fixes a horde of pyflake warnings
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2024
diff changeset
1355 _("use 'hg evolve --continue' or 'hg update -C .' to abort"))
1597
7876ed4fceb7 evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1594
diff changeset
1356 cmdutil.unfinishedstates.append(data)
7876ed4fceb7 evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1594
diff changeset
1357
3472
05bd493d496d evolve: add evolve info to cmdutil.afterresolvedstates
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3470
diff changeset
1358 afterresolved = ('evolvestate', _('hg evolve --continue'))
3473
b2f591aa4507 grab: add grab info to cmdutil.afterresolvedstates
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3472
diff changeset
1359 grabresolved = ('grabstate', _('hg grab --continue'))
3472
05bd493d496d evolve: add evolve info to cmdutil.afterresolvedstates
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3470
diff changeset
1360 cmdutil.afterresolvedstates.append(afterresolved)
3473
b2f591aa4507 grab: add grab info to cmdutil.afterresolvedstates
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3472
diff changeset
1361 cmdutil.afterresolvedstates.append(grabresolved)
3472
05bd493d496d evolve: add evolve info to cmdutil.afterresolvedstates
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3470
diff changeset
1362
1597
7876ed4fceb7 evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1594
diff changeset
1363 @eh.wrapfunction(hg, 'clean')
7876ed4fceb7 evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1594
diff changeset
1364 def clean(orig, repo, *args, **kwargs):
7876ed4fceb7 evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1594
diff changeset
1365 ret = orig(repo, *args, **kwargs)
2070
9105c3c54045 cleanup: stop using 'repo.join' methods
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2064
diff changeset
1366 util.unlinkpath(repo.vfs.join('evolvestate'), ignoremissing=True)
1597
7876ed4fceb7 evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 1594
diff changeset
1367 return ret