author | Boris Feld <boris.feld@octobus.net> |
Thu, 18 May 2017 17:40:07 +0200 | |
changeset 2414 | fcf54ec1eaf7 |
parent 2407 | 783a74c60a5e |
child 2415 | 89a5dabbb43d |
permissions | -rw-r--r-- |
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 |
|
f026e85bd0b2
evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2290
diff
changeset
|
23 |
With the extensions various evolution events will display warning (new unstable |
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 |
f026e85bd0b2
evolve: update extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2290
diff
changeset
|
35 |
Mercurial version 3.8). |
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 |
|
26d638e419df
auto-push: move config help in the extension help
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2294
diff
changeset
|
37 |
New Config: |
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 |
|
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
|
47 |
""" |
2049
b81d3775006b
evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2048
diff
changeset
|
48 |
|
584
af3b0d696e7f
evolve: add tested with info
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
577
diff
changeset
|
49 |
|
1414
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
50 |
evolutionhelptext = """ |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
51 |
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
|
52 |
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
|
53 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
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
|
58 |
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
|
59 |
: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
|
60 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
of history concurrently. |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
73 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
74 |
Current feature status |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
75 |
====================== |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
76 |
|
1710 | 77 |
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
|
78 |
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
|
79 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
80 |
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
|
81 |
assert support for the obsolescence feature (this can currently only be done |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
82 |
via an extension).""".strip() |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
83 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
84 |
|
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
|
85 |
import os |
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
|
86 |
import sys |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
87 |
import random |
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
|
88 |
import re |
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
|
89 |
import collections |
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
|
90 |
import errno |
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
|
91 |
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
|
92 |
|
1678 | 93 |
try: |
94 |
import StringIO as io |
|
95 |
StringIO = io.StringIO |
|
96 |
except ImportError: |
|
97 |
import io |
|
98 |
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
|
99 |
|
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
100 |
|
1825
377d94d6c889
evolve: proactively detect bad version early
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1824
diff
changeset
|
101 |
try: |
377d94d6c889
evolve: proactively detect bad version early
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1824
diff
changeset
|
102 |
from mercurial import registrar |
377d94d6c889
evolve: proactively detect bad version early
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1824
diff
changeset
|
103 |
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
|
104 |
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
|
105 |
from . import metadata |
1825
377d94d6c889
evolve: proactively detect bad version early
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1824
diff
changeset
|
106 |
raise ImportError('evolve needs 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
|
107 |
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
|
108 |
|
670
97ce1f801309
evolve: drop unused import
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
663
diff
changeset
|
109 |
import mercurial |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
110 |
from mercurial import util |
1513
4f7e0e0318a5
prune: reuse revset from repair instead of copy-pasting code
Ryan McElroy <rmcelroy@fb.com>
parents:
1512
diff
changeset
|
111 |
from mercurial import repair |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
112 |
|
1834
f23a97d14895
compat: drop compat for older wireproto implementation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1833
diff
changeset
|
113 |
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
|
114 |
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
|
115 |
obsolete._enabled = True |
617
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
116 |
|
1823
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
117 |
from mercurial import ( |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
118 |
bookmarks as bookmarksmod, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
119 |
cmdutil, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
120 |
commands, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
121 |
context, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
122 |
copies, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
123 |
error, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
124 |
extensions, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
125 |
help, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
126 |
hg, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
127 |
lock as lockmod, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
128 |
merge, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
129 |
node, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
130 |
patch, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
131 |
phases, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
132 |
revset, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
133 |
scmutil, |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
134 |
templatekw, |
2289
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
135 |
obsolete |
1823
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
136 |
) |
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
137 |
|
649d7a574c3f
evolve: cleanup imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1822
diff
changeset
|
138 |
from mercurial.commands import walkopts, commitopts, commitopts2, mergetoolopts |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
139 |
from mercurial.i18n import _ |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
140 |
from mercurial.node import nullid |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
141 |
|
2041
3b6550261614
exthelper: extract into its own submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
142 |
from . import ( |
2245
a14e05e4bb20
checkheads: import our own copy of the checkheads code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2123
diff
changeset
|
143 |
checkheads, |
2123
cf7b4ab31f0c
split: move the debugcommand into a dedicated module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2122
diff
changeset
|
144 |
debugcmd, |
2041
3b6550261614
exthelper: extract into its own submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
145 |
exthelper, |
2049
b81d3775006b
evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2048
diff
changeset
|
146 |
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
|
147 |
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
|
148 |
obsexchange, |
2286
a4c5744a7b93
safeguard: add an option to disable automatic publishing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2275
diff
changeset
|
149 |
safeguard, |
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
|
150 |
utility, |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2396
diff
changeset
|
151 |
obshistory |
2041
3b6550261614
exthelper: extract into its own submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
152 |
) |
3b6550261614
exthelper: extract into its own submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
153 |
|
2049
b81d3775006b
evolve: move extension metadata in their own module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2048
diff
changeset
|
154 |
__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
|
155 |
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
|
156 |
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
|
157 |
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
|
158 |
|
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
|
159 |
sha1re = re.compile(r'\b[0-9a-f]{6,40}\b') |
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
|
160 |
|
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
|
161 |
# 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
|
162 |
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
|
163 |
|
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
|
164 |
obsexcmsg = utility.obsexcmsg |
1838
6942750831bb
serveronly: deduplicate code with the main evolve extension
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1836
diff
changeset
|
165 |
|
2404
c07f752137f4
label: rename 'evolve.short_node' to 'evolve.node'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2403
diff
changeset
|
166 |
colortable = {'evolve.node': 'yellow', |
2337
c0ed4adf965e
obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents:
2336
diff
changeset
|
167 |
'evolve.user': 'green', |
c0ed4adf965e
obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents:
2336
diff
changeset
|
168 |
'evolve.rev': 'blue', |
c0ed4adf965e
obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents:
2336
diff
changeset
|
169 |
'evolve.short_description': '', |
c0ed4adf965e
obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents:
2336
diff
changeset
|
170 |
'evolve.date': 'cyan', |
c0ed4adf965e
obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents:
2336
diff
changeset
|
171 |
'evolve.current_rev': 'bold', |
c0ed4adf965e
obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents:
2336
diff
changeset
|
172 |
'evolve.verb': '', |
c0ed4adf965e
obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents:
2336
diff
changeset
|
173 |
} |
c0ed4adf965e
obshistory: add some color
Boris Feld <boris.feld@octobus.net>
parents:
2336
diff
changeset
|
174 |
|
820
a9a66143e2ec
exchange: actually use _pushkeyescape fallback
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
819
diff
changeset
|
175 |
_pack = struct.pack |
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
176 |
_unpack = struct.unpack |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
177 |
|
1296
23819e1d61fd
evolve: add -i flag to amend command
Laurent Charignon <lcharignon@fb.com>
parents:
1281
diff
changeset
|
178 |
aliases, entry = cmdutil.findcmd('commit', commands.table) |
2100
e5b06a6d8d4b
compat: drop some <hg-3.4 compatibility code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2070
diff
changeset
|
179 |
interactiveopt = [['i', 'interactive', None, _('use interactive mode')]] |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
180 |
# This extension contains the following code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
181 |
# |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
182 |
# - Extension Helper code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
183 |
# - Obsolescence cache |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
184 |
# - ... |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
185 |
# - Older format compat |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
186 |
|
2041
3b6550261614
exthelper: extract into its own submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
187 |
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
|
188 |
eh.merge(debugcmd.eh) |
2053
f3765c4a352a
exchange: rename the module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2051
diff
changeset
|
189 |
eh.merge(obsexchange.eh) |
2245
a14e05e4bb20
checkheads: import our own copy of the checkheads code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2123
diff
changeset
|
190 |
eh.merge(checkheads.eh) |
2286
a4c5744a7b93
safeguard: add an option to disable automatic publishing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2275
diff
changeset
|
191 |
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
|
192 |
eh.merge(obscache.eh) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
193 |
uisetup = eh.final_uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
194 |
extsetup = eh.final_extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
195 |
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
|
196 |
cmdtable = eh.cmdtable |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
197 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
198 |
##################################################################### |
1213
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
199 |
### Option configuration ### |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
200 |
##################################################################### |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
201 |
|
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
202 |
@eh.reposetup # must be the first of its kin. |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
203 |
def _configureoptions(ui, repo): |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
204 |
# If no capabilities are specified, enable everything. |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
205 |
# This is so existing evolve users don't need to change their config. |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
206 |
evolveopts = ui.configlist('experimental', 'evolution') |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
207 |
if not evolveopts: |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
208 |
evolveopts = ['all'] |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
209 |
ui.setconfig('experimental', 'evolution', evolveopts, 'evolve') |
1213
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
210 |
|
1226
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
211 |
@eh.uisetup |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
212 |
def _configurecmdoptions(ui): |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
213 |
# Unregister evolve commands if the command capability is not specified. |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
214 |
# |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
215 |
# 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
|
216 |
# guarantee it happens after the above configuration, but before the |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
217 |
# extsetup functions. |
1441
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
218 |
evolvecommands = ui.configlist('experimental', 'evolutioncommands') |
1226
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
219 |
evolveopts = ui.configlist('experimental', 'evolution') |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
220 |
if evolveopts and (commandopt not in evolveopts and |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
221 |
'all' not in evolveopts): |
1441
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
222 |
# 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
|
223 |
whitelist = set() |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
224 |
for cmd in evolvecommands: |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
225 |
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
|
226 |
if not matchingevolvecommands: |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
227 |
raise error.Abort(_('unknown command: %s') % cmd) |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
228 |
elif len(matchingevolvecommands) > 1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
229 |
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
|
230 |
raise error.Abort(msg % (cmd, matchingevolvecommands)) |
1441
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
231 |
else: |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
232 |
whitelist.add(matchingevolvecommands[0]) |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
233 |
for disabledcmd in set(cmdtable) - whitelist: |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
234 |
del cmdtable[disabledcmd] |
1213
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
235 |
|
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
236 |
##################################################################### |
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
|
237 |
### 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
|
238 |
##################################################################### |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
239 |
|
976
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
240 |
commitopts3 = [ |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
241 |
('D', 'current-date', None, |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
242 |
_('record the current date as commit date')), |
985
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
243 |
('U', 'current-user', None, |
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
244 |
_('record the current user as committer')), |
976
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
245 |
] |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
246 |
|
985
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
247 |
def _resolveoptions(ui, opts): |
976
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
248 |
"""modify commit options dict to handle related options |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
249 |
|
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
250 |
For now, all it does is figure out the commit date: respect -D unless |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
251 |
-d was supplied. |
577
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
252 |
""" |
976
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
253 |
# N.B. this is extremely similar to setupheaderopts() in mq.py |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
254 |
if not opts.get('date') and opts.get('current_date'): |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
255 |
opts['date'] = '%d %d' % util.makedate() |
985
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
256 |
if not opts.get('user') and opts.get('current_user'): |
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
257 |
opts['user'] = ui.username() |
577
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
258 |
|
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
259 |
getrevs = obsolete.getrevs |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
260 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
261 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
262 |
### Additional Utilities ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
263 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
264 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
265 |
# 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
|
266 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
267 |
# - Function to create markers |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
268 |
# - 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
|
269 |
# - "troubles" method on changectx |
1661 | 270 |
# - 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
|
271 |
# - function to find useful changeset to stabilize |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
272 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
273 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
274 |
### Useful alias |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
275 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
276 |
@eh.uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
277 |
def _installalias(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
278 |
if ui.config('alias', 'pstatus', None) is None: |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
279 |
ui.setconfig('alias', 'pstatus', 'status --rev .^', 'evolve') |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
280 |
if ui.config('alias', 'pdiff', None) is None: |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
281 |
ui.setconfig('alias', 'pdiff', 'diff --rev .^', 'evolve') |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
282 |
if ui.config('alias', 'olog', None) is None: |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
283 |
ui.setconfig('alias', 'olog', "log -r 'precursors(.)' --hidden", |
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
284 |
'evolve') |
497
43e1b2cab789
evolve: add the odiff alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
492
diff
changeset
|
285 |
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
|
286 |
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
|
287 |
"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
|
288 |
'evolve') |
696
121e2d265e85
alias: add a grab alias
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
695
diff
changeset
|
289 |
if ui.config('alias', 'grab', None) is None: |
1104
cb36a4eb0157
evolve: fix the 'grab' alias to work on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
1101
diff
changeset
|
290 |
if os.name == 'nt': |
cb36a4eb0157
evolve: fix the 'grab' alias to work on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
1101
diff
changeset
|
291 |
ui.setconfig('alias', 'grab', |
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
|
292 |
"! " + util.hgexecutable() |
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
|
293 |
+ " rebase --dest . --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
|
294 |
+ util.hgexecutable() + " up tip", |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
295 |
'evolve') |
1104
cb36a4eb0157
evolve: fix the 'grab' alias to work on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
1101
diff
changeset
|
296 |
else: |
cb36a4eb0157
evolve: fix the 'grab' alias to work on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
1101
diff
changeset
|
297 |
ui.setconfig('alias', 'grab', |
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
|
298 |
"! $HG rebase --dest . --rev $@ && $HG up tip", |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
299 |
'evolve') |
696
121e2d265e85
alias: add a grab alias
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
695
diff
changeset
|
300 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
301 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
302 |
### Troubled revset symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
303 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
304 |
@eh.revset('troubled') |
594 | 305 |
def revsettroubled(repo, subset, x): |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
306 |
"""``troubled()`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
307 |
Changesets with troubles. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
308 |
""" |
993
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
309 |
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
|
310 |
troubled = set() |
61849d45d47e
evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1380
diff
changeset
|
311 |
troubled.update(getrevs(repo, 'unstable')) |
61849d45d47e
evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1380
diff
changeset
|
312 |
troubled.update(getrevs(repo, 'bumped')) |
61849d45d47e
evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1380
diff
changeset
|
313 |
troubled.update(getrevs(repo, 'divergent')) |
61849d45d47e
evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1380
diff
changeset
|
314 |
troubled = revset.baseset(troubled) |
61849d45d47e
evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1380
diff
changeset
|
315 |
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
|
316 |
return subset & troubled |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
317 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
318 |
### Obsolescence graph |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
319 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
320 |
# 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
|
321 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
322 |
def _precursors(repo, s): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
323 |
"""Precursor of a changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
324 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
325 |
nm = repo.changelog.nodemap |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
326 |
markerbysubj = repo.obsstore.precursors |
1377
01bdeb847f81
evolve: avoid creating changectx object in _precursors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1376
diff
changeset
|
327 |
node = repo.changelog.node |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
328 |
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
|
329 |
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
|
330 |
pr = nm.get(p[0]) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
331 |
if pr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
332 |
cs.add(pr) |
1383
cf62abb62941
evolve: move 'precursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1382
diff
changeset
|
333 |
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
|
334 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
335 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
336 |
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
|
337 |
"""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
|
338 |
node = repo.changelog.node |
a127f0f3bf5f
evolve: avoid creating changectx object in _allprecursors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1377
diff
changeset
|
339 |
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
|
340 |
seen = set() |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
341 |
allsubjects = repo.obsstore.precursors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
342 |
while toproceed: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
343 |
nc = toproceed.pop() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
344 |
for mark in allsubjects.get(nc, ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
345 |
np = mark[0] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
346 |
if np not in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
347 |
seen.add(np) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
348 |
toproceed.append(np) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
349 |
nm = repo.changelog.nodemap |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
350 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
351 |
for p in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
352 |
pr = nm.get(p) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
353 |
if pr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
354 |
cs.add(pr) |
1384
64c8b8c27811
evolve: move 'allprecursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1383
diff
changeset
|
355 |
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
|
356 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
357 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
358 |
def _successors(repo, s): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
359 |
"""Successors of a changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
360 |
cs = set() |
1379
693cdcd809f2
evolve: avoid creating changectx object in _successors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1378
diff
changeset
|
361 |
node = repo.changelog.node |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
362 |
nm = repo.changelog.nodemap |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
363 |
markerbyobj = repo.obsstore.successors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
364 |
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
|
365 |
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
|
366 |
for sub in p[1]: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
367 |
sr = nm.get(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
368 |
if sr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
369 |
cs.add(sr) |
1385
c2584407afbf
evolve: move 'successors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1384
diff
changeset
|
370 |
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
|
371 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
372 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
373 |
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
|
374 |
"""transitive successors of a subset |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
375 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
376 |
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
|
377 |
marker. """ |
1380
43dcf62237be
evolve: avoid creating changectx object in _allsuccessors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1379
diff
changeset
|
378 |
node = repo.changelog.node |
43dcf62237be
evolve: avoid creating changectx object in _allsuccessors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1379
diff
changeset
|
379 |
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
|
380 |
seen = set() |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
381 |
allobjects = repo.obsstore.successors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
382 |
while toproceed: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
383 |
nc = toproceed.pop() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
384 |
for mark in allobjects.get(nc, ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
385 |
if mark[2] & haltonflags: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
386 |
continue |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
387 |
for sub in mark[1]: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
388 |
if sub == nullid: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
389 |
continue # should not be here! |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
390 |
if sub not in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
391 |
seen.add(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
392 |
toproceed.append(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
393 |
nm = repo.changelog.nodemap |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
394 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
395 |
for s in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
396 |
sr = nm.get(s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
397 |
if sr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
398 |
cs.add(sr) |
1386
b5eaec8a53d0
evolve: move 'allsuccessors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1385
diff
changeset
|
399 |
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
|
400 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
401 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
402 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
403 |
### Extending revset and template ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
404 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
405 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
406 |
# 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
|
407 |
# they are subject to changes |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
408 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
409 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
410 |
### XXX I'm not sure this revset is useful |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
411 |
@eh.revset('suspended') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
412 |
def revsetsuspended(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
413 |
"""``suspended()`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
414 |
Obsolete changesets with non-obsolete descendants. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
415 |
""" |
1307
677c5da57b9c
evolve: remove unused variables
Laurent Charignon <lcharignon@fb.com>
parents:
1306
diff
changeset
|
416 |
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
|
417 |
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
|
418 |
suspended.sort() |
c431f827f366
evolve: move 'suspended()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1381
diff
changeset
|
419 |
return subset & suspended |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
420 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
421 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
422 |
@eh.revset('precursors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
423 |
def revsetprecursors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
424 |
"""``precursors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
425 |
Immediate precursors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
426 |
""" |
1204
161b8f6e7402
evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents:
1203
diff
changeset
|
427 |
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
|
428 |
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
|
429 |
s.sort() |
cf62abb62941
evolve: move 'precursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1382
diff
changeset
|
430 |
return subset & s |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
431 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
432 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
433 |
@eh.revset('allprecursors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
434 |
def revsetallprecursors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
435 |
"""``allprecursors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
436 |
Transitive precursors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
437 |
""" |
1204
161b8f6e7402
evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents:
1203
diff
changeset
|
438 |
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
|
439 |
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
|
440 |
s.sort() |
64c8b8c27811
evolve: move 'allprecursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1383
diff
changeset
|
441 |
return subset & s |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
442 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
443 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
444 |
@eh.revset('successors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
445 |
def revsetsuccessors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
446 |
"""``successors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
447 |
Immediate successors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
448 |
""" |
1204
161b8f6e7402
evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents:
1203
diff
changeset
|
449 |
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
|
450 |
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
|
451 |
s.sort() |
c2584407afbf
evolve: move 'successors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1384
diff
changeset
|
452 |
return subset & s |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
453 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
454 |
@eh.revset('allsuccessors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
455 |
def revsetallsuccessors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
456 |
"""``allsuccessors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
457 |
Transitive successors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
458 |
""" |
1204
161b8f6e7402
evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents:
1203
diff
changeset
|
459 |
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
|
460 |
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
|
461 |
s.sort() |
b5eaec8a53d0
evolve: move 'allsuccessors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1385
diff
changeset
|
462 |
return subset & s |
491
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 |
### template keywords |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
465 |
# XXX it does not handle troubles well :-/ |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
466 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
467 |
@eh.templatekw('obsolete') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
468 |
def obsoletekw(repo, ctx, templ, **args): |
1732
f4047fba5e90
templates: change {obsolete} to emit only "obsolete" or ""
Martin von Zweigbergk <martinvonz@google.com>
parents:
1729
diff
changeset
|
469 |
""":obsolete: String. Whether the changeset is ``obsolete``. |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
470 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
471 |
if ctx.obsolete(): |
1732
f4047fba5e90
templates: change {obsolete} to emit only "obsolete" or ""
Martin von Zweigbergk <martinvonz@google.com>
parents:
1729
diff
changeset
|
472 |
return 'obsolete' |
f4047fba5e90
templates: change {obsolete} to emit only "obsolete" or ""
Martin von Zweigbergk <martinvonz@google.com>
parents:
1729
diff
changeset
|
473 |
return '' |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
474 |
|
1399
9ff6d9240f16
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
949
diff
changeset
|
475 |
@eh.templatekw('troubles') |
2271
1af1b0debd4b
template: pass all mapping data to showlist()
Yuya Nishihara <yuya@tcha.org>
parents:
2245
diff
changeset
|
476 |
def showtroubles(**args): |
1399
9ff6d9240f16
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
949
diff
changeset
|
477 |
""":troubles: List of strings. Evolution troubles affecting the changeset |
9ff6d9240f16
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
949
diff
changeset
|
478 |
(zero or more of "unstable", "divergent" or "bumped").""" |
2271
1af1b0debd4b
template: pass all mapping data to showlist()
Yuya Nishihara <yuya@tcha.org>
parents:
2245
diff
changeset
|
479 |
ctx = args['ctx'] |
2272
eb47d436cdc3
template: adapt to new showlist() API introduced by hg e5eab0fe69ee
Yuya Nishihara <yuya@tcha.org>
parents:
2271
diff
changeset
|
480 |
try: |
eb47d436cdc3
template: adapt to new showlist() API introduced by hg e5eab0fe69ee
Yuya Nishihara <yuya@tcha.org>
parents:
2271
diff
changeset
|
481 |
# specify plural= explicitly to trigger TypeError on hg < 4.2 |
eb47d436cdc3
template: adapt to new showlist() API introduced by hg e5eab0fe69ee
Yuya Nishihara <yuya@tcha.org>
parents:
2271
diff
changeset
|
482 |
return templatekw.showlist('trouble', ctx.troubles(), args, |
eb47d436cdc3
template: adapt to new showlist() API introduced by hg e5eab0fe69ee
Yuya Nishihara <yuya@tcha.org>
parents:
2271
diff
changeset
|
483 |
plural='troubles') |
eb47d436cdc3
template: adapt to new showlist() API introduced by hg e5eab0fe69ee
Yuya Nishihara <yuya@tcha.org>
parents:
2271
diff
changeset
|
484 |
except TypeError: |
eb47d436cdc3
template: adapt to new showlist() API introduced by hg e5eab0fe69ee
Yuya Nishihara <yuya@tcha.org>
parents:
2271
diff
changeset
|
485 |
return templatekw.showlist('trouble', ctx.troubles(), plural='troubles', |
eb47d436cdc3
template: adapt to new showlist() API introduced by hg e5eab0fe69ee
Yuya Nishihara <yuya@tcha.org>
parents:
2271
diff
changeset
|
486 |
**args) |
1399
9ff6d9240f16
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
949
diff
changeset
|
487 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
488 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
489 |
### Various trouble warning ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
490 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
491 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
492 |
# 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
|
493 |
|
1527
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
494 |
|
2289
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
495 |
def _getobsoletereason(repo, revnode): |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
496 |
""" Return a tuple containing: |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
497 |
- the reason a revision is obsolete (diverged, pruned or superseed) |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
498 |
- the list of successors short node if the revision is neither pruned |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
499 |
or has diverged |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
500 |
""" |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
501 |
successorssets = obsolete.successorssets(repo, revnode) |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
502 |
|
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
503 |
if len(successorssets) == 0: |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
504 |
# The commit has been pruned |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
505 |
return ('pruned', []) |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
506 |
elif len(successorssets) > 1: |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
507 |
return ('diverged', []) |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
508 |
else: |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
509 |
# No divergence, only one set of successors |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
510 |
successors = [node.short(node_id) for node_id in successorssets[0]] |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
511 |
|
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
512 |
if len(successors) == 1: |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
513 |
return ('superseed', successors) |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
514 |
else: |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
515 |
return ('superseed_split', successors) |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
516 |
|
1527
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
517 |
def _warnobsoletewc(ui, repo): |
2289
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
518 |
rev = repo['.'] |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
519 |
|
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
520 |
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
|
521 |
return |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
522 |
|
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
523 |
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
|
524 |
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
|
525 |
|
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
526 |
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
|
527 |
|
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
528 |
# Check that evolve is activated for performance reasons |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
529 |
if ui.quiet or not obsolete.isenabled(repo, commandopt): |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
530 |
return |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
531 |
|
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
532 |
# Show a warning for helping the user to solve the issue |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
533 |
reason, successors = _getobsoletereason(repo, rev.node()) |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
534 |
|
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
535 |
if reason == 'pruned': |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
536 |
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
|
537 |
elif reason == 'diverged': |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
538 |
debugcommand = "hg evolve -list --divergent" |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
539 |
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
|
540 |
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
|
541 |
elif reason == 'superseed': |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
542 |
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
|
543 |
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
|
544 |
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
|
545 |
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
|
546 |
|
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
547 |
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
|
548 |
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
|
549 |
else: |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
550 |
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
|
551 |
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
|
552 |
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
|
553 |
solvemsg = msg % successorsmsg |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
554 |
else: |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
555 |
raise ValueError(reason) |
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
556 |
|
61d073590fb7
ui: add better messages when the working copy become obsolete.
Boris Feld <boris.feld@octobus.net>
parents:
2286
diff
changeset
|
557 |
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
|
558 |
|
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
|
559 |
if util.safehasattr(context, '_filterederror'): |
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
|
560 |
# if < hg-4.2 we do not update the message |
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
|
561 |
@eh.wrapfunction(context, '_filterederror') |
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
|
562 |
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
|
563 |
"""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
|
564 |
|
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
|
565 |
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
|
566 |
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
|
567 |
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
|
568 |
|
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
|
569 |
unfilteredrepo = repo.unfiltered() |
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
|
570 |
rev = unfilteredrepo[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
|
571 |
reason, successors = _getobsoletereason(unfilteredrepo, rev.node()) |
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
|
572 |
|
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
|
573 |
# Be more precise in cqse the revision is 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
|
574 |
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
|
575 |
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
|
576 |
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
|
577 |
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
|
578 |
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
|
579 |
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
|
580 |
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
|
581 |
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
|
582 |
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
|
583 |
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
|
584 |
|
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
|
585 |
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
|
586 |
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
|
587 |
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
|
588 |
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
|
589 |
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
|
590 |
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
|
591 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
592 |
@eh.wrapcommand("update") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
593 |
@eh.wrapcommand("pull") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
594 |
def wrapmayobsoletewc(origfn, ui, repo, *args, **opts): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
595 |
"""Warn that the working directory parent is an obsolete changeset""" |
1452
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
596 |
def warnobsolete(): |
1527
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
597 |
_warnobsoletewc(ui, repo) |
1452
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
598 |
wlock = None |
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
599 |
try: |
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
600 |
wlock = repo.wlock() |
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
601 |
repo._afterlock(warnobsolete) |
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
602 |
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
|
603 |
finally: |
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
604 |
lockmod.release(wlock) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
605 |
return res |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
606 |
|
1527
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
607 |
@eh.wrapcommand("parents") |
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
608 |
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
|
609 |
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
|
610 |
_warnobsoletewc(ui, repo) |
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
611 |
return res |
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
612 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
613 |
# XXX this could wrap transaction code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
614 |
# 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
|
615 |
@eh.wrapcommand("commit") |
763
966e2659e989
import: warn about new unstable changesets
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
762
diff
changeset
|
616 |
@eh.wrapcommand("import") |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
617 |
@eh.wrapcommand("push") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
618 |
@eh.wrapcommand("pull") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
619 |
@eh.wrapcommand("graft") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
620 |
@eh.wrapcommand("phase") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
621 |
@eh.wrapcommand("unbundle") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
622 |
def warnobserrors(orig, ui, repo, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
623 |
"""display warning is the command resulted in more instable changeset""" |
658
2a2b8c95bb43
evolve: remove revset calls in warnobserror
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
657
diff
changeset
|
624 |
# 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
|
625 |
# 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
|
626 |
filtered = repo.changelog.filteredrevs |
2a2b8c95bb43
evolve: remove revset calls in warnobserror
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
657
diff
changeset
|
627 |
priorunstables = len(set(getrevs(repo, 'unstable')) - filtered) |
2a2b8c95bb43
evolve: remove revset calls in warnobserror
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
657
diff
changeset
|
628 |
priorbumpeds = len(set(getrevs(repo, 'bumped')) - filtered) |
2a2b8c95bb43
evolve: remove revset calls in warnobserror
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
657
diff
changeset
|
629 |
priordivergents = len(set(getrevs(repo, 'divergent')) - filtered) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
630 |
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
|
631 |
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
|
632 |
newunstables = \ |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
633 |
len(set(getrevs(repo, 'unstable')) - filtered) - priorunstables |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
634 |
newbumpeds = \ |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
635 |
len(set(getrevs(repo, 'bumped')) - filtered) - priorbumpeds |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
636 |
newdivergents = \ |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
637 |
len(set(getrevs(repo, 'divergent')) - filtered) - priordivergents |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
638 |
if newunstables > 0: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
639 |
ui.warn(_('%i new unstable changesets\n') % newunstables) |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
640 |
if newbumpeds > 0: |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
641 |
ui.warn(_('%i new bumped changesets\n') % newbumpeds) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
642 |
if newdivergents > 0: |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
643 |
ui.warn(_('%i new divergent changesets\n') % newdivergents) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
644 |
return ret |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
645 |
|
1122
c8750f4388c8
evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents:
1120
diff
changeset
|
646 |
@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
|
647 |
def push(orig, repo, *args, **opts): |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
648 |
"""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
|
649 |
""" |
1122
c8750f4388c8
evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents:
1120
diff
changeset
|
650 |
try: |
c8750f4388c8
evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents:
1120
diff
changeset
|
651 |
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
|
652 |
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
|
653 |
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
|
654 |
"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
|
655 |
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
|
656 |
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
|
657 |
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
|
658 |
ex.hint = hint |
c8750f4388c8
evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents:
1120
diff
changeset
|
659 |
raise |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
660 |
|
788
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
661 |
def summaryhook(ui, repo): |
513
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
662 |
def write(fmt, count): |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
663 |
s = fmt % count |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
664 |
if count: |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
665 |
ui.write(s) |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
666 |
else: |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
667 |
ui.note(s) |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
668 |
|
1640 | 669 |
state = _evolvestateread(repo) |
670 |
if state is not None: |
|
671 |
# i18n: column positioning for "hg summary" |
|
672 |
ui.write(_('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
|
673 |
|
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
674 |
@eh.extsetup |
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
675 |
def obssummarysetup(ui): |
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
676 |
cmdutil.summaryhooks.add('evolve', summaryhook) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
677 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
678 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
679 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
680 |
### Core Other extension compat ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
681 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
682 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
683 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
684 |
@eh.extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
685 |
def _rebasewrapping(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
686 |
# warning about more obsolete |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
687 |
try: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
688 |
rebase = extensions.find('rebase') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
689 |
if rebase: |
572
dc107acd0bd2
adapt to core rebase support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
571
diff
changeset
|
690 |
extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
691 |
except KeyError: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
692 |
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
|
693 |
try: |
718262019c6f
evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
677
diff
changeset
|
694 |
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
|
695 |
if histedit: |
718262019c6f
evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
677
diff
changeset
|
696 |
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
|
697 |
except KeyError: |
1575 | 698 |
pass # histedit not found |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
699 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
700 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
701 |
### Old Evolve extension content ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
702 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
703 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
704 |
# XXX need clean up and proper sorting in other section |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
705 |
|
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
706 |
### changeset rewriting logic |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
707 |
############################# |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
708 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
709 |
def rewrite(repo, old, updates, head, newbases, commitopts): |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
710 |
"""Return (nodeid, created) where nodeid is the identifier of the |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
711 |
changeset generated by the rewrite process, and created is True if |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
712 |
nodeid was actually created. If created is False, nodeid |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
713 |
references a changeset existing before the rewrite call. |
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
714 |
""" |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
715 |
wlock = lock = tr = None |
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
716 |
try: |
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
717 |
wlock = repo.wlock() |
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
718 |
lock = repo.lock() |
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
719 |
tr = repo.transaction('rewrite') |
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
|
720 |
if len(old.parents()) > 1: # XXX remove this unnecessary limitation. |
1505
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
721 |
raise error.Abort(_('cannot amend merge changesets')) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
722 |
base = old.p1() |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
723 |
updatebookmarks = _bookmarksupdater(repo, old.node(), tr) |
1505
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
724 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
725 |
# commit a new version of the old changeset, including the update |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
726 |
# collect all files which might be affected |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
727 |
files = set(old.files()) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
728 |
for u in updates: |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
729 |
files.update(u.files()) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
730 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
731 |
# Recompute copies (avoid recording a -> b -> a) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
732 |
copied = copies.pathcopies(base, head) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
733 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
734 |
# prune files which were reverted by the updates |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
735 |
def samefile(f): |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
736 |
if f in head.manifest(): |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
737 |
a = head.filectx(f) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
738 |
if f in base.manifest(): |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
739 |
b = base.filectx(f) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
740 |
return (a.data() == b.data() |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
741 |
and a.flags() == b.flags()) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
742 |
else: |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
743 |
return False |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
744 |
else: |
1505
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
745 |
return f not in base.manifest() |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
746 |
files = [f for f in files if not samefile(f)] |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
747 |
# commit version of these files as defined by head |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
748 |
headmf = head.manifest() |
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
|
749 |
|
1505
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
750 |
def filectxfn(repo, ctx, path): |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
751 |
if path in headmf: |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
752 |
fctx = head[path] |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
753 |
flags = fctx.flags() |
1828
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
754 |
mctx = context.memfilectx(repo, fctx.path(), fctx.data(), |
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
755 |
islink='l' in flags, |
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
756 |
isexec='x' in flags, |
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
757 |
copied=copied.get(path)) |
1505
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
758 |
return mctx |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
759 |
return None |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
760 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
761 |
message = cmdutil.logmessage(repo.ui, commitopts) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
762 |
if not message: |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
763 |
message = old.description() |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
764 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
765 |
user = commitopts.get('user') or old.user() |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
766 |
date = commitopts.get('date') or None # old.date() |
1510
b86eea66ed02
evolve: be more complete about copying extra from old revisions
Augie Fackler <raf@durin42.com>
parents:
1509
diff
changeset
|
767 |
extra = dict(commitopts.get('extra', old.extra())) |
1505
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
768 |
extra['branch'] = head.branch() |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
769 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
770 |
new = context.memctx(repo, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
771 |
parents=newbases, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
772 |
text=message, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
773 |
files=files, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
774 |
filectxfn=filectxfn, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
775 |
user=user, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
776 |
date=date, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
777 |
extra=extra) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
778 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
779 |
if commitopts.get('edit'): |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
780 |
new._text = cmdutil.commitforceeditor(repo, new, []) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
781 |
revcount = len(repo) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
782 |
newid = repo.commitctx(new) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
783 |
new = repo[newid] |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
784 |
created = len(repo) != revcount |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
785 |
updatebookmarks(newid) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
786 |
|
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
787 |
tr.close() |
1505
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
788 |
return newid, created |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
789 |
finally: |
1554
59f5bb1f1877
transaction: fix release order in 'rewrite'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1547
diff
changeset
|
790 |
lockmod.release(tr, lock, wlock) |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
791 |
|
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
792 |
class MergeFailure(error.Abort): |
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
793 |
pass |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
794 |
|
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
795 |
def relocate(repo, orig, dest, pctx=None, keepbranch=False): |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
796 |
"""rewrite <rev> on dest""" |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
797 |
if orig.rev() == dest.rev(): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
798 |
raise error.Abort(_('tried to relocate a node on top of itself'), |
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
|
799 |
hint=_("This shouldn't happen. If you still " |
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
|
800 |
"need to move changesets, please do so " |
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
|
801 |
"manually with nothing to rebase - working " |
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
|
802 |
"directory parent is also destination")) |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
803 |
|
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
804 |
if pctx is None: |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
805 |
if len(orig.parents()) == 2: |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
806 |
raise error.Abort(_("tried to relocate a merge commit without " |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
807 |
"specifying which parent should be moved"), |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
808 |
hint=_("Specify the parent by passing in pctx")) |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
809 |
pctx = orig.p1() |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
810 |
|
1106
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
811 |
commitmsg = orig.description() |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
812 |
|
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
813 |
cache = {} |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
814 |
sha1s = re.findall(sha1re, commitmsg) |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
815 |
unfi = repo.unfiltered() |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
816 |
for sha1 in sha1s: |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
817 |
ctx = None |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
818 |
try: |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
819 |
ctx = unfi[sha1] |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
820 |
except error.RepoLookupError: |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
821 |
continue |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
822 |
|
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
823 |
if not ctx.obsolete(): |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
824 |
continue |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
825 |
|
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
826 |
successors = obsolete.successorssets(repo, ctx.node(), cache) |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
827 |
|
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
828 |
# We can't make any assumptions about how to update the hash if the |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
829 |
# cset in question was split or diverged. |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
830 |
if len(successors) == 1 and len(successors[0]) == 1: |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
831 |
newsha1 = node.hex(successors[0][0]) |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
832 |
commitmsg = commitmsg.replace(sha1, newsha1[:len(sha1)]) |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
833 |
else: |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
834 |
repo.ui.note(_('The stale commit message reference to %s could ' |
1145
fb51113a1c08
evolve: add the missing newline to output messages where needed
Matt Harbison <matt_harbison@yahoo.com>
parents:
1144
diff
changeset
|
835 |
'not be updated\n') % sha1) |
1106
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
836 |
|
1593
2f117c299325
evolve: remove meaningless transaction nesting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1592
diff
changeset
|
837 |
tr = repo.currenttransaction() |
2f117c299325
evolve: remove meaningless transaction nesting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1592
diff
changeset
|
838 |
assert tr is not None |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
839 |
try: |
1729
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
840 |
r = _evolvemerge(repo, orig, dest, pctx, keepbranch) |
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
|
841 |
if r[-1]: # some conflict |
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
|
842 |
raise error.Abort(_('unresolved merge conflicts ' |
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
|
843 |
'(see hg help resolve)')) |
1729
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
844 |
nodenew = _relocatecommit(repo, orig, commitmsg) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
845 |
except error.Abort as exc: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
846 |
repo.dirstate.beginparentchange() |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
847 |
repo.setparents(repo['.'].node(), nullid) |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
848 |
repo.dirstate.write(tr) |
1729
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
849 |
# fix up dirstate for copies and renames |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
850 |
copies.duplicatecopies(repo, dest.rev(), orig.p1().rev()) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
851 |
repo.dirstate.endparentchange() |
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
|
852 |
|
1729
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
853 |
class LocalMergeFailure(MergeFailure, exc.__class__): |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
854 |
pass |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
855 |
exc.__class__ = LocalMergeFailure |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
856 |
tr.close() # to keep changes in this transaction (e.g. dirstate) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
857 |
raise |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
858 |
_finalizerelocate(repo, orig, dest, nodenew, tr) |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
859 |
return nodenew |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
860 |
|
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
861 |
def _bookmarksupdater(repo, oldid, tr): |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
862 |
"""Return a callable update(newid) updating the current bookmark |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
863 |
and bookmarks bound to oldid to newid. |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
864 |
""" |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
865 |
def updatebookmarks(newid): |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
866 |
dirty = False |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
867 |
oldbookmarks = repo.nodebookmarks(oldid) |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
868 |
if oldbookmarks: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
869 |
for b in oldbookmarks: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
870 |
repo._bookmarks[b] = newid |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
871 |
dirty = True |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
872 |
if dirty: |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
873 |
repo._bookmarks.recordchange(tr) |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
874 |
return updatebookmarks |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
875 |
|
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
876 |
### new command |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
877 |
############################# |
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
878 |
metadataopts = [ |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
879 |
('d', 'date', '', |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
880 |
_('record the specified date in metadata'), _('DATE')), |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
881 |
('u', 'user', '', |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
882 |
_('record the specified user in metadata'), _('USER')), |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
883 |
] |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
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.uisetup |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
886 |
def _installimportobsolete(ui): |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
887 |
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
|
888 |
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
|
889 |
_('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
|
890 |
'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
|
891 |
|
953
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
892 |
@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
|
893 |
def tryimportone(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
|
894 |
extracted = patch.extract(ui, hunk) |
1830
53aae4b4e791
compat: drop compatibility layer for 'tryimportone'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1829
diff
changeset
|
895 |
expected = extracted.get('nodeid') |
1115
cc19b6400dae
import: fix the "is None" check for the Node
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1109
diff
changeset
|
896 |
if expected is not None: |
1055
cfe1b9d3e5d9
import: handle patch with no node information
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1054
diff
changeset
|
897 |
expected = node.bin(expected) |
953
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
898 |
oldextract = patch.extract |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
899 |
try: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
900 |
patch.extract = lambda ui, hunk: extracted |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
901 |
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
|
902 |
finally: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
903 |
patch.extract = oldextract |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
904 |
created = ret[1] |
1055
cfe1b9d3e5d9
import: handle patch with no node information
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1054
diff
changeset
|
905 |
if (opts['obsolete'] and None not in (created, expected) |
cfe1b9d3e5d9
import: handle patch with no node information
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1054
diff
changeset
|
906 |
and created != expected): |
953
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
907 |
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
|
908 |
try: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
909 |
metadata = {'user': ui.username()} |
1054
93e920feff5e
import: compare binary node with binary node when using --obsolete
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1052
diff
changeset
|
910 |
repo.obsstore.create(tr, expected, (created,), |
953
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
911 |
metadata=metadata) |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
912 |
tr.close() |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
913 |
finally: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
914 |
tr.release() |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
915 |
return ret |
930
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
927
diff
changeset
|
916 |
|
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
917 |
|
894
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
918 |
def _deprecatealias(oldalias, newalias): |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
919 |
'''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
|
920 |
|
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
921 |
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
|
922 |
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
|
923 |
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
|
924 |
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
|
925 |
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
|
926 |
|
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
927 |
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
|
928 |
''' |
1226
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
929 |
try: |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
930 |
aliases, entry = cmdutil.findcmd(newalias, cmdtable) |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
931 |
except error.UnknownCommand: |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
932 |
# Commands may be disabled |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
933 |
return |
1680
7caa5f2040c5
py3: use items() instead of iteritems()
timeless@gmail.com
parents:
1679
diff
changeset
|
934 |
for alias, e in cmdtable.items(): |
894
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
935 |
if e is entry: |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
936 |
break |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
937 |
|
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
938 |
synopsis = '(DEPRECATED)' |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
939 |
if len(entry) > 2: |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
940 |
fn, opts, _syn = entry |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
941 |
else: |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
942 |
fn, opts, = entry |
1496 | 943 |
deprecationwarning = _('%s have been deprecated in favor of %s\n') % ( |
944 |
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
|
945 |
|
894
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
946 |
def newfn(*args, **kwargs): |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
947 |
ui = args[0] |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
948 |
ui.warn(deprecationwarning) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
949 |
util.checksignature(fn)(*args, **kwargs) |
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
|
950 |
newfn.__doc__ = deprecationwarning |
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
951 |
cmdwrapper = eh.command(oldalias, opts, synopsis) |
894
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
952 |
cmdwrapper(newfn) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
953 |
|
895
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
954 |
@eh.extsetup |
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
955 |
def deprecatealiases(ui): |
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
956 |
_deprecatealias('gup', 'next') |
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
957 |
_deprecatealias('gdown', 'previous') |
894
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
958 |
|
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
959 |
def _solveone(ui, repo, ctx, dryrun, confirm, progresscb, category): |
1320
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
960 |
"""Resolve the troubles affecting one revision""" |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
961 |
wlock = lock = tr = None |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
962 |
try: |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
963 |
wlock = repo.wlock() |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
964 |
lock = repo.lock() |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
965 |
tr = repo.transaction("evolve") |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
966 |
if 'unstable' == category: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
967 |
result = _solveunstable(ui, repo, ctx, dryrun, confirm, progresscb) |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
968 |
elif 'bumped' == category: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
969 |
result = _solvebumped(ui, repo, ctx, dryrun, confirm, progresscb) |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
970 |
elif 'divergent' == category: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
971 |
result = _solvedivergent(ui, repo, ctx, dryrun, confirm, |
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
|
972 |
progresscb) |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
973 |
else: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
974 |
assert False, "unknown trouble category: %s" % (category) |
1320
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
975 |
tr.close() |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
976 |
return result |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
977 |
finally: |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
978 |
lockmod.release(tr, lock, wlock) |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
979 |
|
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
980 |
def _handlenotrouble(ui, repo, allopt, revopt, anyopt, targetcat): |
1327
7821a00fb6de
evolve: rename handlenotrouble to _handlenotrouble and add doc
Laurent Charignon <lcharignon@fb.com>
parents:
1326
diff
changeset
|
981 |
"""Used by the evolve function to display an error message when |
7821a00fb6de
evolve: rename handlenotrouble to _handlenotrouble and add doc
Laurent Charignon <lcharignon@fb.com>
parents:
1326
diff
changeset
|
982 |
no troubles can be resolved""" |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
983 |
troublecategories = ['bumped', 'divergent', 'unstable'] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
984 |
unselectedcategories = [c for c in troublecategories if c != targetcat] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
985 |
msg = None |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
986 |
hint = None |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
987 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
988 |
troubled = { |
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
|
989 |
"unstable": repo.revs("unstable()"), |
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
|
990 |
"divergent": repo.revs("divergent()"), |
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
|
991 |
"bumped": repo.revs("bumped()"), |
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
|
992 |
"all": repo.revs("troubled()"), |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
993 |
} |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
994 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
995 |
hintmap = { |
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
|
996 |
'bumped': _("do you want to use --bumped"), |
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
|
997 |
'bumped+divergent': _("do you want to use --bumped or --divergent"), |
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
|
998 |
'bumped+unstable': _("do you want to use --bumped or --unstable"), |
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
|
999 |
'divergent': _("do you want to use --divergent"), |
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
|
1000 |
'divergent+unstable': _("do you want to use --divergent" |
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
|
1001 |
" or --unstable"), |
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
|
1002 |
'unstable': _("do you want to use --unstable"), |
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
|
1003 |
'any+bumped': _("do you want to use --any (or --rev) and --bumped"), |
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
|
1004 |
'any+bumped+divergent': _("do you want to use --any (or --rev) and" |
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
|
1005 |
" --bumped or --divergent"), |
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
|
1006 |
'any+bumped+unstable': _("do you want to use --any (or --rev) and" |
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
|
1007 |
"--bumped or --unstable"), |
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
|
1008 |
'any+divergent': _("do you want to use --any (or --rev) and" |
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
|
1009 |
" --divergent"), |
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
|
1010 |
'any+divergent+unstable': _("do you want to use --any (or --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
|
1011 |
" and --divergent or --unstable"), |
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
|
1012 |
'any+unstable': _("do you want to use --any (or --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
|
1013 |
"and --unstable"), |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1014 |
} |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1015 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1016 |
if revopt: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1017 |
revs = scmutil.revrange(repo, revopt) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1018 |
if not revs: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1019 |
msg = _("set of specified revisions is empty") |
1316
f11363699766
evolve: refactoring of the code displaying error when no trouble found
Laurent Charignon <lcharignon@fb.com>
parents:
1315
diff
changeset
|
1020 |
else: |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1021 |
msg = _("no %s changesets in specified revisions") % targetcat |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1022 |
othertroubles = [] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1023 |
for cat in unselectedcategories: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1024 |
if revs & troubled[cat]: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1025 |
othertroubles.append(cat) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1026 |
if othertroubles: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1027 |
hint = hintmap['+'.join(othertroubles)] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1028 |
|
1422
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1029 |
elif anyopt: |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1030 |
msg = _("no %s changesets to evolve") % targetcat |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1031 |
othertroubles = [] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1032 |
for cat in unselectedcategories: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1033 |
if troubled[cat]: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1034 |
othertroubles.append(cat) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1035 |
if othertroubles: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1036 |
hint = hintmap['+'.join(othertroubles)] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1037 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1038 |
else: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1039 |
# evolve without any option = relative to the current wdir |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1040 |
if targetcat == 'unstable': |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1041 |
msg = _("nothing to evolve on current working copy parent") |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1042 |
else: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1043 |
msg = _("current working copy parent is not %s") % targetcat |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1044 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1045 |
p1 = repo['.'].rev() |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1046 |
othertroubles = [] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1047 |
for cat in unselectedcategories: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1048 |
if p1 in troubled[cat]: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1049 |
othertroubles.append(cat) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1050 |
if othertroubles: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1051 |
hint = hintmap['+'.join(othertroubles)] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1052 |
else: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1053 |
l = len(troubled[targetcat]) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1054 |
if l: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1055 |
hint = _("%d other %s in the repository, do you want --any " |
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
|
1056 |
"or --rev") % (l, targetcat) |
750
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1057 |
else: |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1058 |
othertroubles = [] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1059 |
for cat in unselectedcategories: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1060 |
if troubled[cat]: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1061 |
othertroubles.append(cat) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1062 |
if othertroubles: |
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
|
1063 |
hint = hintmap['any+' + ('+'.join(othertroubles))] |
750
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1064 |
else: |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1065 |
msg = _("no troubled changesets") |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1066 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1067 |
assert msg is not None |
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
|
1068 |
ui.write_err("%s\n" % msg) |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1069 |
if hint: |
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
|
1070 |
ui.write_err("(%s)\n" % hint) |
1316
f11363699766
evolve: refactoring of the code displaying error when no trouble found
Laurent Charignon <lcharignon@fb.com>
parents:
1315
diff
changeset
|
1071 |
return 2 |
f11363699766
evolve: refactoring of the code displaying error when no trouble found
Laurent Charignon <lcharignon@fb.com>
parents:
1315
diff
changeset
|
1072 |
else: |
f11363699766
evolve: refactoring of the code displaying error when no trouble found
Laurent Charignon <lcharignon@fb.com>
parents:
1315
diff
changeset
|
1073 |
return 1 |
1324
739208d1ee62
evolve: extract cleanup logic in the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1323
diff
changeset
|
1074 |
|
739208d1ee62
evolve: extract cleanup logic in the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1323
diff
changeset
|
1075 |
def _cleanup(ui, repo, startnode, showprogress): |
739208d1ee62
evolve: extract cleanup logic in the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1323
diff
changeset
|
1076 |
if showprogress: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1077 |
ui.progress(_('evolve'), None) |
1099
bac4e0bc9f6a
evolve: write a status message when the working directory changes
David Soria Parra <davidsp@fb.com>
parents:
1067
diff
changeset
|
1078 |
if repo['.'] != startnode: |
bac4e0bc9f6a
evolve: write a status message when the working directory changes
David Soria Parra <davidsp@fb.com>
parents:
1067
diff
changeset
|
1079 |
ui.status(_('working directory is now at %s\n') % repo['.']) |
bac4e0bc9f6a
evolve: write a status message when the working directory changes
David Soria Parra <davidsp@fb.com>
parents:
1067
diff
changeset
|
1080 |
|
1408
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1081 |
class MultipleSuccessorsError(RuntimeError): |
1569
bd1468c23d88
evolve: scattered typo fixes in comments, docstrings
Greg Ward <greg@gerg.ca>
parents:
1528
diff
changeset
|
1082 |
"""Exception raised by _singlesuccessor when multiple successor sets exists |
1408
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1083 |
|
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1084 |
The object contains the list of successorssets in its 'successorssets' |
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1085 |
attribute to call to easily recover. |
509
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1086 |
""" |
1408
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1087 |
|
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1088 |
def __init__(self, successorssets): |
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1089 |
self.successorssets = successorssets |
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1090 |
|
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1091 |
def _singlesuccessor(repo, p): |
1369
4ed67cce8c23
evolve: properly evolve stacked unstable with --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1364
diff
changeset
|
1092 |
"""returns p (as rev) if not obsolete or its unique latest successors |
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1093 |
|
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1094 |
fail if there are no such successor""" |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1095 |
|
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1096 |
if not p.obsolete(): |
1369
4ed67cce8c23
evolve: properly evolve stacked unstable with --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1364
diff
changeset
|
1097 |
return p.rev() |
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1098 |
obs = repo[p] |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1099 |
ui = repo.ui |
630
722b52c75f02
compat: adapt to upstreaming of divergent logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
622
diff
changeset
|
1100 |
newer = obsolete.successorssets(repo, obs.node()) |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1101 |
# search of a parent which is not killed |
1440
afe46c3b15db
evolve: clarify code in _singlesuccessor
Laurent Charignon <lcharignon@fb.com>
parents:
1428
diff
changeset
|
1102 |
while not newer: |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1103 |
ui.debug("stabilize target %s is plain dead," |
1145
fb51113a1c08
evolve: add the missing newline to output messages where needed
Matt Harbison <matt_harbison@yahoo.com>
parents:
1144
diff
changeset
|
1104 |
" trying to stabilize on its parent\n" % |
1144
b2a78b950a51
evolve: add the missing argument to a debug statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
1143
diff
changeset
|
1105 |
obs) |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1106 |
obs = obs.parents()[0] |
630
722b52c75f02
compat: adapt to upstreaming of divergent logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
622
diff
changeset
|
1107 |
newer = obsolete.successorssets(repo, obs.node()) |
1428
20a3b0b27bfe
evolve: raise MultipleSuccessorsError when computing dependency for split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1427
diff
changeset
|
1108 |
if len(newer) > 1 or len(newer[0]) > 1: |
1408
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1109 |
raise MultipleSuccessorsError(newer) |
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1110 |
|
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1111 |
return repo[newer[0][0]].rev() |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1112 |
|
1361
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1113 |
def builddependencies(repo, revs): |
1411
64515965c0df
evolve: some style fix
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1410
diff
changeset
|
1114 |
"""returns dependency graphs giving an order to solve instability of revs |
64515965c0df
evolve: some style fix
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1410
diff
changeset
|
1115 |
(see _orderrevs for more information on usage)""" |
1361
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1116 |
|
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1117 |
# For each troubled revision we keep track of what instability if any should |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1118 |
# be resolved in order to resolve it. Example: |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1119 |
# dependencies = {3: [6], 6:[]} |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1120 |
# Means that: 6 has no dependency, 3 depends on 6 to be solved |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1121 |
dependencies = {} |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1122 |
# rdependencies is the inverted dict of dependencies |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1123 |
rdependencies = collections.defaultdict(set) |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1124 |
|
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1125 |
for r in revs: |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1126 |
dependencies[r] = set() |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1127 |
for p in repo[r].parents(): |
1408
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1128 |
try: |
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1129 |
succ = _singlesuccessor(repo, p) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1130 |
except MultipleSuccessorsError as exc: |
1408
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1131 |
dependencies[r] = exc.successorssets |
1418
ed9a8b1ee9bd
evolve: fix error in builddependencies
Laurent Charignon <lcharignon@fb.com>
parents:
1415
diff
changeset
|
1132 |
continue |
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1133 |
if succ in revs: |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1134 |
dependencies[r].add(succ) |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1135 |
rdependencies[succ].add(r) |
1361
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1136 |
return dependencies, rdependencies |
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1137 |
|
1467
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1138 |
def _dedupedivergents(repo, revs): |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1139 |
"""Dedupe the divergents revs in revs to get one from each group with the |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1140 |
lowest revision numbers |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1141 |
""" |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1142 |
repo = repo.unfiltered() |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1143 |
res = set() |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1144 |
# To not reevaluate divergents of the same group once one is encountered |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1145 |
discarded = set() |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1146 |
for rev in revs: |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1147 |
if rev in discarded: |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1148 |
continue |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1149 |
divergent = repo[rev] |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1150 |
base, others = divergentdata(divergent) |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1151 |
othersrevs = [o.rev() for o in others] |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1152 |
res.add(min([divergent.rev()] + othersrevs)) |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1153 |
discarded.update(othersrevs) |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1154 |
return res |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1155 |
|
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1156 |
def _selectrevs(repo, allopt, revopt, anyopt, targetcat): |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1157 |
"""select troubles in repo matching according to given options""" |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1158 |
revs = set() |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1159 |
if allopt or revopt: |
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
|
1160 |
revs = repo.revs("%s()" % targetcat) |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1161 |
if revopt: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1162 |
revs = scmutil.revrange(repo, revopt) & revs |
1626
0edb545503fe
topic: 'hg evolve --all' pick all trouble within current topic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1624
diff
changeset
|
1163 |
elif not anyopt: |
0edb545503fe
topic: 'hg evolve --all' pick all trouble within current topic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1624
diff
changeset
|
1164 |
topic = getattr(repo, 'currenttopic', '') |
0edb545503fe
topic: 'hg evolve --all' pick all trouble within current topic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1624
diff
changeset
|
1165 |
if topic: |
0edb545503fe
topic: 'hg evolve --all' pick all trouble within current topic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1624
diff
changeset
|
1166 |
revs = repo.revs('topic(%s)', topic) & revs |
0edb545503fe
topic: 'hg evolve --all' pick all trouble within current topic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1624
diff
changeset
|
1167 |
elif targetcat == 'unstable': |
0edb545503fe
topic: 'hg evolve --all' pick all trouble within current topic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1624
diff
changeset
|
1168 |
revs = _aspiringdescendant(repo, |
0edb545503fe
topic: 'hg evolve --all' pick all trouble within current topic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1624
diff
changeset
|
1169 |
repo.revs('(.::) - obsolete()::')) |
0edb545503fe
topic: 'hg evolve --all' pick all trouble within current topic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1624
diff
changeset
|
1170 |
revs = set(revs) |
1467
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1171 |
if targetcat == 'divergent': |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1172 |
# Pick one divergent per group of divergents |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1173 |
revs = _dedupedivergents(repo, revs) |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1174 |
elif anyopt: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1175 |
revs = repo.revs('first(%s())' % (targetcat)) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1176 |
elif targetcat == 'unstable': |
1421
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1177 |
revs = set(_aspiringchildren(repo, repo.revs('(.::) - obsolete()::'))) |
1420
0b714c4ad9ff
evolve: consider all potential candidates on bare evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1419
diff
changeset
|
1178 |
if 1 < len(revs): |
0b714c4ad9ff
evolve: consider all potential candidates on bare evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1419
diff
changeset
|
1179 |
msg = "multiple evolve candidates" |
0b714c4ad9ff
evolve: consider all potential candidates on bare evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1419
diff
changeset
|
1180 |
hint = (_("select one of %s with --rev") |
0b714c4ad9ff
evolve: consider all potential candidates on bare evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1419
diff
changeset
|
1181 |
% ', '.join([str(repo[r]) for r in sorted(revs)])) |
0b714c4ad9ff
evolve: consider all potential candidates on bare evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1419
diff
changeset
|
1182 |
raise error.Abort(msg, hint=hint) |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1183 |
elif targetcat in repo['.'].troubles(): |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1184 |
revs = set([repo['.'].rev()]) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1185 |
return revs |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1186 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1187 |
|
1411
64515965c0df
evolve: some style fix
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1410
diff
changeset
|
1188 |
def _orderrevs(repo, revs): |
64515965c0df
evolve: some style fix
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1410
diff
changeset
|
1189 |
"""Compute an ordering to solve instability for the given revs |
1361
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1190 |
|
1571
0e8936e7cb89
evolve: improve the confusing docstring for _orderrevs()
Greg Ward <greg@gerg.ca>
parents:
1570
diff
changeset
|
1191 |
revs is a list of unstable revisions. |
0e8936e7cb89
evolve: improve the confusing docstring for _orderrevs()
Greg Ward <greg@gerg.ca>
parents:
1570
diff
changeset
|
1192 |
|
0e8936e7cb89
evolve: improve the confusing docstring for _orderrevs()
Greg Ward <greg@gerg.ca>
parents:
1570
diff
changeset
|
1193 |
Returns the same revisions ordered to solve their instability from the |
1361
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1194 |
bottom to the top of the stack that the stabilization process will produce |
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1195 |
eventually. |
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1196 |
|
1571
0e8936e7cb89
evolve: improve the confusing docstring for _orderrevs()
Greg Ward <greg@gerg.ca>
parents:
1570
diff
changeset
|
1197 |
This ensures the minimal number of stabilizations, as we can stabilize each |
0e8936e7cb89
evolve: improve the confusing docstring for _orderrevs()
Greg Ward <greg@gerg.ca>
parents:
1570
diff
changeset
|
1198 |
revision on its final stabilized destination. |
1361
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1199 |
""" |
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1200 |
# Step 1: Build the dependency graph |
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1201 |
dependencies, rdependencies = builddependencies(repo, revs) |
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1202 |
# Step 2: Build the ordering |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1203 |
# Remove the revisions with no dependency(A) and add them to the ordering. |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1204 |
# Removing these revisions leads to new revisions with no dependency (the |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1205 |
# one depending on A) that we can remove from the dependency graph and add |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1206 |
# to the ordering. We progress in a similar fashion until the ordering is |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1207 |
# built |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1208 |
solvablerevs = collections.deque([r for r in sorted(dependencies.keys()) |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1209 |
if not dependencies[r]]) |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1210 |
ordering = [] |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1211 |
while solvablerevs: |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1212 |
rev = solvablerevs.popleft() |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1213 |
for dependent in rdependencies[rev]: |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1214 |
dependencies[dependent].remove(rev) |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1215 |
if not dependencies[dependent]: |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1216 |
solvablerevs.append(dependent) |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1217 |
del dependencies[rev] |
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1218 |
ordering.append(rev) |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1219 |
|
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1220 |
ordering.extend(sorted(dependencies)) |
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1221 |
return ordering |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1222 |
|
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1223 |
def divergentsets(repo, ctx): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1224 |
"""Compute sets of commits divergent with a given one""" |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1225 |
cache = {} |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1226 |
base = {} |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1227 |
for n in obsolete.allprecursors(repo.obsstore, [ctx.node()]): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1228 |
if n == ctx.node(): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1229 |
# a node can't be a base for divergence with itself |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1230 |
continue |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1231 |
nsuccsets = obsolete.successorssets(repo, n, cache) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1232 |
for nsuccset in nsuccsets: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1233 |
if ctx.node() in nsuccset: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1234 |
# we are only interested in *other* successor sets |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1235 |
continue |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1236 |
if tuple(nsuccset) in base: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1237 |
# we already know the latest base for this divergency |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1238 |
continue |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1239 |
base[tuple(nsuccset)] = n |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1240 |
divergence = [] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1241 |
for divset, b in base.iteritems(): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1242 |
divergence.append({ |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1243 |
'divergentnodes': divset, |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1244 |
'commonprecursor': b |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1245 |
}) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1246 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1247 |
return divergence |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1248 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1249 |
def _preparelistctxs(items, condition): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1250 |
return [item.hex() for item in items if condition(item)] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1251 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1252 |
def _formatctx(fm, ctx): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1253 |
fm.data(node=ctx.hex()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1254 |
fm.data(desc=ctx.description()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1255 |
fm.data(date=ctx.date()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1256 |
fm.data(user=ctx.user()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1257 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1258 |
def listtroubles(ui, repo, troublecategories, **opts): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1259 |
"""Print all the troubles for the repo (or given revset)""" |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1260 |
troublecategories = troublecategories or ['divergent', 'unstable', 'bumped'] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1261 |
showunstable = 'unstable' in troublecategories |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1262 |
showbumped = 'bumped' in troublecategories |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1263 |
showdivergent = 'divergent' in troublecategories |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1264 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1265 |
revs = repo.revs('+'.join("%s()" % t for t in troublecategories)) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1266 |
if opts.get('rev'): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1267 |
revs = revs & repo.revs(opts.get('rev')) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1268 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1269 |
fm = ui.formatter('evolvelist', opts) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1270 |
for rev in revs: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1271 |
ctx = repo[rev] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1272 |
unpars = _preparelistctxs(ctx.parents(), lambda p: p.unstable()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1273 |
obspars = _preparelistctxs(ctx.parents(), lambda p: p.obsolete()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1274 |
imprecs = _preparelistctxs(repo.set("allprecursors(%n)", ctx.node()), |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1275 |
lambda p: not p.mutable()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1276 |
dsets = divergentsets(repo, ctx) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1277 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1278 |
fm.startitem() |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1279 |
# plain formatter section |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1280 |
hashlen, desclen = 12, 60 |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1281 |
desc = ctx.description() |
1637
078e6777ac15
list: limit to descriptions to firstline
timeless@gmail.com
parents:
1636
diff
changeset
|
1282 |
if desc: |
078e6777ac15
list: limit to descriptions to firstline
timeless@gmail.com
parents:
1636
diff
changeset
|
1283 |
desc = desc.splitlines()[0] |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1284 |
desc = (desc[:desclen] + '...') if len(desc) > desclen else desc |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1285 |
fm.plain('%s: ' % ctx.hex()[:hashlen]) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1286 |
fm.plain('%s\n' % desc) |
1682
fe4b41a2af4e
evolve: include node, rev, desc, and phase in list
timeless@gmail.com
parents:
1681
diff
changeset
|
1287 |
fm.data(node=ctx.hex(), rev=ctx.rev(), desc=desc, phase=ctx.phasestr()) |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1288 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1289 |
for unpar in unpars if showunstable else []: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1290 |
fm.plain(' unstable: %s (unstable parent)\n' % unpar[:hashlen]) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1291 |
for obspar in obspars if showunstable else []: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1292 |
fm.plain(' unstable: %s (obsolete parent)\n' % obspar[:hashlen]) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1293 |
for imprec in imprecs if showbumped else []: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1294 |
fm.plain(' bumped: %s (immutable precursor)\n' % imprec[:hashlen]) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1295 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1296 |
if dsets and showdivergent: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1297 |
for dset in dsets: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1298 |
fm.plain(' divergent: ') |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1299 |
first = True |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1300 |
for n in dset['divergentnodes']: |
1646
7e1b49cda66c
list: report the phase for divergent commits
timeless@gmail.com
parents:
1640
diff
changeset
|
1301 |
t = "%s (%s)" if first else " %s (%s)" |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1302 |
first = False |
1646
7e1b49cda66c
list: report the phase for divergent commits
timeless@gmail.com
parents:
1640
diff
changeset
|
1303 |
fm.plain(t % (node.hex(n)[:hashlen], repo[n].phasestr())) |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1304 |
comprec = node.hex(dset['commonprecursor'])[:hashlen] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1305 |
fm.plain(" (precursor %s)\n" % comprec) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1306 |
fm.plain("\n") |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1307 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1308 |
# templater-friendly section |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1309 |
_formatctx(fm, ctx) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1310 |
troubles = [] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1311 |
for unpar in unpars: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1312 |
troubles.append({'troubletype': 'unstable', 'sourcenode': unpar, |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1313 |
'sourcetype': 'unstableparent'}) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1314 |
for obspar in obspars: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1315 |
troubles.append({'troubletype': 'unstable', 'sourcenode': obspar, |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1316 |
'sourcetype': 'obsoleteparent'}) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1317 |
for imprec in imprecs: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1318 |
troubles.append({'troubletype': 'bumped', 'sourcenode': imprec, |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1319 |
'sourcetype': 'immutableprecursor'}) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1320 |
for dset in dsets: |
1681 | 1321 |
divnodes = [{'node': node.hex(n), |
1682
fe4b41a2af4e
evolve: include node, rev, desc, and phase in list
timeless@gmail.com
parents:
1681
diff
changeset
|
1322 |
'phase': repo[n].phasestr(), |
1681 | 1323 |
} for n in dset['divergentnodes']] |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1324 |
troubles.append({'troubletype': 'divergent', |
1681 | 1325 |
'commonprecursor': node.hex(dset['commonprecursor']), |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1326 |
'divergentnodes': divnodes}) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1327 |
fm.data(troubles=troubles) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1328 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1329 |
fm.end() |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1330 |
|
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1331 |
@eh.command( |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1332 |
'^evolve|stabilize|solve', |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1333 |
[('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
|
1334 |
_('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
|
1335 |
('', 'confirm', False, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1336 |
_('ask for confirmation before performing the action')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1337 |
('A', 'any', False, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1338 |
_('also consider troubled changesets unrelated to current working ' |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1339 |
'directory')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1340 |
('r', 'rev', [], _('solves troubles of these revisions')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1341 |
('', 'bumped', False, _('solves only bumped changesets')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1342 |
('', 'divergent', False, _('solves only divergent changesets')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1343 |
('', 'unstable', False, _('solves only unstable changesets (default)')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1344 |
('a', 'all', False, _('evolve all troubled changesets related to the ' |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1345 |
'current working directory and its descendants')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1346 |
('c', 'continue', False, _('continue an interrupted evolution')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1347 |
('l', 'list', False, 'provide details on troubled changesets in the repo'), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1348 |
] + mergetoolopts, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1349 |
_('[OPTIONS]...') |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1350 |
) |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1351 |
def evolve(ui, repo, **opts): |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1352 |
"""solve troubled changesets in your repository |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1353 |
|
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1354 |
Modifying history can lead to various types of troubled changesets: |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1355 |
unstable, bumped, or divergent. The evolve command resolves your troubles |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1356 |
by executing one of the following actions: |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1357 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1358 |
- update working copy to a successor |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1359 |
- rebase an unstable changeset |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1360 |
- extract the desired changes from a bumped changeset |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1361 |
- fuse divergent changesets back together |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1362 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1363 |
If you pass no arguments, evolve works in automatic mode: it will execute a |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1364 |
single action to reduce instability related to your working copy. There are |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1365 |
two cases for this action. First, if the parent of your working copy is |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1366 |
obsolete, evolve updates to the parent's successor. Second, if the working |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1367 |
copy parent is not obsolete but has obsolete predecessors, then evolve |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1368 |
determines if there is an unstable changeset that can be rebased onto the |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1369 |
working copy parent in order to reduce instability. |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1370 |
If so, evolve rebases that changeset. If not, evolve refuses to guess your |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1371 |
intention, and gives a hint about what you might want to do next. |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1372 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1373 |
Any time evolve creates a changeset, it updates the working copy to the new |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1374 |
changeset. (Currently, every successful evolve operation involves an update |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1375 |
as well; this may change in future.) |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1376 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1377 |
Automatic mode only handles common use cases. For example, it avoids taking |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1378 |
action in the case of ambiguity, and it ignores unstable changesets that |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1379 |
are not related to your working copy. |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1380 |
It also refuses to solve bumped or divergent changesets unless you explicity |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1381 |
request such behavior (see below). |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1382 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1383 |
Eliminating all instability around your working copy may require multiple |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1384 |
invocations of :hg:`evolve`. Alternately, use ``--all`` to recursively |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1385 |
select and evolve all unstable changesets that can be rebased onto the |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1386 |
working copy parent. |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1387 |
This is more powerful than successive invocations, since ``--all`` handles |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1388 |
ambiguous cases (e.g. unstable changesets with multiple children) by |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1389 |
evolving all branches. |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1390 |
|
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1391 |
When your repository cannot be handled by automatic mode, you might need to |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1392 |
use ``--rev`` to specify a changeset to evolve. For example, if you have |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1393 |
an unstable changeset that is not related to the working copy parent, |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1394 |
you could use ``--rev`` to evolve it. Or, if some changeset has multiple |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1395 |
unstable children, evolve in automatic mode refuses to guess which one to |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1396 |
evolve; you have to use ``--rev`` in that case. |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1397 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1398 |
Alternately, ``--any`` makes evolve search for the next evolvable changeset |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1399 |
regardless of whether it is related to the working copy parent. |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1400 |
|
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1401 |
You can supply multiple revisions to evolve multiple troubled changesets |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1402 |
in a single invocation. In revset terms, ``--any`` is equivalent to ``--rev |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1403 |
first(unstable())``. ``--rev`` and ``--all`` are mutually exclusive, as are |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1404 |
``--rev`` and ``--any``. |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1405 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1406 |
``hg evolve --any --all`` is useful for cleaning up instability across all |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1407 |
branches, letting evolve figure out the appropriate order and destination. |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1408 |
|
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1409 |
When you have troubled changesets that are not unstable, :hg:`evolve` |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1410 |
refuses to consider them unless you specify the category of trouble you |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1411 |
wish to resolve, with ``--bumped`` or ``--divergent``. These options are |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1412 |
currently mutually exclusive with each other and with ``--unstable`` |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1413 |
(the default). You can combine ``--bumped`` or ``--divergent`` with |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1414 |
``--rev``, ``--all``, or ``--any``. |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1415 |
|
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1416 |
You can also use the evolve command to list the troubles affecting your |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1417 |
repository by using the --list flag. You can choose to display only some |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1418 |
categories of troubles with the --unstable, --divergent or --bumped flags. |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
1419 |
""" |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1420 |
|
1325
1fe3da0b4601
evolve: add --rev option to the evolve command
Laurent Charignon <lcharignon@fb.com>
parents:
1324
diff
changeset
|
1421 |
# Options |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1422 |
listopt = opts['list'] |
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1423 |
contopt = opts['continue'] |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1424 |
anyopt = opts['any'] |
704 | 1425 |
allopt = opts['all'] |
1318
29363f79514f
evolve: move code to track progress and start node
Laurent Charignon <lcharignon@fb.com>
parents:
1317
diff
changeset
|
1426 |
startnode = repo['.'] |
703
a246b02499d9
evolve: extract evolve --any implementation into a function.
Levi Bard <levi@unity3d.com>
parents:
663
diff
changeset
|
1427 |
dryrunopt = opts['dry_run'] |
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1428 |
confirmopt = opts['confirm'] |
1325
1fe3da0b4601
evolve: add --rev option to the evolve command
Laurent Charignon <lcharignon@fb.com>
parents:
1324
diff
changeset
|
1429 |
revopt = opts['rev'] |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1430 |
troublecategories = ['bumped', 'divergent', 'unstable'] |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1431 |
specifiedcategories = [t for t in troublecategories if opts[t]] |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1432 |
if listopt: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1433 |
listtroubles(ui, repo, specifiedcategories, **opts) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1434 |
return |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1435 |
|
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1436 |
targetcat = 'unstable' |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1437 |
if 1 < len(specifiedcategories): |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1438 |
msg = _('cannot specify more than one trouble category to solve (yet)') |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1439 |
raise error.Abort(msg) |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1440 |
elif len(specifiedcategories) == 1: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1441 |
targetcat = specifiedcategories[0] |
1409
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1442 |
elif repo['.'].obsolete(): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1443 |
displayer = cmdutil.show_changeset(ui, repo, |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1444 |
{'template': shorttemplate}) |
1409
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1445 |
# no args and parent is obsolete, update to successors |
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1446 |
try: |
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1447 |
ctx = repo[_singlesuccessor(repo, repo['.'])] |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1448 |
except MultipleSuccessorsError as exc: |
1409
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1449 |
repo.ui.write_err('parent is obsolete with multiple successors:\n') |
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1450 |
for ln in exc.successorssets: |
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1451 |
for n in ln: |
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1452 |
displayer.show(repo[n]) |
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1453 |
return 2 |
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1454 |
|
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1455 |
ui.status(_('update:')) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1456 |
if not ui.quiet: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1457 |
displayer.show(ctx) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1458 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1459 |
if dryrunopt: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1460 |
return 0 |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1461 |
res = hg.update(repo, ctx.rev()) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1462 |
if ctx != startnode: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1463 |
ui.status(_('working directory is now at %s\n') % ctx) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1464 |
return res |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1465 |
|
986
c1f8ece4182d
evolve: add --tool option so we don't have to use HGMERGE
Greg Ward <greg@gerg.ca>
parents:
985
diff
changeset
|
1466 |
ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve') |
1323
603104c880f7
evolve: simplify the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1322
diff
changeset
|
1467 |
troubled = set(repo.revs('troubled()')) |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1468 |
|
1318
29363f79514f
evolve: move code to track progress and start node
Laurent Charignon <lcharignon@fb.com>
parents:
1317
diff
changeset
|
1469 |
# Progress handling |
29363f79514f
evolve: move code to track progress and start node
Laurent Charignon <lcharignon@fb.com>
parents:
1317
diff
changeset
|
1470 |
seen = 1 |
1323
603104c880f7
evolve: simplify the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1322
diff
changeset
|
1471 |
count = allopt and len(troubled) or 1 |
1319
8376fe35ebda
evolve: add new variable and comment
Laurent Charignon <lcharignon@fb.com>
parents:
1318
diff
changeset
|
1472 |
showprogress = allopt |
1318
29363f79514f
evolve: move code to track progress and start node
Laurent Charignon <lcharignon@fb.com>
parents:
1317
diff
changeset
|
1473 |
|
29363f79514f
evolve: move code to track progress and start node
Laurent Charignon <lcharignon@fb.com>
parents:
1317
diff
changeset
|
1474 |
def progresscb(): |
1325
1fe3da0b4601
evolve: add --rev option to the evolve command
Laurent Charignon <lcharignon@fb.com>
parents:
1324
diff
changeset
|
1475 |
if revopt or allopt: |
1624
081605c2e9b6
evolve: mark progress units for translation
Anton Shestakov <av6@dwimlabs.net>
parents:
1623
diff
changeset
|
1476 |
ui.progress(_('evolve'), seen, unit=_('changesets'), total=count) |
1099
bac4e0bc9f6a
evolve: write a status message when the working directory changes
David Soria Parra <davidsp@fb.com>
parents:
1067
diff
changeset
|
1477 |
|
1319
8376fe35ebda
evolve: add new variable and comment
Laurent Charignon <lcharignon@fb.com>
parents:
1318
diff
changeset
|
1478 |
# Continuation handling |
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1479 |
if contopt: |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1480 |
if anyopt: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1481 |
raise error.Abort('cannot specify both "--any" and "--continue"') |
704 | 1482 |
if allopt: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1483 |
raise error.Abort('cannot specify both "--all" and "--continue"') |
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1484 |
state = _evolvestateread(repo) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1485 |
if state is None: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1486 |
raise error.Abort('no evolve to continue') |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1487 |
orig = repo[state['current']] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1488 |
# XXX This is a terrible terrible hack, please get rid of it. |
1722
b4be34677fda
continue: ensure we hold the wlock before writing file to disk
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1720
diff
changeset
|
1489 |
lock = repo.wlock() |
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1490 |
try: |
2051
74934195747b
evolve: switch away from deprecated repo.opener
Martin von Zweigbergk <martinvonz@google.com>
parents:
2049
diff
changeset
|
1491 |
repo.vfs.write('graftstate', orig.hex() + '\n') |
1722
b4be34677fda
continue: ensure we hold the wlock before writing file to disk
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1720
diff
changeset
|
1492 |
try: |
b4be34677fda
continue: ensure we hold the wlock before writing file to disk
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1720
diff
changeset
|
1493 |
graftcmd = commands.table['graft'][0] |
b4be34677fda
continue: ensure we hold the wlock before writing file to disk
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1720
diff
changeset
|
1494 |
ret = graftcmd(ui, repo, old_obsolete=True, **{'continue': True}) |
b4be34677fda
continue: ensure we hold the wlock before writing file to disk
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1720
diff
changeset
|
1495 |
_evolvestatedelete(repo) |
b4be34677fda
continue: ensure we hold the wlock before writing file to disk
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1720
diff
changeset
|
1496 |
return ret |
b4be34677fda
continue: ensure we hold the wlock before writing file to disk
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1720
diff
changeset
|
1497 |
finally: |
2070
9105c3c54045
cleanup: stop using 'repo.join' methods
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2064
diff
changeset
|
1498 |
util.unlinkpath(repo.vfs.join('graftstate'), ignoremissing=True) |
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1499 |
finally: |
1722
b4be34677fda
continue: ensure we hold the wlock before writing file to disk
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1720
diff
changeset
|
1500 |
lock.release() |
1402
08ae023882f1
evolve: check for uncommited change earlier
Laurent Charignon <lcharignon@fb.com>
parents:
1398
diff
changeset
|
1501 |
cmdutil.bailifchanged(repo) |
08ae023882f1
evolve: check for uncommited change earlier
Laurent Charignon <lcharignon@fb.com>
parents:
1398
diff
changeset
|
1502 |
|
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1503 |
if revopt and allopt: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1504 |
raise error.Abort('cannot specify both "--rev" and "--all"') |
1405
eaf82490af76
evolve: prevent using --rev and --any together
Laurent Charignon <lcharignon@fb.com>
parents:
1404
diff
changeset
|
1505 |
if revopt and anyopt: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1506 |
raise error.Abort('cannot specify both "--rev" and "--any"') |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1507 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1508 |
revs = _selectrevs(repo, allopt, revopt, anyopt, targetcat) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1509 |
|
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1510 |
if not revs: |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1511 |
return _handlenotrouble(ui, repo, allopt, revopt, anyopt, targetcat) |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1512 |
|
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1513 |
# For the progress bar to show |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1514 |
count = len(revs) |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1515 |
# Order the revisions |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1516 |
if targetcat == 'unstable': |
1411
64515965c0df
evolve: some style fix
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1410
diff
changeset
|
1517 |
revs = _orderrevs(repo, revs) |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1518 |
for rev in revs: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1519 |
progresscb() |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1520 |
_solveone(ui, repo, repo[rev], dryrunopt, confirmopt, |
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
|
1521 |
progresscb, targetcat) |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1522 |
seen += 1 |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1523 |
progresscb() |
1324
739208d1ee62
evolve: extract cleanup logic in the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1323
diff
changeset
|
1524 |
_cleanup(ui, repo, startnode, showprogress) |
1099
bac4e0bc9f6a
evolve: write a status message when the working directory changes
David Soria Parra <davidsp@fb.com>
parents:
1067
diff
changeset
|
1525 |
|
1421
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1526 |
def _possibledestination(repo, rev): |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1527 |
"""return all changesets that may be a new parent for REV""" |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1528 |
tonode = repo.changelog.node |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1529 |
parents = repo.changelog.parentrevs |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1530 |
torev = repo.changelog.rev |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1531 |
dest = set() |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1532 |
tovisit = list(parents(rev)) |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1533 |
while tovisit: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1534 |
r = tovisit.pop() |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1535 |
succsets = obsolete.successorssets(repo, tonode(r)) |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1536 |
if not succsets: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1537 |
tovisit.extend(parents(r)) |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1538 |
else: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1539 |
# We should probably pick only one destination from split |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1540 |
# (case where '1 < len(ss)'), This could be the currently tipmost |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1541 |
# but logic is less clear when result of the split are now on |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1542 |
# multiple branches. |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1543 |
for ss in succsets: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1544 |
for n in ss: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1545 |
dest.add(torev(n)) |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1546 |
return dest |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1547 |
|
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1548 |
def _aspiringchildren(repo, revs): |
1420
0b714c4ad9ff
evolve: consider all potential candidates on bare evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1419
diff
changeset
|
1549 |
"""Return a list of changectx which can be stabilized on top of pctx or |
1421
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1550 |
one of its descendants. Empty list if none can be found.""" |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1551 |
target = set(revs) |
1420
0b714c4ad9ff
evolve: consider all potential candidates on bare evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1419
diff
changeset
|
1552 |
result = [] |
1421
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1553 |
for r in repo.revs('unstable() - %ld', revs): |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1554 |
dest = _possibledestination(repo, r) |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1555 |
if target & dest: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1556 |
result.append(r) |
1420
0b714c4ad9ff
evolve: consider all potential candidates on bare evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1419
diff
changeset
|
1557 |
return result |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1558 |
|
1422
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1559 |
def _aspiringdescendant(repo, revs): |
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1560 |
"""Return a list of changectx which can be stabilized on top of pctx or |
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1561 |
one of its descendants recursively. Empty list if none can be found.""" |
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1562 |
target = set(revs) |
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1563 |
result = set(target) |
1423
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1564 |
paths = collections.defaultdict(set) |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1565 |
for r in repo.revs('unstable() - %ld', revs): |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1566 |
for d in _possibledestination(repo, r): |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1567 |
paths[d].add(r) |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1568 |
|
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1569 |
result = set(target) |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1570 |
tovisit = list(revs) |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1571 |
while tovisit: |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1572 |
base = tovisit.pop() |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1573 |
for unstable in paths[base]: |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1574 |
if unstable not in result: |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1575 |
tovisit.append(unstable) |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1576 |
result.add(unstable) |
1422
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1577 |
return sorted(result - target) |
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1578 |
|
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1579 |
def _solveunstable(ui, repo, orig, dryrun=False, confirm=False, |
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1580 |
progresscb=None): |
1569
bd1468c23d88
evolve: scattered typo fixes in comments, docstrings
Greg Ward <greg@gerg.ca>
parents:
1528
diff
changeset
|
1581 |
"""Stabilize an unstable changeset""" |
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1582 |
pctx = orig.p1() |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1583 |
if len(orig.parents()) == 2: |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1584 |
if not pctx.obsolete(): |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1585 |
pctx = orig.p2() # second parent is obsolete ? |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1586 |
elif orig.p2().obsolete(): |
1639 | 1587 |
hint = _("Redo the merge (%s) and use `hg prune <old> " |
1588 |
"--succ <new>` to obsolete the old one") % orig.hex()[:12] |
|
1638 | 1589 |
ui.warn(_("warning: no support for evolving merge changesets " |
1590 |
"with two obsolete parents yet\n") + |
|
1591 |
_("(%s)\n") % hint) |
|
1592 |
return False |
|
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1593 |
|
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1594 |
if not pctx.obsolete(): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1595 |
ui.warn(_("cannot solve instability of %s, skipping\n") % orig) |
1354
b4a62d6f0353
evolve: don't crash on singled out revisions
Laurent Charignon <lcharignon@fb.com>
parents:
1351
diff
changeset
|
1596 |
return False |
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1597 |
obs = pctx |
630
722b52c75f02
compat: adapt to upstreaming of divergent logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
622
diff
changeset
|
1598 |
newer = obsolete.successorssets(repo, obs.node()) |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1599 |
# search of a parent which is not killed |
588
89c8550019d0
mercurial: replace all `newerversion` call by `successorsset` call
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
587
diff
changeset
|
1600 |
while not newer or newer == [()]: |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1601 |
ui.debug("stabilize target %s is plain dead," |
1145
fb51113a1c08
evolve: add the missing newline to output messages where needed
Matt Harbison <matt_harbison@yahoo.com>
parents:
1144
diff
changeset
|
1602 |
" trying to stabilize on its parent\n" % |
1144
b2a78b950a51
evolve: add the missing argument to a debug statement
Matt Harbison <matt_harbison@yahoo.com>
parents:
1143
diff
changeset
|
1603 |
obs) |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1604 |
obs = obs.parents()[0] |
630
722b52c75f02
compat: adapt to upstreaming of divergent logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
622
diff
changeset
|
1605 |
newer = obsolete.successorssets(repo, obs.node()) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1606 |
if len(newer) > 1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1607 |
msg = _("skipping %s: divergent rewriting. can't choose " |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1608 |
"destination\n") % obs |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1609 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1610 |
return 2 |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1611 |
targets = newer[0] |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1612 |
assert targets |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1613 |
if len(targets) > 1: |
1481
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1614 |
# split target, figure out which one to pick, are they all in line? |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1615 |
targetrevs = [repo[r].rev() for r in targets] |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1616 |
roots = repo.revs('roots(%ld)', targetrevs) |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1617 |
heads = repo.revs('heads(%ld)', targetrevs) |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1618 |
if len(roots) > 1 or len(heads) > 1: |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1619 |
msg = "cannot solve split accross two branches\n" |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1620 |
ui.write_err(msg) |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1621 |
return 2 |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1622 |
target = repo[heads.first()] |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1623 |
else: |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1624 |
target = targets[0] |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1625 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1626 |
target = repo[target] |
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1627 |
if not ui.quiet or confirm: |
1046
296d48e1f55a
evolve: gather evolve output together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1045
diff
changeset
|
1628 |
repo.ui.write(_('move:')) |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
1629 |
displayer.show(orig) |
1046
296d48e1f55a
evolve: gather evolve output together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1045
diff
changeset
|
1630 |
repo.ui.write(_('atop:')) |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
1631 |
displayer.show(target) |
1390
03f202bed47f
evolve: fix default value for --confirm
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1389
diff
changeset
|
1632 |
if confirm and ui.prompt('perform evolve? [Ny]', 'n') != 'y': |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1633 |
raise error.Abort(_('evolve aborted by user')) |
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
|
1634 |
if progresscb: |
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
|
1635 |
progresscb() |
546
415540dee2bd
fix missing --dest evolve output in dryrun
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
540
diff
changeset
|
1636 |
todo = 'hg rebase -r %s -d %s\n' % (orig, target) |
468
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1637 |
if dryrun: |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
1638 |
repo.ui.write(todo) |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1639 |
else: |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1640 |
repo.ui.note(todo) |
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
|
1641 |
if progresscb: |
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
|
1642 |
progresscb() |
1141
ca17770d2ee9
evolve: preserve branch change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1140
diff
changeset
|
1643 |
keepbranch = orig.p1().branch() != orig.branch() |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1644 |
try: |
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1645 |
relocate(repo, orig, target, pctx, keepbranch) |
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
1646 |
except MergeFailure: |
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1647 |
_evolvestatewrite(repo, {'current': orig.node()}) |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1648 |
repo.ui.write_err(_('evolve failed!\n')) |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1649 |
repo.ui.write_err( |
1756
a7dcfff8c4a9
evolve: use single quotes in usage messages
Martin von Zweigbergk <martinvonz@google.com>
parents:
1755
diff
changeset
|
1650 |
_("fix conflict and run 'hg evolve --continue'" |
a7dcfff8c4a9
evolve: use single quotes in usage messages
Martin von Zweigbergk <martinvonz@google.com>
parents:
1755
diff
changeset
|
1651 |
" or use 'hg update -C .' to abort\n")) |
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
1652 |
raise |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1653 |
|
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1654 |
def _solvebumped(ui, repo, bumped, dryrun=False, confirm=False, |
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1655 |
progresscb=None): |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1656 |
"""Stabilize a bumped changeset""" |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1657 |
repo = repo.unfiltered() |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1658 |
bumped = repo[bumped.rev()] |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1659 |
# For now we deny bumped merge |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1660 |
if len(bumped.parents()) > 1: |
1496 | 1661 |
msg = _('skipping %s : we do not handle merge yet\n') % bumped |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1662 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1663 |
return 2 |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1664 |
prec = repo.set('last(allprecursors(%d) and public())', bumped).next() |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1665 |
# For now we deny target merge |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1666 |
if len(prec.parents()) > 1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1667 |
msg = _('skipping: %s: public version is a merge, ' |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1668 |
'this is not handled yet\n') % prec |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1669 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1670 |
return 2 |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1671 |
|
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1672 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1673 |
if not ui.quiet or confirm: |
1046
296d48e1f55a
evolve: gather evolve output together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1045
diff
changeset
|
1674 |
repo.ui.write(_('recreate:')) |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1675 |
displayer.show(bumped) |
1046
296d48e1f55a
evolve: gather evolve output together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1045
diff
changeset
|
1676 |
repo.ui.write(_('atop:')) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1677 |
displayer.show(prec) |
1390
03f202bed47f
evolve: fix default value for --confirm
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1389
diff
changeset
|
1678 |
if confirm and ui.prompt('perform evolve? [Ny]', 'n') != 'y': |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1679 |
raise error.Abort(_('evolve aborted by user')) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1680 |
if dryrun: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1681 |
todo = 'hg rebase --rev %s --dest %s;\n' % (bumped, prec.p1()) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1682 |
repo.ui.write(todo) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1683 |
repo.ui.write(('hg update %s;\n' % prec)) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1684 |
repo.ui.write(('hg revert --all --rev %s;\n' % bumped)) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1685 |
repo.ui.write(('hg commit --msg "bumped update to %s"')) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1686 |
return 0 |
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
|
1687 |
if progresscb: |
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
|
1688 |
progresscb() |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1689 |
newid = tmpctx = None |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1690 |
tmpctx = bumped |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1691 |
# Basic check for common parent. Far too complicated and fragile |
1593
2f117c299325
evolve: remove meaningless transaction nesting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1592
diff
changeset
|
1692 |
tr = repo.currenttransaction() |
2f117c299325
evolve: remove meaningless transaction nesting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1592
diff
changeset
|
1693 |
assert tr is not None |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
1694 |
bmupdate = _bookmarksupdater(repo, bumped.node(), tr) |
1729
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1695 |
if not list(repo.set('parents(%d) and parents(%d)', bumped, prec)): |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1696 |
# Need to rebase the changeset at the right place |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1697 |
repo.ui.status( |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1698 |
_('rebasing to destination parent: %s\n') % prec.p1()) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1699 |
try: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1700 |
tmpid = relocate(repo, bumped, prec.p1()) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1701 |
if tmpid is not None: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1702 |
tmpctx = repo[tmpid] |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1703 |
obsolete.createmarkers(repo, [(bumped, (tmpctx,))]) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1704 |
except MergeFailure: |
2051
74934195747b
evolve: switch away from deprecated repo.opener
Martin von Zweigbergk <martinvonz@google.com>
parents:
2049
diff
changeset
|
1705 |
repo.vfs.write('graftstate', bumped.hex() + '\n') |
1729
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1706 |
repo.ui.write_err(_('evolution failed!\n')) |
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
|
1707 |
msg = _("fix conflict and run 'hg evolve --continue'\n") |
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
|
1708 |
repo.ui.write_err(msg) |
1729
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1709 |
raise |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1710 |
# Create the new commit context |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1711 |
repo.ui.status(_('computing new diff\n')) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1712 |
files = set() |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1713 |
copied = copies.pathcopies(prec, bumped) |
1736 | 1714 |
precmanifest = prec.manifest().copy() |
1729
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1715 |
# 3.3.2 needs a list. |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1716 |
# future 3.4 don't detect the size change during iteration |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1717 |
# this is fishy |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1718 |
for key, val in list(bumped.manifest().iteritems()): |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1719 |
precvalue = precmanifest.get(key, None) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1720 |
if precvalue is not None: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1721 |
del precmanifest[key] |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1722 |
if precvalue != val: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1723 |
files.add(key) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1724 |
files.update(precmanifest) # add missing files |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1725 |
# commit it |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1726 |
if files: # something to commit! |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1727 |
def filectxfn(repo, ctx, path): |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1728 |
if path in bumped: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1729 |
fctx = bumped[path] |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1730 |
flags = fctx.flags() |
1828
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
1731 |
mctx = context.memfilectx(repo, fctx.path(), fctx.data(), |
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
1732 |
islink='l' in flags, |
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
1733 |
isexec='x' in flags, |
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
1734 |
copied=copied.get(path)) |
1729
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1735 |
return mctx |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1736 |
return None |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1737 |
text = 'bumped update to %s:\n\n' % prec |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1738 |
text += bumped.description() |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1739 |
|
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1740 |
new = context.memctx(repo, |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1741 |
parents=[prec.node(), node.nullid], |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1742 |
text=text, |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1743 |
files=files, |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1744 |
filectxfn=filectxfn, |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1745 |
user=bumped.user(), |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1746 |
date=bumped.date(), |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1747 |
extra=bumped.extra()) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1748 |
|
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1749 |
newid = repo.commitctx(new) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1750 |
if newid is None: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1751 |
obsolete.createmarkers(repo, [(tmpctx, ())]) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1752 |
newid = prec.node() |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1753 |
else: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1754 |
phases.retractboundary(repo, tr, bumped.phase(), [newid]) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1755 |
obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))], |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1756 |
flag=obsolete.bumpedfix) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1757 |
bmupdate(newid) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1758 |
repo.ui.status(_('committed as %s\n') % node.short(newid)) |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1759 |
# reroute the working copy parent to the new changeset |
1112
c3e23fbf7bd7
evolve: wrap setparents calls in begin/endparentchange
Siddharth Agarwal <sid0@fb.com>
parents:
1111
diff
changeset
|
1760 |
repo.dirstate.beginparentchange() |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1761 |
repo.dirstate.setparents(newid, node.nullid) |
1112
c3e23fbf7bd7
evolve: wrap setparents calls in begin/endparentchange
Siddharth Agarwal <sid0@fb.com>
parents:
1111
diff
changeset
|
1762 |
repo.dirstate.endparentchange() |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1763 |
|
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1764 |
def _solvedivergent(ui, repo, divergent, dryrun=False, confirm=False, |
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1765 |
progresscb=None): |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1766 |
repo = repo.unfiltered() |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1767 |
divergent = repo[divergent.rev()] |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1768 |
base, others = divergentdata(divergent) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1769 |
if len(others) > 1: |
760
bbb3a0e1dfea
evolve: add more details when we abort for case not handled yet
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
757
diff
changeset
|
1770 |
othersstr = "[%s]" % (','.join([str(i) for i in others])) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1771 |
msg = _("skipping %d:divergent with a changeset that got splitted" |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1772 |
" into multiple ones:\n" |
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
|
1773 |
"|[%s]\n" |
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
|
1774 |
"| This is not handled by automatic evolution yet\n" |
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
|
1775 |
"| You have to fallback to manual handling with commands " |
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
|
1776 |
"such as:\n" |
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
|
1777 |
"| - hg touch -D\n" |
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
|
1778 |
"| - hg prune\n" |
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
|
1779 |
"| \n" |
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
|
1780 |
"| You should contact your local evolution Guru for help.\n" |
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
|
1781 |
) % (divergent, othersstr) |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1782 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1783 |
return 2 |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1784 |
other = others[0] |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1785 |
if len(other.parents()) > 1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1786 |
msg = _("skipping %s: divergent changeset can't be " |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1787 |
"a merge (yet)\n") % divergent |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1788 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1789 |
hint = _("You have to fallback to solving this by hand...\n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1790 |
"| This probably means redoing the merge and using \n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1791 |
"| `hg prune` to kill older version.\n") |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1792 |
ui.write_err(hint) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1793 |
return 2 |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1794 |
if other.p1() not in divergent.parents(): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1795 |
msg = _("skipping %s: have a different parent than %s " |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1796 |
"(not handled yet)\n") % (divergent, other) |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1797 |
hint = _("| %(d)s, %(o)s are not based on the same changeset.\n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1798 |
"| With the current state of its implementation, \n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1799 |
"| evolve does not work in that case.\n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1800 |
"| rebase one of them next to the other and run \n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1801 |
"| this command again.\n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1802 |
"| - either: hg rebase --dest 'p1(%(d)s)' -r %(o)s\n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1803 |
"| - or: hg rebase --dest 'p1(%(o)s)' -r %(d)s\n" |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1804 |
) % {'d': divergent, 'o': other} |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1805 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1806 |
ui.write_err(hint) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1807 |
return 2 |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1808 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1809 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1810 |
if not ui.quiet or confirm: |
1046
296d48e1f55a
evolve: gather evolve output together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1045
diff
changeset
|
1811 |
ui.write(_('merge:')) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1812 |
displayer.show(divergent) |
1046
296d48e1f55a
evolve: gather evolve output together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1045
diff
changeset
|
1813 |
ui.write(_('with: ')) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1814 |
displayer.show(other) |
1046
296d48e1f55a
evolve: gather evolve output together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1045
diff
changeset
|
1815 |
ui.write(_('base: ')) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1816 |
displayer.show(base) |
1498
3d9a546dcbc5
evolve: annotate translatable strings with _()
timeless@mozdev.org
parents:
1497
diff
changeset
|
1817 |
if confirm and ui.prompt(_('perform evolve? [Ny]'), 'n') != 'y': |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1818 |
raise error.Abort(_('evolve aborted by user')) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1819 |
if dryrun: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1820 |
ui.write(('hg update -c %s &&\n' % divergent)) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1821 |
ui.write(('hg merge %s &&\n' % other)) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1822 |
ui.write(('hg commit -m "auto merge resolving conflict between ' |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1823 |
'%s and %s"&&\n' % (divergent, other))) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1824 |
ui.write(('hg up -C %s &&\n' % base)) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1825 |
ui.write(('hg revert --all --rev tip &&\n')) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1826 |
ui.write(('hg commit -m "`hg log -r %s --template={desc}`";\n' |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1827 |
% divergent)) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1828 |
return |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1829 |
if divergent not in repo[None].parents(): |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1830 |
repo.ui.status(_('updating to "local" conflict\n')) |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1831 |
hg.update(repo, divergent.rev()) |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1832 |
repo.ui.note(_('merging divergent changeset\n')) |
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
|
1833 |
if progresscb: |
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
|
1834 |
progresscb() |
1831
0195dc7bdfa4
compat: drop compatibility layer around update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1830
diff
changeset
|
1835 |
stats = merge.update(repo, |
0195dc7bdfa4
compat: drop compatibility layer around update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1830
diff
changeset
|
1836 |
other.node(), |
0195dc7bdfa4
compat: drop compatibility layer around update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1830
diff
changeset
|
1837 |
branchmerge=True, |
0195dc7bdfa4
compat: drop compatibility layer around update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1830
diff
changeset
|
1838 |
force=False, |
0195dc7bdfa4
compat: drop compatibility layer around update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1830
diff
changeset
|
1839 |
ancestor=base.node(), |
0195dc7bdfa4
compat: drop compatibility layer around update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1830
diff
changeset
|
1840 |
mergeancestor=True) |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1841 |
hg._showstats(repo, stats) |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1842 |
if stats[3]: |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1843 |
repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " |
1755
6c78a5470583
evolve: prefer "abort" over "abandon" in messages for consistency
Martin von Zweigbergk <martinvonz@google.com>
parents:
1754
diff
changeset
|
1844 |
"or 'hg update -C .' to abort\n")) |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1845 |
if stats[3] > 0: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1846 |
raise error.Abort('merge conflict between several amendments ' |
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
|
1847 |
'(this is not automated yet)', |
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
|
1848 |
hint="""/!\ You can try: |
534
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1849 |
/!\ * manual merge + resolve => new cset X |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1850 |
/!\ * hg up to the parent of the amended changeset (which are named W and Z) |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1851 |
/!\ * hg revert --all -r X |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1852 |
/!\ * hg ci -m "same message as the amended changeset" => new cset Y |
1631
7463f5880ce9
prune: remove the kill alias
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1630
diff
changeset
|
1853 |
/!\ * hg prune -n Y W Z |
534
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1854 |
""") |
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
|
1855 |
if progresscb: |
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
|
1856 |
progresscb() |
1536
9afe9e0191a1
evolve: evolve --divergent failed when merge had nothing to do (issue4950)
Laurent Charignon <lcharignon@fb.com>
parents:
1532
diff
changeset
|
1857 |
emtpycommitallowed = repo.ui.backupconfig('ui', 'allowemptycommit') |
1593
2f117c299325
evolve: remove meaningless transaction nesting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1592
diff
changeset
|
1858 |
tr = repo.currenttransaction() |
2f117c299325
evolve: remove meaningless transaction nesting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1592
diff
changeset
|
1859 |
assert tr is not None |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1860 |
try: |
1636
13f830540a14
config: report evolve as origin for config
timeless@gmail.com
parents:
1635
diff
changeset
|
1861 |
repo.ui.setconfig('ui', 'allowemptycommit', True, 'evolve') |
1112
c3e23fbf7bd7
evolve: wrap setparents calls in begin/endparentchange
Siddharth Agarwal <sid0@fb.com>
parents:
1111
diff
changeset
|
1862 |
repo.dirstate.beginparentchange() |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1863 |
repo.dirstate.setparents(divergent.node(), node.nullid) |
1112
c3e23fbf7bd7
evolve: wrap setparents calls in begin/endparentchange
Siddharth Agarwal <sid0@fb.com>
parents:
1111
diff
changeset
|
1864 |
repo.dirstate.endparentchange() |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1865 |
oldlen = len(repo) |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1866 |
amend(ui, repo, message='', logfile='') |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1867 |
if oldlen == len(repo): |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1868 |
new = divergent |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1869 |
# no changes |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1870 |
else: |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1871 |
new = repo['.'] |
1070
527b12a59628
drop relevant marker compat
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1069
diff
changeset
|
1872 |
obsolete.createmarkers(repo, [(other, (new,))]) |
1069
356552e55489
evolve: always use the transaction version of phase movement
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1068
diff
changeset
|
1873 |
phases.retractboundary(repo, tr, other.phase(), [new.node()]) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1874 |
finally: |
1536
9afe9e0191a1
evolve: evolve --divergent failed when merge had nothing to do (issue4950)
Laurent Charignon <lcharignon@fb.com>
parents:
1532
diff
changeset
|
1875 |
repo.ui.restoreconfig(emtpycommitallowed) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1876 |
|
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1877 |
def divergentdata(ctx): |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1878 |
"""return base, other part of a conflict |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1879 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1880 |
This only return the first one. |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1881 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1882 |
XXX this woobly function won't survive XXX |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1883 |
""" |
1375
9e062e6598e9
evolve: search divergence within all precursors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1374
diff
changeset
|
1884 |
repo = ctx._repo.unfiltered() |
9e062e6598e9
evolve: search divergence within all precursors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1374
diff
changeset
|
1885 |
for base in repo.set('reverse(allprecursors(%d))', ctx): |
630
722b52c75f02
compat: adapt to upstreaming of divergent logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
622
diff
changeset
|
1886 |
newer = obsolete.successorssets(ctx._repo, base.node()) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1887 |
# drop filter and solution including the original ctx |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1888 |
newer = [n for n in newer if n and ctx.node() not in n] |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1889 |
if newer: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1890 |
return base, tuple(ctx._repo[o] for o in newer[0]) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1891 |
raise error.Abort("base of divergent changeset %s not found" % ctx, |
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
|
1892 |
hint='this case is not yet handled') |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1893 |
|
2396
c1485ebdd6b9
color: update the shorttemplate to use colors
Boris Feld <boris.feld@octobus.net>
parents:
2350
diff
changeset
|
1894 |
shorttemplate = "[{label('evolve.rev', rev)}] {desc|firstline}\n" |
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
|
1895 |
|
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1896 |
@eh.command( |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1897 |
'^previous', |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1898 |
[('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
|
1899 |
_('move active bookmark after update')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1900 |
('', 'merge', False, _('bring uncommitted change along')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1901 |
('', '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
|
1902 |
('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
|
1903 |
_('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
|
1904 |
'[OPTION]...') |
1160
e29a813f6af5
Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents:
1157
diff
changeset
|
1905 |
def cmdprevious(ui, repo, **opts): |
1572
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
1906 |
"""update to parent revision |
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
1907 |
|
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
1908 |
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
|
1909 |
wlock = None |
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
1910 |
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
|
1911 |
if not dryrunopt: |
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
1912 |
wlock = repo.wlock() |
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
1913 |
try: |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1914 |
wkctx = repo[None] |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1915 |
wparents = wkctx.parents() |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1916 |
if len(wparents) != 1: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1917 |
raise error.Abort('merge in progress') |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1918 |
if not opts['merge']: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1919 |
try: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1920 |
cmdutil.bailifchanged(repo) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1921 |
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
|
1922 |
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
|
1923 |
raise |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1924 |
|
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1925 |
parents = wparents[0].parents() |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1926 |
topic = getattr(repo, 'currenttopic', '') |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1927 |
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
|
1928 |
parents = [ctx for ctx in parents if ctx.topic() == topic] |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1929 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1930 |
if not parents: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1931 |
ui.warn(_('no parent in topic "%s"\n') % topic) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1932 |
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
|
1933 |
elif len(parents) == 1: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1934 |
p = parents[0] |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
1935 |
bm = repo._activebookmark |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1936 |
shouldmove = opts.get('move_bookmark') and bm is not None |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1937 |
if dryrunopt: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1938 |
ui.write(('hg update %s;\n' % p.rev())) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1939 |
if shouldmove: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1940 |
ui.write(('hg bookmark %s -r %s;\n' % (bm, p.rev()))) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1941 |
else: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1942 |
ret = hg.update(repo, p.rev()) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1943 |
if not ret: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1944 |
tr = lock = None |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1945 |
try: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1946 |
lock = repo.lock() |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1947 |
tr = repo.transaction('previous') |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1948 |
if shouldmove: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1949 |
repo._bookmarks[bm] = p.node() |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1950 |
repo._bookmarks.recordchange(tr) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1951 |
else: |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
1952 |
bookmarksmod.deactivate(repo) |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1953 |
tr.close() |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1954 |
finally: |
1742
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
1955 |
lockmod.release(tr, lock) |
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
1956 |
|
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1957 |
displayer.show(p) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1958 |
return 0 |
1500 | 1959 |
else: |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1960 |
for p in parents: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1961 |
displayer.show(p) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1962 |
ui.warn(_('multiple parents, explicitly update to one\n')) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1963 |
return 1 |
1742
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
1964 |
finally: |
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
1965 |
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
|
1966 |
|
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1967 |
@eh.command( |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1968 |
'^next', |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1969 |
[('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
|
1970 |
_('move active bookmark after update')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1971 |
('', 'merge', False, _('bring uncommitted change along')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
1972 |
('', '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
|
1973 |
('', '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
|
1974 |
('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
|
1975 |
_('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
|
1976 |
'[OPTION]...') |
1160
e29a813f6af5
Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents:
1157
diff
changeset
|
1977 |
def cmdnext(ui, repo, **opts): |
1572
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
1978 |
"""update to next child revision |
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
1979 |
|
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
1980 |
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
|
1981 |
|
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
1982 |
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
|
1983 |
""" |
1742
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
1984 |
wlock = None |
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
1985 |
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
|
1986 |
if not dryrunopt: |
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
1987 |
wlock = repo.wlock() |
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
1988 |
try: |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1989 |
wkctx = repo[None] |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1990 |
wparents = wkctx.parents() |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1991 |
if len(wparents) != 1: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1992 |
raise error.Abort('merge in progress') |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1993 |
if not opts['merge']: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1994 |
try: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1995 |
cmdutil.bailifchanged(repo) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1996 |
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
|
1997 |
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
|
1998 |
raise |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
1999 |
|
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2000 |
children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()] |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2001 |
topic = getattr(repo, 'currenttopic', '') |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2002 |
filtered = [] |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2003 |
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
|
2004 |
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
|
2005 |
# 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
|
2006 |
children = [ctx for ctx in children 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
|
2007 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2008 |
if len(children) == 1: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2009 |
c = children[0] |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
2010 |
bm = repo._activebookmark |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2011 |
shouldmove = opts.get('move_bookmark') and bm is not None |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2012 |
if dryrunopt: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2013 |
ui.write(('hg update %s;\n' % c.rev())) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2014 |
if shouldmove: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2015 |
ui.write(('hg bookmark %s -r %s;\n' % (bm, c.rev()))) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2016 |
else: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2017 |
ret = hg.update(repo, c.rev()) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2018 |
if not ret: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2019 |
lock = tr = None |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2020 |
try: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2021 |
lock = repo.lock() |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2022 |
tr = repo.transaction('next') |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2023 |
if shouldmove: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2024 |
repo._bookmarks[bm] = c.node() |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2025 |
repo._bookmarks.recordchange(tr) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2026 |
else: |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
2027 |
bookmarksmod.deactivate(repo) |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2028 |
tr.close() |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2029 |
finally: |
1742
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
2030 |
lockmod.release(tr, lock) |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2031 |
displayer.show(c) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2032 |
result = 0 |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2033 |
elif children: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2034 |
ui.warn(_("ambigious next changeset:\n")) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2035 |
for c in children: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2036 |
displayer.show(c) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2037 |
ui.warn(_('explicitly update to one of them\n')) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2038 |
result = 1 |
1500 | 2039 |
else: |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2040 |
aspchildren = _aspiringchildren(repo, [repo['.'].rev()]) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2041 |
if topic: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2042 |
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
|
2043 |
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
|
2044 |
# 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
|
2045 |
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
|
2046 |
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
|
2047 |
if filtered: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2048 |
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
|
2049 |
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
|
2050 |
else: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2051 |
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
|
2052 |
if aspchildren: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2053 |
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
|
2054 |
'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
|
2055 |
ui.warn(msg % len(aspchildren)) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2056 |
result = 1 |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2057 |
elif 1 < len(aspchildren): |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2058 |
ui.warn(_("ambigious next (unstable) changeset:\n")) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2059 |
for c in aspchildren: |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2060 |
displayer.show(repo[c]) |
1756
a7dcfff8c4a9
evolve: use single quotes in usage messages
Martin von Zweigbergk <martinvonz@google.com>
parents:
1755
diff
changeset
|
2061 |
ui.warn(_("(run 'hg evolve --rev REV' on one of them)\n")) |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2062 |
return 1 |
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
|
2063 |
else: |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2064 |
cmdutil.bailifchanged(repo) |
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2065 |
result = _solveone(ui, repo, repo[aspchildren[0]], dryrunopt, |
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
|
2066 |
False, lambda: None, category='unstable') |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2067 |
if not result: |
2405
4ff849709fea
label: add a label for the node in the "wc now at" message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2404
diff
changeset
|
2068 |
ui.status(_('working directory now at %s\n') |
4ff849709fea
label: add a label for the node in the "wc now at" message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2404
diff
changeset
|
2069 |
% ui.label(repo['.'], 'evolve.node')) |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2070 |
return result |
1449
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2071 |
return 1 |
1741
8c05184672ae
evolve: indent cmdnext and cmdprev ready for locking change (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1739
diff
changeset
|
2072 |
return result |
1742
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
2073 |
finally: |
970a4c13ebc3
evolve: lock the working copy early in next and prev (issue5244)
Simon Farnsworth <simonfar@fb.com>
parents:
1741
diff
changeset
|
2074 |
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
|
2075 |
|
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2076 |
def _reachablefrombookmark(repo, revs, bookmarks): |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2077 |
"""filter revisions and bookmarks reachable from the given bookmark |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2078 |
yoinked from mq.py |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2079 |
""" |
1561
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
2080 |
repomarks = repo._bookmarks |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2081 |
if not bookmarks.issubset(repomarks): |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2082 |
raise error.Abort(_("bookmark '%s' not found") % |
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
|
2083 |
','.join(sorted(bookmarks - set(repomarks.keys())))) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2084 |
|
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2085 |
# If the requested bookmark is not the only one pointing to a |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2086 |
# a revision we have to only delete the bookmark and not strip |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2087 |
# anything. revsets cannot detect that case. |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2088 |
nodetobookmarks = {} |
2024
10d80adec0c2
evolve: prevent global variable shadowing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2023
diff
changeset
|
2089 |
for mark, bnode in repomarks.iteritems(): |
10d80adec0c2
evolve: prevent global variable shadowing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2023
diff
changeset
|
2090 |
nodetobookmarks.setdefault(bnode, []).append(mark) |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2091 |
for marks in nodetobookmarks.values(): |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2092 |
if bookmarks.issuperset(marks): |
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
|
2093 |
rsrevs = repair.stripbmrevset(repo, marks[0]) |
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
|
2094 |
revs = set(revs) |
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
|
2095 |
revs.update(set(rsrevs)) |
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
|
2096 |
revs = sorted(revs) |
1561
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
2097 |
return repomarks, revs |
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
2098 |
|
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2099 |
def _deletebookmark(repo, repomarks, bookmarks): |
1501
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2100 |
wlock = lock = tr = None |
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2101 |
try: |
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2102 |
wlock = repo.wlock() |
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2103 |
lock = repo.lock() |
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2104 |
tr = repo.transaction('prune') |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2105 |
for bookmark in bookmarks: |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2106 |
del repomarks[bookmark] |
1561
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
2107 |
repomarks.recordchange(tr) |
1501
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2108 |
tr.close() |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2109 |
for bookmark in sorted(bookmarks): |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2110 |
repo.ui.write(_("bookmark '%s' deleted\n") % bookmark) |
1501
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2111 |
finally: |
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2112 |
lockmod.release(tr, lock, wlock) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2113 |
|
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2114 |
def _getmetadata(**opts): |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2115 |
metadata = {} |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2116 |
date = opts.get('date') |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2117 |
user = opts.get('user') |
818
fcdd9b8c970b
prune: accept '0 0' as a valide --date value
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
757
diff
changeset
|
2118 |
if date: |
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2119 |
metadata['date'] = '%i %i' % util.parsedate(date) |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2120 |
if user: |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2121 |
metadata['user'] = user |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2122 |
return metadata |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2123 |
|
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2124 |
@eh.command( |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2125 |
'^prune|obsolete', |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2126 |
[('n', 'new', [], _("successor changeset (DEPRECATED)")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2127 |
('s', 'succ', [], _("successor changeset")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2128 |
('r', 'rev', [], _("revisions to prune")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2129 |
('k', 'keep', None, _("does not modify working copy during prune")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2130 |
('', 'biject', False, _("do a 1-1 map between rev and successor ranges")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2131 |
('', 'fold', False, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2132 |
_("record a fold (multiple precursors, one successors)")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2133 |
('', 'split', False, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2134 |
_("record a split (on precursor, multiple successors)")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2135 |
('B', 'bookmark', [], _("remove revs only reachable from given" |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2136 |
" bookmark"))] + metadataopts, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2137 |
_('[OPTION] [-r] REV...')) |
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
|
2138 |
# XXX -U --noupdate option to prevent wc update and or bookmarks update ? |
681
eff18fcaaddc
prune: improve command function name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
680
diff
changeset
|
2139 |
def cmdprune(ui, repo, *revs, **opts): |
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
2140 |
"""hide changesets by marking them obsolete |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2141 |
|
1574
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2142 |
Pruned changesets are obsolete with no successors. If they also have no |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2143 |
descendants, they are hidden (invisible to all commands). |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2144 |
|
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2145 |
Non-obsolete descendants of pruned changesets become "unstable". Use :hg:`evolve` |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2146 |
to handle this situation. |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2147 |
|
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2148 |
When you prune the parent of your working copy, Mercurial updates the working |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2149 |
copy to a non-obsolete parent. |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2150 |
|
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2151 |
You can use ``--succ`` to tell Mercurial that a newer version (successor) of the |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2152 |
pruned changeset exists. Mercurial records successor revisions in obsolescence |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2153 |
markers. |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2154 |
|
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2155 |
You can use the ``--biject`` option to specify a 1-1 mapping (bijection) between |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2156 |
revisions to pruned (precursor) and successor changesets. This option may be |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2157 |
removed in a future release (with the functionality provided automatically). |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2158 |
|
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2159 |
If you specify multiple revisions in ``--succ``, you are recording a "split" and |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2160 |
must acknowledge it by passing ``--split``. Similarly, when you prune multiple |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2161 |
changesets with a single successor, you must pass the ``--fold`` option. |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2162 |
""" |
1134
7173c70ab2c3
prune: stop reinjecting all selected revisions back into the revrange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1132
diff
changeset
|
2163 |
revs = scmutil.revrange(repo, list(revs) + opts.get('rev')) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2164 |
succs = opts['new'] + opts['succ'] |
1564
42c30774e63d
prune: changing bookmark argument to be a list
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1563
diff
changeset
|
2165 |
bookmarks = set(opts.get('bookmark')) |
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2166 |
metadata = _getmetadata(**opts) |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
2167 |
biject = opts.get('biject') |
1471
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2168 |
fold = opts.get('fold') |
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2169 |
split = opts.get('split') |
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2170 |
|
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2171 |
options = [o for o in ('biject', 'fold', 'split') if opts.get(o)] |
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2172 |
if 1 < len(options): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2173 |
raise error.Abort(_("can only specify one of %s") % ', '.join(options)) |
689
d48aae167b9d
prune: documentation update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
688
diff
changeset
|
2174 |
|
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2175 |
if bookmarks: |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2176 |
repomarks, revs = _reachablefrombookmark(repo, revs, bookmarks) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2177 |
if not revs: |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2178 |
# no revisions to prune - delete bookmark immediately |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2179 |
_deletebookmark(repo, repomarks, bookmarks) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2180 |
|
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2181 |
if not revs: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2182 |
raise error.Abort(_('nothing to prune')) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2183 |
|
1295
1ac05eef72ca
prune: prune fix transaction pattern
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1294
diff
changeset
|
2184 |
wlock = lock = tr = None |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2185 |
try: |
1019
0c733dab0036
prune: lock inside the try
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1018
diff
changeset
|
2186 |
wlock = repo.wlock() |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
2187 |
lock = repo.lock() |
1294
d1c29db2e055
prune: fix pruning w/ bookmarks and inhibit
Durham Goode <durham@fb.com>
parents:
1283
diff
changeset
|
2188 |
tr = repo.transaction('prune') |
691
6e63b4185a5c
prune: update inline documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
690
diff
changeset
|
2189 |
# defines pruned changesets |
684
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
2190 |
precs = [] |
1134
7173c70ab2c3
prune: stop reinjecting all selected revisions back into the revrange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1132
diff
changeset
|
2191 |
revs.sort() |
7173c70ab2c3
prune: stop reinjecting all selected revisions back into the revrange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1132
diff
changeset
|
2192 |
for p in revs: |
684
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
2193 |
cp = repo[p] |
687
6c1fbef2952e
prune: test and improve message of immutable aborting.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
685
diff
changeset
|
2194 |
if not cp.mutable(): |
927 | 2195 |
# note: createmarkers() would have raised something anyway |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2196 |
raise error.Abort('cannot prune immutable changeset: %s' % cp, |
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
|
2197 |
hint="see 'hg help phases' for details") |
684
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
2198 |
precs.append(cp) |
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
2199 |
if not precs: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2200 |
raise error.Abort('nothing to prune') |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2201 |
|
1684
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
2202 |
if _disallowednewunstable(repo, revs): |
1779
ba9fabaca91b
prune: improve error message if unstable changes are disallowed
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1778
diff
changeset
|
2203 |
raise error.Abort(_("cannot prune in the middle of a stack"), |
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
|
2204 |
hint=_("new unstable changesets are not allowed")) |
1397
35f2f54b557c
evolve: make prune respect allowunsable
Laurent Charignon <lcharignon@fb.com>
parents:
1396
diff
changeset
|
2205 |
|
691
6e63b4185a5c
prune: update inline documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
690
diff
changeset
|
2206 |
# defines successors changesets |
1135
db16c4ad15d0
fixup previous changesets (after forgot to amend).
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1134
diff
changeset
|
2207 |
sucs = scmutil.revrange(repo, succs) |
db16c4ad15d0
fixup previous changesets (after forgot to amend).
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1134
diff
changeset
|
2208 |
sucs.sort() |
db16c4ad15d0
fixup previous changesets (after forgot to amend).
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1134
diff
changeset
|
2209 |
sucs = tuple(repo[n] for n in sucs) |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
2210 |
if not biject and len(sucs) > 1 and len(precs) > 1: |
684
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
2211 |
msg = "Can't use multiple successors for multiple precursors" |
1689
60752ed8d2d4
prune: suggest --biject in error "hint"
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1688
diff
changeset
|
2212 |
hint = _("use --biject to mark a series as a replacement" |
60752ed8d2d4
prune: suggest --biject in error "hint"
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1688
diff
changeset
|
2213 |
" for another") |
60752ed8d2d4
prune: suggest --biject in error "hint"
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1688
diff
changeset
|
2214 |
raise error.Abort(msg, hint=hint) |
1471
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2215 |
elif biject and len(sucs) != len(precs): |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
2216 |
msg = "Can't use %d successors for %d precursors" \ |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
2217 |
% (len(sucs), len(precs)) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2218 |
raise error.Abort(msg) |
1471
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2219 |
elif (len(precs) == 1 and len(sucs) > 1) and not split: |
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2220 |
msg = "please add --split if you want to do a split" |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2221 |
raise error.Abort(msg) |
1471
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2222 |
elif len(sucs) == 1 and len(precs) > 1 and not fold: |
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2223 |
msg = "please add --fold if you want to do a fold" |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2224 |
raise error.Abort(msg) |
1471
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2225 |
elif biject: |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
2226 |
relations = [(p, (s,)) for p, s in zip(precs, sucs)] |
1471
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2227 |
else: |
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2228 |
relations = [(p, sucs) for p in precs] |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
2229 |
|
683
6d24bd455f79
simplify locking in prune
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
682
diff
changeset
|
2230 |
wdp = repo['.'] |
931
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2231 |
|
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2232 |
if len(sucs) == 1 and len(precs) == 1 and wdp in precs: |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2233 |
# '.' killed, so update to the successor |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2234 |
newnode = sucs[0] |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2235 |
else: |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2236 |
# update to an unkilled parent |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2237 |
newnode = wdp |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2238 |
|
1239
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2239 |
while newnode in precs or newnode.obsolete(): |
931
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2240 |
newnode = newnode.parents()[0] |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2241 |
|
683
6d24bd455f79
simplify locking in prune
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
682
diff
changeset
|
2242 |
if newnode.node() != wdp.node(): |
1221
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2243 |
if opts.get('keep', False): |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2244 |
# This is largely the same as the implementation in |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2245 |
# strip.stripcmd(). We might want to refactor this somewhere |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2246 |
# common at some point. |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2247 |
|
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2248 |
# only reset the dirstate for files that would actually change |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2249 |
# between the working context and uctx |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2250 |
descendantrevs = repo.revs("%d::." % newnode.rev()) |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2251 |
changedfiles = [] |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2252 |
for rev in descendantrevs: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2253 |
# blindly reset the files, regardless of what actually |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2254 |
# changed |
1221
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2255 |
changedfiles.extend(repo[rev].files()) |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2256 |
|
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2257 |
# reset files that only changed in the dirstate too |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2258 |
dirstate = repo.dirstate |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2259 |
dirchanges = [f for f in dirstate if dirstate[f] != 'n'] |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2260 |
changedfiles.extend(dirchanges) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2261 |
repo.dirstate.rebuild(newnode.node(), newnode.manifest(), |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2262 |
changedfiles) |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
2263 |
dirstate.write(tr) |
1221
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2264 |
else: |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
2265 |
bookactive = repo._activebookmark |
1344 | 2266 |
# Active bookmark that we don't want to delete (with -B option) |
2267 |
# we deactivate and move it before the update and reactivate it |
|
2268 |
# after |
|
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2269 |
movebookmark = bookactive and not bookmarks |
1344 | 2270 |
if movebookmark: |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
2271 |
bookmarksmod.deactivate(repo) |
1344 | 2272 |
repo._bookmarks[bookactive] = newnode.node() |
1555
0ff262537f98
prune: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1554
diff
changeset
|
2273 |
repo._bookmarks.recordchange(tr) |
1221
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2274 |
commands.update(ui, repo, newnode.rev()) |
2405
4ff849709fea
label: add a label for the node in the "wc now at" message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2404
diff
changeset
|
2275 |
ui.status(_('working directory now at %s\n') |
4ff849709fea
label: add a label for the node in the "wc now at" message
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2404
diff
changeset
|
2276 |
% ui.label(newnode, 'evolve.node')) |
1344 | 2277 |
if movebookmark: |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
2278 |
bookmarksmod.activate(repo, bookactive) |
1342
16017e1bb2a1
prune: with active bookmark should stay active
Laurent Charignon <lcharignon@fb.com>
parents:
1340
diff
changeset
|
2279 |
|
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2280 |
# update bookmarks |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2281 |
if bookmarks: |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2282 |
_deletebookmark(repo, repomarks, bookmarks) |
1239
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2283 |
|
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2284 |
# create markers |
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2285 |
obsolete.createmarkers(repo, relations, metadata=metadata) |
1468
bc6cf6cc06fd
evolve: remove trailing spaces
André Sintzoff <andre.sintzoff@gmail.com>
parents:
1467
diff
changeset
|
2286 |
|
1239
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2287 |
# informs that changeset have been pruned |
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2288 |
ui.status(_('%i changesets pruned\n') % len(precs)) |
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2289 |
|
693
d3c1fe0035d1
prune: handle bookmark
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
691
diff
changeset
|
2290 |
for ctx in repo.unfiltered().set('bookmark() and %ld', precs): |
1101
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2291 |
# used to be: |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2292 |
# |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2293 |
# ldest = list(repo.set('max((::%d) - obsolete())', ctx)) |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2294 |
# if ldest: |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2295 |
# c = ldest[0] |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2296 |
# |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2297 |
# but then revset took a lazy arrow in the knee and became much |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2298 |
# slower. The new forms makes as much sense and a much faster. |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2299 |
for dest in ctx.ancestors(): |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2300 |
if not dest.obsolete(): |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
2301 |
updatebookmarks = _bookmarksupdater(repo, ctx.node(), tr) |
1101
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2302 |
updatebookmarks(dest.node()) |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2303 |
break |
1294
d1c29db2e055
prune: fix pruning w/ bookmarks and inhibit
Durham Goode <durham@fb.com>
parents:
1283
diff
changeset
|
2304 |
|
d1c29db2e055
prune: fix pruning w/ bookmarks and inhibit
Durham Goode <durham@fb.com>
parents:
1283
diff
changeset
|
2305 |
tr.close() |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2306 |
finally: |
1295
1ac05eef72ca
prune: prune fix transaction pattern
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1294
diff
changeset
|
2307 |
lockmod.release(tr, lock, wlock) |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2308 |
|
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2309 |
@eh.command( |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2310 |
'amend|refresh', |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2311 |
[('A', 'addremove', None, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2312 |
_('mark new/missing files as added/removed before committing')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2313 |
('e', 'edit', False, _('invoke editor on commit messages')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2314 |
('', 'close-branch', None, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2315 |
_('mark a branch as closed, hiding it from the branch list')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2316 |
('s', 'secret', None, _('use the secret phase for committing')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2317 |
] + walkopts + commitopts + commitopts2 + commitopts3 + interactiveopt, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2318 |
_('[OPTION]... [FILE]...')) |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2319 |
def amend(ui, repo, *pats, **opts): |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2320 |
"""combine a changeset with updates and replace it with a new one |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2321 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2322 |
Commits a new changeset incorporating both the changes to the given files |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2323 |
and all the changes from the current parent changeset into the repository. |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2324 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2325 |
See :hg:`commit` for details about committing changes. |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2326 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2327 |
If you don't specify -m, the parent's message will be reused. |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2328 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2329 |
Behind the scenes, Mercurial first commits the update as a regular child |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2330 |
of the current parent. Then it creates a new commit on the parent's parents |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2331 |
with the updated contents. Then it changes the working copy parent to this |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2332 |
new combined changeset. Finally, the old changeset and its update are hidden |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2333 |
from :hg:`log` (unless you use --hidden with log). |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2334 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2335 |
Returns 0 on success, 1 if nothing changed. |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2336 |
""" |
742
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2337 |
opts = opts.copy() |
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2338 |
edit = opts.pop('edit', False) |
1140
b7d85cd8ec7b
amend: allow the --logfile argument to work properly
Matt Harbison <matt_harbison@yahoo.com>
parents:
1137
diff
changeset
|
2339 |
log = opts.get('logfile') |
742
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2340 |
opts['amend'] = True |
1140
b7d85cd8ec7b
amend: allow the --logfile argument to work properly
Matt Harbison <matt_harbison@yahoo.com>
parents:
1137
diff
changeset
|
2341 |
if not (edit or opts['message'] or log): |
742
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2342 |
opts['message'] = repo['.'].description() |
985
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
2343 |
_resolveoptions(ui, opts) |
742
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2344 |
_alias, commitcmd = cmdutil.findcmd('commit', commands.table) |
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2345 |
return commitcmd[0](ui, repo, *pats, **opts) |
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
2346 |
|
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2347 |
|
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2348 |
def _touchedbetween(repo, source, dest, match=None): |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2349 |
touched = set() |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2350 |
for files in repo.status(source, dest, match=match)[:3]: |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2351 |
touched.update(files) |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2352 |
return touched |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2353 |
|
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2354 |
def _commitfiltered(repo, ctx, match, target=None): |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2355 |
"""Recommit ctx with changed files not in match. Return the new |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2356 |
node identifier, or None if nothing changed. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2357 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2358 |
base = ctx.p1() |
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2359 |
if target is None: |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2360 |
target = base |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2361 |
# ctx |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2362 |
initialfiles = _touchedbetween(repo, base, ctx) |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2363 |
if base == target: |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2364 |
affected = set(f for f in initialfiles if match(f)) |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2365 |
newcontent = set() |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2366 |
else: |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2367 |
affected = _touchedbetween(repo, target, ctx, match=match) |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2368 |
newcontent = _touchedbetween(repo, target, base, match=match) |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2369 |
# The commit touchs all existing files |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2370 |
# + all file that needs a new content |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2371 |
# - the file affected bny uncommit with the same content than base. |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2372 |
files = (initialfiles - affected) | newcontent |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2373 |
if not newcontent and files == initialfiles: |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2374 |
return None |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2375 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2376 |
# Filter copies |
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2377 |
copied = copies.pathcopies(target, ctx) |
1786
b674277ea4ef
uncommit: don't lose copy information of remaining files (issue5403)
Martin von Zweigbergk <martinvonz@google.com>
parents:
1784
diff
changeset
|
2378 |
copied = dict((dst, src) for dst, src in copied.iteritems() |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2379 |
if dst in files) |
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
|
2380 |
|
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2381 |
def filectxfn(repo, memctx, path, contentctx=ctx, redirect=newcontent): |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2382 |
if path in redirect: |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2383 |
return filectxfn(repo, memctx, path, contentctx=target, redirect=()) |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2384 |
if path not in contentctx: |
1086
96b9e0c31cc1
compat: adapt to change to memctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1085
diff
changeset
|
2385 |
return None |
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2386 |
fctx = contentctx[path] |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2387 |
flags = fctx.flags() |
1828
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
2388 |
mctx = context.memfilectx(repo, fctx.path(), fctx.data(), |
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
2389 |
islink='l' in flags, |
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
2390 |
isexec='x' in flags, |
2b80c01b3f58
compat: drop compatibility layer around memctx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1827
diff
changeset
|
2391 |
copied=copied.get(path)) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2392 |
return mctx |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2393 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2394 |
new = context.memctx(repo, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2395 |
parents=[base.node(), node.nullid], |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2396 |
text=ctx.description(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2397 |
files=files, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2398 |
filectxfn=filectxfn, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2399 |
user=ctx.user(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2400 |
date=ctx.date(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2401 |
extra=ctx.extra()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2402 |
# commitctx always create a new revision, no need to check |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2403 |
newid = repo.commitctx(new) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2404 |
return newid |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2405 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2406 |
def _uncommitdirstate(repo, oldctx, match): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2407 |
"""Fix the dirstate after switching the working directory from |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2408 |
oldctx to a copy of oldctx not containing changed files matched by |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2409 |
match. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2410 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2411 |
ctx = repo['.'] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2412 |
ds = repo.dirstate |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2413 |
copies = dict(ds.copies()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2414 |
m, a, r = repo.status(oldctx.p1(), oldctx, match=match)[:3] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2415 |
for f in m: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2416 |
if ds[f] == 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2417 |
# modified + removed -> removed |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2418 |
continue |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2419 |
ds.normallookup(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2420 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2421 |
for f in a: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2422 |
if ds[f] == 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2423 |
# added + removed -> unknown |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2424 |
ds.drop(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2425 |
elif ds[f] != 'a': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2426 |
ds.add(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2427 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2428 |
for f in r: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2429 |
if ds[f] == 'a': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2430 |
# removed + added -> normal |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2431 |
ds.normallookup(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2432 |
elif ds[f] != 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2433 |
ds.remove(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2434 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2435 |
# Merge old parent and old working dir copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2436 |
oldcopies = {} |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2437 |
for f in (m + a): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2438 |
src = oldctx[f].renamed() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2439 |
if src: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2440 |
oldcopies[f] = src[0] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2441 |
oldcopies.update(copies) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2442 |
copies = dict((dst, oldcopies.get(src, src)) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2443 |
for dst, src in oldcopies.iteritems()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2444 |
# Adjust the dirstate copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2445 |
for dst, src in copies.iteritems(): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2446 |
if (src not in ctx or dst in ctx or ds[dst] != 'a'): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2447 |
src = None |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2448 |
ds.copy(src, dst) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2449 |
|
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2450 |
@eh.command( |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2451 |
'^uncommit', |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2452 |
[('a', 'all', None, _('uncommit all changes when no arguments given')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2453 |
('r', 'rev', '', _('revert commit content to REV instead')), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2454 |
] + commands.walkopts, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2455 |
_('[OPTION]... [NAME]')) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2456 |
def uncommit(ui, repo, *pats, **opts): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2457 |
"""move changes from parent revision to working directory |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2458 |
|
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
2459 |
Changes to selected files in the checked out revision appear again as |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2460 |
uncommitted changed in the working directory. A new revision |
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
2461 |
without the selected changes is created, becomes the checked out |
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
2462 |
revision, and obsoletes the previous one. |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2463 |
|
867
6a67606e1c34
evolve: fix typos in uncommit docstring
André Sintzoff <andre.sintzoff@gmail.com>
parents:
858
diff
changeset
|
2464 |
The --include option specifies patterns to uncommit. |
6a67606e1c34
evolve: fix typos in uncommit docstring
André Sintzoff <andre.sintzoff@gmail.com>
parents:
858
diff
changeset
|
2465 |
The --exclude option specifies patterns to keep in the commit. |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2466 |
|
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2467 |
The --rev argument let you change the commit file to a content of another |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2468 |
revision. It still does not change the content of your file in the working |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2469 |
directory. |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2470 |
|
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2471 |
Return 0 if changed files are uncommitted. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2472 |
""" |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2473 |
|
1022 | 2474 |
wlock = lock = tr = None |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2475 |
try: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2476 |
wlock = repo.wlock() |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2477 |
lock = repo.lock() |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2478 |
wctx = repo[None] |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2479 |
if len(wctx.parents()) <= 0: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2480 |
raise error.Abort(_("cannot uncommit null changeset")) |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2481 |
if len(wctx.parents()) > 1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2482 |
raise error.Abort(_("cannot uncommit while merging")) |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2483 |
old = repo['.'] |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2484 |
if old.phase() == phases.public: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2485 |
raise error.Abort(_("cannot rewrite immutable changeset")) |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2486 |
if len(old.parents()) > 1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2487 |
raise error.Abort(_("cannot uncommit merge changeset")) |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2488 |
oldphase = old.phase() |
1022 | 2489 |
|
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2490 |
rev = None |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2491 |
if opts.get('rev'): |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2492 |
rev = scmutil.revsingle(repo, opts.get('rev')) |
1143
160fd06312fc
uncommit: abort when rev specifies the current changeset
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
1141
diff
changeset
|
2493 |
ctx = repo[None] |
160fd06312fc
uncommit: abort when rev specifies the current changeset
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
1141
diff
changeset
|
2494 |
if ctx.p1() == rev or ctx.p2() == rev: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2495 |
raise error.Abort(_("cannot uncommit to parent changeset")) |
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2496 |
|
1364
f00d91365ab9
evolve: make uncommit respect allowunsable
Laurent Charignon <lcharignon@fb.com>
parents:
1361
diff
changeset
|
2497 |
onahead = old.rev() in repo.changelog.headrevs() |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2498 |
disallowunstable = not obsolete.isenabled(repo, |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2499 |
obsolete.allowunstableopt) |
1364
f00d91365ab9
evolve: make uncommit respect allowunsable
Laurent Charignon <lcharignon@fb.com>
parents:
1361
diff
changeset
|
2500 |
if disallowunstable and not onahead: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2501 |
raise error.Abort(_("cannot uncommit in the middle of a stack")) |
1364
f00d91365ab9
evolve: make uncommit respect allowunsable
Laurent Charignon <lcharignon@fb.com>
parents:
1361
diff
changeset
|
2502 |
|
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2503 |
# Recommit the filtered changeset |
1022 | 2504 |
tr = repo.transaction('uncommit') |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
2505 |
updatebookmarks = _bookmarksupdater(repo, old.node(), tr) |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2506 |
newid = None |
1351
69e5de3e6129
evolve: small refactoring of the uncommit function
Laurent Charignon <lcharignon@fb.com>
parents:
1350
diff
changeset
|
2507 |
includeorexclude = opts.get('include') or opts.get('exclude') |
69e5de3e6129
evolve: small refactoring of the uncommit function
Laurent Charignon <lcharignon@fb.com>
parents:
1350
diff
changeset
|
2508 |
if (pats or includeorexclude or opts.get('all')): |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2509 |
match = scmutil.match(old, pats, opts) |
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2510 |
newid = _commitfiltered(repo, old, match, target=rev) |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2511 |
if newid is None: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2512 |
raise error.Abort(_('nothing to uncommit'), |
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
|
2513 |
hint=_("use --all to uncommit all files")) |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2514 |
# Move local changes on filtered changeset |
1070
527b12a59628
drop relevant marker compat
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1069
diff
changeset
|
2515 |
obsolete.createmarkers(repo, [(old, (repo[newid],))]) |
1069
356552e55489
evolve: always use the transaction version of phase movement
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1068
diff
changeset
|
2516 |
phases.retractboundary(repo, tr, oldphase, [newid]) |
1112
c3e23fbf7bd7
evolve: wrap setparents calls in begin/endparentchange
Siddharth Agarwal <sid0@fb.com>
parents:
1111
diff
changeset
|
2517 |
repo.dirstate.beginparentchange() |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2518 |
repo.dirstate.setparents(newid, node.nullid) |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2519 |
_uncommitdirstate(repo, old, match) |
1112
c3e23fbf7bd7
evolve: wrap setparents calls in begin/endparentchange
Siddharth Agarwal <sid0@fb.com>
parents:
1111
diff
changeset
|
2520 |
repo.dirstate.endparentchange() |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2521 |
updatebookmarks(newid) |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2522 |
if not repo[newid].files(): |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2523 |
ui.warn(_("new changeset is empty\n")) |
1756
a7dcfff8c4a9
evolve: use single quotes in usage messages
Martin von Zweigbergk <martinvonz@google.com>
parents:
1755
diff
changeset
|
2524 |
ui.status(_("(use 'hg prune .' to remove it)\n")) |
1022 | 2525 |
tr.close() |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2526 |
finally: |
1022 | 2527 |
lockmod.release(tr, lock, wlock) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2528 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2529 |
@eh.wrapcommand('commit') |
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
2530 |
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
|
2531 |
tr = None |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2532 |
if kwargs.get('amend', False): |
1255
a2d4901e211e
commit: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1253
diff
changeset
|
2533 |
wlock = lock = None |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2534 |
else: |
1255
a2d4901e211e
commit: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1253
diff
changeset
|
2535 |
wlock = repo.wlock() |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2536 |
lock = repo.lock() |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2537 |
try: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2538 |
obsoleted = kwargs.get('obsolete', []) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2539 |
if obsoleted: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2540 |
obsoleted = repo.set('%lr', obsoleted) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2541 |
result = orig(ui, repo, *arg, **kwargs) |
1659 | 2542 |
if not result: # commit succeeded |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2543 |
new = repo['-1'] |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2544 |
oldbookmarks = [] |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
2545 |
markers = [] |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2546 |
for old in obsoleted: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2547 |
oldbookmarks.extend(repo.nodebookmarks(old.node())) |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
2548 |
markers.append((old, (new,))) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
2549 |
if markers: |
1070
527b12a59628
drop relevant marker compat
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1069
diff
changeset
|
2550 |
obsolete.createmarkers(repo, markers) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2551 |
for book in oldbookmarks: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2552 |
repo._bookmarks[book] = new.node() |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2553 |
if oldbookmarks: |
1558
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2554 |
if not wlock: |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2555 |
wlock = repo.wlock() |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2556 |
if not lock: |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2557 |
lock = repo.lock() |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2558 |
tr = repo.transaction('commit') |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2559 |
repo._bookmarks.recordchange(tr) |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2560 |
tr.close() |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2561 |
return result |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2562 |
finally: |
1558
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2563 |
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
|
2564 |
|
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2565 |
@eh.command( |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2566 |
'^split', |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2567 |
[('r', 'rev', [], _("revision to split")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2568 |
] + commitopts + commitopts2, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2569 |
_('hg split [OPTION]... [-r] REV')) |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2570 |
def cmdsplit(ui, repo, *revs, **opts): |
1575 | 2571 |
"""split a changeset into smaller changesets |
1573
0b4cec85d4ab
evolve: improve help for split command
Greg Ward <greg@gerg.ca>
parents:
1572
diff
changeset
|
2572 |
|
0b4cec85d4ab
evolve: improve help for split command
Greg Ward <greg@gerg.ca>
parents:
1572
diff
changeset
|
2573 |
By default, split the current revision by prompting for all its hunks to be |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2574 |
redistributed into new changesets. |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2575 |
|
1573
0b4cec85d4ab
evolve: improve help for split command
Greg Ward <greg@gerg.ca>
parents:
1572
diff
changeset
|
2576 |
Use --rev to split a given changeset instead. |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2577 |
""" |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2578 |
tr = wlock = lock = None |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2579 |
newcommits = [] |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2580 |
|
1598
2a08ef812b84
evolve: make split respect rev args passed without --rev or -r
Kostia Balytskyi <ikostia@fb.com>
parents:
1597
diff
changeset
|
2581 |
revarg = (list(revs) + opts.get('rev')) or ['.'] |
2a08ef812b84
evolve: make split respect rev args passed without --rev or -r
Kostia Balytskyi <ikostia@fb.com>
parents:
1597
diff
changeset
|
2582 |
if len(revarg) != 1: |
2a08ef812b84
evolve: make split respect rev args passed without --rev or -r
Kostia Balytskyi <ikostia@fb.com>
parents:
1597
diff
changeset
|
2583 |
msg = _("more than one revset is given") |
2a08ef812b84
evolve: make split respect rev args passed without --rev or -r
Kostia Balytskyi <ikostia@fb.com>
parents:
1597
diff
changeset
|
2584 |
hnt = _("use either `hg split <rs>` or `hg split --rev <rs>`, not both") |
2a08ef812b84
evolve: make split respect rev args passed without --rev or -r
Kostia Balytskyi <ikostia@fb.com>
parents:
1597
diff
changeset
|
2585 |
raise error.Abort(msg, hint=hnt) |
2a08ef812b84
evolve: make split respect rev args passed without --rev or -r
Kostia Balytskyi <ikostia@fb.com>
parents:
1597
diff
changeset
|
2586 |
|
2a08ef812b84
evolve: make split respect rev args passed without --rev or -r
Kostia Balytskyi <ikostia@fb.com>
parents:
1597
diff
changeset
|
2587 |
rev = scmutil.revsingle(repo, revarg[0]) |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2588 |
try: |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2589 |
wlock = repo.wlock() |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2590 |
lock = repo.lock() |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2591 |
cmdutil.bailifchanged(repo) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2592 |
tr = repo.transaction('split') |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2593 |
ctx = repo[rev] |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2594 |
r = ctx.rev() |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2595 |
disallowunstable = not obsolete.isenabled(repo, |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2596 |
obsolete.allowunstableopt) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2597 |
if disallowunstable: |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2598 |
# XXX We should check head revs |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2599 |
if repo.revs("(%d::) - %d", rev, rev): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2600 |
raise error.Abort(_("cannot split commit: %s not a head") % ctx) |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2601 |
|
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2602 |
if len(ctx.parents()) > 1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2603 |
raise error.Abort(_("cannot split merge commits")) |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2604 |
prev = ctx.p1() |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
2605 |
bmupdate = _bookmarksupdater(repo, ctx.node(), tr) |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
2606 |
bookactive = repo._activebookmark |
1485
1ba64be11bf8
split: handle bookmarks instead of leaving them on precursor
Laurent Charignon <lcharignon@fb.com>
parents:
1484
diff
changeset
|
2607 |
if bookactive is not None: |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
2608 |
repo.ui.status(_("(leaving bookmark %s)\n") % repo._activebookmark) |
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
2609 |
bookmarksmod.deactivate(repo) |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2610 |
hg.update(repo, prev) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2611 |
|
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2612 |
commands.revert(ui, repo, rev=r, all=True) |
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
|
2613 |
|
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2614 |
def haschanges(): |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2615 |
modified, added, removed, deleted = repo.status()[:4] |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2616 |
return modified or added or removed or deleted |
1677
48c3a472aec7
split: rewrite the pre-split commit message
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
1669
diff
changeset
|
2617 |
msg = ("HG: This is the original pre-split commit message. " |
48c3a472aec7
split: rewrite the pre-split commit message
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
1669
diff
changeset
|
2618 |
"Edit it as appropriate.\n\n") |
1531
47f48af730ce
split: preserve original changesets description
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1528
diff
changeset
|
2619 |
msg += ctx.description() |
47f48af730ce
split: preserve original changesets description
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1528
diff
changeset
|
2620 |
opts['message'] = msg |
47f48af730ce
split: preserve original changesets description
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1528
diff
changeset
|
2621 |
opts['edit'] = True |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2622 |
while haschanges(): |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2623 |
pats = () |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2624 |
cmdutil.dorecord(ui, repo, commands.commit, 'commit', False, |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2625 |
cmdutil.recordfilter, *pats, **opts) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2626 |
# TODO: Does no seem like the best way to do this |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2627 |
# We should make dorecord return the newly created commit |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2628 |
newcommits.append(repo['.']) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2629 |
if haschanges(): |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2630 |
if ui.prompt('Done splitting? [yN]', default='n') == 'y': |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2631 |
commands.commit(ui, repo, **opts) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2632 |
newcommits.append(repo['.']) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2633 |
break |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2634 |
else: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2635 |
ui.status(_("no more change to split\n")) |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2636 |
|
1739
904ae1b2087b
split: avoid trying to split an empty commit (issue5191)
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
1735
diff
changeset
|
2637 |
if newcommits: |
904ae1b2087b
split: avoid trying to split an empty commit (issue5191)
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
1735
diff
changeset
|
2638 |
tip = repo[newcommits[-1]] |
904ae1b2087b
split: avoid trying to split an empty commit (issue5191)
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
1735
diff
changeset
|
2639 |
bmupdate(tip.node()) |
904ae1b2087b
split: avoid trying to split an empty commit (issue5191)
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
1735
diff
changeset
|
2640 |
if bookactive is not None: |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
2641 |
bookmarksmod.activate(repo, bookactive) |
1739
904ae1b2087b
split: avoid trying to split an empty commit (issue5191)
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
1735
diff
changeset
|
2642 |
obsolete.createmarkers(repo, [(repo[r], newcommits)]) |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2643 |
tr.close() |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2644 |
finally: |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2645 |
lockmod.release(tr, lock, wlock) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2646 |
|
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2647 |
|
1220
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2648 |
@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
|
2649 |
('', '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
|
2650 |
"backup bundle")), |
1220
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2651 |
]) |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2652 |
def stripwrapper(orig, ui, repo, *revs, **kwargs): |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2653 |
if (not ui.configbool('experimental', 'prunestrip') or |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2654 |
kwargs.get('bundle', False)): |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2655 |
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
|
2656 |
|
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2657 |
if kwargs.get('force'): |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2658 |
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
|
2659 |
"enabled\n")) |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2660 |
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
|
2661 |
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
|
2662 |
"evolve enabled\n")) |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2663 |
|
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2664 |
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
|
2665 |
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
|
2666 |
revs = repo.revs("(%ld)::", revs) |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2667 |
kwargs['rev'] = [] |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2668 |
kwargs['new'] = [] |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2669 |
kwargs['succ'] = [] |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2670 |
kwargs['biject'] = False |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2671 |
return cmdprune(ui, repo, *revs, **kwargs) |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2672 |
|
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2673 |
@eh.command( |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2674 |
'^touch', |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2675 |
[('r', 'rev', [], 'revision to update'), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2676 |
('D', 'duplicate', False, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2677 |
'do not mark the new revision as successor of the old one'), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2678 |
('A', 'allowdivergence', False, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2679 |
'mark the new revision as successor of the old one potentially creating ' |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2680 |
'divergence')], |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2681 |
# allow to choose the seed ? |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2682 |
_('[-r] revs')) |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2683 |
def touch(ui, repo, *revs, **opts): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2684 |
"""create successors that are identical to their predecessors except |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2685 |
for the changeset ID |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
2686 |
|
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
2687 |
This is used to "resurrect" changesets |
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
2688 |
""" |
701
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2689 |
duplicate = opts['duplicate'] |
1589
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2690 |
allowdivergence = opts['allowdivergence'] |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2691 |
revs = list(revs) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2692 |
revs.extend(opts['rev']) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2693 |
if not revs: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2694 |
revs = ['.'] |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2695 |
revs = scmutil.revrange(repo, revs) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2696 |
if not revs: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2697 |
ui.write_err('no revision to touch\n') |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2698 |
return 1 |
701
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2699 |
if not duplicate and repo.revs('public() and %ld', revs): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2700 |
raise error.Abort("can't touch public revision") |
1589
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2701 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2702 |
wlock = lock = tr = None |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2703 |
try: |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2704 |
wlock = repo.wlock() |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2705 |
lock = repo.lock() |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2706 |
tr = repo.transaction('touch') |
702
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2707 |
revs.sort() # ensure parent are run first |
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2708 |
newmapping = {} |
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2709 |
for r in revs: |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2710 |
ctx = repo[r] |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2711 |
extra = ctx.extra().copy() |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2712 |
extra['__touch-noise__'] = random.randint(0, 0xffffffff) |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2713 |
# search for touched parent |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2714 |
p1 = ctx.p1().node() |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2715 |
p2 = ctx.p2().node() |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2716 |
p1 = newmapping.get(p1, p1) |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2717 |
p2 = newmapping.get(p2, p2) |
1589
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2718 |
|
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2719 |
if not (duplicate or allowdivergence): |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2720 |
# The user hasn't yet decided what to do with the revived |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2721 |
# cset, let's ask |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2722 |
sset = obsolete.successorssets(repo, ctx.node()) |
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
|
2723 |
nodivergencerisk = (len(sset) == 0 or |
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
|
2724 |
(len(sset) == 1 and |
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
|
2725 |
len(sset[0]) == 1 and |
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
|
2726 |
repo[sset[0][0]].rev() == ctx.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
|
2727 |
)) |
1589
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2728 |
if nodivergencerisk: |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2729 |
duplicate = False |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2730 |
else: |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2731 |
displayer.show(ctx) |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2732 |
index = ui.promptchoice( |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2733 |
_("reviving this changeset will create divergence" |
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
|
2734 |
" unless you make a duplicate.\n(a)llow divergence or" |
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
|
2735 |
" (d)uplicate the changeset? $$ &Allowdivergence $$ " |
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
|
2736 |
"&Duplicate"), 0) |
1589
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2737 |
choice = ['allowdivergence', 'duplicate'][index] |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2738 |
if choice == 'allowdivergence': |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2739 |
duplicate = False |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2740 |
else: |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2741 |
duplicate = True |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2742 |
|
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2743 |
new, unusedvariable = rewrite(repo, ctx, [], ctx, |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2744 |
[p1, p2], |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2745 |
commitopts={'extra': extra}) |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2746 |
# store touched version to help potential children |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2747 |
newmapping[ctx.node()] = new |
1589
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2748 |
|
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2749 |
if not duplicate: |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2750 |
obsolete.createmarkers(repo, [(ctx, (repo[new],))]) |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2751 |
phases.retractboundary(repo, tr, ctx.phase(), [new]) |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2752 |
if ctx in repo[None].parents(): |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2753 |
repo.dirstate.beginparentchange() |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2754 |
repo.dirstate.setparents(new, node.nullid) |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2755 |
repo.dirstate.endparentchange() |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2756 |
tr.close() |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2757 |
finally: |
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
2758 |
lockmod.release(tr, lock, wlock) |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2759 |
|
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2760 |
@eh.command( |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2761 |
'^fold|squash', |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2762 |
[('r', 'rev', [], _("revision to fold")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2763 |
('', 'exact', None, _("only fold specified revisions")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2764 |
('', 'from', None, _("fold revisions linearly to working copy parent")) |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2765 |
] + commitopts + commitopts2, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2766 |
_('hg fold [OPTION]... [-r] REV')) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2767 |
def fold(ui, repo, *revs, **opts): |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2768 |
"""fold multiple revisions into a single one |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2769 |
|
1782
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2770 |
With --from, folds all the revisions linearly between the given revisions |
1463
71a3aa0349c5
evolve: improve the help of the fold command
Laurent Charignon <lcharignon@fb.com>
parents:
1460
diff
changeset
|
2771 |
and the parent of the working directory. |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2772 |
|
1782
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2773 |
With --exact, folds only the specified revisions while ignoring the |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2774 |
parent of the working directory. In this case, the given revisions must |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2775 |
form a linear unbroken chain. |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2776 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2777 |
.. container:: verbose |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2778 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2779 |
Some examples: |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2780 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2781 |
- Fold the current revision with its parent:: |
702
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2782 |
|
1782
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2783 |
hg fold --from .^ |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2784 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2785 |
- Fold all draft revisions with working directory parent:: |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2786 |
|
1782
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2787 |
hg fold --from 'draft()' |
702
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2788 |
|
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2789 |
See :hg:`help phases` for more about draft revisions and |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2790 |
:hg:`help revsets` for more about the `draft()` keyword |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2791 |
|
1469
fa1a27009c76
evolve: fix typo in fold docstring
André Sintzoff <andre.sintzoff@gmail.com>
parents:
1468
diff
changeset
|
2792 |
- Fold revisions between 3 and 6 with the working directory parent:: |
1464
d830d4e9f212
fold: avoid using x:y in the help
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1463
diff
changeset
|
2793 |
|
1782
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2794 |
hg fold --from 3::6 |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2795 |
|
1463
71a3aa0349c5
evolve: improve the help of the fold command
Laurent Charignon <lcharignon@fb.com>
parents:
1460
diff
changeset
|
2796 |
- Fold revisions 3 and 4: |
71a3aa0349c5
evolve: improve the help of the fold command
Laurent Charignon <lcharignon@fb.com>
parents:
1460
diff
changeset
|
2797 |
|
71a3aa0349c5
evolve: improve the help of the fold command
Laurent Charignon <lcharignon@fb.com>
parents:
1460
diff
changeset
|
2798 |
hg fold "3 + 4" --exact |
71a3aa0349c5
evolve: improve the help of the fold command
Laurent Charignon <lcharignon@fb.com>
parents:
1460
diff
changeset
|
2799 |
|
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2800 |
- Only fold revisions linearly between foo and @:: |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2801 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2802 |
hg fold foo::@ --exact |
702
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2803 |
""" |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2804 |
revs = list(revs) |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2805 |
revs.extend(opts['rev']) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2806 |
if not revs: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2807 |
raise error.Abort(_('no revisions specified')) |
995
0f3a7efd6ee9
fold: emit error message when folding a single revision
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
994
diff
changeset
|
2808 |
|
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2809 |
revs = scmutil.revrange(repo, revs) |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2810 |
|
1782
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2811 |
if opts['from'] and opts['exact']: |
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2812 |
raise error.Abort(_('cannot use both --from and --exact')) |
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2813 |
elif opts['from']: |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2814 |
# Try to extend given revision starting from the working directory |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2815 |
extrevs = repo.revs('(%ld::.) or (.::%ld)', revs, revs) |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2816 |
discardedrevs = [r for r in revs if r not in extrevs] |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2817 |
if discardedrevs: |
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
|
2818 |
msg = _("cannot fold non-linear revisions") |
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
|
2819 |
hint = _("given revisions are unrelated to parent of working" |
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
|
2820 |
" directory") |
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
|
2821 |
raise error.Abort(msg, hint=hint) |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2822 |
revs = extrevs |
1782
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2823 |
elif opts['exact']: |
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2824 |
# Nothing to do; "revs" is already set correctly |
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2825 |
pass |
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2826 |
else: |
a046e78c3290
fold: require --from flag for folding revisions to working copy
Martin von Zweigbergk <martinvonz@google.com>
parents:
1781
diff
changeset
|
2827 |
raise error.Abort(_('must specify either --from or --exact')) |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2828 |
|
1784
c3741a5adbb0
fold: cleanly abort on empty fold set (issue5453)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1765
diff
changeset
|
2829 |
if not revs: |
c3741a5adbb0
fold: cleanly abort on empty fold set (issue5453)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1765
diff
changeset
|
2830 |
raise error.Abort(_('specified revisions evaluate to an empty set'), |
c3741a5adbb0
fold: cleanly abort on empty fold set (issue5453)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1765
diff
changeset
|
2831 |
hint=_('use different revision arguments')) |
c3741a5adbb0
fold: cleanly abort on empty fold set (issue5453)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1765
diff
changeset
|
2832 |
elif len(revs) == 1: |
995
0f3a7efd6ee9
fold: emit error message when folding a single revision
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
994
diff
changeset
|
2833 |
ui.write_err(_('single revision specified, nothing to fold\n')) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2834 |
return 1 |
995
0f3a7efd6ee9
fold: emit error message when folding a single revision
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
994
diff
changeset
|
2835 |
|
515 | 2836 |
wlock = lock = None |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2837 |
try: |
515 | 2838 |
wlock = repo.wlock() |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2839 |
lock = repo.lock() |
1687
73e0018c423f
fold: move sanity check after locking
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1686
diff
changeset
|
2840 |
|
73e0018c423f
fold: move sanity check after locking
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1686
diff
changeset
|
2841 |
root, head = _foldcheck(repo, revs) |
73e0018c423f
fold: move sanity check after locking
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1686
diff
changeset
|
2842 |
|
1781
39ef492603c6
fold: use 'fold', not 'touch', for transaction description
Martin von Zweigbergk <martinvonz@google.com>
parents:
1779
diff
changeset
|
2843 |
tr = repo.transaction('fold') |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2844 |
try: |
915
1ebe5c51919b
fold: enable --date and --user options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
912
diff
changeset
|
2845 |
commitopts = opts.copy() |
515 | 2846 |
allctx = [repo[r] for r in revs] |
2847 |
targetphase = max(c.phase() for c in allctx) |
|
933
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2848 |
|
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2849 |
if commitopts.get('message') or commitopts.get('logfile'): |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2850 |
commitopts['edit'] = False |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2851 |
else: |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2852 |
msgs = ["HG: This is a fold of %d changesets." % len(allctx)] |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2853 |
msgs += ["HG: Commit message of changeset %s.\n\n%s\n" % |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2854 |
(c.rev(), c.description()) for c in allctx] |
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
|
2855 |
commitopts['message'] = "\n".join(msgs) |
933
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2856 |
commitopts['edit'] = True |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2857 |
|
993
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
2858 |
newid, unusedvariable = rewrite(repo, root, allctx, head, |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2859 |
[root.p1().node(), |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2860 |
root.p2().node()], |
993
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
2861 |
commitopts=commitopts) |
1069
356552e55489
evolve: always use the transaction version of phase movement
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1068
diff
changeset
|
2862 |
phases.retractboundary(repo, tr, targetphase, [newid]) |
1070
527b12a59628
drop relevant marker compat
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1069
diff
changeset
|
2863 |
obsolete.createmarkers(repo, [(ctx, (repo[newid],)) |
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
|
2864 |
for ctx in allctx]) |
515 | 2865 |
tr.close() |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2866 |
finally: |
515 | 2867 |
tr.release() |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2868 |
ui.status('%i changesets folded\n' % len(revs)) |
632
cb0807646f5a
fold: work around potential bug with filtering
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
631
diff
changeset
|
2869 |
if repo['.'].rev() in revs: |
549
b047e9417d96
Properly update after fold
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
548
diff
changeset
|
2870 |
hg.update(repo, newid) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2871 |
finally: |
515 | 2872 |
lockmod.release(lock, wlock) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2873 |
|
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2874 |
@eh.command( |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2875 |
'^metaedit', |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2876 |
[('r', 'rev', [], _("revision to edit")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2877 |
('', 'fold', None, _("also fold specified revisions into one")), |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2878 |
] + commitopts + commitopts2, |
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
2879 |
_('hg metaedit [OPTION]... [-r] [REV]')) |
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2880 |
def metaedit(ui, repo, *revs, **opts): |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2881 |
"""edit commit information |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2882 |
|
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2883 |
Edits the commit information for the specified revisions. By default, edits |
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2884 |
commit information for the working directory parent. |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2885 |
|
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2886 |
With --fold, also folds multiple revisions into one if necessary. In this |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2887 |
case, the given revisions must form a linear unbroken chain. |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2888 |
|
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2889 |
.. container:: verbose |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2890 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2891 |
Some examples: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2892 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2893 |
- Edit the commit message for the working directory parent:: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2894 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2895 |
hg metaedit |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2896 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2897 |
- Change the username for the working directory parent:: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2898 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2899 |
hg metaedit --user 'New User <new-email@example.com>' |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2900 |
|
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2901 |
- Combine all draft revisions that are ancestors of foo but not of @ into |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2902 |
one:: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2903 |
|
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2904 |
hg metaedit --fold 'draft() and only(foo,@)' |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2905 |
|
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2906 |
See :hg:`help phases` for more about draft revisions, and |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2907 |
:hg:`help revsets` for more about the `draft()` and `only()` keywords. |
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2908 |
""" |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2909 |
revs = list(revs) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2910 |
revs.extend(opts['rev']) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2911 |
if not revs: |
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2912 |
if opts['fold']: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2913 |
raise error.Abort(_('revisions must be specified with --fold')) |
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2914 |
revs = ['.'] |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2915 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2916 |
wlock = lock = None |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2917 |
try: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2918 |
wlock = repo.wlock() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2919 |
lock = repo.lock() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2920 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2921 |
revs = scmutil.revrange(repo, revs) |
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2922 |
if not opts['fold'] and len(revs) > 1: |
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2923 |
# TODO: handle multiple revisions. This is somewhat tricky because |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2924 |
# if we want to edit a series of commits: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2925 |
# |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2926 |
# a ---- b ---- c |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2927 |
# |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2928 |
# we need to rewrite a first, then directly rewrite b on top of the |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2929 |
# new a, then rewrite c on top of the new b. So we need to handle |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2930 |
# revisions in topological order. |
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2931 |
raise error.Abort(_('editing multiple revisions without --fold is ' |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2932 |
'not currently supported')) |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2933 |
|
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2934 |
if opts['fold']: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2935 |
root, head = _foldcheck(repo, revs) |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2936 |
else: |
1688
031682c1faa2
metaedit: check for public changeset before instability
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1687
diff
changeset
|
2937 |
if repo.revs("%ld and public()", revs): |
031682c1faa2
metaedit: check for public changeset before instability
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1687
diff
changeset
|
2938 |
raise error.Abort(_('cannot edit commit information for public ' |
031682c1faa2
metaedit: check for public changeset before instability
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1687
diff
changeset
|
2939 |
'revisions')) |
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2940 |
newunstable = _disallowednewunstable(repo, revs) |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2941 |
if newunstable: |
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
|
2942 |
msg = _('cannot edit commit information in the middle' |
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
|
2943 |
' of a stack') |
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
|
2944 |
hint = _('%s will become unstable and new unstable changes' |
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
|
2945 |
' are not allowed') |
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
|
2946 |
hint %= repo[newunstable.first()] |
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
|
2947 |
raise error.Abort(msg, hint=hint) |
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2948 |
root = head = repo[revs.first()] |
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2949 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2950 |
wctx = repo[None] |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2951 |
p1 = wctx.p1() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2952 |
tr = repo.transaction('metaedit') |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2953 |
newp1 = None |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2954 |
try: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2955 |
commitopts = opts.copy() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2956 |
allctx = [repo[r] for r in revs] |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2957 |
targetphase = max(c.phase() for c in allctx) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2958 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2959 |
if commitopts.get('message') or commitopts.get('logfile'): |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2960 |
commitopts['edit'] = False |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2961 |
else: |
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2962 |
if opts['fold']: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2963 |
msgs = ["HG: This is a fold of %d changesets." % len(allctx)] |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2964 |
msgs += ["HG: Commit message of changeset %s.\n\n%s\n" % |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2965 |
(c.rev(), c.description()) for c in allctx] |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2966 |
else: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2967 |
msgs = [head.description()] |
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
|
2968 |
commitopts['message'] = "\n".join(msgs) |
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2969 |
commitopts['edit'] = True |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2970 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2971 |
# TODO: if the author and message are the same, don't create a new |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2972 |
# hash. Right now we create a new hash because the date can be |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2973 |
# different. |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2974 |
newid, created = rewrite(repo, root, allctx, head, |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2975 |
[root.p1().node(), root.p2().node()], |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2976 |
commitopts=commitopts) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2977 |
if created: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2978 |
if p1.rev() in revs: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2979 |
newp1 = newid |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2980 |
phases.retractboundary(repo, tr, targetphase, [newid]) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2981 |
obsolete.createmarkers(repo, [(ctx, (repo[newid],)) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2982 |
for ctx in allctx]) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2983 |
else: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2984 |
ui.status(_("nothing changed\n")) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2985 |
tr.close() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2986 |
finally: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2987 |
tr.release() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2988 |
|
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2989 |
if opts['fold']: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
2990 |
ui.status('%i changesets folded\n' % len(revs)) |
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2991 |
if newp1 is not None: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2992 |
hg.update(repo, newp1) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2993 |
finally: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2994 |
lockmod.release(lock, wlock) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
2995 |
|
1683
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
2996 |
def _foldcheck(repo, revs): |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
2997 |
roots = repo.revs('roots(%ld)', revs) |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
2998 |
if len(roots) > 1: |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
2999 |
raise error.Abort(_("cannot fold non-linear revisions " |
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
|
3000 |
"(multiple roots given)")) |
1683
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3001 |
root = repo[roots.first()] |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3002 |
if root.phase() <= phases.public: |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3003 |
raise error.Abort(_("cannot fold public revisions")) |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3004 |
heads = repo.revs('heads(%ld)', revs) |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3005 |
if len(heads) > 1: |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3006 |
raise error.Abort(_("cannot fold non-linear revisions " |
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
|
3007 |
"(multiple heads given)")) |
1683
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3008 |
head = repo[heads.first()] |
1684
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3009 |
if _disallowednewunstable(repo, revs): |
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
|
3010 |
msg = _("cannot fold chain not ending with a head or with branching") |
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
|
3011 |
hint = _("new unstable changesets are not allowed") |
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
|
3012 |
raise error.Abort(msg, hint=hint) |
1683
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3013 |
return root, head |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
3014 |
|
1684
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3015 |
def _disallowednewunstable(repo, revs): |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3016 |
allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3017 |
if allowunstable: |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3018 |
return revset.baseset() |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3019 |
return repo.revs("(%ld::) - %ld", revs, revs) |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3020 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
3021 |
@eh.wrapcommand('graft') |
117
438fe133b068
Add a -o and -O option to graft.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
116
diff
changeset
|
3022 |
def graftwrapper(orig, ui, repo, *revs, **kwargs): |
419
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
3023 |
kwargs = dict(kwargs) |
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
3024 |
revs = list(revs) + kwargs.get('rev', []) |
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
3025 |
kwargs['rev'] = [] |
417
a1fb18ad29a1
evolve: avoid duplication in graft wrapper
Patrick Mezard <patrick@mezard.eu>
parents:
416
diff
changeset
|
3026 |
obsoleted = kwargs.setdefault('obsolete', []) |
419
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
3027 |
|
1256
f8cb01637e75
graft: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1255
diff
changeset
|
3028 |
wlock = lock = None |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3029 |
try: |
1256
f8cb01637e75
graft: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1255
diff
changeset
|
3030 |
wlock = repo.wlock() |
f8cb01637e75
graft: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1255
diff
changeset
|
3031 |
lock = repo.lock() |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3032 |
if kwargs.get('old_obsolete'): |
418
18a0d96ed559
evolve: graft --continue is optional, test
Patrick Mezard <patrick@mezard.eu>
parents:
417
diff
changeset
|
3033 |
if kwargs.get('continue'): |
2051
74934195747b
evolve: switch away from deprecated repo.opener
Martin von Zweigbergk <martinvonz@google.com>
parents:
2049
diff
changeset
|
3034 |
obsoleted.extend(repo.vfs.read('graftstate').splitlines()) |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3035 |
else: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3036 |
obsoleted.extend(revs) |
151
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
3037 |
# convert obsolete target into revs to avoid alias joke |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
3038 |
obsoleted[:] = [str(i) for i in repo.revs('%lr', obsoleted)] |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
3039 |
if obsoleted and len(revs) > 1: |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
3040 |
|
743
af74a5cdf96b
conform to the Mercurial custom of lowercase messages
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
742
diff
changeset
|
3041 |
raise error.Abort(_('cannot graft multiple revisions while ' |
151
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
3042 |
'obsoleting (for now).')) |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
3043 |
|
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
|
3044 |
return commitwrapper(orig, ui, repo, *revs, **kwargs) |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3045 |
finally: |
1256
f8cb01637e75
graft: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1255
diff
changeset
|
3046 |
lockmod.release(lock, wlock) |
117
438fe133b068
Add a -o and -O option to graft.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
116
diff
changeset
|
3047 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
3048 |
@eh.extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
3049 |
def oldevolveextsetup(ui): |
1631
7463f5880ce9
prune: remove the kill alias
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1630
diff
changeset
|
3050 |
for cmd in ['prune', 'uncommit', 'touch', 'fold']: |
1226
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3051 |
try: |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3052 |
entry = extensions.wrapcommand(cmdtable, cmd, |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3053 |
warnobserrors) |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3054 |
except error.UnknownCommand: |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3055 |
# Commands may be disabled |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3056 |
continue |
356
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
355
diff
changeset
|
3057 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
3058 |
entry = cmdutil.findcmd('commit', commands.table)[1] |
303 | 3059 |
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
|
3060 |
_("make commit obsolete this revision (DEPRECATED)"))) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
3061 |
entry = cmdutil.findcmd('graft', commands.table)[1] |
303 | 3062 |
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
|
3063 |
_("make graft obsoletes this revision (DEPRECATED)"))) |
303 | 3064 |
entry[1].append(('O', 'old-obsolete', False, |
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
|
3065 |
_("make graft obsoletes its source (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
|
3066 |
|
1302
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3067 |
@eh.wrapfunction(obsolete, '_checkinvalidmarkers') |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3068 |
def _checkinvalidmarkers(orig, markers): |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3069 |
"""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
|
3070 |
|
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3071 |
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
|
3072 |
subtle handling. |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3073 |
""" |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3074 |
if 'debugobsconvert' in sys.argv: |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3075 |
return |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3076 |
for mark in markers: |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3077 |
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
|
3078 |
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
|
3079 |
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
|
3080 |
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
|
3081 |
|
2043
c64300906a32
exthelper: move command declaration into the exthelper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2041
diff
changeset
|
3082 |
@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
|
3083 |
'debugobsconvert', |
2053
f3765c4a352a
exchange: rename the module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2051
diff
changeset
|
3084 |
[('', '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
|
3085 |
'') |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3086 |
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
|
3087 |
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
|
3088 |
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
|
3089 |
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
|
3090 |
raise error.Abort(msg) |
1465
777e5c369d99
compat: use svfs instead of sopener
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1464
diff
changeset
|
3091 |
f = repo.svfs('obsstore', 'wb', atomictemp=True) |
1169
6f08a8f6bb1d
debugobsconvert: also deduplicate markers in the process
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
3092 |
known = set() |
6f08a8f6bb1d
debugobsconvert: also deduplicate markers in the process
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
3093 |
markers = [] |
1172
8d28bb4fc127
debugobsconvert: fix 6f08a8f6bb1d and add proper test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1171
diff
changeset
|
3094 |
for m in origmarkers: |
1202
4099b087f672
evolve: handle invalid obsmarkers in the `debugobsconvert`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1198
diff
changeset
|
3095 |
# filter out invalid markers |
4099b087f672
evolve: handle invalid obsmarkers in the `debugobsconvert`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1198
diff
changeset
|
3096 |
if nullid in m[1]: |
4099b087f672
evolve: handle invalid obsmarkers in the `debugobsconvert`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1198
diff
changeset
|
3097 |
m = list(m) |
4099b087f672
evolve: handle invalid obsmarkers in the `debugobsconvert`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1198
diff
changeset
|
3098 |
m[1] = tuple(s for s in m[1] if s != nullid) |
4099b087f672
evolve: handle invalid obsmarkers in the `debugobsconvert`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1198
diff
changeset
|
3099 |
m = tuple(m) |
1169
6f08a8f6bb1d
debugobsconvert: also deduplicate markers in the process
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
3100 |
if m in known: |
6f08a8f6bb1d
debugobsconvert: also deduplicate markers in the process
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
3101 |
continue |
1172
8d28bb4fc127
debugobsconvert: fix 6f08a8f6bb1d and add proper test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1171
diff
changeset
|
3102 |
known.add(m) |
1169
6f08a8f6bb1d
debugobsconvert: also deduplicate markers in the process
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
3103 |
markers.append(m) |
1170
4697f23e0ede
debugobsconvert: fix a typo on "version"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1169
diff
changeset
|
3104 |
ui.write(_('Old store is version %d, will rewrite in version %d\n') % ( |
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3105 |
repo.obsstore._version, new_format)) |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3106 |
map(f.write, obsolete.encodemarkers(markers, True, new_format)) |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3107 |
f.close() |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3108 |
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
|
3109 |
|
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3110 |
|
1827
15ec53d46f44
compat: drop handling of ancestral 'helploader' caller
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1826
diff
changeset
|
3111 |
def _helploader(ui): |
1414
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3112 |
return help.gettext(evolutionhelptext) |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3113 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3114 |
@eh.uisetup |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3115 |
def _setuphelp(ui): |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3116 |
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
|
3117 |
if entry[0] == "evolution": |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3118 |
break |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3119 |
else: |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3120 |
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
|
3121 |
_helploader)) |
1414
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3122 |
help.helptable.sort() |
1567
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3123 |
|
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3124 |
def _relocatecommit(repo, orig, commitmsg): |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3125 |
if commitmsg is None: |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3126 |
commitmsg = orig.description() |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3127 |
extra = dict(orig.extra()) |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3128 |
if 'branch' in extra: |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3129 |
del extra['branch'] |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3130 |
extra['rebase_source'] = orig.hex() |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3131 |
|
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3132 |
backup = repo.ui.backupconfig('phases', 'new-commit') |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3133 |
try: |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3134 |
targetphase = max(orig.phase(), phases.draft) |
1636
13f830540a14
config: report evolve as origin for config
timeless@gmail.com
parents:
1635
diff
changeset
|
3135 |
repo.ui.setconfig('phases', 'new-commit', targetphase, 'evolve') |
1567
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3136 |
# Commit might fail if unresolved files exist |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3137 |
nodenew = repo.commit(text=commitmsg, user=orig.user(), |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3138 |
date=orig.date(), extra=extra) |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3139 |
finally: |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3140 |
repo.ui.restoreconfig(backup) |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3141 |
return nodenew |
1568
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3142 |
|
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3143 |
def _finalizerelocate(repo, orig, dest, nodenew, tr): |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3144 |
destbookmarks = repo.nodebookmarks(dest.node()) |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3145 |
nodesrc = orig.node() |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3146 |
destphase = repo[nodesrc].phase() |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3147 |
oldbookmarks = repo.nodebookmarks(nodesrc) |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3148 |
if nodenew is not None: |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3149 |
phases.retractboundary(repo, tr, destphase, [nodenew]) |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3150 |
obsolete.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))]) |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3151 |
for book in oldbookmarks: |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3152 |
repo._bookmarks[book] = nodenew |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3153 |
else: |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3154 |
obsolete.createmarkers(repo, [(repo[nodesrc], ())]) |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3155 |
# Behave like rebase, move bookmarks to dest |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3156 |
for book in oldbookmarks: |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3157 |
repo._bookmarks[book] = dest.node() |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3158 |
for book in destbookmarks: # restore bookmark that rebase move |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3159 |
repo._bookmarks[book] = dest.node() |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3160 |
if oldbookmarks or destbookmarks: |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
3161 |
repo._bookmarks.recordchange(tr) |
1592
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
3162 |
|
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3163 |
evolvestateversion = 0 |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3164 |
|
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3165 |
@eh.uisetup |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3166 |
def setupevolveunfinished(ui): |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3167 |
data = ('evolvestate', True, 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
|
3168 |
_("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
|
3169 |
cmdutil.unfinishedstates.append(data) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3170 |
|
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3171 |
@eh.wrapfunction(hg, 'clean') |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3172 |
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
|
3173 |
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
|
3174 |
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
|
3175 |
return ret |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3176 |
|
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3177 |
def _evolvestatewrite(repo, state): |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3178 |
# [version] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3179 |
# [type][length][content] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3180 |
# |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3181 |
# `version` is a 4 bytes integer (handled at higher level) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3182 |
# `type` is a single character, `length` is a 4 byte integer, and |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3183 |
# `content` is an arbitrary byte sequence of length `length`. |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3184 |
f = repo.vfs('evolvestate', 'w') |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3185 |
try: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3186 |
f.write(_pack('>I', evolvestateversion)) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3187 |
current = state['current'] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3188 |
key = 'C' # as in 'current' |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3189 |
format = '>sI%is' % len(current) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3190 |
f.write(_pack(format, key, len(current), current)) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3191 |
finally: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3192 |
f.close() |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3193 |
|
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3194 |
def _evolvestateread(repo): |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3195 |
try: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3196 |
f = repo.vfs('evolvestate') |
1679
6103f6ac8110
py3: change except from two comma to as notation
timeless@gmail.com
parents:
1678
diff
changeset
|
3197 |
except IOError as err: |
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3198 |
if err.errno != errno.ENOENT: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3199 |
raise |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3200 |
return None |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3201 |
try: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3202 |
versionblob = f.read(4) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3203 |
if len(versionblob) < 4: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3204 |
repo.ui.debug('ignoring corrupted evolvestte (file contains %i bits)' |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3205 |
% len(versionblob)) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3206 |
return None |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3207 |
version = _unpack('>I', versionblob)[0] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3208 |
if version != evolvestateversion: |
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
|
3209 |
msg = _('unknown evolvestate version %i') % version |
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
|
3210 |
raise error.Abort(msg, hint=_('upgrade your evolve')) |
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3211 |
records = [] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3212 |
data = f.read() |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3213 |
off = 0 |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3214 |
end = len(data) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3215 |
while off < end: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3216 |
rtype = data[off] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3217 |
off += 1 |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3218 |
length = _unpack('>I', data[off:(off + 4)])[0] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3219 |
off += 4 |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3220 |
record = data[off:(off + length)] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3221 |
off += length |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3222 |
if rtype == 't': |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3223 |
rtype, record = record[0], record[1:] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3224 |
records.append((rtype, record)) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3225 |
state = {} |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3226 |
for rtype, rdata in records: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3227 |
if rtype == 'C': |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3228 |
state['current'] = rdata |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3229 |
elif rtype.lower(): |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3230 |
repo.ui.debug('ignore evolve state record type %s' % rtype) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3231 |
else: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3232 |
raise error.Abort(_('unknown evolvestate field type %r') |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3233 |
% rtype, hint=_('upgrade your evolve')) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3234 |
return state |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3235 |
finally: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3236 |
f.close() |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3237 |
|
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
3238 |
def _evolvestatedelete(repo): |
2070
9105c3c54045
cleanup: stop using 'repo.join' methods
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2064
diff
changeset
|
3239 |
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
|
3240 |
|
1592
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
3241 |
def _evolvemerge(repo, orig, dest, pctx, keepbranch): |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
3242 |
"""Used by the evolve function to merge dest on top of pctx. |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
3243 |
return the same tuple as merge.graft""" |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
3244 |
if repo['.'].rev() != dest.rev(): |
1831
0195dc7bdfa4
compat: drop compatibility layer around update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1830
diff
changeset
|
3245 |
merge.update(repo, |
0195dc7bdfa4
compat: drop compatibility layer around update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1830
diff
changeset
|
3246 |
dest, |
0195dc7bdfa4
compat: drop compatibility layer around update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1830
diff
changeset
|
3247 |
branchmerge=False, |
0195dc7bdfa4
compat: drop compatibility layer around update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1830
diff
changeset
|
3248 |
force=True) |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
3249 |
if repo._activebookmark: |
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
|
3250 |
repo.ui.status(_("(leaving bookmark %s)\n") % repo._activebookmark) |
1835
93d4661a6ee7
compat: drop bookmark compatibility layer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1834
diff
changeset
|
3251 |
bookmarksmod.deactivate(repo) |
1592
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
3252 |
if keepbranch: |
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
|
3253 |
repo.dirstate.setbranch(orig.branch()) |
1627
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
3254 |
if util.safehasattr(repo, 'currenttopic'): |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
3255 |
# uurrgs |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
3256 |
# there no other topic setter yet |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
3257 |
if not orig.topic() and repo.vfs.exists('topic'): |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
3258 |
repo.vfs.unlink('topic') |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
3259 |
else: |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
3260 |
with repo.vfs.open('topic', 'w') as f: |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
3261 |
f.write(orig.topic()) |
1592
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
3262 |
|
1826
19df96c0d670
compat: drop hack around a 'graft' signature change
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1825
diff
changeset
|
3263 |
return merge.graft(repo, orig, pctx, ['local', 'graft'], True) |
2336
93a37e13424f
obshistory: add a debugobshistory command to show obs history of a revs
Boris Feld <boris.feld@octobus.net>
parents:
2311
diff
changeset
|
3264 |
|
93a37e13424f
obshistory: add a debugobshistory command to show obs history of a revs
Boris Feld <boris.feld@octobus.net>
parents:
2311
diff
changeset
|
3265 |
@eh.command( |
93a37e13424f
obshistory: add a debugobshistory command to show obs history of a revs
Boris Feld <boris.feld@octobus.net>
parents:
2311
diff
changeset
|
3266 |
'^debugobshistory', |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2405
diff
changeset
|
3267 |
[('G', 'graph', True, _("show the revision DAG")), |
2414
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3268 |
('r', 'rev', [], _('show the specified revision or revset'), _('REV')) |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2405
diff
changeset
|
3269 |
] + commands.formatteropts, |
2342
e28026b4d3c1
obshistory: use formatter instead of ui.write in the debugobshistory command
Boris Feld <boris.feld@octobus.net>
parents:
2337
diff
changeset
|
3270 |
_('hg debugobshistory [OPTION]... [REV]')) |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2396
diff
changeset
|
3271 |
def cmdobshistory(ui, repo, *revs, **opts): |
2414
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3272 |
"""show the obsolescence history of the specified revisions. |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3273 |
|
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3274 |
By default this command prints the selected revisions and all its |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3275 |
precursors. For precursors pointing on existing revisions in the repository, |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3276 |
it will display revisions node id, revision number and the first line of the |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3277 |
description. For precursors pointing on non existing revisions in the |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3278 |
repository (that can happen when exchanging obsolescence-markers), display |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3279 |
only the node id. |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3280 |
|
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3281 |
In both case, for each node, its obsolescence marker will be displayed with |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3282 |
the obsolescence operation (rewritten or pruned) in addition of the user and |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3283 |
date of the operation. |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3284 |
|
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3285 |
The output is a graph by default but can deactivated with the option '--no- |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3286 |
graph'. |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3287 |
|
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3288 |
'o' is a changeset, '@' is a working directory parent, 'x' is obsolete, |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3289 |
and '+' represents a fork where the changeset from the lines below is a |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3290 |
parent of the 'o' merge on the same line. |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3291 |
|
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3292 |
Paths in the DAG are represented with '|', '/' and so forth. |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3293 |
|
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3294 |
Returns 0 on success. |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3295 |
""" |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3296 |
revs = list(revs) + opts['rev'] |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3297 |
if not revs: |
fcf54ec1eaf7
obshistory: add docstring to cmddebugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2407
diff
changeset
|
3298 |
revs = ['.'] |
2336
93a37e13424f
obshistory: add a debugobshistory command to show obs history of a revs
Boris Feld <boris.feld@octobus.net>
parents:
2311
diff
changeset
|
3299 |
revs = scmutil.revrange(repo, revs) |
2407
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2405
diff
changeset
|
3300 |
|
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2405
diff
changeset
|
3301 |
if opts['graph']: |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2405
diff
changeset
|
3302 |
return obshistory._debugobshistorygraph(ui, repo, revs, opts) |
783a74c60a5e
obshistory: add a graph option on the debugobshistory command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2405
diff
changeset
|
3303 |
|
2342
e28026b4d3c1
obshistory: use formatter instead of ui.write in the debugobshistory command
Boris Feld <boris.feld@octobus.net>
parents:
2337
diff
changeset
|
3304 |
fm = ui.formatter('debugobshistory', opts) |
2350
ea816b5c1cf6
obshistory: only display each revision once in debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2349
diff
changeset
|
3305 |
revs.reverse() |
2403
1b348702d79e
obshistory: refactor debugobshistory
Boris Feld <boris.feld@octobus.net>
parents:
2396
diff
changeset
|
3306 |
obshistory._debugobshistorysingle(fm, repo, revs) |
2342
e28026b4d3c1
obshistory: use formatter instead of ui.write in the debugobshistory command
Boris Feld <boris.feld@octobus.net>
parents:
2337
diff
changeset
|
3307 |
|
e28026b4d3c1
obshistory: use formatter instead of ui.write in the debugobshistory command
Boris Feld <boris.feld@octobus.net>
parents:
2337
diff
changeset
|
3308 |
fm.end() |