author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
Sat, 10 Sep 2016 13:26:19 +0200 | |
changeset 1733 | 060fe417679f |
parent 1732 | f4047fba5e90 |
child 1736 | c9a79b432907 |
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. |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
8 |
|
893
12ed6dfa8eea
evolve: downcase first word in module doc
Olle Lundberg <geek@nerd.sh>
parents:
892
diff
changeset
|
9 |
'''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
|
10 |
|
540
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
11 |
This extension provides several commands to mutate history and deal with |
1666 | 12 |
resulting issues. |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
13 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
14 |
It also: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
15 |
|
1669 | 16 |
- enables the "Changeset Obsolescence" feature of Mercurial, |
540
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
17 |
- alters core commands and extensions that rewrite history to use |
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
18 |
this feature, |
1011
0b44ae30cf3b
evolve: drop reference to 2.3 in the extension help text
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
973
diff
changeset
|
19 |
- improves some aspect of the early implementation in Mercurial core |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
20 |
''' |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
21 |
|
1717
2ad40d972a74
prepare release 5.4.1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1713
diff
changeset
|
22 |
__version__ = '5.4.1' |
2ad40d972a74
prepare release 5.4.1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1713
diff
changeset
|
23 |
testedwith = '3.4.3 3.5.2 3.6.2 3.7.3 3.8.1 3.9' |
1726
192cdab2884e
evolve: update buglink to point to bz.mercurial-scm.org
Anton Shestakov <av6@dwimlabs.net>
parents:
1722
diff
changeset
|
24 |
buglink = 'https://bz.mercurial-scm.org/' |
584
af3b0d696e7f
evolve: add tested with info
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
577
diff
changeset
|
25 |
|
1414
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
26 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
27 |
evolutionhelptext = """ |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
28 |
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
|
29 |
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
|
30 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
31 |
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
|
32 |
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
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
: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
|
37 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
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
|
44 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
of history concurrently. |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
50 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
51 |
Current feature status |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
52 |
====================== |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
53 |
|
1710 | 54 |
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
|
55 |
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
|
56 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
57 |
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
|
58 |
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
|
59 |
via an extension).""".strip() |
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 |
|
1104
cb36a4eb0157
evolve: fix the 'grab' alias to work on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
1101
diff
changeset
|
62 |
import sys, os |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
63 |
import random |
1678 | 64 |
try: |
65 |
import StringIO as io |
|
66 |
StringIO = io.StringIO |
|
67 |
except ImportError: |
|
68 |
import io |
|
69 |
StringIO = io.StringIO |
|
1106
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
70 |
import re |
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
71 |
import collections |
1309
b621e5da03e1
evolve: add missing import
Laurent Charignon <lcharignon@fb.com>
parents:
1308
diff
changeset
|
72 |
import socket |
b621e5da03e1
evolve: add missing import
Laurent Charignon <lcharignon@fb.com>
parents:
1308
diff
changeset
|
73 |
import errno |
1713
00612a019547
evolve: use hashlib to compute sha1 hashes
Jeroen Vaelen <jeroen@fb.com>
parents:
1710
diff
changeset
|
74 |
import hashlib |
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
75 |
import struct |
1106
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
76 |
sha1re = re.compile(r'\b[0-9a-f]{6,40}\b') |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
77 |
|
670
97ce1f801309
evolve: drop unused import
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
663
diff
changeset
|
78 |
import mercurial |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
79 |
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
|
80 |
from mercurial import repair |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
81 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
82 |
try: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
83 |
from mercurial import obsolete |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
84 |
if not obsolete._enabled: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
85 |
obsolete._enabled = True |
952
f83f46411b09
evolve: bump requirement to 3.0.1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
950
diff
changeset
|
86 |
from mercurial import wireproto |
f83f46411b09
evolve: bump requirement to 3.0.1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
950
diff
changeset
|
87 |
gboptslist = getattr(wireproto, 'gboptslist', None) |
955
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
88 |
gboptsmap = getattr(wireproto, 'gboptsmap', None) |
591
012e48e80840
evolve: require Mercurial 2.4 to work
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
590
diff
changeset
|
89 |
except (ImportError, AttributeError): |
955
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
90 |
gboptslist = gboptsmap = None |
617
469befc27b26
detect incompatibility with future mercurial 2.5
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
616
diff
changeset
|
91 |
|
1226
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
92 |
# Flags for enabling optional parts of evolve |
1227
3d9c5f5df6d8
evolve: change config option name
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1226
diff
changeset
|
93 |
commandopt = 'allnewcommands' |
585
f013ca072bd9
evolve: detect and abort if 2.4 is detected
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
584
diff
changeset
|
94 |
|
1561
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
95 |
from mercurial import bookmarks as bookmarksmod |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
96 |
from mercurial import cmdutil |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
97 |
from mercurial import commands |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
98 |
from mercurial import context |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
99 |
from mercurial import copies |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
100 |
from mercurial import error |
817
c2bf0eb727f1
exchange: only push the set of marker relevant to want we push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
816
diff
changeset
|
101 |
from mercurial import exchange |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
102 |
from mercurial import extensions |
1414
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
103 |
from mercurial import help |
880
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
104 |
from mercurial import httppeer |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
105 |
from mercurial import hg |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
106 |
from mercurial import lock as lockmod |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
107 |
from mercurial import merge |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
108 |
from mercurial import node |
113
3bdabdbb4140
adapt evolution to phase in core.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
108
diff
changeset
|
109 |
from mercurial import phases |
930
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
927
diff
changeset
|
110 |
from mercurial import patch |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
111 |
from mercurial import revset |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
112 |
from mercurial import scmutil |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
113 |
from mercurial import templatekw |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
114 |
from mercurial.i18n import _ |
986
c1f8ece4182d
evolve: add --tool option so we don't have to use HGMERGE
Greg Ward <greg@gerg.ca>
parents:
985
diff
changeset
|
115 |
from mercurial.commands import walkopts, commitopts, commitopts2, mergetoolopts |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
116 |
from mercurial.node import nullid |
820
a9a66143e2ec
exchange: actually use _pushkeyescape fallback
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
819
diff
changeset
|
117 |
from mercurial import wireproto |
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
118 |
from mercurial import localrepo |
869
e9eeef0d07ec
exchange: enforce permission on new wireprotocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
868
diff
changeset
|
119 |
from mercurial.hgweb import hgweb_mod |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
120 |
|
1067
5d063fed9e3d
evolve: yield to relevant markers handling in core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1063
diff
changeset
|
121 |
cmdtable = {} |
5d063fed9e3d
evolve: yield to relevant markers handling in core
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1063
diff
changeset
|
122 |
command = cmdutil.command(cmdtable) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
123 |
|
820
a9a66143e2ec
exchange: actually use _pushkeyescape fallback
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
819
diff
changeset
|
124 |
_pack = struct.pack |
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
125 |
_unpack = struct.unpack |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
126 |
|
955
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
127 |
if gboptsmap is not None: |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
128 |
memfilectx = context.memfilectx |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
129 |
elif gboptslist is not None: |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
130 |
oldmemfilectx = context.memfilectx |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
131 |
def memfilectx(repo, *args, **kwargs): |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
132 |
return oldmemfilectx(*args, **kwargs) |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
133 |
else: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
134 |
raise ImportError('evolve needs version %s or above' % |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
135 |
min(testedwith.split())) |
955
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
136 |
|
1296
23819e1d61fd
evolve: add -i flag to amend command
Laurent Charignon <lcharignon@fb.com>
parents:
1281
diff
changeset
|
137 |
aliases, entry = cmdutil.findcmd('commit', commands.table) |
1340
f455ce2a3587
evolve: migrate off of now-dead util.any
Augie Fackler <raf@durin42.com>
parents:
1335
diff
changeset
|
138 |
hasinteractivemode = any(['interactive' in e for e in entry[1]]) |
1296
23819e1d61fd
evolve: add -i flag to amend command
Laurent Charignon <lcharignon@fb.com>
parents:
1281
diff
changeset
|
139 |
if hasinteractivemode: |
23819e1d61fd
evolve: add -i flag to amend command
Laurent Charignon <lcharignon@fb.com>
parents:
1281
diff
changeset
|
140 |
interactiveopt = [['i', 'interactive', None, _('use interactive mode')]] |
23819e1d61fd
evolve: add -i flag to amend command
Laurent Charignon <lcharignon@fb.com>
parents:
1281
diff
changeset
|
141 |
else: |
23819e1d61fd
evolve: add -i flag to amend command
Laurent Charignon <lcharignon@fb.com>
parents:
1281
diff
changeset
|
142 |
interactiveopt = [] |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
143 |
# This extension contains the following code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
144 |
# |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
145 |
# - Extension Helper code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
146 |
# - Obsolescence cache |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
147 |
# - ... |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
148 |
# - Older format compat |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
149 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
150 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
151 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
152 |
### Extension helper ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
153 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
154 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
155 |
class exthelper(object): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
156 |
"""Helper for modular extension setup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
157 |
|
1569
bd1468c23d88
evolve: scattered typo fixes in comments, docstrings
Greg Ward <greg@gerg.ca>
parents:
1528
diff
changeset
|
158 |
A single helper should be instantiated for each extension. Helper |
bd1468c23d88
evolve: scattered typo fixes in comments, docstrings
Greg Ward <greg@gerg.ca>
parents:
1528
diff
changeset
|
159 |
methods are then used as decorators for various purpose. |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
160 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
161 |
All decorators return the original function and may be chained. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
162 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
163 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
164 |
def __init__(self): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
165 |
self._uicallables = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
166 |
self._extcallables = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
167 |
self._repocallables = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
168 |
self._revsetsymbols = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
169 |
self._templatekws = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
170 |
self._commandwrappers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
171 |
self._extcommandwrappers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
172 |
self._functionwrappers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
173 |
self._duckpunchers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
174 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
175 |
def final_uisetup(self, ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
176 |
"""Method to be used as the extension uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
177 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
178 |
The following operations belong here: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
179 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
180 |
- Changes to ui.__class__ . The ui object that will be used to run the |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
181 |
command has not yet been created. Changes made here will affect ui |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
182 |
objects created after this, and in particular the ui that will be |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
183 |
passed to runcommand |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
184 |
- Command wraps (extensions.wrapcommand) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
185 |
- Changes that need to be visible to other extensions: because |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
186 |
initialization occurs in phases (all extensions run uisetup, then all |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
187 |
run extsetup), a change made here will be visible to other extensions |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
188 |
during extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
189 |
- Monkeypatch or wrap function (extensions.wrapfunction) of dispatch |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
190 |
module members |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
191 |
- Setup of pre-* and post-* hooks |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
192 |
- pushkey setup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
193 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
194 |
for cont, funcname, func in self._duckpunchers: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
195 |
setattr(cont, funcname, func) |
1218
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
196 |
for command, wrapper, opts in self._commandwrappers: |
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
197 |
entry = extensions.wrapcommand(commands.table, command, wrapper) |
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
198 |
if opts: |
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
199 |
for short, long, val, msg in opts: |
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
200 |
entry[1].append((short, long, val, msg)) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
201 |
for cont, funcname, wrapper in self._functionwrappers: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
202 |
extensions.wrapfunction(cont, funcname, wrapper) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
203 |
for c in self._uicallables: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
204 |
c(ui) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
205 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
206 |
def final_extsetup(self, ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
207 |
"""Method to be used as a the extension extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
208 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
209 |
The following operations belong here: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
210 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
211 |
- Changes depending on the status of other extensions. (if |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
212 |
extensions.find('mq')) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
213 |
- Add a global option to all commands |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
214 |
- Register revset functions |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
215 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
216 |
knownexts = {} |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
217 |
for name, symbol in self._revsetsymbols: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
218 |
revset.symbols[name] = symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
219 |
for name, kw in self._templatekws: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
220 |
templatekw.keywords[name] = kw |
1218
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
221 |
for ext, command, wrapper, opts in self._extcommandwrappers: |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
222 |
if ext not in knownexts: |
1219
658b0d032699
wrapcommand: fix wrapping extensions that aren't enabled
Durham Goode <durham@fb.com>
parents:
1218
diff
changeset
|
223 |
try: |
658b0d032699
wrapcommand: fix wrapping extensions that aren't enabled
Durham Goode <durham@fb.com>
parents:
1218
diff
changeset
|
224 |
e = extensions.find(ext) |
658b0d032699
wrapcommand: fix wrapping extensions that aren't enabled
Durham Goode <durham@fb.com>
parents:
1218
diff
changeset
|
225 |
except KeyError: |
658b0d032699
wrapcommand: fix wrapping extensions that aren't enabled
Durham Goode <durham@fb.com>
parents:
1218
diff
changeset
|
226 |
# Extension isn't enabled, so don't bother trying to wrap |
658b0d032699
wrapcommand: fix wrapping extensions that aren't enabled
Durham Goode <durham@fb.com>
parents:
1218
diff
changeset
|
227 |
# it. |
658b0d032699
wrapcommand: fix wrapping extensions that aren't enabled
Durham Goode <durham@fb.com>
parents:
1218
diff
changeset
|
228 |
continue |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
229 |
knownexts[ext] = e.cmdtable |
1218
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
230 |
entry = extensions.wrapcommand(knownexts[ext], command, wrapper) |
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
231 |
if opts: |
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
232 |
for short, long, val, msg in opts: |
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
233 |
entry[1].append((short, long, val, msg)) |
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
234 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
235 |
for c in self._extcallables: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
236 |
c(ui) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
237 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
238 |
def final_reposetup(self, ui, repo): |
1667 | 239 |
"""Method to be used as the extension reposetup |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
240 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
241 |
The following operations belong here: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
242 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
243 |
- All hooks but pre-* and post-* |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
244 |
- Modify configuration variables |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
245 |
- Changes to repo.__class__, repo.dirstate.__class__ |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
246 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
247 |
for c in self._repocallables: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
248 |
c(ui, repo) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
249 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
250 |
def uisetup(self, call): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
251 |
"""Decorated function will be executed during uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
252 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
253 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
254 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
255 |
@eh.uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
256 |
def setupbabar(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
257 |
print 'this is uisetup!' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
258 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
259 |
self._uicallables.append(call) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
260 |
return call |
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 |
def extsetup(self, call): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
263 |
"""Decorated function will be executed during extsetup |
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 |
example:: |
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 |
@eh.extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
268 |
def setupcelestine(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
269 |
print 'this is extsetup!' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
270 |
""" |
672
f7834b360f8f
evolve: fix extsetup extension helper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
671
diff
changeset
|
271 |
self._extcallables.append(call) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
272 |
return call |
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 |
def reposetup(self, call): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
275 |
"""Decorated function will be executed during reposetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
276 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
277 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
278 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
279 |
@eh.reposetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
280 |
def setupzephir(ui, repo): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
281 |
print 'this is reposetup!' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
282 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
283 |
self._repocallables.append(call) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
284 |
return call |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
285 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
286 |
def revset(self, symbolname): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
287 |
"""Decorated function is a revset symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
288 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
289 |
The name of the symbol must be given as the decorator argument. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
290 |
The symbol is added during `extsetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
291 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
292 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
293 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
294 |
@eh.revset('hidden') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
295 |
def revsetbabar(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
296 |
args = revset.getargs(x, 0, 0, 'babar accept no argument') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
297 |
return [r for r in subset if 'babar' in repo[r].description()] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
298 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
299 |
def dec(symbol): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
300 |
self._revsetsymbols.append((symbolname, symbol)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
301 |
return symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
302 |
return dec |
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 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
305 |
def templatekw(self, keywordname): |
1376
8bb2e04cc18c
evolve: fix the template keyworkd decorator docstring
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1375
diff
changeset
|
306 |
"""Decorated function is a template keyword |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
307 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
308 |
The name of the keyword must be given as the decorator argument. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
309 |
The symbol is added during `extsetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
310 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
311 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
312 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
313 |
@eh.templatekw('babar') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
314 |
def kwbabar(ctx): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
315 |
return 'babar' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
316 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
317 |
def dec(keyword): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
318 |
self._templatekws.append((keywordname, keyword)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
319 |
return keyword |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
320 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
321 |
|
1218
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
322 |
def wrapcommand(self, command, extension=None, opts=[]): |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
323 |
"""Decorated function is a command wrapper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
324 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
325 |
The name of the command must be given as the decorator argument. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
326 |
The wrapping is installed during `uisetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
327 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
328 |
If the second option `extension` argument is provided, the wrapping |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
329 |
will be applied in the extension commandtable. This argument must be a |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
330 |
string that will be searched using `extension.find` if not found and |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
331 |
Abort error is raised. If the wrapping applies to an extension, it is |
1668
d158ba628e2a
Grammar: paragraphs should end with periods
timeless@gmail.com
parents:
1667
diff
changeset
|
332 |
installed during `extsetup`. |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
333 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
334 |
example:: |
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 |
@eh.wrapcommand('summary') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
337 |
def wrapsummary(orig, ui, repo, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
338 |
ui.note('Barry!') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
339 |
return orig(ui, repo, *args, **kwargs) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
340 |
|
1218
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
341 |
The `opts` argument allows specifying additional arguments for the |
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
342 |
command. |
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
343 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
344 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
345 |
def dec(wrapper): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
346 |
if extension is None: |
1218
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
347 |
self._commandwrappers.append((command, wrapper, opts)) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
348 |
else: |
1218
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
349 |
self._extcommandwrappers.append((extension, command, wrapper, |
dd5e62979100
wrapcommand: allow adding additional arguments to commands
Durham Goode <durham@fb.com>
parents:
1214
diff
changeset
|
350 |
opts)) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
351 |
return wrapper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
352 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
353 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
354 |
def wrapfunction(self, container, funcname): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
355 |
"""Decorated function is a function wrapper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
356 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
357 |
This function takes two arguments, the container and the name of the |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
358 |
function to wrap. The wrapping is performed during `uisetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
359 |
(there is no extension support) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
360 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
361 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
362 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
363 |
@eh.function(discovery, 'checkheads') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
364 |
def wrapfunction(orig, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
365 |
ui.note('His head smashed in and his heart cut out') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
366 |
return orig(*args, **kwargs) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
367 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
368 |
def dec(wrapper): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
369 |
self._functionwrappers.append((container, funcname, wrapper)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
370 |
return wrapper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
371 |
return dec |
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 addattr(self, container, funcname): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
374 |
"""Decorated function is to be added to the container |
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 |
This function takes two arguments, the container and the name of the |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
377 |
function to wrap. The wrapping is performed during `uisetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
378 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
379 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
380 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
381 |
@eh.function(context.changectx, 'babar') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
382 |
def babar(ctx): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
383 |
return 'babar' in ctx.description |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
384 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
385 |
def dec(func): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
386 |
self._duckpunchers.append((container, funcname, func)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
387 |
return func |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
388 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
389 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
390 |
eh = exthelper() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
391 |
uisetup = eh.final_uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
392 |
extsetup = eh.final_extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
393 |
reposetup = eh.final_reposetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
394 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
395 |
##################################################################### |
1213
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
396 |
### Option configuration ### |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
397 |
##################################################################### |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
398 |
|
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
399 |
@eh.reposetup # must be the first of its kin. |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
400 |
def _configureoptions(ui, repo): |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
401 |
# If no capabilities are specified, enable everything. |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
402 |
# 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
|
403 |
evolveopts = ui.configlist('experimental', 'evolution') |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
404 |
if not evolveopts: |
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
405 |
evolveopts = ['all'] |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
406 |
ui.setconfig('experimental', 'evolution', evolveopts, 'evolve') |
1213
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
407 |
|
1226
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
408 |
@eh.uisetup |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
409 |
def _configurecmdoptions(ui): |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
410 |
# Unregister evolve commands if the command capability is not specified. |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
411 |
# |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
412 |
# 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
|
413 |
# guarantee it happens after the above configuration, but before the |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
414 |
# extsetup functions. |
1441
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
415 |
evolvecommands = ui.configlist('experimental', 'evolutioncommands') |
1226
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
416 |
evolveopts = ui.configlist('experimental', 'evolution') |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
417 |
if evolveopts and (commandopt not in evolveopts and |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
418 |
'all' not in evolveopts): |
1441
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
419 |
# 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
|
420 |
whitelist = set() |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
421 |
for cmd in evolvecommands: |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
422 |
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
|
423 |
if not matchingevolvecommands: |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
424 |
raise error.Abort(_('unknown command: %s') % cmd) |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
425 |
elif len(matchingevolvecommands) > 1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
426 |
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
|
427 |
raise error.Abort(msg % (cmd, matchingevolvecommands)) |
1441
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
428 |
else: |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
429 |
whitelist.add(matchingevolvecommands[0]) |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
430 |
for disabledcmd in set(cmdtable) - whitelist: |
a4abe588d77f
evolve: mechanism to load some commands selectively
Laurent Charignon <lcharignon@fb.com>
parents:
1440
diff
changeset
|
431 |
del cmdtable[disabledcmd] |
1213
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
432 |
|
7118996bdf43
config: enable all obsolete options
Durham Goode <durham@fb.com>
parents:
1212
diff
changeset
|
433 |
##################################################################### |
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
|
434 |
### 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
|
435 |
##################################################################### |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
436 |
|
976
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
437 |
commitopts3 = [ |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
438 |
('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
|
439 |
_('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
|
440 |
('U', 'current-user', None, |
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
441 |
_('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
|
442 |
] |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
443 |
|
985
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
444 |
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
|
445 |
"""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
|
446 |
|
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
447 |
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
|
448 |
-d was supplied. |
577
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
449 |
""" |
976
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
450 |
# 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
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
opts['user'] = ui.username() |
577
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
455 |
|
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
456 |
getrevs = obsolete.getrevs |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
457 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
458 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
459 |
### Additional Utilities ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
460 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
461 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
462 |
# 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
|
463 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
464 |
# - Function to create markers |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
465 |
# - 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
|
466 |
# - "troubles" method on changectx |
1661 | 467 |
# - 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
|
468 |
# - function to find useful changeset to stabilize |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
469 |
|
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 |
### Useful alias |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
472 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
473 |
@eh.uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
474 |
def _installalias(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
475 |
if ui.config('alias', 'pstatus', None) is None: |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
476 |
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
|
477 |
if ui.config('alias', 'pdiff', None) is None: |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
478 |
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
|
479 |
if ui.config('alias', 'olog', None) is None: |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
480 |
ui.setconfig('alias', 'olog', "log -r 'precursors(.)' --hidden", |
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
481 |
'evolve') |
497
43e1b2cab789
evolve: add the odiff alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
492
diff
changeset
|
482 |
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
|
483 |
ui.setconfig('alias', 'odiff', |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
484 |
"diff --hidden --rev 'limit(precursors(.),1)' --rev .", |
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
485 |
'evolve') |
696
121e2d265e85
alias: add a grab alias
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
695
diff
changeset
|
486 |
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
|
487 |
if os.name == 'nt': |
cb36a4eb0157
evolve: fix the 'grab' alias to work on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
1101
diff
changeset
|
488 |
ui.setconfig('alias', 'grab', |
1109
212f24013455
evolve: really fix the 'grab' alias on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
1106
diff
changeset
|
489 |
"! " + util.hgexecutable() + " rebase --dest . --rev $@ && " |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
490 |
+ util.hgexecutable() + " up tip", |
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
491 |
'evolve') |
1104
cb36a4eb0157
evolve: fix the 'grab' alias to work on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
1101
diff
changeset
|
492 |
else: |
cb36a4eb0157
evolve: fix the 'grab' alias to work on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
1101
diff
changeset
|
493 |
ui.setconfig('alias', 'grab', |
1635
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
494 |
"! $HG rebase --dest . --rev $@ && $HG up tip", |
91ba7e0daff6
alias: report evolve as origin for aliases
timeless@gmail.com
parents:
1634
diff
changeset
|
495 |
'evolve') |
696
121e2d265e85
alias: add a grab alias
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
695
diff
changeset
|
496 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
497 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
498 |
### Troubled revset symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
499 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
500 |
@eh.revset('troubled') |
594 | 501 |
def revsettroubled(repo, subset, x): |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
502 |
"""``troubled()`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
503 |
Changesets with troubles. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
504 |
""" |
993
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
505 |
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
|
506 |
troubled = set() |
61849d45d47e
evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1380
diff
changeset
|
507 |
troubled.update(getrevs(repo, 'unstable')) |
61849d45d47e
evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1380
diff
changeset
|
508 |
troubled.update(getrevs(repo, 'bumped')) |
61849d45d47e
evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1380
diff
changeset
|
509 |
troubled.update(getrevs(repo, 'divergent')) |
61849d45d47e
evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1380
diff
changeset
|
510 |
troubled = revset.baseset(troubled) |
61849d45d47e
evolve: move 'troubled()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1380
diff
changeset
|
511 |
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
|
512 |
return subset & troubled |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
513 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
514 |
### Obsolescence graph |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
515 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
516 |
# 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
|
517 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
518 |
def _precursors(repo, s): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
519 |
"""Precursor of a changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
520 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
521 |
nm = repo.changelog.nodemap |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
522 |
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
|
523 |
node = repo.changelog.node |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
524 |
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
|
525 |
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
|
526 |
pr = nm.get(p[0]) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
527 |
if pr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
528 |
cs.add(pr) |
1383
cf62abb62941
evolve: move 'precursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1382
diff
changeset
|
529 |
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
|
530 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
531 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
532 |
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
|
533 |
"""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
|
534 |
node = repo.changelog.node |
a127f0f3bf5f
evolve: avoid creating changectx object in _allprecursors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1377
diff
changeset
|
535 |
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
|
536 |
seen = set() |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
537 |
allsubjects = repo.obsstore.precursors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
538 |
while toproceed: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
539 |
nc = toproceed.pop() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
540 |
for mark in allsubjects.get(nc, ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
541 |
np = mark[0] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
542 |
if np not in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
543 |
seen.add(np) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
544 |
toproceed.append(np) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
545 |
nm = repo.changelog.nodemap |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
546 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
547 |
for p in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
548 |
pr = nm.get(p) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
549 |
if pr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
550 |
cs.add(pr) |
1384
64c8b8c27811
evolve: move 'allprecursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1383
diff
changeset
|
551 |
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
|
552 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
553 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
554 |
def _successors(repo, s): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
555 |
"""Successors of a changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
556 |
cs = set() |
1379
693cdcd809f2
evolve: avoid creating changectx object in _successors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1378
diff
changeset
|
557 |
node = repo.changelog.node |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
558 |
nm = repo.changelog.nodemap |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
559 |
markerbyobj = repo.obsstore.successors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
560 |
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
|
561 |
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
|
562 |
for sub in p[1]: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
563 |
sr = nm.get(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
564 |
if sr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
565 |
cs.add(sr) |
1385
c2584407afbf
evolve: move 'successors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1384
diff
changeset
|
566 |
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
|
567 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
568 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
569 |
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
|
570 |
"""transitive successors of a subset |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
571 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
572 |
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
|
573 |
marker. """ |
1380
43dcf62237be
evolve: avoid creating changectx object in _allsuccessors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1379
diff
changeset
|
574 |
node = repo.changelog.node |
43dcf62237be
evolve: avoid creating changectx object in _allsuccessors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1379
diff
changeset
|
575 |
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
|
576 |
seen = set() |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
577 |
allobjects = repo.obsstore.successors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
578 |
while toproceed: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
579 |
nc = toproceed.pop() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
580 |
for mark in allobjects.get(nc, ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
581 |
if mark[2] & haltonflags: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
582 |
continue |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
583 |
for sub in mark[1]: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
584 |
if sub == nullid: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
585 |
continue # should not be here! |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
586 |
if sub not in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
587 |
seen.add(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
588 |
toproceed.append(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
589 |
nm = repo.changelog.nodemap |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
590 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
591 |
for s in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
592 |
sr = nm.get(s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
593 |
if sr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
594 |
cs.add(sr) |
1386
b5eaec8a53d0
evolve: move 'allsuccessors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1385
diff
changeset
|
595 |
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
|
596 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
597 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
598 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
599 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
600 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
601 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
602 |
### Extending revset and template ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
603 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
604 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
605 |
# 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
|
606 |
# they are subject to changes |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
607 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
608 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
609 |
### 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
|
610 |
@eh.revset('suspended') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
611 |
def revsetsuspended(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
612 |
"""``suspended()`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
613 |
Obsolete changesets with non-obsolete descendants. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
614 |
""" |
1307
677c5da57b9c
evolve: remove unused variables
Laurent Charignon <lcharignon@fb.com>
parents:
1306
diff
changeset
|
615 |
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
|
616 |
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
|
617 |
suspended.sort() |
c431f827f366
evolve: move 'suspended()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1381
diff
changeset
|
618 |
return subset & suspended |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
619 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
620 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
621 |
@eh.revset('precursors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
622 |
def revsetprecursors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
623 |
"""``precursors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
624 |
Immediate precursors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
625 |
""" |
1204
161b8f6e7402
evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents:
1203
diff
changeset
|
626 |
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
|
627 |
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
|
628 |
s.sort() |
cf62abb62941
evolve: move 'precursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1382
diff
changeset
|
629 |
return subset & s |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
630 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
631 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
632 |
@eh.revset('allprecursors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
633 |
def revsetallprecursors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
634 |
"""``allprecursors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
635 |
Transitive precursors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
636 |
""" |
1204
161b8f6e7402
evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents:
1203
diff
changeset
|
637 |
s = revset.getset(repo, revset.fullreposet(repo), x) |
1384
64c8b8c27811
evolve: move 'allprecursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1383
diff
changeset
|
638 |
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
|
639 |
s.sort() |
64c8b8c27811
evolve: move 'allprecursors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1383
diff
changeset
|
640 |
return subset & s |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
641 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
642 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
643 |
@eh.revset('successors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
644 |
def revsetsuccessors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
645 |
"""``successors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
646 |
Immediate successors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
647 |
""" |
1204
161b8f6e7402
evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents:
1203
diff
changeset
|
648 |
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
|
649 |
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
|
650 |
s.sort() |
c2584407afbf
evolve: move 'successors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1384
diff
changeset
|
651 |
return subset & s |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
652 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
653 |
@eh.revset('allsuccessors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
654 |
def revsetallsuccessors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
655 |
"""``allsuccessors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
656 |
Transitive successors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
657 |
""" |
1204
161b8f6e7402
evolve: use 3.2+ fullreposet to evaluate argument set (issue4515)
Yuya Nishihara <yuya@tcha.org>
parents:
1203
diff
changeset
|
658 |
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
|
659 |
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
|
660 |
s.sort() |
b5eaec8a53d0
evolve: move 'allsuccessors()' to smarted usage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1385
diff
changeset
|
661 |
return subset & s |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
662 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
663 |
### template keywords |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
664 |
# XXX it does not handle troubles well :-/ |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
665 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
666 |
@eh.templatekw('obsolete') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
667 |
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
|
668 |
""":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
|
669 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
670 |
if ctx.obsolete(): |
1732
f4047fba5e90
templates: change {obsolete} to emit only "obsolete" or ""
Martin von Zweigbergk <martinvonz@google.com>
parents:
1729
diff
changeset
|
671 |
return 'obsolete' |
f4047fba5e90
templates: change {obsolete} to emit only "obsolete" or ""
Martin von Zweigbergk <martinvonz@google.com>
parents:
1729
diff
changeset
|
672 |
return '' |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
673 |
|
1399
9ff6d9240f16
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
949
diff
changeset
|
674 |
@eh.templatekw('troubles') |
9ff6d9240f16
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
949
diff
changeset
|
675 |
def showtroubles(repo, ctx, **args): |
9ff6d9240f16
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
949
diff
changeset
|
676 |
""":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
|
677 |
(zero or more of "unstable", "divergent" or "bumped").""" |
9ff6d9240f16
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
949
diff
changeset
|
678 |
return templatekw.showlist('trouble', ctx.troubles(), plural='troubles', |
9ff6d9240f16
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
949
diff
changeset
|
679 |
**args) |
9ff6d9240f16
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
949
diff
changeset
|
680 |
|
491
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 |
### Various trouble warning ### |
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 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
685 |
# 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
|
686 |
|
1527
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
687 |
|
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
688 |
def _warnobsoletewc(ui, repo): |
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
689 |
if repo['.'].obsolete(): |
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
690 |
ui.warn(_('working directory parent is obsolete!\n')) |
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
691 |
if (not ui.quiet) and obsolete.isenabled(repo, commandopt): |
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
692 |
ui.warn(_('(use "hg evolve" to update to its successor)\n')) |
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
693 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
694 |
@eh.wrapcommand("update") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
695 |
@eh.wrapcommand("pull") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
696 |
def wrapmayobsoletewc(origfn, ui, repo, *args, **opts): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
697 |
"""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
|
698 |
def warnobsolete(): |
1527
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
699 |
_warnobsoletewc(ui, repo) |
1452
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
700 |
wlock = None |
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
701 |
try: |
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
702 |
wlock = repo.wlock() |
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
703 |
repo._afterlock(warnobsolete) |
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
704 |
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
|
705 |
finally: |
1bcbd14cf159
merge back with 3.3 compat branch
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1451
diff
changeset
|
706 |
lockmod.release(wlock) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
707 |
return res |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
708 |
|
1527
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
709 |
@eh.wrapcommand("parents") |
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
710 |
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
|
711 |
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
|
712 |
_warnobsoletewc(ui, repo) |
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
713 |
return res |
e080d2ae2656
parents: avoid locking the repository during 'hg parents'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1519
diff
changeset
|
714 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
715 |
# XXX this could wrap transaction code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
716 |
# 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
|
717 |
@eh.wrapcommand("commit") |
763
966e2659e989
import: warn about new unstable changesets
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
762
diff
changeset
|
718 |
@eh.wrapcommand("import") |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
719 |
@eh.wrapcommand("push") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
720 |
@eh.wrapcommand("pull") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
721 |
@eh.wrapcommand("graft") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
722 |
@eh.wrapcommand("phase") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
723 |
@eh.wrapcommand("unbundle") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
724 |
def warnobserrors(orig, ui, repo, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
725 |
"""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
|
726 |
# 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
|
727 |
# 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
|
728 |
filtered = repo.changelog.filteredrevs |
2a2b8c95bb43
evolve: remove revset calls in warnobserror
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
657
diff
changeset
|
729 |
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
|
730 |
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
|
731 |
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
|
732 |
ret = orig(ui, repo, *args, **kwargs) |
552
f7e54d4a3b90
warning: work around phase limitation when computing warnings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
551
diff
changeset
|
733 |
# workaround phase stupidity |
649
d318fbb1cd67
evolve: stop working around phase limitation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
647
diff
changeset
|
734 |
#phases._filterunknown(ui, repo.changelog, repo._phasecache.phaseroots) |
658
2a2b8c95bb43
evolve: remove revset calls in warnobserror
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
657
diff
changeset
|
735 |
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
|
736 |
newunstables = \ |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
737 |
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
|
738 |
newbumpeds = \ |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
739 |
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
|
740 |
newdivergents = \ |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
741 |
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
|
742 |
if newunstables > 0: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
743 |
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
|
744 |
if newbumpeds > 0: |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
745 |
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
|
746 |
if newdivergents > 0: |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
747 |
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
|
748 |
return ret |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
749 |
|
1122
c8750f4388c8
evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents:
1120
diff
changeset
|
750 |
@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
|
751 |
def push(orig, repo, *args, **opts): |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
752 |
"""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
|
753 |
""" |
1122
c8750f4388c8
evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents:
1120
diff
changeset
|
754 |
try: |
c8750f4388c8
evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents:
1120
diff
changeset
|
755 |
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
|
756 |
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
|
757 |
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
|
758 |
"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
|
759 |
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
|
760 |
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
|
761 |
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
|
762 |
ex.hint = hint |
c8750f4388c8
evolve: wrap exchange.push() for compatability with core mercurial 4d52e6eb98ea
Matt Harbison <matt_harbison@yahoo.com>
parents:
1120
diff
changeset
|
763 |
raise |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
764 |
|
788
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
765 |
def summaryhook(ui, repo): |
513
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
766 |
def write(fmt, count): |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
767 |
s = fmt % count |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
768 |
if count: |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
769 |
ui.write(s) |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
770 |
else: |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
771 |
ui.note(s) |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
772 |
|
1580
b915e0d54db0
evolve: duplicate evolution summary entries (issue5014)
Laurent Charignon <lcharignon@fb.com>
parents:
1576
diff
changeset
|
773 |
# util.versiontuple was introduced in 3.6.2 |
b915e0d54db0
evolve: duplicate evolution summary entries (issue5014)
Laurent Charignon <lcharignon@fb.com>
parents:
1576
diff
changeset
|
774 |
if not util.safehasattr(util, 'versiontuple'): |
b915e0d54db0
evolve: duplicate evolution summary entries (issue5014)
Laurent Charignon <lcharignon@fb.com>
parents:
1576
diff
changeset
|
775 |
nbunstable = len(getrevs(repo, 'unstable')) |
b915e0d54db0
evolve: duplicate evolution summary entries (issue5014)
Laurent Charignon <lcharignon@fb.com>
parents:
1576
diff
changeset
|
776 |
nbbumped = len(getrevs(repo, 'bumped')) |
b915e0d54db0
evolve: duplicate evolution summary entries (issue5014)
Laurent Charignon <lcharignon@fb.com>
parents:
1576
diff
changeset
|
777 |
nbdivergent = len(getrevs(repo, 'divergent')) |
b915e0d54db0
evolve: duplicate evolution summary entries (issue5014)
Laurent Charignon <lcharignon@fb.com>
parents:
1576
diff
changeset
|
778 |
write('unstable: %i changesets\n', nbunstable) |
b915e0d54db0
evolve: duplicate evolution summary entries (issue5014)
Laurent Charignon <lcharignon@fb.com>
parents:
1576
diff
changeset
|
779 |
write('bumped: %i changesets\n', nbbumped) |
b915e0d54db0
evolve: duplicate evolution summary entries (issue5014)
Laurent Charignon <lcharignon@fb.com>
parents:
1576
diff
changeset
|
780 |
write('divergent: %i changesets\n', nbdivergent) |
b915e0d54db0
evolve: duplicate evolution summary entries (issue5014)
Laurent Charignon <lcharignon@fb.com>
parents:
1576
diff
changeset
|
781 |
else: |
b915e0d54db0
evolve: duplicate evolution summary entries (issue5014)
Laurent Charignon <lcharignon@fb.com>
parents:
1576
diff
changeset
|
782 |
# In 3.6.2, summary in core gained this feature, no need to display it |
b915e0d54db0
evolve: duplicate evolution summary entries (issue5014)
Laurent Charignon <lcharignon@fb.com>
parents:
1576
diff
changeset
|
783 |
pass |
1640 | 784 |
state = _evolvestateread(repo) |
785 |
if state is not None: |
|
786 |
# i18n: column positioning for "hg summary" |
|
787 |
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
|
788 |
|
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
789 |
@eh.extsetup |
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
790 |
def obssummarysetup(ui): |
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
791 |
cmdutil.summaryhooks.add('evolve', summaryhook) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
792 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
793 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
794 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
795 |
### Core Other extension compat ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
796 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
797 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
798 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
799 |
@eh.extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
800 |
def _rebasewrapping(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
801 |
# warning about more obsolete |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
802 |
try: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
803 |
rebase = extensions.find('rebase') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
804 |
if rebase: |
572
dc107acd0bd2
adapt to core rebase support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
571
diff
changeset
|
805 |
extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
806 |
except KeyError: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
807 |
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
|
808 |
try: |
718262019c6f
evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
677
diff
changeset
|
809 |
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
|
810 |
if histedit: |
718262019c6f
evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
677
diff
changeset
|
811 |
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
|
812 |
except KeyError: |
1575 | 813 |
pass # histedit not found |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
814 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
815 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
816 |
### Old Evolve extension content ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
817 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
818 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
819 |
# 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
|
820 |
|
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
821 |
### util function |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
822 |
############################# |
303 | 823 |
|
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
824 |
### changeset rewriting logic |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
825 |
############################# |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
826 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
827 |
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
|
828 |
"""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
|
829 |
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
|
830 |
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
|
831 |
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
|
832 |
""" |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
833 |
wlock = lock = tr = None |
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
834 |
try: |
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
835 |
wlock = repo.wlock() |
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
836 |
lock = repo.lock() |
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
837 |
tr = repo.transaction('rewrite') |
1662 | 838 |
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
|
839 |
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
|
840 |
base = old.p1() |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
841 |
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
|
842 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
843 |
# 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
|
844 |
# 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
|
845 |
files = set(old.files()) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
846 |
for u in updates: |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
847 |
files.update(u.files()) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
848 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
849 |
# 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
|
850 |
copied = copies.pathcopies(base, head) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
851 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
852 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
853 |
# 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
|
854 |
def samefile(f): |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
855 |
if f in head.manifest(): |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
856 |
a = head.filectx(f) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
857 |
if f in base.manifest(): |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
858 |
b = base.filectx(f) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
859 |
return (a.data() == b.data() |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
860 |
and a.flags() == b.flags()) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
861 |
else: |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
862 |
return False |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
863 |
else: |
1505
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
864 |
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
|
865 |
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
|
866 |
# 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
|
867 |
headmf = head.manifest() |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
868 |
def filectxfn(repo, ctx, path): |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
869 |
if path in headmf: |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
870 |
fctx = head[path] |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
871 |
flags = fctx.flags() |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
872 |
mctx = memfilectx(repo, fctx.path(), fctx.data(), |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
873 |
islink='l' in flags, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
874 |
isexec='x' in flags, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
875 |
copied=copied.get(path)) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
876 |
return mctx |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
877 |
return None |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
878 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
879 |
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
|
880 |
if not message: |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
881 |
message = old.description() |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
882 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
883 |
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
|
884 |
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
|
885 |
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
|
886 |
extra['branch'] = head.branch() |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
887 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
888 |
new = context.memctx(repo, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
889 |
parents=newbases, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
890 |
text=message, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
891 |
files=files, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
892 |
filectxfn=filectxfn, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
893 |
user=user, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
894 |
date=date, |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
895 |
extra=extra) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
896 |
|
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
897 |
if commitopts.get('edit'): |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
898 |
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
|
899 |
revcount = len(repo) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
900 |
newid = repo.commitctx(new) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
901 |
new = repo[newid] |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
902 |
created = len(repo) != revcount |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
903 |
updatebookmarks(newid) |
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
904 |
|
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
905 |
tr.close() |
1505
53a6dbc33e36
evolve: indentation change for making next patch more legible
Laurent Charignon <lcharignon@fb.com>
parents:
1504
diff
changeset
|
906 |
return newid, created |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
907 |
finally: |
1554
59f5bb1f1877
transaction: fix release order in 'rewrite'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1547
diff
changeset
|
908 |
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
|
909 |
|
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
910 |
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
|
911 |
pass |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
912 |
|
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
913 |
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
|
914 |
"""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
|
915 |
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
|
916 |
raise error.Abort(_('tried to relocate a node on top of itself'), |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
917 |
hint=_("This shouldn't happen. If you still " |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
918 |
"need to move changesets, please do so " |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
919 |
"manually with nothing to rebase - working " |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
920 |
"directory parent is also destination")) |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
921 |
|
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
922 |
if pctx is None: |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
923 |
if len(orig.parents()) == 2: |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
924 |
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
|
925 |
"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
|
926 |
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
|
927 |
pctx = orig.p1() |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
928 |
|
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
929 |
destbookmarks = repo.nodebookmarks(dest.node()) |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
930 |
nodesrc = orig.node() |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
931 |
destphase = repo[nodesrc].phase() |
1106
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
932 |
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
|
933 |
|
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
934 |
cache = {} |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
935 |
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
|
936 |
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
|
937 |
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
|
938 |
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
|
939 |
try: |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
940 |
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
|
941 |
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
|
942 |
continue |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
943 |
|
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
944 |
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
|
945 |
continue |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
946 |
|
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
947 |
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
|
948 |
|
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
949 |
# 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
|
950 |
# 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
|
951 |
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
|
952 |
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
|
953 |
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
|
954 |
else: |
6b0cf1b73693
evolve: replace each obsolete sha1 in the description with its latest successor
Matt Harbison <matt_harbison@yahoo.com>
parents:
1104
diff
changeset
|
955 |
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
|
956 |
'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
|
957 |
|
1593
2f117c299325
evolve: remove meaningless transaction nesting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1592
diff
changeset
|
958 |
tr = repo.currenttransaction() |
2f117c299325
evolve: remove meaningless transaction nesting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1592
diff
changeset
|
959 |
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
|
960 |
try: |
1729
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
961 |
r = _evolvemerge(repo, orig, dest, pctx, keepbranch) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
962 |
if r[-1]: #some conflict |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
963 |
raise error.Abort( |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
964 |
'unresolved merge conflicts (see hg help resolve)') |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
965 |
nodenew = _relocatecommit(repo, orig, commitmsg) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
966 |
except error.Abort as exc: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
967 |
repo.dirstate.beginparentchange() |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
968 |
repo.setparents(repo['.'].node(), nullid) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
969 |
writedirstate(repo.dirstate, tr) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
970 |
# fix up dirstate for copies and renames |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
971 |
copies.duplicatecopies(repo, dest.rev(), orig.p1().rev()) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
972 |
repo.dirstate.endparentchange() |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
973 |
class LocalMergeFailure(MergeFailure, exc.__class__): |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
974 |
pass |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
975 |
exc.__class__ = LocalMergeFailure |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
976 |
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
|
977 |
raise |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
978 |
oldbookmarks = repo.nodebookmarks(nodesrc) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
979 |
_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
|
980 |
return nodenew |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
981 |
|
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
982 |
def _bookmarksupdater(repo, oldid, tr): |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
983 |
"""Return a callable update(newid) updating the current bookmark |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
984 |
and bookmarks bound to oldid to newid. |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
985 |
""" |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
986 |
def updatebookmarks(newid): |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
987 |
dirty = False |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
988 |
oldbookmarks = repo.nodebookmarks(oldid) |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
989 |
if oldbookmarks: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
990 |
for b in oldbookmarks: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
991 |
repo._bookmarks[b] = newid |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
992 |
dirty = True |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
993 |
if dirty: |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
994 |
repo._bookmarks.recordchange(tr) |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
995 |
return updatebookmarks |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
996 |
|
1330
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
997 |
### bookmarks api compatibility layer ### |
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
998 |
def bmdeactivate(repo): |
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
999 |
try: |
1561
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
1000 |
return bookmarksmod.deactivate(repo) |
1330
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
1001 |
except AttributeError: |
1561
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
1002 |
return bookmarksmod.unsetcurrent(repo) |
1389
87aceaed5c69
prune: use the bookmark wrapper for 3.4 compatibility
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1386
diff
changeset
|
1003 |
def bmactivate(repo, book): |
87aceaed5c69
prune: use the bookmark wrapper for 3.4 compatibility
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1386
diff
changeset
|
1004 |
try: |
1561
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
1005 |
return bookmarksmod.activate(repo, book) |
1389
87aceaed5c69
prune: use the bookmark wrapper for 3.4 compatibility
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1386
diff
changeset
|
1006 |
except AttributeError: |
1561
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
1007 |
return bookmarksmod.setcurrent(repo, book) |
1330
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
1008 |
|
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
1009 |
def bmactive(repo): |
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
1010 |
try: |
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
1011 |
return repo._activebookmark |
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
1012 |
except AttributeError: |
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
1013 |
return repo._bookmarkcurrent |
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
1014 |
|
1514
324cd13838f1
evolve: have dirstate collaborate with transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1513
diff
changeset
|
1015 |
### dirstate compatibility layer < hg 3.6 |
324cd13838f1
evolve: have dirstate collaborate with transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1513
diff
changeset
|
1016 |
|
324cd13838f1
evolve: have dirstate collaborate with transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1513
diff
changeset
|
1017 |
def writedirstate(dirstate, tr): |
1720
fe64e69da57b
dirstate: use arg count for version check
Ryan McElroy <rmcelroy@fb.com>
parents:
1717
diff
changeset
|
1018 |
if dirstate.write.func_code.co_argcount != 1: # mercurial 3.6 and above |
1514
324cd13838f1
evolve: have dirstate collaborate with transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1513
diff
changeset
|
1019 |
return dirstate.write(tr) |
324cd13838f1
evolve: have dirstate collaborate with transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1513
diff
changeset
|
1020 |
return dirstate.write() |
324cd13838f1
evolve: have dirstate collaborate with transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1513
diff
changeset
|
1021 |
|
324cd13838f1
evolve: have dirstate collaborate with transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1513
diff
changeset
|
1022 |
|
324cd13838f1
evolve: have dirstate collaborate with transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1513
diff
changeset
|
1023 |
|
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1024 |
### new command |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1025 |
############################# |
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1026 |
metadataopts = [ |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1027 |
('d', 'date', '', |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1028 |
_('record the specified date in metadata'), _('DATE')), |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1029 |
('u', 'user', '', |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1030 |
_('record the specified user in metadata'), _('USER')), |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1031 |
] |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1032 |
|
953
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1033 |
@eh.uisetup |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1034 |
def _installimportobsolete(ui): |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1035 |
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
|
1036 |
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
|
1037 |
_('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
|
1038 |
'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
|
1039 |
|
953
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1040 |
@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
|
1041 |
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
|
1042 |
extracted = patch.extract(ui, hunk) |
1511
91b6a30424a3
evolve: compatibility with coming 3.6
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1503
diff
changeset
|
1043 |
if util.safehasattr(extracted, 'get'): |
91b6a30424a3
evolve: compatibility with coming 3.6
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1503
diff
changeset
|
1044 |
# mercurial 3.6 return a dictionary there |
91b6a30424a3
evolve: compatibility with coming 3.6
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1503
diff
changeset
|
1045 |
expected = extracted.get('nodeid') |
91b6a30424a3
evolve: compatibility with coming 3.6
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1503
diff
changeset
|
1046 |
else: |
91b6a30424a3
evolve: compatibility with coming 3.6
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1503
diff
changeset
|
1047 |
expected = extracted[5] |
1115
cc19b6400dae
import: fix the "is None" check for the Node
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1109
diff
changeset
|
1048 |
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
|
1049 |
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
|
1050 |
oldextract = patch.extract |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1051 |
try: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1052 |
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
|
1053 |
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
|
1054 |
finally: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1055 |
patch.extract = oldextract |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1056 |
created = ret[1] |
1055
cfe1b9d3e5d9
import: handle patch with no node information
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1054
diff
changeset
|
1057 |
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
|
1058 |
and created != expected): |
953
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1059 |
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
|
1060 |
try: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1061 |
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
|
1062 |
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
|
1063 |
metadata=metadata) |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1064 |
tr.close() |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1065 |
finally: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1066 |
tr.release() |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
1067 |
return ret |
930
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
927
diff
changeset
|
1068 |
|
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1069 |
|
894
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1070 |
def _deprecatealias(oldalias, newalias): |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1071 |
'''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
|
1072 |
|
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1073 |
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
|
1074 |
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
|
1075 |
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
|
1076 |
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
|
1077 |
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
|
1078 |
|
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1079 |
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
|
1080 |
''' |
1226
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
1081 |
try: |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
1082 |
aliases, entry = cmdutil.findcmd(newalias, cmdtable) |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
1083 |
except error.UnknownCommand: |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
1084 |
# Commands may be disabled |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
1085 |
return |
1680
7caa5f2040c5
py3: use items() instead of iteritems()
timeless@gmail.com
parents:
1679
diff
changeset
|
1086 |
for alias, e in cmdtable.items(): |
894
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1087 |
if e is entry: |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1088 |
break |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1089 |
|
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1090 |
synopsis = '(DEPRECATED)' |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1091 |
if len(entry) > 2: |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1092 |
fn, opts, _syn = entry |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1093 |
else: |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1094 |
fn, opts, = entry |
1496 | 1095 |
deprecationwarning = _('%s have been deprecated in favor of %s\n') % ( |
1096 |
oldalias, newalias) |
|
894
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1097 |
def newfn(*args, **kwargs): |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1098 |
ui = args[0] |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1099 |
ui.warn(deprecationwarning) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1100 |
util.checksignature(fn)(*args, **kwargs) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1101 |
newfn.__doc__ = deprecationwarning |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1102 |
cmdwrapper = command(oldalias, opts, synopsis) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1103 |
cmdwrapper(newfn) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1104 |
|
895
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
1105 |
@eh.extsetup |
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
1106 |
def deprecatealiases(ui): |
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
1107 |
_deprecatealias('gup', 'next') |
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
1108 |
_deprecatealias('gdown', 'previous') |
894
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
1109 |
|
811
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1110 |
@command('debugrecordpruneparents', [], '') |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1111 |
def cmddebugrecordpruneparents(ui, repo): |
1570
0edb2c25f806
evolve: improve help for some debug commands
Greg Ward <greg@gerg.ca>
parents:
1569
diff
changeset
|
1112 |
"""add parent data to prune markers when possible |
0edb2c25f806
evolve: improve help for some debug commands
Greg Ward <greg@gerg.ca>
parents:
1569
diff
changeset
|
1113 |
|
0edb2c25f806
evolve: improve help for some debug commands
Greg Ward <greg@gerg.ca>
parents:
1569
diff
changeset
|
1114 |
This command searches the repo for prune markers without parent information. |
0edb2c25f806
evolve: improve help for some debug commands
Greg Ward <greg@gerg.ca>
parents:
1569
diff
changeset
|
1115 |
If the pruned node is locally known, it creates a new marker with parent |
0edb2c25f806
evolve: improve help for some debug commands
Greg Ward <greg@gerg.ca>
parents:
1569
diff
changeset
|
1116 |
data. |
0edb2c25f806
evolve: improve help for some debug commands
Greg Ward <greg@gerg.ca>
parents:
1569
diff
changeset
|
1117 |
""" |
811
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1118 |
pgop = 'reading markers' |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1119 |
|
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1120 |
# lock from the beginning to prevent race |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1121 |
wlock = lock = tr = None |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1122 |
try: |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1123 |
wlock = repo.wlock() |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1124 |
lock = repo.lock() |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1125 |
tr = repo.transaction('recordpruneparents') |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1126 |
unfi = repo.unfiltered() |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1127 |
nm = unfi.changelog.nodemap |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1128 |
store = repo.obsstore |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1129 |
pgtotal = len(store._all) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1130 |
for idx, mark in enumerate(list(store._all)): |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1131 |
if not mark[1]: |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1132 |
rev = nm.get(mark[0]) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1133 |
if rev is not None: |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1134 |
ctx = unfi[rev] |
1311
d6a740947197
evolve: update cmddebugrecordpruneparents to the new markers creation API
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1310
diff
changeset
|
1135 |
parents = tuple(p.node() for p in ctx.parents()) |
811
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1136 |
before = len(store._all) |
1622
d49f4ad04fbd
debugrecordpruneparents: fix an apparent typo (marks)
Anton Shestakov <av6@dwimlabs.net>
parents:
1615
diff
changeset
|
1137 |
store.create(tr, mark[0], mark[1], mark[2], mark[3], |
1311
d6a740947197
evolve: update cmddebugrecordpruneparents to the new markers creation API
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1310
diff
changeset
|
1138 |
parents=parents) |
811
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1139 |
if len(store._all) - before: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1140 |
ui.write(_('created new markers for %i\n') % rev) |
811
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1141 |
ui.progress(pgop, idx, total=pgtotal) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1142 |
tr.close() |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1143 |
ui.progress(pgop, None) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1144 |
finally: |
1018
30262465b932
debugrecordpruneparents: release tr the same way than the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1017
diff
changeset
|
1145 |
lockmod.release(tr, lock, wlock) |
930
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
927
diff
changeset
|
1146 |
|
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1147 |
@command('debugobsstorestat', [], '') |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1148 |
def cmddebugobsstorestat(ui, repo): |
1570
0edb2c25f806
evolve: improve help for some debug commands
Greg Ward <greg@gerg.ca>
parents:
1569
diff
changeset
|
1149 |
"""print statistics about obsolescence markers in the repo""" |
1315
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1150 |
def _updateclustermap(nodes, mark, clustersmap): |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1151 |
c = (set(nodes), set([mark])) |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1152 |
toproceed = set(nodes) |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1153 |
while toproceed: |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1154 |
n = toproceed.pop() |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1155 |
other = clustersmap.get(n) |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1156 |
if (other is not None |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1157 |
and other is not c): |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1158 |
other[0].update(c[0]) |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1159 |
other[1].update(c[1]) |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1160 |
for on in c[0]: |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1161 |
if on in toproceed: |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1162 |
continue |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1163 |
clustersmap[on] = other |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1164 |
c = other |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1165 |
clustersmap[n] = c |
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1166 |
|
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1167 |
store = repo.obsstore |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1168 |
unfi = repo.unfiltered() |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1169 |
nm = unfi.changelog.nodemap |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1170 |
ui.write(_('markers total: %9i\n') % len(store._all)) |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1171 |
sucscount = [0, 0 , 0, 0] |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1172 |
known = 0 |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1173 |
parentsdata = 0 |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1174 |
metakeys = {} |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1175 |
# node -> cluster mapping |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1176 |
# a cluster is a (set(nodes), set(markers)) tuple |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1177 |
clustersmap = {} |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1178 |
# same data using parent information |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1179 |
pclustersmap = {} |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1180 |
for mark in store: |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1181 |
if mark[0] in nm: |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1182 |
known += 1 |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1183 |
nbsucs = len(mark[1]) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1184 |
sucscount[min(nbsucs, 3)] += 1 |
1129
da565c825429
evolve: adapt to the new metadata storage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1128
diff
changeset
|
1185 |
meta = mark[3] |
da565c825429
evolve: adapt to the new metadata storage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1128
diff
changeset
|
1186 |
for key, value in meta: |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1187 |
metakeys.setdefault(key, 0) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1188 |
metakeys[key] += 1 |
1129
da565c825429
evolve: adapt to the new metadata storage
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1128
diff
changeset
|
1189 |
meta = dict(meta) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1190 |
parents = [meta.get('p1'), meta.get('p2')] |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1191 |
parents = [node.bin(p) for p in parents if p is not None] |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1192 |
if parents: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1193 |
parentsdata += 1 |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1194 |
# cluster handling |
1315
445d7f46f25d
evolve: refactor code computing stats of obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1314
diff
changeset
|
1195 |
nodes = set(mark[1]) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1196 |
nodes.add(mark[0]) |
1468
bc6cf6cc06fd
evolve: remove trailing spaces
André Sintzoff <andre.sintzoff@gmail.com>
parents:
1467
diff
changeset
|
1197 |
_updateclustermap(nodes, mark, clustersmap) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1198 |
# same with parent data |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1199 |
nodes.update(parents) |
1468
bc6cf6cc06fd
evolve: remove trailing spaces
André Sintzoff <andre.sintzoff@gmail.com>
parents:
1467
diff
changeset
|
1200 |
_updateclustermap(nodes, mark, pclustersmap) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1201 |
|
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1202 |
# freezing the result |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1203 |
for c in clustersmap.values(): |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1204 |
fc = (frozenset(c[0]), frozenset(c[1])) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1205 |
for n in fc[0]: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1206 |
clustersmap[n] = fc |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1207 |
# same with parent data |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1208 |
for c in pclustersmap.values(): |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1209 |
fc = (frozenset(c[0]), frozenset(c[1])) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1210 |
for n in fc[0]: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1211 |
pclustersmap[n] = fc |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1212 |
ui.write((' for known precursors: %9i\n' % known)) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1213 |
ui.write((' with parents data: %9i\n' % parentsdata)) |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1214 |
# successors data |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1215 |
ui.write(('markers with no successors: %9i\n' % sucscount[0])) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1216 |
ui.write((' 1 successors: %9i\n' % sucscount[1])) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1217 |
ui.write((' 2 successors: %9i\n' % sucscount[2])) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1218 |
ui.write((' more than 2 successors: %9i\n' % sucscount[3])) |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1219 |
# meta data info |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1220 |
ui.write((' available keys:\n')) |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1221 |
for key in sorted(metakeys): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1222 |
ui.write((' %15s: %9i\n' % (key, metakeys[key]))) |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1223 |
|
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1224 |
allclusters = list(set(clustersmap.values())) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1225 |
allclusters.sort(key=lambda x: len(x[1])) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1226 |
ui.write(('disconnected clusters: %9i\n' % len(allclusters))) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1227 |
|
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1228 |
ui.write(' any known node: %9i\n' |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1229 |
% len([c for c in allclusters |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1230 |
if [n for n in c[0] if nm.get(n) is not None]])) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1231 |
if allclusters: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1232 |
nbcluster = len(allclusters) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1233 |
ui.write((' smallest length: %9i\n' % len(allclusters[0][1]))) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1234 |
ui.write((' longer length: %9i\n' |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1235 |
% len(allclusters[-1][1]))) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1236 |
median = len(allclusters[nbcluster//2][1]) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1237 |
ui.write((' median length: %9i\n' % median)) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1238 |
mean = sum(len(x[1]) for x in allclusters) // nbcluster |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1239 |
ui.write((' mean length: %9i\n' % mean)) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1240 |
allpclusters = list(set(pclustersmap.values())) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1241 |
allpclusters.sort(key=lambda x: len(x[1])) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1242 |
ui.write((' using parents data: %9i\n' % len(allpclusters))) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1243 |
ui.write(' any known node: %9i\n' |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1244 |
% len([c for c in allclusters |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1245 |
if [n for n in c[0] if nm.get(n) is not None]])) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1246 |
if allpclusters: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1247 |
nbcluster = len(allpclusters) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1248 |
ui.write((' smallest length: %9i\n' |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1249 |
% len(allpclusters[0][1]))) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1250 |
ui.write((' longer length: %9i\n' |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1251 |
% len(allpclusters[-1][1]))) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1252 |
median = len(allpclusters[nbcluster//2][1]) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1253 |
ui.write((' median length: %9i\n' % median)) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1254 |
mean = sum(len(x[1]) for x in allpclusters) // nbcluster |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1255 |
ui.write((' mean length: %9i\n' % mean)) |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1256 |
|
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1257 |
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
|
1258 |
"""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
|
1259 |
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
|
1260 |
try: |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
1261 |
wlock = repo.wlock() |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
1262 |
lock = repo.lock() |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
1263 |
tr = repo.transaction("evolve") |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1264 |
if 'unstable' == category: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1265 |
result = _solveunstable(ui, repo, ctx, dryrun, confirm, progresscb) |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1266 |
elif 'bumped' == category: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1267 |
result = _solvebumped(ui, repo, ctx, dryrun, confirm, progresscb) |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1268 |
elif 'divergent' == category: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1269 |
result = _solvedivergent(ui, repo, ctx, dryrun, confirm, |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1270 |
progresscb) |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1271 |
else: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1272 |
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
|
1273 |
tr.close() |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
1274 |
return result |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
1275 |
finally: |
b5cd96395867
evolve: extract the logic to solve one change into a method
Laurent Charignon <lcharignon@fb.com>
parents:
1319
diff
changeset
|
1276 |
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
|
1277 |
|
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1278 |
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
|
1279 |
"""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
|
1280 |
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
|
1281 |
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
|
1282 |
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
|
1283 |
msg = None |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1284 |
hint = None |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1285 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1286 |
troubled = { |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1287 |
"unstable": repo.revs("unstable()"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1288 |
"divergent": repo.revs("divergent()"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1289 |
"bumped": repo.revs("bumped()"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1290 |
"all": repo.revs("troubled()"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1291 |
} |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1292 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1293 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1294 |
hintmap = { |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1295 |
'bumped': _("do you want to use --bumped"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1296 |
'bumped+divergent': _("do you want to use --bumped or --divergent"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1297 |
'bumped+unstable': _("do you want to use --bumped or --unstable"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1298 |
'divergent': _("do you want to use --divergent"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1299 |
'divergent+unstable': _("do you want to use --divergent" |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1300 |
" or --unstable"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1301 |
'unstable': _("do you want to use --unstable"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1302 |
'any+bumped': _("do you want to use --any (or --rev) and --bumped"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1303 |
'any+bumped+divergent': _("do you want to use --any (or --rev) and" |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1304 |
" --bumped or --divergent"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1305 |
'any+bumped+unstable': _("do you want to use --any (or --rev) and" |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1306 |
"--bumped or --unstable"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1307 |
'any+divergent': _("do you want to use --any (or --rev) and" |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1308 |
" --divergent"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1309 |
'any+divergent+unstable': _("do you want to use --any (or --rev)" |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1310 |
" and --divergent or --unstable"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1311 |
'any+unstable': _("do you want to use --any (or --rev)" |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1312 |
"and --unstable"), |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1313 |
} |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1314 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1315 |
if revopt: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1316 |
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
|
1317 |
if not revs: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1318 |
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
|
1319 |
else: |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1320 |
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
|
1321 |
othertroubles = [] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1322 |
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
|
1323 |
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
|
1324 |
othertroubles.append(cat) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1325 |
if othertroubles: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1326 |
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
|
1327 |
|
1422
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1328 |
elif anyopt: |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1329 |
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
|
1330 |
othertroubles = [] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1331 |
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
|
1332 |
if troubled[cat]: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1333 |
othertroubles.append(cat) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1334 |
if othertroubles: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1335 |
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
|
1336 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1337 |
else: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1338 |
# 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
|
1339 |
if targetcat == 'unstable': |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1340 |
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
|
1341 |
else: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1342 |
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
|
1343 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1344 |
p1 = repo['.'].rev() |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1345 |
othertroubles = [] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1346 |
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
|
1347 |
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
|
1348 |
othertroubles.append(cat) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1349 |
if othertroubles: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1350 |
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
|
1351 |
else: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1352 |
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
|
1353 |
if l: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1354 |
hint = _("%d other %s in the repository, do you want --any " |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1355 |
"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
|
1356 |
else: |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1357 |
othertroubles = [] |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1358 |
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
|
1359 |
if troubled[cat]: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1360 |
othertroubles.append(cat) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1361 |
if othertroubles: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1362 |
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
|
1363 |
else: |
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1364 |
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
|
1365 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1366 |
assert msg is not None |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1367 |
ui.write_err(msg+"\n") |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1368 |
if hint: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1369 |
ui.write_err("("+hint+")\n") |
1316
f11363699766
evolve: refactoring of the code displaying error when no trouble found
Laurent Charignon <lcharignon@fb.com>
parents:
1315
diff
changeset
|
1370 |
return 2 |
f11363699766
evolve: refactoring of the code displaying error when no trouble found
Laurent Charignon <lcharignon@fb.com>
parents:
1315
diff
changeset
|
1371 |
else: |
f11363699766
evolve: refactoring of the code displaying error when no trouble found
Laurent Charignon <lcharignon@fb.com>
parents:
1315
diff
changeset
|
1372 |
return 1 |
1324
739208d1ee62
evolve: extract cleanup logic in the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1323
diff
changeset
|
1373 |
|
739208d1ee62
evolve: extract cleanup logic in the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1323
diff
changeset
|
1374 |
def _cleanup(ui, repo, startnode, showprogress): |
739208d1ee62
evolve: extract cleanup logic in the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1323
diff
changeset
|
1375 |
if showprogress: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1376 |
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
|
1377 |
if repo['.'] != startnode: |
bac4e0bc9f6a
evolve: write a status message when the working directory changes
David Soria Parra <davidsp@fb.com>
parents:
1067
diff
changeset
|
1378 |
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
|
1379 |
|
1408
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1380 |
class MultipleSuccessorsError(RuntimeError): |
1569
bd1468c23d88
evolve: scattered typo fixes in comments, docstrings
Greg Ward <greg@gerg.ca>
parents:
1528
diff
changeset
|
1381 |
"""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
|
1382 |
|
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1383 |
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
|
1384 |
attribute to call to easily recover. |
509
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1385 |
""" |
1408
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1386 |
|
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1387 |
def __init__(self, successorssets): |
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1388 |
self.successorssets = successorssets |
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1389 |
|
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1390 |
def _singlesuccessor(repo, p): |
1369
4ed67cce8c23
evolve: properly evolve stacked unstable with --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1364
diff
changeset
|
1391 |
"""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
|
1392 |
|
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1393 |
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
|
1394 |
|
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1395 |
if not p.obsolete(): |
1369
4ed67cce8c23
evolve: properly evolve stacked unstable with --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1364
diff
changeset
|
1396 |
return p.rev() |
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1397 |
obs = repo[p] |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1398 |
ui = repo.ui |
630
722b52c75f02
compat: adapt to upstreaming of divergent logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
622
diff
changeset
|
1399 |
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
|
1400 |
# search of a parent which is not killed |
1440
afe46c3b15db
evolve: clarify code in _singlesuccessor
Laurent Charignon <lcharignon@fb.com>
parents:
1428
diff
changeset
|
1401 |
while not newer: |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1402 |
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
|
1403 |
" 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
|
1404 |
obs) |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1405 |
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
|
1406 |
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
|
1407 |
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
|
1408 |
raise MultipleSuccessorsError(newer) |
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1409 |
|
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1410 |
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
|
1411 |
|
1361
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1412 |
def builddependencies(repo, revs): |
1411
64515965c0df
evolve: some style fix
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1410
diff
changeset
|
1413 |
"""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
|
1414 |
(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
|
1415 |
|
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1416 |
# 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
|
1417 |
# 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
|
1418 |
# dependencies = {3: [6], 6:[]} |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1419 |
# 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
|
1420 |
dependencies = {} |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1421 |
# 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
|
1422 |
rdependencies = collections.defaultdict(set) |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1423 |
|
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1424 |
for r in revs: |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1425 |
dependencies[r] = set() |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1426 |
for p in repo[r].parents(): |
1408
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1427 |
try: |
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1428 |
succ = _singlesuccessor(repo, p) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1429 |
except MultipleSuccessorsError as exc: |
1408
b3afdc0815d0
evolve: skip unstable changesets with multiple successorssets
Laurent Charignon <lcharignon@fb.com>
parents:
1407
diff
changeset
|
1430 |
dependencies[r] = exc.successorssets |
1418
ed9a8b1ee9bd
evolve: fix error in builddependencies
Laurent Charignon <lcharignon@fb.com>
parents:
1415
diff
changeset
|
1431 |
continue |
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1432 |
if succ in revs: |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1433 |
dependencies[r].add(succ) |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1434 |
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
|
1435 |
return dependencies, rdependencies |
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1436 |
|
1467
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1437 |
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
|
1438 |
"""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
|
1439 |
lowest revision numbers |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1440 |
""" |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1441 |
repo = repo.unfiltered() |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1442 |
res = set() |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1443 |
# 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
|
1444 |
discarded = set() |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1445 |
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
|
1446 |
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
|
1447 |
continue |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1448 |
divergent = repo[rev] |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1449 |
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
|
1450 |
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
|
1451 |
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
|
1452 |
discarded.update(othersrevs) |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1453 |
return res |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
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 |
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
|
1456 |
"""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
|
1457 |
revs = set() |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1458 |
if allopt or revopt: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1459 |
revs = repo.revs(targetcat+'()') |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1460 |
if revopt: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1461 |
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
|
1462 |
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
|
1463 |
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
|
1464 |
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
|
1465 |
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
|
1466 |
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
|
1467 |
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
|
1468 |
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
|
1469 |
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
|
1470 |
if targetcat == 'divergent': |
5c385b812500
evolve: dedupe divergents when running evolve --all --any or evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1466
diff
changeset
|
1471 |
# 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
|
1472 |
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
|
1473 |
elif anyopt: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1474 |
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
|
1475 |
elif targetcat == 'unstable': |
1421
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1476 |
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
|
1477 |
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
|
1478 |
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
|
1479 |
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
|
1480 |
% ', '.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
|
1481 |
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
|
1482 |
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
|
1483 |
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
|
1484 |
return revs |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1485 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1486 |
|
1411
64515965c0df
evolve: some style fix
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1410
diff
changeset
|
1487 |
def _orderrevs(repo, revs): |
64515965c0df
evolve: some style fix
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1410
diff
changeset
|
1488 |
"""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
|
1489 |
|
1571
0e8936e7cb89
evolve: improve the confusing docstring for _orderrevs()
Greg Ward <greg@gerg.ca>
parents:
1570
diff
changeset
|
1490 |
revs is a list of unstable revisions. |
0e8936e7cb89
evolve: improve the confusing docstring for _orderrevs()
Greg Ward <greg@gerg.ca>
parents:
1570
diff
changeset
|
1491 |
|
0e8936e7cb89
evolve: improve the confusing docstring for _orderrevs()
Greg Ward <greg@gerg.ca>
parents:
1570
diff
changeset
|
1492 |
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
|
1493 |
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
|
1494 |
eventually. |
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1495 |
|
1571
0e8936e7cb89
evolve: improve the confusing docstring for _orderrevs()
Greg Ward <greg@gerg.ca>
parents:
1570
diff
changeset
|
1496 |
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
|
1497 |
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
|
1498 |
""" |
043e5ca9322f
evolve: extract the code computing dependencies in a separate function
Laurent Charignon <lcharignon@fb.com>
parents:
1357
diff
changeset
|
1499 |
# 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
|
1500 |
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
|
1501 |
# Step 2: Build the ordering |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1502 |
# 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
|
1503 |
# 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
|
1504 |
# 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
|
1505 |
# 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
|
1506 |
# built |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1507 |
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
|
1508 |
if not dependencies[r]]) |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1509 |
ordering = [] |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1510 |
while solvablerevs: |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1511 |
rev = solvablerevs.popleft() |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1512 |
for dependent in rdependencies[rev]: |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1513 |
dependencies[dependent].remove(rev) |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1514 |
if not dependencies[dependent]: |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1515 |
solvablerevs.append(dependent) |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1516 |
del dependencies[rev] |
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1517 |
ordering.append(rev) |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1518 |
|
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1519 |
ordering.extend(sorted(dependencies)) |
1357
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1520 |
return ordering |
3bb7a080da4d
evolve: add ordering of the revisions for evolve --rev
Laurent Charignon <lcharignon@fb.com>
parents:
1354
diff
changeset
|
1521 |
|
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1522 |
def divergentsets(repo, ctx): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1523 |
"""Compute sets of commits divergent with a given one""" |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1524 |
cache = {} |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1525 |
succsets = {} |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1526 |
base = {} |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1527 |
for n in obsolete.allprecursors(repo.obsstore, [ctx.node()]): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1528 |
if n == ctx.node(): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1529 |
# 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
|
1530 |
continue |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1531 |
nsuccsets = obsolete.successorssets(repo, n, cache) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1532 |
for nsuccset in nsuccsets: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1533 |
if ctx.node() in nsuccset: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1534 |
# we are only interested in *other* successor sets |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1535 |
continue |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1536 |
if tuple(nsuccset) in base: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1537 |
# we already know the latest base for this divergency |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1538 |
continue |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1539 |
base[tuple(nsuccset)] = n |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1540 |
divergence = [] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1541 |
for divset, b in base.iteritems(): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1542 |
divergence.append({ |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1543 |
'divergentnodes': divset, |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1544 |
'commonprecursor': b |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1545 |
}) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1546 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1547 |
return divergence |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1548 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1549 |
def _preparelistctxs(items, condition): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1550 |
return [item.hex() for item in items if condition(item)] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1551 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1552 |
def _formatctx(fm, ctx): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1553 |
fm.data(node=ctx.hex()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1554 |
fm.data(desc=ctx.description()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1555 |
fm.data(date=ctx.date()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1556 |
fm.data(user=ctx.user()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1557 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1558 |
def listtroubles(ui, repo, troublecategories, **opts): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1559 |
"""Print all the troubles for the repo (or given revset)""" |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1560 |
troublecategories = troublecategories or ['divergent', 'unstable', 'bumped'] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1561 |
showunstable = 'unstable' in troublecategories |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1562 |
showbumped = 'bumped' in troublecategories |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1563 |
showdivergent = 'divergent' in troublecategories |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1564 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1565 |
revs = repo.revs('+'.join("%s()" % t for t in troublecategories)) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1566 |
if opts.get('rev'): |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1567 |
revs = revs & repo.revs(opts.get('rev')) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1568 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1569 |
fm = ui.formatter('evolvelist', opts) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1570 |
for rev in revs: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1571 |
ctx = repo[rev] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1572 |
unpars = _preparelistctxs(ctx.parents(), lambda p: p.unstable()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1573 |
obspars = _preparelistctxs(ctx.parents(), lambda p: p.obsolete()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1574 |
imprecs = _preparelistctxs(repo.set("allprecursors(%n)", ctx.node()), |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1575 |
lambda p: not p.mutable()) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1576 |
dsets = divergentsets(repo, ctx) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1577 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1578 |
fm.startitem() |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1579 |
# plain formatter section |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1580 |
hashlen, desclen = 12, 60 |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1581 |
desc = ctx.description() |
1637
078e6777ac15
list: limit to descriptions to firstline
timeless@gmail.com
parents:
1636
diff
changeset
|
1582 |
if desc: |
078e6777ac15
list: limit to descriptions to firstline
timeless@gmail.com
parents:
1636
diff
changeset
|
1583 |
desc = desc.splitlines()[0] |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1584 |
desc = (desc[:desclen] + '...') if len(desc) > desclen else desc |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1585 |
fm.plain('%s: ' % ctx.hex()[:hashlen]) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1586 |
fm.plain('%s\n' % desc) |
1682
fe4b41a2af4e
evolve: include node, rev, desc, and phase in list
timeless@gmail.com
parents:
1681
diff
changeset
|
1587 |
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
|
1588 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1589 |
for unpar in unpars if showunstable else []: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1590 |
fm.plain(' unstable: %s (unstable parent)\n' % unpar[:hashlen]) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1591 |
for obspar in obspars if showunstable else []: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1592 |
fm.plain(' unstable: %s (obsolete parent)\n' % obspar[:hashlen]) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1593 |
for imprec in imprecs if showbumped else []: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1594 |
fm.plain(' bumped: %s (immutable precursor)\n' % imprec[:hashlen]) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1595 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1596 |
if dsets and showdivergent: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1597 |
for dset in dsets: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1598 |
fm.plain(' divergent: ') |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1599 |
first = True |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1600 |
for n in dset['divergentnodes']: |
1646
7e1b49cda66c
list: report the phase for divergent commits
timeless@gmail.com
parents:
1640
diff
changeset
|
1601 |
t = "%s (%s)" if first else " %s (%s)" |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1602 |
first = False |
1646
7e1b49cda66c
list: report the phase for divergent commits
timeless@gmail.com
parents:
1640
diff
changeset
|
1603 |
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
|
1604 |
comprec = node.hex(dset['commonprecursor'])[:hashlen] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1605 |
fm.plain(" (precursor %s)\n" % comprec) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1606 |
fm.plain("\n") |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1607 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1608 |
# templater-friendly section |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1609 |
_formatctx(fm, ctx) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1610 |
troubles = [] |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1611 |
for unpar in unpars: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1612 |
troubles.append({'troubletype': 'unstable', 'sourcenode': unpar, |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1613 |
'sourcetype': 'unstableparent'}) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1614 |
for obspar in obspars: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1615 |
troubles.append({'troubletype': 'unstable', 'sourcenode': obspar, |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1616 |
'sourcetype': 'obsoleteparent'}) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1617 |
for imprec in imprecs: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1618 |
troubles.append({'troubletype': 'bumped', 'sourcenode': imprec, |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1619 |
'sourcetype': 'immutableprecursor'}) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1620 |
for dset in dsets: |
1681 | 1621 |
divnodes = [{'node': node.hex(n), |
1682
fe4b41a2af4e
evolve: include node, rev, desc, and phase in list
timeless@gmail.com
parents:
1681
diff
changeset
|
1622 |
'phase': repo[n].phasestr(), |
1681 | 1623 |
} for n in dset['divergentnodes']] |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1624 |
troubles.append({'troubletype': 'divergent', |
1681 | 1625 |
'commonprecursor': node.hex(dset['commonprecursor']), |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1626 |
'divergentnodes': divnodes}) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1627 |
fm.data(troubles=troubles) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1628 |
|
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1629 |
fm.end() |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1630 |
|
714
3867f7b1fe6e
evolve: remove duplicate alias.
Levi Bard <levi@unity3d.com>
parents:
710
diff
changeset
|
1631 |
@command('^evolve|stabilize|solve', |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1632 |
[('n', 'dry-run', False, |
1498
3d9a546dcbc5
evolve: annotate translatable strings with _()
timeless@mozdev.org
parents:
1497
diff
changeset
|
1633 |
_('do not perform actions, just print what would be done')), |
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1634 |
('', 'confirm', False, |
1498
3d9a546dcbc5
evolve: annotate translatable strings with _()
timeless@mozdev.org
parents:
1497
diff
changeset
|
1635 |
_('ask for confirmation before performing the action')), |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1636 |
('A', 'any', False, |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1637 |
_('also consider troubled changesets unrelated to current working ' |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1638 |
'directory')), |
1498
3d9a546dcbc5
evolve: annotate translatable strings with _()
timeless@mozdev.org
parents:
1497
diff
changeset
|
1639 |
('r', 'rev', [], _('solves troubles of these revisions')), |
3d9a546dcbc5
evolve: annotate translatable strings with _()
timeless@mozdev.org
parents:
1497
diff
changeset
|
1640 |
('', 'bumped', False, _('solves only bumped changesets')), |
3d9a546dcbc5
evolve: annotate translatable strings with _()
timeless@mozdev.org
parents:
1497
diff
changeset
|
1641 |
('', 'divergent', False, _('solves only divergent changesets')), |
3d9a546dcbc5
evolve: annotate translatable strings with _()
timeless@mozdev.org
parents:
1497
diff
changeset
|
1642 |
('', 'unstable', False, _('solves only unstable changesets (default)')), |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1643 |
('a', 'all', False, _('evolve all troubled changesets related to the ' |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1644 |
'current working directory and its descendants')), |
1498
3d9a546dcbc5
evolve: annotate translatable strings with _()
timeless@mozdev.org
parents:
1497
diff
changeset
|
1645 |
('c', 'continue', False, _('continue an interrupted evolution')), |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1646 |
('l', 'list', False, 'provide details on troubled changesets in the repo'), |
986
c1f8ece4182d
evolve: add --tool option so we don't have to use HGMERGE
Greg Ward <greg@gerg.ca>
parents:
985
diff
changeset
|
1647 |
] + mergetoolopts, |
303 | 1648 |
_('[OPTIONS]...')) |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1649 |
def evolve(ui, repo, **opts): |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1650 |
"""solve troubled changesets in your repository |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1651 |
|
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1652 |
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
|
1653 |
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
|
1654 |
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
|
1655 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1656 |
- update working copy to a successor |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1657 |
- rebase an unstable changeset |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1658 |
- 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
|
1659 |
- fuse divergent changesets back together |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1660 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1661 |
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
|
1662 |
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
|
1663 |
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
|
1664 |
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
|
1665 |
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
|
1666 |
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
|
1667 |
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
|
1668 |
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
|
1669 |
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
|
1670 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1671 |
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
|
1672 |
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
|
1673 |
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
|
1674 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1675 |
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
|
1676 |
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
|
1677 |
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
|
1678 |
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
|
1679 |
request such behavior (see below). |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1680 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1681 |
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
|
1682 |
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
|
1683 |
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
|
1684 |
working copy parent. |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1685 |
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
|
1686 |
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
|
1687 |
evolving all branches. |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1688 |
|
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1689 |
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
|
1690 |
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
|
1691 |
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
|
1692 |
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
|
1693 |
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
|
1694 |
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
|
1695 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1696 |
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
|
1697 |
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
|
1698 |
|
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1699 |
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
|
1700 |
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
|
1701 |
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
|
1702 |
``--rev`` and ``--any``. |
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1703 |
|
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1704 |
``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
|
1705 |
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
|
1706 |
|
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1707 |
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
|
1708 |
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
|
1709 |
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
|
1710 |
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
|
1711 |
(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
|
1712 |
``--rev``, ``--all``, or ``--any``. |
1528
afb0a33c4f6c
evolve: rewrite command help (evolve command only)
Greg Ward <greg@gerg.ca>
parents:
1527
diff
changeset
|
1713 |
|
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1714 |
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
|
1715 |
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
|
1716 |
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
|
1717 |
""" |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1718 |
|
1325
1fe3da0b4601
evolve: add --rev option to the evolve command
Laurent Charignon <lcharignon@fb.com>
parents:
1324
diff
changeset
|
1719 |
# Options |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1720 |
listopt = opts['list'] |
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1721 |
contopt = opts['continue'] |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1722 |
anyopt = opts['any'] |
704 | 1723 |
allopt = opts['all'] |
1318
29363f79514f
evolve: move code to track progress and start node
Laurent Charignon <lcharignon@fb.com>
parents:
1317
diff
changeset
|
1724 |
startnode = repo['.'] |
703
a246b02499d9
evolve: extract evolve --any implementation into a function.
Levi Bard <levi@unity3d.com>
parents:
663
diff
changeset
|
1725 |
dryrunopt = opts['dry_run'] |
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1726 |
confirmopt = opts['confirm'] |
1325
1fe3da0b4601
evolve: add --rev option to the evolve command
Laurent Charignon <lcharignon@fb.com>
parents:
1324
diff
changeset
|
1727 |
revopt = opts['rev'] |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1728 |
troublecategories = ['bumped', 'divergent', 'unstable'] |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1729 |
specifiedcategories = [t for t in troublecategories if opts[t]] |
1634
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1730 |
if listopt: |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1731 |
listtroubles(ui, repo, specifiedcategories, **opts) |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1732 |
return |
9ae4e79a28f3
evolve--list: initial implementation
Kostia Balytskyi <ikostia@fb.com>
parents:
1633
diff
changeset
|
1733 |
|
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1734 |
targetcat = 'unstable' |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1735 |
if 1 < len(specifiedcategories): |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1736 |
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
|
1737 |
raise error.Abort(msg) |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1738 |
elif len(specifiedcategories) == 1: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1739 |
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
|
1740 |
elif repo['.'].obsolete(): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1741 |
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
|
1742 |
{'template': shorttemplate}) |
1409
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1743 |
# 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
|
1744 |
try: |
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1745 |
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
|
1746 |
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
|
1747 |
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
|
1748 |
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
|
1749 |
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
|
1750 |
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
|
1751 |
return 2 |
3276730e4b32
evolve: move the 'update' if '.' is obsolete earlier
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1408
diff
changeset
|
1752 |
|
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1753 |
|
1410
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1754 |
ui.status(_('update:')) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1755 |
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
|
1756 |
displayer.show(ctx) |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1757 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1758 |
if dryrunopt: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1759 |
return 0 |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1760 |
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
|
1761 |
if ctx != startnode: |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1762 |
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
|
1763 |
return res |
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1764 |
|
986
c1f8ece4182d
evolve: add --tool option so we don't have to use HGMERGE
Greg Ward <greg@gerg.ca>
parents:
985
diff
changeset
|
1765 |
ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve') |
1323
603104c880f7
evolve: simplify the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1322
diff
changeset
|
1766 |
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
|
1767 |
|
1318
29363f79514f
evolve: move code to track progress and start node
Laurent Charignon <lcharignon@fb.com>
parents:
1317
diff
changeset
|
1768 |
# Progress handling |
29363f79514f
evolve: move code to track progress and start node
Laurent Charignon <lcharignon@fb.com>
parents:
1317
diff
changeset
|
1769 |
seen = 1 |
1323
603104c880f7
evolve: simplify the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1322
diff
changeset
|
1770 |
count = allopt and len(troubled) or 1 |
1319
8376fe35ebda
evolve: add new variable and comment
Laurent Charignon <lcharignon@fb.com>
parents:
1318
diff
changeset
|
1771 |
showprogress = allopt |
1318
29363f79514f
evolve: move code to track progress and start node
Laurent Charignon <lcharignon@fb.com>
parents:
1317
diff
changeset
|
1772 |
|
29363f79514f
evolve: move code to track progress and start node
Laurent Charignon <lcharignon@fb.com>
parents:
1317
diff
changeset
|
1773 |
def progresscb(): |
1325
1fe3da0b4601
evolve: add --rev option to the evolve command
Laurent Charignon <lcharignon@fb.com>
parents:
1324
diff
changeset
|
1774 |
if revopt or allopt: |
1624
081605c2e9b6
evolve: mark progress units for translation
Anton Shestakov <av6@dwimlabs.net>
parents:
1623
diff
changeset
|
1775 |
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
|
1776 |
|
1319
8376fe35ebda
evolve: add new variable and comment
Laurent Charignon <lcharignon@fb.com>
parents:
1318
diff
changeset
|
1777 |
# Continuation handling |
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1778 |
if contopt: |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1779 |
if anyopt: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1780 |
raise error.Abort('cannot specify both "--any" and "--continue"') |
704 | 1781 |
if allopt: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1782 |
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
|
1783 |
state = _evolvestateread(repo) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1784 |
if state is None: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1785 |
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
|
1786 |
orig = repo[state['current']] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1787 |
# 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
|
1788 |
lock = repo.wlock() |
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1789 |
try: |
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
|
1790 |
repo.opener.write('graftstate', orig.hex() + '\n') |
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
|
1791 |
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
|
1792 |
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
|
1793 |
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
|
1794 |
_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
|
1795 |
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
|
1796 |
finally: |
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
|
1797 |
util.unlinkpath(repo.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
|
1798 |
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
|
1799 |
lock.release() |
1402
08ae023882f1
evolve: check for uncommited change earlier
Laurent Charignon <lcharignon@fb.com>
parents:
1398
diff
changeset
|
1800 |
cmdutil.bailifchanged(repo) |
08ae023882f1
evolve: check for uncommited change earlier
Laurent Charignon <lcharignon@fb.com>
parents:
1398
diff
changeset
|
1801 |
|
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1802 |
|
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1803 |
if revopt and allopt: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1804 |
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
|
1805 |
if revopt and anyopt: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1806 |
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
|
1807 |
|
2c451fece7a6
evolve: unify revision handling and rework error message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1409
diff
changeset
|
1808 |
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
|
1809 |
|
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1810 |
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
|
1811 |
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
|
1812 |
|
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1813 |
# For the progress bar to show |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1814 |
count = len(revs) |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1815 |
# Order the revisions |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1816 |
if targetcat == 'unstable': |
1411
64515965c0df
evolve: some style fix
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1410
diff
changeset
|
1817 |
revs = _orderrevs(repo, revs) |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1818 |
for rev in revs: |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1819 |
progresscb() |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1820 |
_solveone(ui, repo, repo[rev], dryrunopt, confirmopt, |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1821 |
progresscb, targetcat) |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1822 |
seen += 1 |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1823 |
progresscb() |
1324
739208d1ee62
evolve: extract cleanup logic in the evolve function
Laurent Charignon <lcharignon@fb.com>
parents:
1323
diff
changeset
|
1824 |
_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
|
1825 |
|
1421
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1826 |
def _possibledestination(repo, rev): |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1827 |
"""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
|
1828 |
tonode = repo.changelog.node |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1829 |
parents = repo.changelog.parentrevs |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1830 |
torev = repo.changelog.rev |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1831 |
dest = set() |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1832 |
tovisit = list(parents(rev)) |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1833 |
while tovisit: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1834 |
r = tovisit.pop() |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1835 |
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
|
1836 |
if not succsets: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1837 |
tovisit.extend(parents(r)) |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1838 |
else: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1839 |
# 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
|
1840 |
# (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
|
1841 |
# 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
|
1842 |
# multiple branches. |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1843 |
for ss in succsets: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1844 |
for n in ss: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1845 |
dest.add(torev(n)) |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1846 |
return dest |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1847 |
|
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1848 |
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
|
1849 |
"""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
|
1850 |
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
|
1851 |
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
|
1852 |
result = [] |
1421
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1853 |
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
|
1854 |
dest = _possibledestination(repo, r) |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1855 |
if target & dest: |
8f18c7b3af14
rework refactor _aspiringchildren by introducing _possibledestination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1420
diff
changeset
|
1856 |
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
|
1857 |
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
|
1858 |
|
1422
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1859 |
def _aspiringdescendant(repo, revs): |
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1860 |
"""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
|
1861 |
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
|
1862 |
target = set(revs) |
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1863 |
result = set(target) |
1423
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1864 |
paths = collections.defaultdict(set) |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1865 |
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
|
1866 |
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
|
1867 |
paths[d].add(r) |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1868 |
|
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1869 |
result = set(target) |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1870 |
tovisit = list(revs) |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1871 |
while tovisit: |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1872 |
base = tovisit.pop() |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1873 |
for unstable in paths[base]: |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1874 |
if unstable not in result: |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1875 |
tovisit.append(unstable) |
ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1422
diff
changeset
|
1876 |
result.add(unstable) |
1422
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1877 |
return sorted(result - target) |
c868a69c29c5
evolve: distinct between '--all' and '--all --any'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1421
diff
changeset
|
1878 |
|
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1879 |
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
|
1880 |
progresscb=None): |
1569
bd1468c23d88
evolve: scattered typo fixes in comments, docstrings
Greg Ward <greg@gerg.ca>
parents:
1528
diff
changeset
|
1881 |
"""Stabilize an unstable changeset""" |
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1882 |
pctx = orig.p1() |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1883 |
if len(orig.parents()) == 2: |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1884 |
if not pctx.obsolete(): |
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1885 |
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
|
1886 |
elif orig.p2().obsolete(): |
1639 | 1887 |
hint = _("Redo the merge (%s) and use `hg prune <old> " |
1888 |
"--succ <new>` to obsolete the old one") % orig.hex()[:12] |
|
1638 | 1889 |
ui.warn(_("warning: no support for evolving merge changesets " |
1890 |
"with two obsolete parents yet\n") + |
|
1891 |
_("(%s)\n") % hint) |
|
1892 |
return False |
|
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1893 |
|
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1894 |
if not pctx.obsolete(): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1895 |
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
|
1896 |
return False |
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1897 |
obs = pctx |
630
722b52c75f02
compat: adapt to upstreaming of divergent logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
622
diff
changeset
|
1898 |
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
|
1899 |
# 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
|
1900 |
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
|
1901 |
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
|
1902 |
" 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
|
1903 |
obs) |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1904 |
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
|
1905 |
newer = obsolete.successorssets(repo, obs.node()) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1906 |
if len(newer) > 1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1907 |
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
|
1908 |
"destination\n") % obs |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1909 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1910 |
return 2 |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1911 |
targets = newer[0] |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1912 |
assert targets |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1913 |
if len(targets) > 1: |
1481
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1914 |
# 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
|
1915 |
targetrevs = [repo[r].rev() for r in targets] |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1916 |
roots = repo.revs('roots(%ld)', targetrevs) |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1917 |
heads = repo.revs('heads(%ld)', targetrevs) |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1918 |
if len(roots) > 1 or len(heads) > 1: |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1919 |
msg = "cannot solve split accross two branches\n" |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1920 |
ui.write_err(msg) |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1921 |
return 2 |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1922 |
target = repo[heads.first()] |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1923 |
else: |
3c0aebe73482
evolve: handle split commit for instability
Laurent Charignon <lcharignon@fb.com>
parents:
1478
diff
changeset
|
1924 |
target = targets[0] |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1925 |
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
|
1926 |
target = repo[target] |
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1927 |
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
|
1928 |
repo.ui.write(_('move:')) |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
1929 |
displayer.show(orig) |
1046
296d48e1f55a
evolve: gather evolve output together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1045
diff
changeset
|
1930 |
repo.ui.write(_('atop:')) |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
1931 |
displayer.show(target) |
1390
03f202bed47f
evolve: fix default value for --confirm
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1389
diff
changeset
|
1932 |
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
|
1933 |
raise error.Abort(_('evolve aborted by user')) |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1934 |
if progresscb: progresscb() |
546
415540dee2bd
fix missing --dest evolve output in dryrun
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
540
diff
changeset
|
1935 |
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
|
1936 |
if dryrun: |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
1937 |
repo.ui.write(todo) |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1938 |
else: |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1939 |
repo.ui.note(todo) |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1940 |
if progresscb: progresscb() |
1141
ca17770d2ee9
evolve: preserve branch change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1140
diff
changeset
|
1941 |
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
|
1942 |
try: |
1576
526253198860
evolve: handle merge commit with single obsolete parent (issue4389)
Andrew Halberstadt <ahalberstadt@mozilla.com>
parents:
1575
diff
changeset
|
1943 |
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
|
1944 |
except MergeFailure: |
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
1945 |
_evolvestatewrite(repo, {'current': orig.node()}) |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1946 |
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
|
1947 |
repo.ui.write_err( |
1395
362e2c8c5677
evolve: add a hint about how to abort an evolve with conflict
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1392
diff
changeset
|
1948 |
_('fix conflict and run "hg evolve --continue"' |
362e2c8c5677
evolve: add a hint about how to abort an evolve with conflict
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1392
diff
changeset
|
1949 |
' 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
|
1950 |
raise |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1951 |
|
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
1952 |
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
|
1953 |
progresscb=None): |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1954 |
"""Stabilize a bumped changeset""" |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1955 |
repo = repo.unfiltered() |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
1956 |
bumped = repo[bumped.rev()] |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1957 |
# For now we deny bumped merge |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1958 |
if len(bumped.parents()) > 1: |
1496 | 1959 |
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
|
1960 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1961 |
return 2 |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1962 |
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
|
1963 |
# For now we deny target merge |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1964 |
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
|
1965 |
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
|
1966 |
'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
|
1967 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
1968 |
return 2 |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1969 |
|
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1970 |
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
|
1971 |
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
|
1972 |
repo.ui.write(_('recreate:')) |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1973 |
displayer.show(bumped) |
1046
296d48e1f55a
evolve: gather evolve output together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1045
diff
changeset
|
1974 |
repo.ui.write(_('atop:')) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1975 |
displayer.show(prec) |
1390
03f202bed47f
evolve: fix default value for --confirm
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1389
diff
changeset
|
1976 |
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
|
1977 |
raise error.Abort(_('evolve aborted by user')) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1978 |
if dryrun: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1979 |
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
|
1980 |
repo.ui.write(todo) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
1981 |
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
|
1982 |
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
|
1983 |
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
|
1984 |
return 0 |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1985 |
if progresscb: progresscb() |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1986 |
newid = tmpctx = None |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1987 |
tmpctx = bumped |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
1988 |
# 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
|
1989 |
tr = repo.currenttransaction() |
2f117c299325
evolve: remove meaningless transaction nesting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1592
diff
changeset
|
1990 |
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
|
1991 |
bmupdate = _bookmarksupdater(repo, bumped.node(), tr) |
1729
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1992 |
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
|
1993 |
# 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
|
1994 |
repo.ui.status( |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1995 |
_('rebasing to destination parent: %s\n') % prec.p1()) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1996 |
try: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1997 |
tmpid = relocate(repo, bumped, prec.p1()) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1998 |
if tmpid is not None: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
1999 |
tmpctx = repo[tmpid] |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2000 |
obsolete.createmarkers(repo, [(bumped, (tmpctx,))]) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2001 |
except MergeFailure: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2002 |
repo.opener.write('graftstate', bumped.hex() + '\n') |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2003 |
repo.ui.write_err(_('evolution failed!\n')) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2004 |
repo.ui.write_err( |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2005 |
_('fix conflict and run "hg evolve --continue"\n')) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2006 |
raise |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2007 |
# Create the new commit context |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2008 |
repo.ui.status(_('computing new diff\n')) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2009 |
files = set() |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2010 |
copied = copies.pathcopies(prec, bumped) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2011 |
precmanifest = prec.manifest() |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2012 |
# 3.3.2 needs a list. |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2013 |
# 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
|
2014 |
# this is fishy |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2015 |
for key, val in list(bumped.manifest().iteritems()): |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2016 |
precvalue = precmanifest.get(key, None) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2017 |
if precvalue is not None: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2018 |
del precmanifest[key] |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2019 |
if precvalue != val: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2020 |
files.add(key) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2021 |
files.update(precmanifest) # add missing files |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2022 |
# commit it |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2023 |
if files: # something to commit! |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2024 |
def filectxfn(repo, ctx, path): |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2025 |
if path in bumped: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2026 |
fctx = bumped[path] |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2027 |
flags = fctx.flags() |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2028 |
mctx = memfilectx(repo, fctx.path(), fctx.data(), |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2029 |
islink='l' in flags, |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2030 |
isexec='x' in flags, |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2031 |
copied=copied.get(path)) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2032 |
return mctx |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2033 |
return None |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2034 |
text = 'bumped update to %s:\n\n' % prec |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2035 |
text += bumped.description() |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2036 |
|
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2037 |
new = context.memctx(repo, |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2038 |
parents=[prec.node(), node.nullid], |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2039 |
text=text, |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2040 |
files=files, |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2041 |
filectxfn=filectxfn, |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2042 |
user=bumped.user(), |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2043 |
date=bumped.date(), |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2044 |
extra=bumped.extra()) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2045 |
|
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2046 |
newid = repo.commitctx(new) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2047 |
if newid is None: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2048 |
obsolete.createmarkers(repo, [(tmpctx, ())]) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2049 |
newid = prec.node() |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2050 |
else: |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2051 |
phases.retractboundary(repo, tr, bumped.phase(), [newid]) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2052 |
obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))], |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2053 |
flag=obsolete.bumpedfix) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2054 |
bmupdate(newid) |
8ed0266c58a3
evolve: removed redundant try/finally blocks
Pulkit Goyal <7895pulkit@gmail.com>
parents:
1726
diff
changeset
|
2055 |
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
|
2056 |
# 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
|
2057 |
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
|
2058 |
repo.dirstate.setparents(newid, node.nullid) |
1112
c3e23fbf7bd7
evolve: wrap setparents calls in begin/endparentchange
Siddharth Agarwal <sid0@fb.com>
parents:
1111
diff
changeset
|
2059 |
repo.dirstate.endparentchange() |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
2060 |
|
1047
d830377bf186
evolve: adds a --confirm option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1046
diff
changeset
|
2061 |
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
|
2062 |
progresscb=None): |
1404
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
2063 |
repo = repo.unfiltered() |
848a04c078c7
evolve: add selector for trouble types
Laurent Charignon <lcharignon@fb.com>
parents:
1403
diff
changeset
|
2064 |
divergent = repo[divergent.rev()] |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
2065 |
base, others = divergentdata(divergent) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2066 |
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
|
2067 |
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
|
2068 |
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
|
2069 |
" into multiple ones:\n" |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2070 |
"|[%s]\n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2071 |
"| This is not handled by automatic evolution yet\n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2072 |
"| You have to fallback to manual handling with commands " |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2073 |
"such as:\n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2074 |
"| - hg touch -D\n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2075 |
"| - hg prune\n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2076 |
"| \n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2077 |
"| You should contact your local evolution Guru for help.\n" |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2078 |
) % (divergent, othersstr) |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2079 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2080 |
return 2 |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2081 |
other = others[0] |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2082 |
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
|
2083 |
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
|
2084 |
"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
|
2085 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2086 |
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
|
2087 |
"| 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
|
2088 |
"| `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
|
2089 |
ui.write_err(hint) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2090 |
return 2 |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
2091 |
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
|
2092 |
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
|
2093 |
"(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
|
2094 |
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
|
2095 |
"| 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
|
2096 |
"| 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
|
2097 |
"| 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
|
2098 |
"| this command again.\n" |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2099 |
"| - 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
|
2100 |
"| - 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
|
2101 |
) % {'d': divergent, 'o': other} |
1412
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2102 |
ui.write_err(msg) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2103 |
ui.write_err(hint) |
8794a4680bdd
evolve: warn about every skipped evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1411
diff
changeset
|
2104 |
return 2 |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2105 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2106 |
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
|
2107 |
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
|
2108 |
ui.write(_('merge:')) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
2109 |
displayer.show(divergent) |
1046
296d48e1f55a
evolve: gather evolve output together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1045
diff
changeset
|
2110 |
ui.write(_('with: ')) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2111 |
displayer.show(other) |
1046
296d48e1f55a
evolve: gather evolve output together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1045
diff
changeset
|
2112 |
ui.write(_('base: ')) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2113 |
displayer.show(base) |
1498
3d9a546dcbc5
evolve: annotate translatable strings with _()
timeless@mozdev.org
parents:
1497
diff
changeset
|
2114 |
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
|
2115 |
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
|
2116 |
if dryrun: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2117 |
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
|
2118 |
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
|
2119 |
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
|
2120 |
'%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
|
2121 |
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
|
2122 |
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
|
2123 |
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
|
2124 |
% divergent)) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2125 |
return |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2126 |
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
|
2127 |
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
|
2128 |
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
|
2129 |
repo.ui.note(_('merging divergent changeset\n')) |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2130 |
if progresscb: progresscb() |
1632
498329a3c900
evolve: Fix crash when reading docstring
Juntao Li <juntaoli@fb.com>
parents:
1622
diff
changeset
|
2131 |
try: |
498329a3c900
evolve: Fix crash when reading docstring
Juntao Li <juntaoli@fb.com>
parents:
1622
diff
changeset
|
2132 |
stats = merge.update(repo, |
498329a3c900
evolve: Fix crash when reading docstring
Juntao Li <juntaoli@fb.com>
parents:
1622
diff
changeset
|
2133 |
other.node(), |
498329a3c900
evolve: Fix crash when reading docstring
Juntao Li <juntaoli@fb.com>
parents:
1622
diff
changeset
|
2134 |
branchmerge=True, |
498329a3c900
evolve: Fix crash when reading docstring
Juntao Li <juntaoli@fb.com>
parents:
1622
diff
changeset
|
2135 |
force=False, |
498329a3c900
evolve: Fix crash when reading docstring
Juntao Li <juntaoli@fb.com>
parents:
1622
diff
changeset
|
2136 |
ancestor=base.node(), |
498329a3c900
evolve: Fix crash when reading docstring
Juntao Li <juntaoli@fb.com>
parents:
1622
diff
changeset
|
2137 |
mergeancestor=True) |
498329a3c900
evolve: Fix crash when reading docstring
Juntao Li <juntaoli@fb.com>
parents:
1622
diff
changeset
|
2138 |
except TypeError: |
1566
25254b2f8116
evolve: apply API change to 'merge.update'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1564
diff
changeset
|
2139 |
# Mercurial < 43c00ca887d1 (3.7) |
25254b2f8116
evolve: apply API change to 'merge.update'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1564
diff
changeset
|
2140 |
stats = merge.update(repo, |
25254b2f8116
evolve: apply API change to 'merge.update'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1564
diff
changeset
|
2141 |
other.node(), |
25254b2f8116
evolve: apply API change to 'merge.update'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1564
diff
changeset
|
2142 |
branchmerge=True, |
25254b2f8116
evolve: apply API change to 'merge.update'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1564
diff
changeset
|
2143 |
force=False, |
25254b2f8116
evolve: apply API change to 'merge.update'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1564
diff
changeset
|
2144 |
partial=None, |
25254b2f8116
evolve: apply API change to 'merge.update'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1564
diff
changeset
|
2145 |
ancestor=base.node(), |
25254b2f8116
evolve: apply API change to 'merge.update'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1564
diff
changeset
|
2146 |
mergeancestor=True) |
25254b2f8116
evolve: apply API change to 'merge.update'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1564
diff
changeset
|
2147 |
|
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2148 |
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
|
2149 |
if stats[3]: |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2150 |
repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2151 |
"or 'hg update -C .' to abandon\n")) |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2152 |
if stats[3] > 0: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2153 |
raise error.Abort('merge conflict between several amendments ' |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2154 |
'(this is not automated yet)', |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2155 |
hint="""/!\ You can try: |
534
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
2156 |
/!\ * manual merge + resolve => new cset X |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
2157 |
/!\ * 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
|
2158 |
/!\ * hg revert --all -r X |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
2159 |
/!\ * 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
|
2160 |
/!\ * 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
|
2161 |
""") |
1021
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2162 |
if progresscb: progresscb() |
1536
9afe9e0191a1
evolve: evolve --divergent failed when merge had nothing to do (issue4950)
Laurent Charignon <lcharignon@fb.com>
parents:
1532
diff
changeset
|
2163 |
emtpycommitallowed = repo.ui.backupconfig('ui', 'allowemptycommit') |
1593
2f117c299325
evolve: remove meaningless transaction nesting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1592
diff
changeset
|
2164 |
tr = repo.currenttransaction() |
2f117c299325
evolve: remove meaningless transaction nesting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1592
diff
changeset
|
2165 |
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
|
2166 |
try: |
1636
13f830540a14
config: report evolve as origin for config
timeless@gmail.com
parents:
1635
diff
changeset
|
2167 |
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
|
2168 |
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
|
2169 |
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
|
2170 |
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
|
2171 |
oldlen = len(repo) |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2172 |
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
|
2173 |
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
|
2174 |
new = divergent |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2175 |
# no changes |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2176 |
else: |
200f2d9b9f39
evolve: saner locking an transaction in `hg evolve`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1020
diff
changeset
|
2177 |
new = repo['.'] |
1070
527b12a59628
drop relevant marker compat
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1069
diff
changeset
|
2178 |
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
|
2179 |
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
|
2180 |
finally: |
1536
9afe9e0191a1
evolve: evolve --divergent failed when merge had nothing to do (issue4950)
Laurent Charignon <lcharignon@fb.com>
parents:
1532
diff
changeset
|
2181 |
repo.ui.restoreconfig(emtpycommitallowed) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2182 |
|
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
2183 |
def divergentdata(ctx): |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2184 |
"""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
|
2185 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2186 |
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
|
2187 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2188 |
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
|
2189 |
""" |
1375
9e062e6598e9
evolve: search divergence within all precursors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1374
diff
changeset
|
2190 |
repo = ctx._repo.unfiltered() |
9e062e6598e9
evolve: search divergence within all precursors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1374
diff
changeset
|
2191 |
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
|
2192 |
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
|
2193 |
# 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
|
2194 |
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
|
2195 |
if newer: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2196 |
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
|
2197 |
raise error.Abort("base of divergent changeset %s not found" % ctx, |
749
f728edc7fcd1
evolve: abort on unknown divergent changeset base
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
745
diff
changeset
|
2198 |
hint='this case is not yet handled') |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2199 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
2200 |
|
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
2201 |
|
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
|
2202 |
shorttemplate = '[{rev}] {desc|firstline}\n' |
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
|
2203 |
|
895
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
2204 |
@command('^previous', |
1160
e29a813f6af5
Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents:
1157
diff
changeset
|
2205 |
[('B', 'move-bookmark', False, |
1497
cebe06c16837
evolve: do not capitalize description of next/previous
timeless@mozdev.org
parents:
1496
diff
changeset
|
2206 |
_('move active bookmark after update')), |
1500 | 2207 |
('', 'merge', False, _('bring uncommitted change along')), |
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
|
2208 |
('', 'no-topic', False, _('ignore topic and move topologically')), |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2209 |
('n', 'dry-run', False, |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2210 |
_('do not perform actions, just print what would be done'))], |
1500 | 2211 |
'[OPTION]...') |
1160
e29a813f6af5
Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents:
1157
diff
changeset
|
2212 |
def cmdprevious(ui, repo, **opts): |
1572
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
2213 |
"""update to parent revision |
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
2214 |
|
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
2215 |
Displays the summary line of the destination for clarity.""" |
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
|
2216 |
wkctx = repo[None] |
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
|
2217 |
wparents = wkctx.parents() |
1500 | 2218 |
dryrunopt = opts['dry_run'] |
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
|
2219 |
if len(wparents) != 1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2220 |
raise error.Abort('merge in progress') |
1427
fcc467ca740e
next/prev: require --merge to move with uncommitted changes
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1426
diff
changeset
|
2221 |
if not opts['merge']: |
fcc467ca740e
next/prev: require --merge to move with uncommitted changes
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1426
diff
changeset
|
2222 |
try: |
fcc467ca740e
next/prev: require --merge to move with uncommitted changes
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1426
diff
changeset
|
2223 |
cmdutil.bailifchanged(repo) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2224 |
except error.Abort as exc: |
1427
fcc467ca740e
next/prev: require --merge to move with uncommitted changes
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1426
diff
changeset
|
2225 |
exc.hint = _('do you want --merge?') |
fcc467ca740e
next/prev: require --merge to move with uncommitted changes
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1426
diff
changeset
|
2226 |
raise |
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
|
2227 |
|
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
|
2228 |
parents = wparents[0].parents() |
1629
548195454683
topic: restrict 'hg prev' to current topic unless --no-topic is passed
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1628
diff
changeset
|
2229 |
topic = getattr(repo, 'currenttopic', '') |
548195454683
topic: restrict 'hg prev' to current topic unless --no-topic is passed
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1628
diff
changeset
|
2230 |
if topic and not opts.get("no_topic", False): |
548195454683
topic: restrict 'hg prev' to current topic unless --no-topic is passed
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1628
diff
changeset
|
2231 |
parents = [ctx for ctx in parents if ctx.topic() == topic] |
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
|
2232 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
1629
548195454683
topic: restrict 'hg prev' to current topic unless --no-topic is passed
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1628
diff
changeset
|
2233 |
if not parents: |
548195454683
topic: restrict 'hg prev' to current topic unless --no-topic is passed
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1628
diff
changeset
|
2234 |
ui.warn(_('no parent in topic "%s"\n') % topic) |
548195454683
topic: restrict 'hg prev' to current topic unless --no-topic is passed
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1628
diff
changeset
|
2235 |
ui.warn(_('(do you want --no-topic)\n')) |
548195454683
topic: restrict 'hg prev' to current topic unless --no-topic is passed
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1628
diff
changeset
|
2236 |
elif len(parents) == 1: |
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
|
2237 |
p = parents[0] |
1330
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
2238 |
bm = bmactive(repo) |
1160
e29a813f6af5
Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents:
1157
diff
changeset
|
2239 |
shouldmove = opts.get('move_bookmark') and bm is not None |
1500 | 2240 |
if dryrunopt: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2241 |
ui.write(('hg update %s;\n' % p.rev())) |
1160
e29a813f6af5
Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents:
1157
diff
changeset
|
2242 |
if shouldmove: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2243 |
ui.write(('hg bookmark %s -r %s;\n' % (bm, p.rev()))) |
1500 | 2244 |
else: |
2245 |
ret = hg.update(repo, p.rev()) |
|
2246 |
if not ret: |
|
1556
4f008b8acda7
previous: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1555
diff
changeset
|
2247 |
tr = lock = None |
1502
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2248 |
wlock = repo.wlock() |
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2249 |
try: |
1556
4f008b8acda7
previous: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1555
diff
changeset
|
2250 |
lock = repo.lock() |
4f008b8acda7
previous: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1555
diff
changeset
|
2251 |
tr = repo.transaction('previous') |
1502
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2252 |
if shouldmove: |
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2253 |
repo._bookmarks[bm] = p.node() |
1556
4f008b8acda7
previous: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1555
diff
changeset
|
2254 |
repo._bookmarks.recordchange(tr) |
1502
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2255 |
else: |
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2256 |
bmdeactivate(repo) |
1556
4f008b8acda7
previous: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1555
diff
changeset
|
2257 |
tr.close() |
1502
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2258 |
finally: |
1556
4f008b8acda7
previous: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1555
diff
changeset
|
2259 |
lockmod.release(tr, lock, 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
|
2260 |
displayer.show(p) |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
2261 |
return 0 |
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
|
2262 |
else: |
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
|
2263 |
for p in parents: |
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
|
2264 |
displayer.show(p) |
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
|
2265 |
ui.warn(_('multiple parents, explicitly update to one\n')) |
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
|
2266 |
return 1 |
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
|
2267 |
|
895
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
2268 |
@command('^next', |
1160
e29a813f6af5
Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents:
1157
diff
changeset
|
2269 |
[('B', 'move-bookmark', False, |
1497
cebe06c16837
evolve: do not capitalize description of next/previous
timeless@mozdev.org
parents:
1496
diff
changeset
|
2270 |
_('move active bookmark after update')), |
1499 | 2271 |
('', 'merge', False, _('bring uncommitted change along')), |
1500 | 2272 |
('', 'evolve', False, _('evolve the next changeset if necessary')), |
1629
548195454683
topic: restrict 'hg prev' to current topic unless --no-topic is passed
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1628
diff
changeset
|
2273 |
('', 'no-topic', False, _('ignore topic and move topologically')), |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2274 |
('n', 'dry-run', False, |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2275 |
_('do not perform actions, just print what would be done'))], |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2276 |
'[OPTION]...') |
1160
e29a813f6af5
Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents:
1157
diff
changeset
|
2277 |
def cmdnext(ui, repo, **opts): |
1572
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
2278 |
"""update to next child revision |
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
2279 |
|
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
2280 |
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
|
2281 |
|
44e9c0a264de
evolve: improve help for prev, next commands
Greg Ward <greg@gerg.ca>
parents:
1571
diff
changeset
|
2282 |
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
|
2283 |
""" |
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
|
2284 |
wkctx = repo[None] |
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
|
2285 |
wparents = wkctx.parents() |
1500 | 2286 |
dryrunopt = opts['dry_run'] |
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
|
2287 |
if len(wparents) != 1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2288 |
raise error.Abort('merge in progress') |
1427
fcc467ca740e
next/prev: require --merge to move with uncommitted changes
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1426
diff
changeset
|
2289 |
if not opts['merge']: |
fcc467ca740e
next/prev: require --merge to move with uncommitted changes
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1426
diff
changeset
|
2290 |
try: |
fcc467ca740e
next/prev: require --merge to move with uncommitted changes
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1426
diff
changeset
|
2291 |
cmdutil.bailifchanged(repo) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2292 |
except error.Abort as exc: |
1427
fcc467ca740e
next/prev: require --merge to move with uncommitted changes
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1426
diff
changeset
|
2293 |
exc.hint = _('do you want --merge?') |
fcc467ca740e
next/prev: require --merge to move with uncommitted changes
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1426
diff
changeset
|
2294 |
raise |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
82
diff
changeset
|
2295 |
|
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
|
2296 |
children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()] |
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
|
2297 |
topic = getattr(repo, 'currenttopic', '') |
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
|
2298 |
filtered = [] |
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
|
2299 |
if topic and not opts.get("no_topic", False): |
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
|
2300 |
filtered = [ctx for ctx in children if ctx.topic() != topic] |
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
|
2301 |
# XXX N-square membership on children |
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
|
2302 |
children = [ctx for ctx in children if ctx not in filtered] |
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
|
2303 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
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
|
2304 |
if len(children) == 1: |
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
|
2305 |
c = children[0] |
1330
efb75f4d55aa
bookmarks: update to use new bookmarks api via compatibility layer
Ryan McElroy <rmcelroy@fb.com>
parents:
1311
diff
changeset
|
2306 |
bm = bmactive(repo) |
1160
e29a813f6af5
Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents:
1157
diff
changeset
|
2307 |
shouldmove = opts.get('move_bookmark') and bm is not None |
1500 | 2308 |
if dryrunopt: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2309 |
ui.write(('hg update %s;\n' % c.rev())) |
1160
e29a813f6af5
Make next/prev only move bookmarks optionally
Ryan McElroy <rmcelroy@fb.com>
parents:
1157
diff
changeset
|
2310 |
if shouldmove: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2311 |
ui.write(('hg bookmark %s -r %s;\n' % (bm, c.rev()))) |
1500 | 2312 |
else: |
2313 |
ret = hg.update(repo, c.rev()) |
|
2314 |
if not ret: |
|
1557
e72f83f09bdc
next: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1556
diff
changeset
|
2315 |
lock = tr = None |
1502
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2316 |
wlock = repo.wlock() |
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2317 |
try: |
1557
e72f83f09bdc
next: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1556
diff
changeset
|
2318 |
lock = repo.lock() |
e72f83f09bdc
next: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1556
diff
changeset
|
2319 |
tr = repo.transaction('next') |
1502
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2320 |
if shouldmove: |
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2321 |
repo._bookmarks[bm] = c.node() |
1557
e72f83f09bdc
next: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1556
diff
changeset
|
2322 |
repo._bookmarks.recordchange(tr) |
1502
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2323 |
else: |
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2324 |
bmdeactivate(repo) |
1557
e72f83f09bdc
next: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1556
diff
changeset
|
2325 |
tr.close() |
1502
094b54a72c1d
next/prev: properly lock repo before touching bookmarks
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1500
diff
changeset
|
2326 |
finally: |
1557
e72f83f09bdc
next: replace call to bookmarks.write by bookmarks.recordchange
Laurent Charignon <lcharignon@fb.com>
parents:
1556
diff
changeset
|
2327 |
lockmod.release(tr, lock, 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
|
2328 |
displayer.show(c) |
1446
a73d1ee48003
next: refactor the command code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1443
diff
changeset
|
2329 |
result = 0 |
a73d1ee48003
next: refactor the command code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1443
diff
changeset
|
2330 |
elif children: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2331 |
ui.warn(_("ambigious next changeset:\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
|
2332 |
for c in children: |
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
|
2333 |
displayer.show(c) |
1447
09206bdc2db4
next: reword error output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1446
diff
changeset
|
2334 |
ui.warn(_('explicitly update to one of them\n')) |
1446
a73d1ee48003
next: refactor the command code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1443
diff
changeset
|
2335 |
result = 1 |
a73d1ee48003
next: refactor the command code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1443
diff
changeset
|
2336 |
else: |
1448
3c113c097339
next: print some message when on a head with some aspiring children
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1447
diff
changeset
|
2337 |
aspchildren = _aspiringchildren(repo, [repo['.'].rev()]) |
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
|
2338 |
if topic: |
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
|
2339 |
filtered.extend(repo[c] for c in children |
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
|
2340 |
if repo[c].topic() != topic) |
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
|
2341 |
# XXX N-square membership on children |
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
|
2342 |
aspchildren = [ctx for ctx in aspchildren if ctx not in filtered] |
1487
ee5391999f2d
next: properly report no children when --evolve is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1469
diff
changeset
|
2343 |
if not opts['evolve'] or not aspchildren: |
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
|
2344 |
if filtered: |
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
|
2345 |
ui.warn(_('no children on topic "%s"\n') % topic) |
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
|
2346 |
ui.warn(_('do you want --no-topic\n')) |
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
|
2347 |
else: |
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
|
2348 |
ui.warn(_('no children\n')) |
1449
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2349 |
if aspchildren: |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2350 |
msg = _('(%i unstable changesets to be evolved here, ' |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2351 |
'do you want --evolve?)\n') |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2352 |
ui.warn(msg % len(aspchildren)) |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2353 |
result = 1 |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2354 |
elif 1 < len(aspchildren): |
1498
3d9a546dcbc5
evolve: annotate translatable strings with _()
timeless@mozdev.org
parents:
1497
diff
changeset
|
2355 |
ui.warn(_("ambigious next (unstable) changeset:\n")) |
1449
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2356 |
for c in aspchildren: |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2357 |
displayer.show(repo[c]) |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2358 |
ui.warn(_('(run "hg evolve --rev REV" on one of them)\n')) |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2359 |
return 1 |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2360 |
else: |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2361 |
cmdutil.bailifchanged(repo) |
1500 | 2362 |
result = _solveone(ui, repo, repo[aspchildren[0]], dryrunopt, |
1449
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2363 |
False, lambda:None, category='unstable') |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2364 |
if not result: |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2365 |
ui.status(_('working directory now at %s\n') % repo['.']) |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2366 |
return result |
9be1cadf7a07
next: add a --evolve option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1448
diff
changeset
|
2367 |
return 1 |
1446
a73d1ee48003
next: refactor the command code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1443
diff
changeset
|
2368 |
return result |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
82
diff
changeset
|
2369 |
|
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2370 |
def _reachablefrombookmark(repo, revs, bookmarks): |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2371 |
"""filter revisions and bookmarks reachable from the given bookmark |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2372 |
yoinked from mq.py |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2373 |
""" |
1561
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
2374 |
repomarks = repo._bookmarks |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2375 |
if not bookmarks.issubset(repomarks): |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2376 |
raise error.Abort(_("bookmark '%s' not found") % |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2377 |
','.join(sorted(bookmarks - set(repomarks.keys())))) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2378 |
|
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2379 |
# 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
|
2380 |
# 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
|
2381 |
# anything. revsets cannot detect that case. |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2382 |
nodetobookmarks = {} |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2383 |
for mark, node in repomarks.iteritems(): |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2384 |
nodetobookmarks.setdefault(node, []).append(mark) |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2385 |
for marks in nodetobookmarks.values(): |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2386 |
if bookmarks.issuperset(marks): |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2387 |
if util.safehasattr(repair, 'stripbmrevset'): |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2388 |
rsrevs = repair.stripbmrevset(repo, marks[0]) |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2389 |
else: |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2390 |
rsrevs = repo.revs("ancestors(bookmark(%s)) - " |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2391 |
"ancestors(head() and not bookmark(%s)) - " |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2392 |
"ancestors(bookmark() and not bookmark(%s)) - " |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2393 |
"obsolete()", |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2394 |
marks[0], marks[0], marks[0]) |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2395 |
revs = set(revs) |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2396 |
revs.update(set(rsrevs)) |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2397 |
revs = sorted(revs) |
1561
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
2398 |
return repomarks, revs |
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
2399 |
|
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2400 |
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
|
2401 |
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
|
2402 |
try: |
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2403 |
wlock = repo.wlock() |
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2404 |
lock = repo.lock() |
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2405 |
tr = repo.transaction('prune') |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2406 |
for bookmark in bookmarks: |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2407 |
del repomarks[bookmark] |
1561
dbf1532ee868
evolve: renaming local variables
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1558
diff
changeset
|
2408 |
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
|
2409 |
tr.close() |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2410 |
for bookmark in sorted(bookmarks): |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2411 |
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
|
2412 |
finally: |
5c962163f77a
prune: ensure we prune bookmarks in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1487
diff
changeset
|
2413 |
lockmod.release(tr, lock, wlock) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2414 |
|
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2415 |
|
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2416 |
|
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2417 |
def _getmetadata(**opts): |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2418 |
metadata = {} |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2419 |
date = opts.get('date') |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2420 |
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
|
2421 |
if date: |
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2422 |
metadata['date'] = '%i %i' % util.parsedate(date) |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2423 |
if user: |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2424 |
metadata['user'] = user |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2425 |
return metadata |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2426 |
|
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2427 |
|
1631
7463f5880ce9
prune: remove the kill alias
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1630
diff
changeset
|
2428 |
@command('^prune|obsolete', |
682
6cbb52a8401b
prune: rename --new to --succ
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
681
diff
changeset
|
2429 |
[('n', 'new', [], _("successor changeset (DEPRECATED)")), |
6cbb52a8401b
prune: rename --new to --succ
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
681
diff
changeset
|
2430 |
('s', 'succ', [], _("successor changeset")), |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2431 |
('r', 'rev', [], _("revisions to prune")), |
1221
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2432 |
('k', 'keep', None, _("does not modify working copy during prune")), |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
2433 |
('', 'biject', False, _("do a 1-1 map between rev and successor ranges")), |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2434 |
('', 'fold', False, |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2435 |
_("record a fold (multiple precursors, one successors)")), |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2436 |
('', 'split', False, |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2437 |
_("record a split (on precursor, multiple successors)")), |
1564
42c30774e63d
prune: changing bookmark argument to be a list
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1563
diff
changeset
|
2438 |
('B', 'bookmark', [], _("remove revs only reachable from given" |
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2439 |
" bookmark"))] + metadataopts, |
644
8e41d5b78dff
support -r option in prune, add a test for this
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
636
diff
changeset
|
2440 |
_('[OPTION] [-r] REV...')) |
690
929d7617a13d
prune: more command switch idea
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
689
diff
changeset
|
2441 |
# -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
|
2442 |
def cmdprune(ui, repo, *revs, **opts): |
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
2443 |
"""hide changesets by marking them obsolete |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2444 |
|
1574
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2445 |
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
|
2446 |
descendants, they are hidden (invisible to all commands). |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2447 |
|
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2448 |
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
|
2449 |
to handle this situation. |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2450 |
|
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2451 |
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
|
2452 |
copy to a non-obsolete parent. |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2453 |
|
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2454 |
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
|
2455 |
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
|
2456 |
markers. |
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2457 |
|
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2458 |
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
|
2459 |
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
|
2460 |
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
|
2461 |
|
dcfe3afe548b
evolve: rewrite help for prune command
Greg Ward <greg@gerg.ca>
parents:
1573
diff
changeset
|
2462 |
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
|
2463 |
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
|
2464 |
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
|
2465 |
""" |
1134
7173c70ab2c3
prune: stop reinjecting all selected revisions back into the revrange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1132
diff
changeset
|
2466 |
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
|
2467 |
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
|
2468 |
bookmarks = set(opts.get('bookmark')) |
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
2469 |
metadata = _getmetadata(**opts) |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
2470 |
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
|
2471 |
fold = opts.get('fold') |
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2472 |
split = opts.get('split') |
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2473 |
|
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2474 |
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
|
2475 |
if 1 < len(options): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2476 |
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
|
2477 |
|
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2478 |
if bookmarks: |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2479 |
repomarks, revs = _reachablefrombookmark(repo, revs, bookmarks) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2480 |
if not revs: |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2481 |
# 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
|
2482 |
_deletebookmark(repo, repomarks, bookmarks) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2483 |
|
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2484 |
if not revs: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2485 |
raise error.Abort(_('nothing to prune')) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2486 |
|
1295
1ac05eef72ca
prune: prune fix transaction pattern
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1294
diff
changeset
|
2487 |
wlock = lock = tr = None |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2488 |
try: |
1019
0c733dab0036
prune: lock inside the try
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1018
diff
changeset
|
2489 |
wlock = repo.wlock() |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
2490 |
lock = repo.lock() |
1294
d1c29db2e055
prune: fix pruning w/ bookmarks and inhibit
Durham Goode <durham@fb.com>
parents:
1283
diff
changeset
|
2491 |
tr = repo.transaction('prune') |
691
6e63b4185a5c
prune: update inline documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
690
diff
changeset
|
2492 |
# defines pruned changesets |
684
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
2493 |
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
|
2494 |
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
|
2495 |
for p in revs: |
684
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
2496 |
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
|
2497 |
if not cp.mutable(): |
927 | 2498 |
# 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
|
2499 |
raise error.Abort('cannot prune immutable changeset: %s' % cp, |
687
6c1fbef2952e
prune: test and improve message of immutable aborting.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
685
diff
changeset
|
2500 |
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
|
2501 |
precs.append(cp) |
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
2502 |
if not precs: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2503 |
raise error.Abort('nothing to prune') |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2504 |
|
1684
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
2505 |
if _disallowednewunstable(repo, revs): |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
2506 |
raise error.Abort(_("cannot prune in the middle of a stack")) |
1397
35f2f54b557c
evolve: make prune respect allowunsable
Laurent Charignon <lcharignon@fb.com>
parents:
1396
diff
changeset
|
2507 |
|
691
6e63b4185a5c
prune: update inline documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
690
diff
changeset
|
2508 |
# defines successors changesets |
1135
db16c4ad15d0
fixup previous changesets (after forgot to amend).
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1134
diff
changeset
|
2509 |
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
|
2510 |
sucs.sort() |
db16c4ad15d0
fixup previous changesets (after forgot to amend).
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1134
diff
changeset
|
2511 |
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
|
2512 |
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
|
2513 |
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
|
2514 |
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
|
2515 |
" for another") |
60752ed8d2d4
prune: suggest --biject in error "hint"
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1688
diff
changeset
|
2516 |
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
|
2517 |
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
|
2518 |
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
|
2519 |
% (len(sucs), len(precs)) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2520 |
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
|
2521 |
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
|
2522 |
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
|
2523 |
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
|
2524 |
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
|
2525 |
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
|
2526 |
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
|
2527 |
elif biject: |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
2528 |
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
|
2529 |
else: |
4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Laurent Charignon <lcharignon@fb.com>
parents:
1469
diff
changeset
|
2530 |
relations = [(p, sucs) for p in precs] |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
2531 |
|
683
6d24bd455f79
simplify locking in prune
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
682
diff
changeset
|
2532 |
wdp = repo['.'] |
931
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2533 |
|
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2534 |
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
|
2535 |
# '.' 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
|
2536 |
newnode = sucs[0] |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2537 |
else: |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2538 |
# 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
|
2539 |
newnode = wdp |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
2540 |
|
1239
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2541 |
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
|
2542 |
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
|
2543 |
|
1239
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2544 |
|
683
6d24bd455f79
simplify locking in prune
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
682
diff
changeset
|
2545 |
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
|
2546 |
if opts.get('keep', False): |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2547 |
# 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
|
2548 |
# 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
|
2549 |
# common at some point. |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2550 |
|
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2551 |
# 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
|
2552 |
# 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
|
2553 |
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
|
2554 |
changedfiles = [] |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2555 |
for rev in descendantrevs: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2556 |
# 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
|
2557 |
# changed |
1221
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2558 |
changedfiles.extend(repo[rev].files()) |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2559 |
|
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2560 |
# 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
|
2561 |
dirstate = repo.dirstate |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2562 |
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
|
2563 |
changedfiles.extend(dirchanges) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2564 |
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
|
2565 |
changedfiles) |
1515
9729fdcc1fab
prune: have dirstate collaborate with transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1514
diff
changeset
|
2566 |
writedirstate(dirstate, tr) |
1221
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2567 |
else: |
1344 | 2568 |
bookactive = bmactive(repo) |
2569 |
# Active bookmark that we don't want to delete (with -B option) |
|
2570 |
# we deactivate and move it before the update and reactivate it |
|
2571 |
# after |
|
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2572 |
movebookmark = bookactive and not bookmarks |
1344 | 2573 |
if movebookmark: |
1391 | 2574 |
bmdeactivate(repo) |
1344 | 2575 |
repo._bookmarks[bookactive] = newnode.node() |
1555
0ff262537f98
prune: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1554
diff
changeset
|
2576 |
repo._bookmarks.recordchange(tr) |
1221
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2577 |
commands.update(ui, repo, newnode.rev()) |
524dbc8ffeac
prune: add --keep to not touch the working copy
Durham Goode <durham@fb.com>
parents:
1220
diff
changeset
|
2578 |
ui.status(_('working directory now at %s\n') % newnode) |
1344 | 2579 |
if movebookmark: |
1391 | 2580 |
bmactivate(repo, bookactive) |
1342
16017e1bb2a1
prune: with active bookmark should stay active
Laurent Charignon <lcharignon@fb.com>
parents:
1340
diff
changeset
|
2581 |
|
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
2582 |
# update bookmarks |
1563
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2583 |
if bookmarks: |
6a9f0261b181
prune: remove a list of bookmarks
Shubhanshu Agrawal <agrawal.shubhanshu@gmail.com>
parents:
1561
diff
changeset
|
2584 |
_deletebookmark(repo, repomarks, bookmarks) |
1239
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2585 |
|
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2586 |
# create markers |
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2587 |
obsolete.createmarkers(repo, relations, metadata=metadata) |
1468
bc6cf6cc06fd
evolve: remove trailing spaces
André Sintzoff <andre.sintzoff@gmail.com>
parents:
1467
diff
changeset
|
2588 |
|
1239
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2589 |
# informs that changeset have been pruned |
8a06b32061ce
evolve: apply prune update before creating obsolescence markers
Laurent Charignon <lcharignon@fb.com>
parents:
1235
diff
changeset
|
2590 |
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
|
2591 |
|
693
d3c1fe0035d1
prune: handle bookmark
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
691
diff
changeset
|
2592 |
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
|
2593 |
# used to be: |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2594 |
# |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2595 |
# 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
|
2596 |
# if ldest: |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2597 |
# c = ldest[0] |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2598 |
# |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2599 |
# 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
|
2600 |
# 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
|
2601 |
for dest in ctx.ancestors(): |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2602 |
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
|
2603 |
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
|
2604 |
updatebookmarks(dest.node()) |
8cac667a0d7d
prune: work around lazy revset slowdown
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1099
diff
changeset
|
2605 |
break |
1294
d1c29db2e055
prune: fix pruning w/ bookmarks and inhibit
Durham Goode <durham@fb.com>
parents:
1283
diff
changeset
|
2606 |
|
d1c29db2e055
prune: fix pruning w/ bookmarks and inhibit
Durham Goode <durham@fb.com>
parents:
1283
diff
changeset
|
2607 |
tr.close() |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2608 |
finally: |
1295
1ac05eef72ca
prune: prune fix transaction pattern
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1294
diff
changeset
|
2609 |
lockmod.release(tr, lock, wlock) |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
2610 |
|
673
761b5b266985
evolve: removes amend from the list of advertised function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
672
diff
changeset
|
2611 |
@command('amend|refresh', |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2612 |
[('A', 'addremove', None, |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2613 |
_('mark new/missing files as added/removed before committing')), |
303 | 2614 |
('e', 'edit', False, _('invoke editor on commit messages')), |
742
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2615 |
('', 'close-branch', None, |
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2616 |
_('mark a branch as closed, hiding it from the branch list')), |
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2617 |
('s', 'secret', None, _('use the secret phase for committing')), |
1296
23819e1d61fd
evolve: add -i flag to amend command
Laurent Charignon <lcharignon@fb.com>
parents:
1281
diff
changeset
|
2618 |
] + walkopts + commitopts + commitopts2 + commitopts3 + interactiveopt, |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2619 |
_('[OPTION]... [FILE]...')) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2620 |
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
|
2621 |
"""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
|
2622 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2623 |
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
|
2624 |
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
|
2625 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2626 |
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
|
2627 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2628 |
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
|
2629 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2630 |
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
|
2631 |
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
|
2632 |
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
|
2633 |
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
|
2634 |
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
|
2635 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
2636 |
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
|
2637 |
""" |
742
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2638 |
opts = opts.copy() |
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2639 |
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
|
2640 |
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
|
2641 |
opts['amend'] = True |
1140
b7d85cd8ec7b
amend: allow the --logfile argument to work properly
Matt Harbison <matt_harbison@yahoo.com>
parents:
1137
diff
changeset
|
2642 |
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
|
2643 |
opts['message'] = repo['.'].description() |
985
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
2644 |
_resolveoptions(ui, opts) |
742
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2645 |
_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
|
2646 |
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
|
2647 |
|
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2648 |
|
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2649 |
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
|
2650 |
touched = set() |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2651 |
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
|
2652 |
touched.update(files) |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2653 |
return touched |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2654 |
|
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2655 |
def _commitfiltered(repo, ctx, match, target=None): |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2656 |
"""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
|
2657 |
node identifier, or None if nothing changed. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2658 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2659 |
base = ctx.p1() |
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2660 |
if target is None: |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2661 |
target = base |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2662 |
# ctx |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2663 |
initialfiles = _touchedbetween(repo, base, ctx) |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2664 |
if base == target: |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2665 |
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
|
2666 |
newcontent = set() |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2667 |
else: |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2668 |
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
|
2669 |
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
|
2670 |
# The commit touchs all existing files |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2671 |
# + 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
|
2672 |
# - 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
|
2673 |
files = (initialfiles - affected) | newcontent |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2674 |
if not newcontent and files == initialfiles: |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2675 |
return None |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2676 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2677 |
# Filter copies |
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2678 |
copied = copies.pathcopies(target, ctx) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2679 |
copied = dict((src, dst) for src, dst in copied.iteritems() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2680 |
if dst in files) |
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2681 |
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
|
2682 |
if path in redirect: |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2683 |
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
|
2684 |
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
|
2685 |
return None |
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2686 |
fctx = contentctx[path] |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2687 |
flags = fctx.flags() |
955
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
2688 |
mctx = memfilectx(repo, fctx.path(), fctx.data(), |
954
ef155e3ead8f
evolve: abstract access to context.memfilectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
953
diff
changeset
|
2689 |
islink='l' in flags, |
ef155e3ead8f
evolve: abstract access to context.memfilectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
953
diff
changeset
|
2690 |
isexec='x' in flags, |
ef155e3ead8f
evolve: abstract access to context.memfilectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
953
diff
changeset
|
2691 |
copied=copied.get(path)) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2692 |
return mctx |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2693 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2694 |
new = context.memctx(repo, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2695 |
parents=[base.node(), node.nullid], |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2696 |
text=ctx.description(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2697 |
files=files, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2698 |
filectxfn=filectxfn, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2699 |
user=ctx.user(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2700 |
date=ctx.date(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2701 |
extra=ctx.extra()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2702 |
# commitctx always create a new revision, no need to check |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2703 |
newid = repo.commitctx(new) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2704 |
return newid |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2705 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2706 |
def _uncommitdirstate(repo, oldctx, match): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2707 |
"""Fix the dirstate after switching the working directory from |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2708 |
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
|
2709 |
match. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2710 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2711 |
ctx = repo['.'] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2712 |
ds = repo.dirstate |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2713 |
copies = dict(ds.copies()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2714 |
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
|
2715 |
for f in m: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2716 |
if ds[f] == 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2717 |
# modified + removed -> removed |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2718 |
continue |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2719 |
ds.normallookup(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2720 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2721 |
for f in a: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2722 |
if ds[f] == 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2723 |
# added + removed -> unknown |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2724 |
ds.drop(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2725 |
elif ds[f] != 'a': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2726 |
ds.add(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2727 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2728 |
for f in r: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2729 |
if ds[f] == 'a': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2730 |
# removed + added -> normal |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2731 |
ds.normallookup(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2732 |
elif ds[f] != 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2733 |
ds.remove(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2734 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2735 |
# Merge old parent and old working dir copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2736 |
oldcopies = {} |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2737 |
for f in (m + a): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2738 |
src = oldctx[f].renamed() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2739 |
if src: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2740 |
oldcopies[f] = src[0] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2741 |
oldcopies.update(copies) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2742 |
copies = dict((dst, oldcopies.get(src, src)) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2743 |
for dst, src in oldcopies.iteritems()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2744 |
# Adjust the dirstate copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2745 |
for dst, src in copies.iteritems(): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2746 |
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
|
2747 |
src = None |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2748 |
ds.copy(src, dst) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2749 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2750 |
@command('^uncommit', |
314
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
2751 |
[('a', 'all', None, _('uncommit all changes when no arguments given')), |
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2752 |
('r', 'rev', '', _('revert commit content to REV instead')), |
314
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
2753 |
] + commands.walkopts, |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2754 |
_('[OPTION]... [NAME]')) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2755 |
def uncommit(ui, repo, *pats, **opts): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2756 |
"""move changes from parent revision to working directory |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2757 |
|
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
2758 |
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
|
2759 |
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
|
2760 |
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
|
2761 |
revision, and obsoletes the previous one. |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2762 |
|
867
6a67606e1c34
evolve: fix typos in uncommit docstring
André Sintzoff <andre.sintzoff@gmail.com>
parents:
858
diff
changeset
|
2763 |
The --include option specifies patterns to uncommit. |
6a67606e1c34
evolve: fix typos in uncommit docstring
André Sintzoff <andre.sintzoff@gmail.com>
parents:
858
diff
changeset
|
2764 |
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
|
2765 |
|
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2766 |
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
|
2767 |
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
|
2768 |
directory. |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2769 |
|
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2770 |
Return 0 if changed files are uncommitted. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2771 |
""" |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2772 |
|
1022 | 2773 |
wlock = lock = tr = None |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2774 |
try: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2775 |
wlock = repo.wlock() |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2776 |
lock = repo.lock() |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2777 |
wctx = repo[None] |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2778 |
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
|
2779 |
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
|
2780 |
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
|
2781 |
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
|
2782 |
old = repo['.'] |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2783 |
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
|
2784 |
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
|
2785 |
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
|
2786 |
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
|
2787 |
oldphase = old.phase() |
1022 | 2788 |
|
1058
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2789 |
|
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2790 |
rev = None |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2791 |
if opts.get('rev'): |
00bc31523074
uncommit: add a --rev argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1055
diff
changeset
|
2792 |
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
|
2793 |
ctx = repo[None] |
160fd06312fc
uncommit: abort when rev specifies the current changeset
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
1141
diff
changeset
|
2794 |
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
|
2795 |
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
|
2796 |
|
1364
f00d91365ab9
evolve: make uncommit respect allowunsable
Laurent Charignon <lcharignon@fb.com>
parents:
1361
diff
changeset
|
2797 |
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
|
2798 |
disallowunstable = not obsolete.isenabled(repo, |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2799 |
obsolete.allowunstableopt) |
1364
f00d91365ab9
evolve: make uncommit respect allowunsable
Laurent Charignon <lcharignon@fb.com>
parents:
1361
diff
changeset
|
2800 |
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
|
2801 |
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
|
2802 |
|
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2803 |
# Recommit the filtered changeset |
1022 | 2804 |
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
|
2805 |
updatebookmarks = _bookmarksupdater(repo, old.node(), tr) |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2806 |
newid = None |
1351
69e5de3e6129
evolve: small refactoring of the uncommit function
Laurent Charignon <lcharignon@fb.com>
parents:
1350
diff
changeset
|
2807 |
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
|
2808 |
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
|
2809 |
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
|
2810 |
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
|
2811 |
if newid is None: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2812 |
raise error.Abort(_('nothing to uncommit'), |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2813 |
hint=_("use --all to uncommit all files")) |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2814 |
# Move local changes on filtered changeset |
1070
527b12a59628
drop relevant marker compat
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1069
diff
changeset
|
2815 |
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
|
2816 |
phases.retractboundary(repo, tr, oldphase, [newid]) |
1112
c3e23fbf7bd7
evolve: wrap setparents calls in begin/endparentchange
Siddharth Agarwal <sid0@fb.com>
parents:
1111
diff
changeset
|
2817 |
repo.dirstate.beginparentchange() |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2818 |
repo.dirstate.setparents(newid, node.nullid) |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2819 |
_uncommitdirstate(repo, old, match) |
1112
c3e23fbf7bd7
evolve: wrap setparents calls in begin/endparentchange
Siddharth Agarwal <sid0@fb.com>
parents:
1111
diff
changeset
|
2820 |
repo.dirstate.endparentchange() |
1020
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2821 |
updatebookmarks(newid) |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2822 |
if not repo[newid].files(): |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2823 |
ui.warn(_("new changeset is empty\n")) |
155949287628
uncommit: saner locking scheme
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1019
diff
changeset
|
2824 |
ui.status(_('(use "hg prune ." to remove it)\n')) |
1022 | 2825 |
tr.close() |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2826 |
finally: |
1022 | 2827 |
lockmod.release(tr, lock, wlock) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
2828 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2829 |
@eh.wrapcommand('commit') |
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
2830 |
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
|
2831 |
tr = None |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2832 |
if kwargs.get('amend', False): |
1255
a2d4901e211e
commit: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1253
diff
changeset
|
2833 |
wlock = lock = None |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2834 |
else: |
1255
a2d4901e211e
commit: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1253
diff
changeset
|
2835 |
wlock = repo.wlock() |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2836 |
lock = repo.lock() |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2837 |
try: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2838 |
obsoleted = kwargs.get('obsolete', []) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2839 |
if obsoleted: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2840 |
obsoleted = repo.set('%lr', obsoleted) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2841 |
result = orig(ui, repo, *arg, **kwargs) |
1659 | 2842 |
if not result: # commit succeeded |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2843 |
new = repo['-1'] |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2844 |
oldbookmarks = [] |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
2845 |
markers = [] |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2846 |
for old in obsoleted: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2847 |
oldbookmarks.extend(repo.nodebookmarks(old.node())) |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
2848 |
markers.append((old, (new,))) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
2849 |
if markers: |
1070
527b12a59628
drop relevant marker compat
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1069
diff
changeset
|
2850 |
obsolete.createmarkers(repo, markers) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2851 |
for book in oldbookmarks: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2852 |
repo._bookmarks[book] = new.node() |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2853 |
if oldbookmarks: |
1558
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2854 |
if not wlock: |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2855 |
wlock = repo.wlock() |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2856 |
if not lock: |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2857 |
lock = repo.lock() |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2858 |
tr = repo.transaction('commit') |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2859 |
repo._bookmarks.recordchange(tr) |
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2860 |
tr.close() |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2861 |
return result |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2862 |
finally: |
1558
4706475e0c5d
commitwrapper: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1557
diff
changeset
|
2863 |
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
|
2864 |
|
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2865 |
@command('^split', |
1615
b04d73c0a13e
split: fix wording of documentation for --rev option
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
1611
diff
changeset
|
2866 |
[('r', 'rev', [], _("revision to split")), |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2867 |
] + commitopts + commitopts2, |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2868 |
_('hg split [OPTION]... [-r] REV')) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2869 |
def cmdsplit(ui, repo, *revs, **opts): |
1575 | 2870 |
"""split a changeset into smaller changesets |
1573
0b4cec85d4ab
evolve: improve help for split command
Greg Ward <greg@gerg.ca>
parents:
1572
diff
changeset
|
2871 |
|
0b4cec85d4ab
evolve: improve help for split command
Greg Ward <greg@gerg.ca>
parents:
1572
diff
changeset
|
2872 |
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
|
2873 |
redistributed into new changesets. |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2874 |
|
1573
0b4cec85d4ab
evolve: improve help for split command
Greg Ward <greg@gerg.ca>
parents:
1572
diff
changeset
|
2875 |
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
|
2876 |
""" |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2877 |
tr = wlock = lock = None |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2878 |
newcommits = [] |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2879 |
|
1598
2a08ef812b84
evolve: make split respect rev args passed without --rev or -r
Kostia Balytskyi <ikostia@fb.com>
parents:
1597
diff
changeset
|
2880 |
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
|
2881 |
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
|
2882 |
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
|
2883 |
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
|
2884 |
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
|
2885 |
|
2a08ef812b84
evolve: make split respect rev args passed without --rev or -r
Kostia Balytskyi <ikostia@fb.com>
parents:
1597
diff
changeset
|
2886 |
rev = scmutil.revsingle(repo, revarg[0]) |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2887 |
try: |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2888 |
wlock = repo.wlock() |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2889 |
lock = repo.lock() |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2890 |
cmdutil.bailifchanged(repo) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2891 |
tr = repo.transaction('split') |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2892 |
ctx = repo[rev] |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2893 |
r = ctx.rev() |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2894 |
disallowunstable = not obsolete.isenabled(repo, |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2895 |
obsolete.allowunstableopt) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2896 |
if disallowunstable: |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2897 |
# XXX We should check head revs |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2898 |
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
|
2899 |
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
|
2900 |
|
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2901 |
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
|
2902 |
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
|
2903 |
prev = ctx.p1() |
1506
a55c691f4cc0
evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
1505
diff
changeset
|
2904 |
bmupdate = _bookmarksupdater(repo, ctx.node(), tr) |
1485
1ba64be11bf8
split: handle bookmarks instead of leaving them on precursor
Laurent Charignon <lcharignon@fb.com>
parents:
1484
diff
changeset
|
2905 |
bookactive = bmactive(repo) |
1ba64be11bf8
split: handle bookmarks instead of leaving them on precursor
Laurent Charignon <lcharignon@fb.com>
parents:
1484
diff
changeset
|
2906 |
if bookactive is not None: |
1ba64be11bf8
split: handle bookmarks instead of leaving them on precursor
Laurent Charignon <lcharignon@fb.com>
parents:
1484
diff
changeset
|
2907 |
repo.ui.status(_("(leaving bookmark %s)\n") % bmactive(repo)) |
1ba64be11bf8
split: handle bookmarks instead of leaving them on precursor
Laurent Charignon <lcharignon@fb.com>
parents:
1484
diff
changeset
|
2908 |
bmdeactivate(repo) |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2909 |
hg.update(repo, prev) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2910 |
|
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2911 |
commands.revert(ui, repo, rev=r, all=True) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2912 |
def haschanges(): |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2913 |
modified, added, removed, deleted = repo.status()[:4] |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2914 |
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
|
2915 |
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
|
2916 |
"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
|
2917 |
msg += ctx.description() |
47f48af730ce
split: preserve original changesets description
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1528
diff
changeset
|
2918 |
opts['message'] = msg |
47f48af730ce
split: preserve original changesets description
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1528
diff
changeset
|
2919 |
opts['edit'] = True |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2920 |
while haschanges(): |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2921 |
pats = () |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2922 |
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
|
2923 |
cmdutil.recordfilter, *pats, **opts) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2924 |
# 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
|
2925 |
# 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
|
2926 |
newcommits.append(repo['.']) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2927 |
if haschanges(): |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2928 |
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
|
2929 |
commands.commit(ui, repo, **opts) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2930 |
newcommits.append(repo['.']) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2931 |
break |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2932 |
else: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
2933 |
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
|
2934 |
|
1485
1ba64be11bf8
split: handle bookmarks instead of leaving them on precursor
Laurent Charignon <lcharignon@fb.com>
parents:
1484
diff
changeset
|
2935 |
tip = repo[newcommits[-1]] |
1ba64be11bf8
split: handle bookmarks instead of leaving them on precursor
Laurent Charignon <lcharignon@fb.com>
parents:
1484
diff
changeset
|
2936 |
bmupdate(tip.node()) |
1ba64be11bf8
split: handle bookmarks instead of leaving them on precursor
Laurent Charignon <lcharignon@fb.com>
parents:
1484
diff
changeset
|
2937 |
if bookactive is not None: |
1ba64be11bf8
split: handle bookmarks instead of leaving them on precursor
Laurent Charignon <lcharignon@fb.com>
parents:
1484
diff
changeset
|
2938 |
bmactivate(repo, bookactive) |
1478
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2939 |
obsolete.createmarkers(repo, [(repo[r], newcommits)]) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2940 |
tr.close() |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2941 |
finally: |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2942 |
lockmod.release(tr, lock, wlock) |
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2943 |
|
9603aa1ecdfd
evolve: add a command to split commits
Laurent Charignon <lcharignon@fb.com>
parents:
1471
diff
changeset
|
2944 |
|
1220
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2945 |
@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
|
2946 |
('', 'bundle', None, _("delete the commit entirely and move it to a " |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2947 |
"backup bundle")), |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2948 |
]) |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2949 |
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
|
2950 |
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
|
2951 |
kwargs.get('bundle', False)): |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2952 |
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
|
2953 |
|
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2954 |
if kwargs.get('force'): |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2955 |
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
|
2956 |
"enabled\n")) |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2957 |
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
|
2958 |
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
|
2959 |
"evolve enabled\n")) |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2960 |
|
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2961 |
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
|
2962 |
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
|
2963 |
revs = repo.revs("(%ld)::", revs) |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2964 |
kwargs['rev'] = [] |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2965 |
kwargs['new'] = [] |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2966 |
kwargs['succ'] = [] |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2967 |
kwargs['biject'] = False |
71240f696f26
strip: add the option for wrapping the strip command
Durham Goode <durham@fb.com>
parents:
1219
diff
changeset
|
2968 |
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
|
2969 |
|
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2970 |
@command('^touch', |
701
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2971 |
[('r', 'rev', [], 'revision to update'), |
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2972 |
('D', 'duplicate', False, |
1589
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2973 |
'do not mark the new revision as successor of the old one'), |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2974 |
('A', 'allowdivergence', False, |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2975 |
'mark the new revision as successor of the old one potentially creating ' |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
2976 |
'divergence')], |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2977 |
# allow to choose the seed ? |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2978 |
_('[-r] revs')) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2979 |
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
|
2980 |
"""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
|
2981 |
for the changeset ID |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
2982 |
|
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
2983 |
This is used to "resurrect" changesets |
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
2984 |
""" |
701
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2985 |
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
|
2986 |
allowdivergence = opts['allowdivergence'] |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2987 |
revs = list(revs) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2988 |
revs.extend(opts['rev']) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2989 |
if not revs: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2990 |
revs = ['.'] |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2991 |
revs = scmutil.revrange(repo, revs) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2992 |
if not revs: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2993 |
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
|
2994 |
return 1 |
701
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2995 |
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
|
2996 |
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
|
2997 |
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
|
2998 |
wlock = lock = tr = None |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2999 |
try: |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
3000 |
wlock = repo.wlock() |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
3001 |
lock = repo.lock() |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
3002 |
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
|
3003 |
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
|
3004 |
newmapping = {} |
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3005 |
for r in revs: |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3006 |
ctx = repo[r] |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3007 |
extra = ctx.extra().copy() |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3008 |
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
|
3009 |
# search for touched parent |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3010 |
p1 = ctx.p1().node() |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3011 |
p2 = ctx.p2().node() |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3012 |
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
|
3013 |
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
|
3014 |
|
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3015 |
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
|
3016 |
# 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
|
3017 |
# 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
|
3018 |
sset = obsolete.successorssets(repo, ctx.node()) |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3019 |
nodivergencerisk = len(sset) == 0 or ( |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3020 |
len(sset) == 1 and |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3021 |
len(sset[0]) == 1 and |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3022 |
repo[sset[0][0]].rev() == ctx.rev() |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3023 |
) |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3024 |
if nodivergencerisk: |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3025 |
duplicate = False |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3026 |
else: |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3027 |
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
|
3028 |
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
|
3029 |
_("reviving this changeset will create divergence" |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3030 |
" unless you make a duplicate.\n(a)llow divergence or" |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3031 |
" (d)uplicate the changeset? $$ &Allowdivergence $$ " |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3032 |
"&Duplicate"), 0) |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3033 |
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
|
3034 |
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
|
3035 |
duplicate = False |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3036 |
else: |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3037 |
duplicate = True |
d6630a6bff86
touch: prompt the user for what to do with the revived changeset
Laurent Charignon <lcharignon@fb.com>
parents:
1580
diff
changeset
|
3038 |
|
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3039 |
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
|
3040 |
[p1, p2], |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3041 |
commitopts={'extra': extra}) |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3042 |
# 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
|
3043 |
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
|
3044 |
|
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3045 |
if not duplicate: |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3046 |
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
|
3047 |
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
|
3048 |
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
|
3049 |
repo.dirstate.beginparentchange() |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3050 |
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
|
3051 |
repo.dirstate.endparentchange() |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3052 |
tr.close() |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
3053 |
finally: |
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3054 |
lockmod.release(tr, lock, wlock) |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
3055 |
|
934
f13facb01ac5
fold: add squash as a possible alias
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
933
diff
changeset
|
3056 |
@command('^fold|squash', |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3057 |
[('r', 'rev', [], _("revision to fold")), |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3058 |
('', 'exact', None, _("only fold specified revisions")) |
933
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
3059 |
] + commitopts + commitopts2, |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3060 |
_('hg fold [OPTION]... [-r] REV')) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
3061 |
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
|
3062 |
"""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
|
3063 |
|
1463
71a3aa0349c5
evolve: improve the help of the fold command
Laurent Charignon <lcharignon@fb.com>
parents:
1460
diff
changeset
|
3064 |
By default, folds all the revisions linearly between the given revisions |
71a3aa0349c5
evolve: improve the help of the fold command
Laurent Charignon <lcharignon@fb.com>
parents:
1460
diff
changeset
|
3065 |
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
|
3066 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3067 |
Use --exact for folding only the specified revisions while ignoring the |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3068 |
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
|
3069 |
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
|
3070 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3071 |
.. container:: verbose |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3072 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3073 |
Some examples: |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3074 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3075 |
- 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
|
3076 |
|
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3077 |
hg fold .^ |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3078 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3079 |
- 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
|
3080 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3081 |
hg fold 'draft()' |
702
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
3082 |
|
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3083 |
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
|
3084 |
: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
|
3085 |
|
1469
fa1a27009c76
evolve: fix typo in fold docstring
André Sintzoff <andre.sintzoff@gmail.com>
parents:
1468
diff
changeset
|
3086 |
- 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
|
3087 |
|
d830d4e9f212
fold: avoid using x:y in the help
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1463
diff
changeset
|
3088 |
hg fold 3::6 |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3089 |
|
1463
71a3aa0349c5
evolve: improve the help of the fold command
Laurent Charignon <lcharignon@fb.com>
parents:
1460
diff
changeset
|
3090 |
- Fold revisions 3 and 4: |
71a3aa0349c5
evolve: improve the help of the fold command
Laurent Charignon <lcharignon@fb.com>
parents:
1460
diff
changeset
|
3091 |
|
71a3aa0349c5
evolve: improve the help of the fold command
Laurent Charignon <lcharignon@fb.com>
parents:
1460
diff
changeset
|
3092 |
hg fold "3 + 4" --exact |
71a3aa0349c5
evolve: improve the help of the fold command
Laurent Charignon <lcharignon@fb.com>
parents:
1460
diff
changeset
|
3093 |
|
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3094 |
- 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
|
3095 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3096 |
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
|
3097 |
""" |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
3098 |
revs = list(revs) |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3099 |
revs.extend(opts['rev']) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
3100 |
if not revs: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3101 |
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
|
3102 |
|
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3103 |
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
|
3104 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3105 |
if not opts['exact']: |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3106 |
# 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
|
3107 |
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
|
3108 |
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
|
3109 |
if discardedrevs: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3110 |
raise error.Abort(_("cannot fold non-linear revisions"), |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3111 |
hint=_("given revisions are unrelated to parent " |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3112 |
"of working directory")) |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3113 |
revs = extrevs |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
3114 |
|
995
0f3a7efd6ee9
fold: emit error message when folding a single revision
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
994
diff
changeset
|
3115 |
if len(revs) == 1: |
0f3a7efd6ee9
fold: emit error message when folding a single revision
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
994
diff
changeset
|
3116 |
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
|
3117 |
return 1 |
995
0f3a7efd6ee9
fold: emit error message when folding a single revision
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
994
diff
changeset
|
3118 |
|
515 | 3119 |
wlock = lock = None |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
3120 |
try: |
515 | 3121 |
wlock = repo.wlock() |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
3122 |
lock = repo.lock() |
1687
73e0018c423f
fold: move sanity check after locking
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1686
diff
changeset
|
3123 |
|
73e0018c423f
fold: move sanity check after locking
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1686
diff
changeset
|
3124 |
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
|
3125 |
|
515 | 3126 |
tr = repo.transaction('touch') |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
3127 |
try: |
915
1ebe5c51919b
fold: enable --date and --user options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
912
diff
changeset
|
3128 |
commitopts = opts.copy() |
515 | 3129 |
allctx = [repo[r] for r in revs] |
3130 |
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
|
3131 |
|
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
3132 |
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
|
3133 |
commitopts['edit'] = False |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
3134 |
else: |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
3135 |
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
|
3136 |
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
|
3137 |
(c.rev(), c.description()) for c in allctx] |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
3138 |
commitopts['message'] = "\n".join(msgs) |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
3139 |
commitopts['edit'] = True |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
3140 |
|
993
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
3141 |
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
|
3142 |
[root.p1().node(), |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3143 |
root.p2().node()], |
993
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
3144 |
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
|
3145 |
phases.retractboundary(repo, tr, targetphase, [newid]) |
1070
527b12a59628
drop relevant marker compat
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1069
diff
changeset
|
3146 |
obsolete.createmarkers(repo, [(ctx, (repo[newid],)) |
515 | 3147 |
for ctx in allctx]) |
3148 |
tr.close() |
|
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
3149 |
finally: |
515 | 3150 |
tr.release() |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
3151 |
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
|
3152 |
if repo['.'].rev() in revs: |
549
b047e9417d96
Properly update after fold
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
548
diff
changeset
|
3153 |
hg.update(repo, newid) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
3154 |
finally: |
515 | 3155 |
lockmod.release(lock, wlock) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
3156 |
|
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3157 |
@command('^metaedit', |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3158 |
[('r', 'rev', [], _("revision to edit")), |
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3159 |
('', 'fold', None, _("also fold specified revisions into one")), |
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3160 |
] + commitopts + commitopts2, |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3161 |
_('hg metaedit [OPTION]... [-r] [REV]')) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3162 |
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
|
3163 |
"""edit commit information |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3164 |
|
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3165 |
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
|
3166 |
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
|
3167 |
|
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3168 |
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
|
3169 |
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
|
3170 |
|
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3171 |
.. container:: verbose |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3172 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3173 |
Some examples: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3174 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3175 |
- 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
|
3176 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3177 |
hg metaedit |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3178 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3179 |
- 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
|
3180 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3181 |
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
|
3182 |
|
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3183 |
- 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
|
3184 |
one:: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3185 |
|
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3186 |
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
|
3187 |
|
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3188 |
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
|
3189 |
: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
|
3190 |
""" |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3191 |
revs = list(revs) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3192 |
revs.extend(opts['rev']) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3193 |
if not revs: |
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3194 |
if opts['fold']: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3195 |
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
|
3196 |
revs = ['.'] |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3197 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3198 |
wlock = lock = None |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3199 |
try: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3200 |
wlock = repo.wlock() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3201 |
lock = repo.lock() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3202 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3203 |
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
|
3204 |
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
|
3205 |
# 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
|
3206 |
# 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
|
3207 |
# |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3208 |
# a ---- b ---- c |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3209 |
# |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3210 |
# 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
|
3211 |
# 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
|
3212 |
# 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
|
3213 |
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
|
3214 |
'not currently supported')) |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3215 |
|
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3216 |
if opts['fold']: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3217 |
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
|
3218 |
else: |
1688
031682c1faa2
metaedit: check for public changeset before instability
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1687
diff
changeset
|
3219 |
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
|
3220 |
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
|
3221 |
'revisions')) |
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3222 |
newunstable = _disallowednewunstable(repo, revs) |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3223 |
if newunstable: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3224 |
raise error.Abort( |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3225 |
_('cannot edit commit information in the middle of a stack'), |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3226 |
hint=_('%s will be affected') % repo[newunstable.first()]) |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3227 |
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
|
3228 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3229 |
wctx = repo[None] |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3230 |
p1 = wctx.p1() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3231 |
tr = repo.transaction('metaedit') |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3232 |
newp1 = None |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3233 |
try: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3234 |
commitopts = opts.copy() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3235 |
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
|
3236 |
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
|
3237 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3238 |
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
|
3239 |
commitopts['edit'] = False |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3240 |
else: |
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3241 |
if opts['fold']: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3242 |
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
|
3243 |
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
|
3244 |
(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
|
3245 |
else: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3246 |
msgs = [head.description()] |
1685
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3247 |
commitopts['message'] = "\n".join(msgs) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3248 |
commitopts['edit'] = True |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3249 |
|
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3250 |
# 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
|
3251 |
# 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
|
3252 |
# different. |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3253 |
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
|
3254 |
[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
|
3255 |
commitopts=commitopts) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3256 |
if created: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3257 |
if p1.rev() in revs: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3258 |
newp1 = newid |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3259 |
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
|
3260 |
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
|
3261 |
for ctx in allctx]) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3262 |
else: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3263 |
ui.status(_("nothing changed\n")) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3264 |
tr.close() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3265 |
finally: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3266 |
tr.release() |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3267 |
|
1686
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3268 |
if opts['fold']: |
474db2d60202
metaedit: add support for folding commits while editing their metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1685
diff
changeset
|
3269 |
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
|
3270 |
if newp1 is not None: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3271 |
hg.update(repo, newp1) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3272 |
finally: |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3273 |
lockmod.release(lock, wlock) |
4fd0db2f6d84
commands: introduce a new command to edit commit metadata
Siddharth Agarwal <sid0@fb.com>
parents:
1684
diff
changeset
|
3274 |
|
1683
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3275 |
def _foldcheck(repo, revs): |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3276 |
roots = repo.revs('roots(%ld)', revs) |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3277 |
if len(roots) > 1: |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3278 |
raise error.Abort(_("cannot fold non-linear revisions " |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3279 |
"(multiple roots given)")) |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3280 |
root = repo[roots.first()] |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3281 |
if root.phase() <= phases.public: |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3282 |
raise error.Abort(_("cannot fold public revisions")) |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3283 |
heads = repo.revs('heads(%ld)', revs) |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3284 |
if len(heads) > 1: |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3285 |
raise error.Abort(_("cannot fold non-linear revisions " |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3286 |
"(multiple heads given)")) |
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3287 |
head = repo[heads.first()] |
1684
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3288 |
if _disallowednewunstable(repo, revs): |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3289 |
raise error.Abort(_("cannot fold chain not ending with a head "\ |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3290 |
"or with branching")) |
1683
1b1c8c0ab20e
evolve: factor out sanity checks for folds
Siddharth Agarwal <sid0@fb.com>
parents:
1682
diff
changeset
|
3291 |
return root, head |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
3292 |
|
1684
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3293 |
def _disallowednewunstable(repo, revs): |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3294 |
allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt) |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3295 |
if allowunstable: |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3296 |
return revset.baseset() |
40d7b0c4abb1
evolve: factor out check for creating unstable commits
Siddharth Agarwal <sid0@fb.com>
parents:
1683
diff
changeset
|
3297 |
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
|
3298 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
3299 |
@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
|
3300 |
def graftwrapper(orig, ui, repo, *revs, **kwargs): |
419
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
3301 |
kwargs = dict(kwargs) |
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
3302 |
revs = list(revs) + kwargs.get('rev', []) |
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
3303 |
kwargs['rev'] = [] |
417
a1fb18ad29a1
evolve: avoid duplication in graft wrapper
Patrick Mezard <patrick@mezard.eu>
parents:
416
diff
changeset
|
3304 |
obsoleted = kwargs.setdefault('obsolete', []) |
419
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
3305 |
|
1256
f8cb01637e75
graft: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1255
diff
changeset
|
3306 |
wlock = lock = None |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3307 |
try: |
1256
f8cb01637e75
graft: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1255
diff
changeset
|
3308 |
wlock = repo.wlock() |
f8cb01637e75
graft: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1255
diff
changeset
|
3309 |
lock = repo.lock() |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3310 |
if kwargs.get('old_obsolete'): |
418
18a0d96ed559
evolve: graft --continue is optional, test
Patrick Mezard <patrick@mezard.eu>
parents:
417
diff
changeset
|
3311 |
if kwargs.get('continue'): |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3312 |
obsoleted.extend(repo.opener.read('graftstate').splitlines()) |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3313 |
else: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3314 |
obsoleted.extend(revs) |
151
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
3315 |
# 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
|
3316 |
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
|
3317 |
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
|
3318 |
|
743
af74a5cdf96b
conform to the Mercurial custom of lowercase messages
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
742
diff
changeset
|
3319 |
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
|
3320 |
'obsoleting (for now).')) |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
3321 |
|
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3322 |
return commitwrapper(orig, ui, repo,*revs, **kwargs) |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
3323 |
finally: |
1256
f8cb01637e75
graft: avoid potential deadlock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1255
diff
changeset
|
3324 |
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
|
3325 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
3326 |
@eh.extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
3327 |
def oldevolveextsetup(ui): |
1631
7463f5880ce9
prune: remove the kill alias
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1630
diff
changeset
|
3328 |
for cmd in ['prune', 'uncommit', 'touch', 'fold']: |
1226
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3329 |
try: |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3330 |
entry = extensions.wrapcommand(cmdtable, cmd, |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3331 |
warnobserrors) |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3332 |
except error.UnknownCommand: |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3333 |
# Commands may be disabled |
901d2f4b21a9
config: allow disabling commands
Durham Goode <durham@fb.com>
parents:
1221
diff
changeset
|
3334 |
continue |
356
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
355
diff
changeset
|
3335 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
3336 |
entry = cmdutil.findcmd('commit', commands.table)[1] |
303 | 3337 |
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
|
3338 |
_("make commit obsolete this revision (DEPRECATED)"))) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
3339 |
entry = cmdutil.findcmd('graft', commands.table)[1] |
303 | 3340 |
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
|
3341 |
_("make graft obsoletes this revision (DEPRECATED)"))) |
303 | 3342 |
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
|
3343 |
_("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
|
3344 |
|
816
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
3345 |
##################################################################### |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
3346 |
### Obsolescence marker exchange experimenation ### |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
3347 |
##################################################################### |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
3348 |
|
1036
70de12b7721a
evolve: re-introduce the "pushing 42 markers…" message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1035
diff
changeset
|
3349 |
def obsexcmsg(ui, message, important=False): |
70de12b7721a
evolve: re-introduce the "pushing 42 markers…" message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1035
diff
changeset
|
3350 |
verbose = ui.configbool('experimental', 'verbose-obsolescence-exchange', |
70de12b7721a
evolve: re-introduce the "pushing 42 markers…" message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1035
diff
changeset
|
3351 |
False) |
70de12b7721a
evolve: re-introduce the "pushing 42 markers…" message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1035
diff
changeset
|
3352 |
if verbose: |
1035
59bc29c84ce0
evolve: hide the OBSEXC message behind a config option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1034
diff
changeset
|
3353 |
message = 'OBSEXC: ' + message |
1036
70de12b7721a
evolve: re-introduce the "pushing 42 markers…" message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1035
diff
changeset
|
3354 |
if important or verbose: |
1035
59bc29c84ce0
evolve: hide the OBSEXC message behind a config option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1034
diff
changeset
|
3355 |
ui.status(message) |
1033
908273755215
evolve: move OBSEXC message in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1032
diff
changeset
|
3356 |
|
1034
5fd28e46e8f5
evolve: move OBSEXC progress in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1033
diff
changeset
|
3357 |
def obsexcprg(ui, *args, **kwargs): |
1043
6a7d34010f8f
evolve: re enable progress for all
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1042
diff
changeset
|
3358 |
topic = 'obsmarkers exchange' |
1035
59bc29c84ce0
evolve: hide the OBSEXC message behind a config option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1034
diff
changeset
|
3359 |
if ui.configbool('experimental', 'verbose-obsolescence-exchange', False): |
1043
6a7d34010f8f
evolve: re enable progress for all
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1042
diff
changeset
|
3360 |
topic = 'OBSEXC' |
6a7d34010f8f
evolve: re enable progress for all
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1042
diff
changeset
|
3361 |
ui.progress(topic, *args, **kwargs) |
1034
5fd28e46e8f5
evolve: move OBSEXC progress in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1033
diff
changeset
|
3362 |
|
1300
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3363 |
@eh.wrapfunction(exchange, '_pushdiscoveryobsmarkers') |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3364 |
def _pushdiscoveryobsmarkers(orig, pushop): |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3365 |
if (obsolete.isenabled(pushop.repo, obsolete.exchangeopt) |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3366 |
and pushop.repo.obsstore |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3367 |
and 'obsolete' in pushop.remote.listkeys('namespaces')): |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3368 |
repo = pushop.repo |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3369 |
obsexcmsg(repo.ui, "computing relevant nodes\n") |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3370 |
revs = list(repo.revs('::%ln', pushop.futureheads)) |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3371 |
unfi = repo.unfiltered() |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3372 |
cl = unfi.changelog |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3373 |
if not pushop.remote.capable('_evoext_obshash_0'): |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3374 |
# do not trust core yet |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3375 |
# return orig(pushop) |
1076
2039385d6460
discovery: hook on the official discovery for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1075
diff
changeset
|
3376 |
nodes = [cl.node(r) for r in revs] |
1078
5717d023da63
obsexc: use the common discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1077
diff
changeset
|
3377 |
if nodes: |
5717d023da63
obsexc: use the common discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1077
diff
changeset
|
3378 |
obsexcmsg(repo.ui, "computing markers relevant to %i nodes\n" |
5717d023da63
obsexc: use the common discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1077
diff
changeset
|
3379 |
% len(nodes)) |
5717d023da63
obsexc: use the common discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1077
diff
changeset
|
3380 |
pushop.outobsmarkers = repo.obsstore.relevantmarkers(nodes) |
5717d023da63
obsexc: use the common discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1077
diff
changeset
|
3381 |
else: |
5717d023da63
obsexc: use the common discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1077
diff
changeset
|
3382 |
obsexcmsg(repo.ui, "markers already in sync\n") |
5717d023da63
obsexc: use the common discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1077
diff
changeset
|
3383 |
pushop.outobsmarkers = [] |
1300
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3384 |
pushop.outobsmarkers = repo.obsstore.relevantmarkers(nodes) |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3385 |
return |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3386 |
|
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3387 |
common = [] |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3388 |
obsexcmsg(repo.ui, "looking for common markers in %i nodes\n" |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3389 |
% len(revs)) |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3390 |
commonrevs = list(unfi.revs('::%ln', pushop.outgoing.commonheads)) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3391 |
common = findcommonobsmarkers(pushop.ui, unfi, pushop.remote, |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3392 |
commonrevs) |
1300
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3393 |
|
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3394 |
revs = list(unfi.revs('%ld - (::%ln)', revs, common)) |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3395 |
nodes = [cl.node(r) for r in revs] |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3396 |
if nodes: |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3397 |
obsexcmsg(repo.ui, "computing markers relevant to %i nodes\n" |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3398 |
% len(nodes)) |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3399 |
pushop.outobsmarkers = repo.obsstore.relevantmarkers(nodes) |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3400 |
else: |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3401 |
obsexcmsg(repo.ui, "markers already in sync\n") |
4a27123e0696
evolve: stop conditional wrapping of _pushdiscoveryobsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1299
diff
changeset
|
3402 |
pushop.outobsmarkers = [] |
1033
908273755215
evolve: move OBSEXC message in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1032
diff
changeset
|
3403 |
|
1075
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3404 |
@eh.wrapfunction(wireproto, 'capabilities') |
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3405 |
def discocapabilities(orig, repo, proto): |
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3406 |
"""wrapper to advertise new capability""" |
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3407 |
caps = orig(repo, proto) |
1214
4b10e2c6f7e3
config: remove uses of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1213
diff
changeset
|
3408 |
if obsolete.isenabled(repo, obsolete.exchangeopt): |
1075
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3409 |
caps += ' _evoext_obshash_0' |
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3410 |
return caps |
816
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
3411 |
|
1075
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3412 |
@eh.extsetup |
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3413 |
def _installobsmarkersdiscovery(ui): |
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3414 |
hgweb_mod.perms['evoext_obshash'] = 'pull' |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3415 |
hgweb_mod.perms['evoext_obshash1'] = 'pull' |
1075
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3416 |
# wrap command content |
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3417 |
oldcap, args = wireproto.commands['capabilities'] |
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3418 |
def newcap(repo, proto): |
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3419 |
return discocapabilities(oldcap, repo, proto) |
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3420 |
wireproto.commands['capabilities'] = (newcap, args) |
1205f42ae54c
discovery: use a different setup step for discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1074
diff
changeset
|
3421 |
wireproto.commands['evoext_obshash'] = (srv_obshash, 'nodes') |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3422 |
wireproto.commands['evoext_obshash1'] = (srv_obshash1, 'nodes') |
1108
87d60434b434
evolve: keep vague compatibility with 3.1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1107
diff
changeset
|
3423 |
if getattr(exchange, '_pushdiscoveryobsmarkers', None) is None: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3424 |
ui.warn(_('evolve: your mercurial version is too old\n' |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3425 |
'evolve: (running in degraded mode, push will ' |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3426 |
'includes all markers)\n')) |
1108
87d60434b434
evolve: keep vague compatibility with 3.1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1107
diff
changeset
|
3427 |
else: |
87d60434b434
evolve: keep vague compatibility with 3.1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1107
diff
changeset
|
3428 |
olddisco = exchange.pushdiscoverymapping['obsmarker'] |
87d60434b434
evolve: keep vague compatibility with 3.1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1107
diff
changeset
|
3429 |
def newdisco(pushop): |
87d60434b434
evolve: keep vague compatibility with 3.1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1107
diff
changeset
|
3430 |
_pushdiscoveryobsmarkers(olddisco, pushop) |
87d60434b434
evolve: keep vague compatibility with 3.1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1107
diff
changeset
|
3431 |
exchange.pushdiscoverymapping['obsmarker'] = newdisco |
816
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
3432 |
|
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3433 |
### Set discovery START |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3434 |
|
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3435 |
from mercurial import dagutil |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3436 |
from mercurial import setdiscovery |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3437 |
|
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3438 |
def _obshash(repo, nodes, version=0): |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3439 |
if version == 0: |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3440 |
hashs = _obsrelsethashtreefm0(repo) |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3441 |
elif version ==1: |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3442 |
hashs = _obsrelsethashtreefm1(repo) |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3443 |
else: |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3444 |
assert False |
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3445 |
nm = repo.changelog.nodemap |
1073
f15f02007a0b
obshash: resist to unknown revision during discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1072
diff
changeset
|
3446 |
revs = [nm.get(n) for n in nodes] |
f15f02007a0b
obshash: resist to unknown revision during discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1072
diff
changeset
|
3447 |
return [r is None and nullid or hashs[r][1] for r in revs] |
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3448 |
|
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3449 |
def srv_obshash(repo, proto, nodes): |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3450 |
return wireproto.encodelist(_obshash(repo, wireproto.decodelist(nodes))) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3451 |
|
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3452 |
def srv_obshash1(repo, proto, nodes): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3453 |
return wireproto.encodelist(_obshash(repo, wireproto.decodelist(nodes), |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3454 |
version=1)) |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3455 |
|
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3456 |
@eh.addattr(localrepo.localpeer, 'evoext_obshash') |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3457 |
def local_obshash(peer, nodes): |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3458 |
return _obshash(peer._repo, nodes) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3459 |
|
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3460 |
@eh.addattr(localrepo.localpeer, 'evoext_obshash1') |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3461 |
def local_obshash1(peer, nodes): |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3462 |
return _obshash(peer._repo, nodes, version=1) |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3463 |
|
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3464 |
@eh.addattr(wireproto.wirepeer, 'evoext_obshash') |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3465 |
def peer_obshash(self, nodes): |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3466 |
d = self._call("evoext_obshash", nodes=wireproto.encodelist(nodes)) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3467 |
try: |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3468 |
return wireproto.decodelist(d) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3469 |
except ValueError: |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3470 |
self._abort(error.ResponseError(_("unexpected response:"), d)) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3471 |
|
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3472 |
@eh.addattr(wireproto.wirepeer, 'evoext_obshash1') |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3473 |
def peer_obshash1(self, nodes): |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3474 |
d = self._call("evoext_obshash1", nodes=wireproto.encodelist(nodes)) |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3475 |
try: |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3476 |
return wireproto.decodelist(d) |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3477 |
except ValueError: |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3478 |
self._abort(error.ResponseError(_("unexpected response:"), d)) |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3479 |
|
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3480 |
def findcommonobsmarkers(ui, local, remote, probeset, |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3481 |
initialsamplesize=100, |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3482 |
fullsamplesize=200): |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3483 |
# from discovery |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3484 |
roundtrips = 0 |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3485 |
cl = local.changelog |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3486 |
dag = dagutil.revlogdag(cl) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3487 |
missing = set() |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3488 |
common = set() |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3489 |
undecided = set(probeset) |
1494
aca2495425a6
evolve: add progress for the obsmarkers discovery parts
timeless@mozdev.org
parents:
1488
diff
changeset
|
3490 |
totalnb = len(undecided) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3491 |
ui.progress(_("comparing with other"), 0, total=totalnb) |
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3492 |
_takefullsample = setdiscovery._takefullsample |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3493 |
if remote.capable('_evoext_obshash_1'): |
1249
1556d8fed538
discovery: stop being stupid about variable name
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1244
diff
changeset
|
3494 |
getremotehash = remote.evoext_obshash1 |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3495 |
localhash = _obsrelsethashtreefm1(local) |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3496 |
else: |
1249
1556d8fed538
discovery: stop being stupid about variable name
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1244
diff
changeset
|
3497 |
getremotehash = remote.evoext_obshash |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3498 |
localhash = _obsrelsethashtreefm0(local) |
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3499 |
|
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3500 |
while undecided: |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3501 |
|
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3502 |
ui.note(_("sampling from both directions\n")) |
1193
de73285cf504
discovery: do not build sample if undecided is smaller than sample size
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1192
diff
changeset
|
3503 |
if len(undecided) < fullsamplesize: |
de73285cf504
discovery: do not build sample if undecided is smaller than sample size
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1192
diff
changeset
|
3504 |
sample = set(undecided) |
de73285cf504
discovery: do not build sample if undecided is smaller than sample size
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1192
diff
changeset
|
3505 |
else: |
de73285cf504
discovery: do not build sample if undecided is smaller than sample size
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1192
diff
changeset
|
3506 |
sample = _takefullsample(dag, undecided, size=fullsamplesize) |
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3507 |
|
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3508 |
roundtrips += 1 |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3509 |
ui.progress(_("comparing with other"), totalnb - len(undecided), |
1494
aca2495425a6
evolve: add progress for the obsmarkers discovery parts
timeless@mozdev.org
parents:
1488
diff
changeset
|
3510 |
total=totalnb) |
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3511 |
ui.debug("query %i; still undecided: %i, sample size is: %i\n" |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3512 |
% (roundtrips, len(undecided), len(sample))) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3513 |
# indices between sample and externalized version must match |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3514 |
sample = list(sample) |
1249
1556d8fed538
discovery: stop being stupid about variable name
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1244
diff
changeset
|
3515 |
remotehash = getremotehash(dag.externalizeall(sample)) |
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3516 |
|
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3517 |
yesno = [localhash[ix][1] == remotehash[si] |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3518 |
for si, ix in enumerate(sample)] |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3519 |
|
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3520 |
commoninsample = set(n for i, n in enumerate(sample) if yesno[i]) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3521 |
common.update(dag.ancestorset(commoninsample, common)) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3522 |
|
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3523 |
missinginsample = [n for i, n in enumerate(sample) if not yesno[i]] |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3524 |
missing.update(dag.descendantset(missinginsample, missing)) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3525 |
|
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3526 |
undecided.difference_update(missing) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3527 |
undecided.difference_update(common) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3528 |
|
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3529 |
|
1623
47a0ce11b4ca
evolve: ui.progress doesn't use total count if pos is None, let's drop it
Anton Shestakov <av6@dwimlabs.net>
parents:
1620
diff
changeset
|
3530 |
ui.progress(_("comparing with other"), None) |
1072
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3531 |
result = dag.headsetofconnecteds(common) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3532 |
ui.debug("%d total queries\n" % roundtrips) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3533 |
|
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3534 |
if not result: |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3535 |
return set([nullid]) |
1639810c11c2
code movement: gather discovery code together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1071
diff
changeset
|
3536 |
return dag.externalizeall(result) |
816
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
3537 |
|
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
3538 |
|
817
c2bf0eb727f1
exchange: only push the set of marker relevant to want we push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
816
diff
changeset
|
3539 |
_pushkeyescape = getattr(obsolete, '_pushkeyescape', None) |
c2bf0eb727f1
exchange: only push the set of marker relevant to want we push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
816
diff
changeset
|
3540 |
|
854
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
3541 |
class pushobsmarkerStringIO(StringIO): |
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
3542 |
"""hacky string io for progress""" |
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
3543 |
|
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
3544 |
@util.propertycache |
879
85b3d54516a7
exchange: expose length of pushed markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
877
diff
changeset
|
3545 |
def length(self): |
854
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
3546 |
return len(self.getvalue()) |
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
3547 |
|
1080
41d2555141ea
evolve: allow read() from the magic StringIO
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1079
diff
changeset
|
3548 |
def read(self, size=None): |
1624
081605c2e9b6
evolve: mark progress units for translation
Anton Shestakov <av6@dwimlabs.net>
parents:
1623
diff
changeset
|
3549 |
obsexcprg(self.ui, self.tell(), unit=_("bytes"), total=self.length) |
854
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
3550 |
return StringIO.read(self, size) |
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
3551 |
|
961
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
3552 |
def __iter__(self): |
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
3553 |
d = self.read(4096) |
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
3554 |
while d: |
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
3555 |
yield d |
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
3556 |
d = self.read(4096) |
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
3557 |
|
817
c2bf0eb727f1
exchange: only push the set of marker relevant to want we push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
816
diff
changeset
|
3558 |
@eh.wrapfunction(exchange, '_pushobsolete') |
c2bf0eb727f1
exchange: only push the set of marker relevant to want we push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
816
diff
changeset
|
3559 |
def _pushobsolete(orig, pushop): |
c2bf0eb727f1
exchange: only push the set of marker relevant to want we push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
816
diff
changeset
|
3560 |
"""utility function to push obsolete markers to a remote""" |
1005
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
3561 |
stepsdone = getattr(pushop, 'stepsdone', None) |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
3562 |
if stepsdone is not None: |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
3563 |
if 'obsmarkers' in stepsdone: |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
3564 |
return |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
3565 |
stepsdone.add('obsmarkers') |
1118
fbc400c1b022
evolve: adapt to core changeset 4f14303e8954
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1117
diff
changeset
|
3566 |
if util.safehasattr(pushop, 'cgresult'): |
fbc400c1b022
evolve: adapt to core changeset 4f14303e8954
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1117
diff
changeset
|
3567 |
cgresult = pushop.cgresult |
fbc400c1b022
evolve: adapt to core changeset 4f14303e8954
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1117
diff
changeset
|
3568 |
else: |
fbc400c1b022
evolve: adapt to core changeset 4f14303e8954
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1117
diff
changeset
|
3569 |
cgresult = pushop.ret |
fbc400c1b022
evolve: adapt to core changeset 4f14303e8954
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1117
diff
changeset
|
3570 |
if cgresult == 0: |
1077
cdfc19f25478
obsexc: push nothing if push fail
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1076
diff
changeset
|
3571 |
return |
817
c2bf0eb727f1
exchange: only push the set of marker relevant to want we push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
816
diff
changeset
|
3572 |
pushop.ui.debug('try to push obsolete markers to remote\n') |
c2bf0eb727f1
exchange: only push the set of marker relevant to want we push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
816
diff
changeset
|
3573 |
repo = pushop.repo |
c2bf0eb727f1
exchange: only push the set of marker relevant to want we push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
816
diff
changeset
|
3574 |
remote = pushop.remote |
1214
4b10e2c6f7e3
config: remove uses of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1213
diff
changeset
|
3575 |
if (obsolete.isenabled(repo, obsolete.exchangeopt) and repo.obsstore and |
817
c2bf0eb727f1
exchange: only push the set of marker relevant to want we push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
816
diff
changeset
|
3576 |
'obsolete' in remote.listkeys('namespaces')): |
1078
5717d023da63
obsexc: use the common discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1077
diff
changeset
|
3577 |
markers = pushop.outobsmarkers |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3578 |
if not markers: |
1033
908273755215
evolve: move OBSEXC message in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1032
diff
changeset
|
3579 |
obsexcmsg(repo.ui, "no marker to push\n") |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3580 |
elif remote.capable('_evoext_pushobsmarkers_0'): |
961
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
3581 |
obsdata = pushobsmarkerStringIO() |
1091
236a8e81551e
compat: use in-core encodemarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1090
diff
changeset
|
3582 |
for chunk in obsolete.encodemarkers(markers, True): |
236a8e81551e
compat: use in-core encodemarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1090
diff
changeset
|
3583 |
obsdata.write(chunk) |
957
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
3584 |
obsdata.seek(0) |
961
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
3585 |
obsdata.ui = repo.ui |
1037
bddee73b361e
evolve: add "absolescence" in front of markers in the message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1036
diff
changeset
|
3586 |
obsexcmsg(repo.ui, "pushing %i obsolescence markers (%i bytes)\n" |
1036
70de12b7721a
evolve: re-introduce the "pushing 42 markers…" message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1035
diff
changeset
|
3587 |
% (len(markers), len(obsdata.getvalue())), |
70de12b7721a
evolve: re-introduce the "pushing 42 markers…" message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1035
diff
changeset
|
3588 |
True) |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3589 |
remote.evoext_pushobsmarkers_0(obsdata) |
1034
5fd28e46e8f5
evolve: move OBSEXC progress in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1033
diff
changeset
|
3590 |
obsexcprg(repo.ui, None) |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3591 |
else: |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3592 |
rslts = [] |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3593 |
remotedata = _pushkeyescape(markers).items() |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3594 |
totalbytes = sum(len(d) for k, d in remotedata) |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3595 |
sentbytes = 0 |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3596 |
obsexcmsg(repo.ui, "pushing %i obsolescence markers in %i " |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3597 |
"pushkey payload (%i bytes)\n" |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3598 |
% (len(markers), len(remotedata), totalbytes), |
1036
70de12b7721a
evolve: re-introduce the "pushing 42 markers…" message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1035
diff
changeset
|
3599 |
True) |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3600 |
for key, data in remotedata: |
1624
081605c2e9b6
evolve: mark progress units for translation
Anton Shestakov <av6@dwimlabs.net>
parents:
1623
diff
changeset
|
3601 |
obsexcprg(repo.ui, sentbytes, item=key, unit=_("bytes"), |
1034
5fd28e46e8f5
evolve: move OBSEXC progress in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1033
diff
changeset
|
3602 |
total=totalbytes) |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3603 |
rslts.append(remote.pushkey('obsolete', key, '', data)) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3604 |
sentbytes += len(data) |
1624
081605c2e9b6
evolve: mark progress units for translation
Anton Shestakov <av6@dwimlabs.net>
parents:
1623
diff
changeset
|
3605 |
obsexcprg(repo.ui, sentbytes, item=key, unit=_("bytes"), |
1034
5fd28e46e8f5
evolve: move OBSEXC progress in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1033
diff
changeset
|
3606 |
total=totalbytes) |
5fd28e46e8f5
evolve: move OBSEXC progress in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1033
diff
changeset
|
3607 |
obsexcprg(repo.ui, None) |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3608 |
if [r for r in rslts if not r]: |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3609 |
msg = _('failed to push some obsolete markers!\n') |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3610 |
repo.ui.warn(msg) |
1033
908273755215
evolve: move OBSEXC message in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1032
diff
changeset
|
3611 |
obsexcmsg(repo.ui, "DONE\n") |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3612 |
|
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3613 |
|
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3614 |
@eh.addattr(wireproto.wirepeer, 'evoext_pushobsmarkers_0') |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3615 |
def client_pushobsmarkers(self, obsfile): |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3616 |
"""wireprotocol peer method""" |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3617 |
self.requirecap('_evoext_pushobsmarkers_0', |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3618 |
_('push obsolete markers faster')) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3619 |
ret, output = self._callpush('evoext_pushobsmarkers_0', obsfile) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3620 |
for l in output.splitlines(True): |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3621 |
self.ui.status(_('remote: '), l) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3622 |
return ret |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3623 |
|
880
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
3624 |
@eh.addattr(httppeer.httppeer, 'evoext_pushobsmarkers_0') |
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
3625 |
def httpclient_pushobsmarkers(self, obsfile): |
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
3626 |
"""httpprotocol peer method |
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
3627 |
(Cannot simply use _callpush as http is doing some special handling)""" |
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
3628 |
self.requirecap('_evoext_pushobsmarkers_0', |
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
3629 |
_('push obsolete markers faster')) |
1209
fa35aeb64d32
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
1206
diff
changeset
|
3630 |
try: |
fa35aeb64d32
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
1206
diff
changeset
|
3631 |
r = self._call('evoext_pushobsmarkers_0', data=obsfile) |
fa35aeb64d32
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
1206
diff
changeset
|
3632 |
vals = r.split('\n', 1) |
fa35aeb64d32
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
1206
diff
changeset
|
3633 |
if len(vals) < 2: |
fa35aeb64d32
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
1206
diff
changeset
|
3634 |
raise error.ResponseError(_("unexpected response:"), r) |
fa35aeb64d32
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
1206
diff
changeset
|
3635 |
|
fa35aeb64d32
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
1206
diff
changeset
|
3636 |
for l in vals[1].splitlines(True): |
fa35aeb64d32
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
1206
diff
changeset
|
3637 |
if l.strip(): |
fa35aeb64d32
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
1206
diff
changeset
|
3638 |
self.ui.status(_('remote: '), l) |
fa35aeb64d32
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
1206
diff
changeset
|
3639 |
return vals[0] |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3640 |
except socket.error as err: |
1209
fa35aeb64d32
evolve: prevent a crash in httpclient_pushobsmarkers() when pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
1206
diff
changeset
|
3641 |
if err.args[0] in (errno.ECONNRESET, errno.EPIPE): |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3642 |
raise error.Abort(_('push failed: %s') % err.args[1]) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3643 |
raise error.Abort(err.args[1]) |
880
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
3644 |
|
1081
dddb8a70437c
obsexc: add support for evoext_pushobsmarkers_0 on localpeer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1080
diff
changeset
|
3645 |
@eh.wrapfunction(localrepo.localrepository, '_restrictcapabilities') |
dddb8a70437c
obsexc: add support for evoext_pushobsmarkers_0 on localpeer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1080
diff
changeset
|
3646 |
def local_pushobsmarker_capabilities(orig, repo, caps): |
dddb8a70437c
obsexc: add support for evoext_pushobsmarkers_0 on localpeer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1080
diff
changeset
|
3647 |
caps = orig(repo, caps) |
dddb8a70437c
obsexc: add support for evoext_pushobsmarkers_0 on localpeer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1080
diff
changeset
|
3648 |
caps.add('_evoext_pushobsmarkers_0') |
dddb8a70437c
obsexc: add support for evoext_pushobsmarkers_0 on localpeer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1080
diff
changeset
|
3649 |
return caps |
dddb8a70437c
obsexc: add support for evoext_pushobsmarkers_0 on localpeer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1080
diff
changeset
|
3650 |
|
1314
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3651 |
def _pushobsmarkers(repo, data): |
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3652 |
tr = lock = None |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3653 |
try: |
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3654 |
lock = repo.lock() |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3655 |
tr = repo.transaction('pushkey: obsolete markers') |
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3656 |
new = repo.obsstore.mergemarkers(tr, data) |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3657 |
if new is not None: |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3658 |
obsexcmsg(repo.ui, "%i obsolescence markers added\n" % new, True) |
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3659 |
tr.close() |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3660 |
finally: |
1308
676d88a82d4a
evolve: improve transaction related code to use the lock module
Laurent Charignon <lcharignon@fb.com>
parents:
1307
diff
changeset
|
3661 |
lockmod.release(tr, lock) |
888
097ddcb0da25
evolve: add a hook related to the new pushobsmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
887
diff
changeset
|
3662 |
repo.hook('evolve_pushobsmarkers') |
1314
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3663 |
|
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3664 |
@eh.addattr(localrepo.localpeer, 'evoext_pushobsmarkers_0') |
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3665 |
def local_pushobsmarkers(peer, obsfile): |
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3666 |
data = obsfile.read() |
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3667 |
_pushobsmarkers(peer._repo, data) |
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3668 |
|
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3669 |
def srv_pushobsmarkers(repo, proto): |
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3670 |
"""wireprotocol command""" |
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3671 |
fp = StringIO() |
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3672 |
proto.redirect() |
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3673 |
proto.getfile(fp) |
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3674 |
data = fp.getvalue() |
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3675 |
fp.close() |
d13d97363521
evolve: refactoring of code related to pushing obs markers
Laurent Charignon <lcharignon@fb.com>
parents:
1313
diff
changeset
|
3676 |
_pushobsmarkers(repo, data) |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3677 |
return wireproto.pushres(0) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3678 |
|
1095
26334cfd4e95
evolve: fix a typo in a long function name
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1094
diff
changeset
|
3679 |
def _buildpullobsmarkersboundaries(pullop): |
825
7671717afef8
exchange: extract computation of pulled markers boundary in a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
824
diff
changeset
|
3680 |
"""small funtion returning the argument for pull markers call |
7671717afef8
exchange: extract computation of pulled markers boundary in a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
824
diff
changeset
|
3681 |
may to contains 'heads' and 'common'. skip the key for None. |
7671717afef8
exchange: extract computation of pulled markers boundary in a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
824
diff
changeset
|
3682 |
|
7671717afef8
exchange: extract computation of pulled markers boundary in a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
824
diff
changeset
|
3683 |
Its a separed functio to play around with strategy for that.""" |
865
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
3684 |
repo = pullop.repo |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
3685 |
remote = pullop.remote |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
3686 |
unfi = repo.unfiltered() |
1196
9e3f332f7630
discovery: filter null from the discovery revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1193
diff
changeset
|
3687 |
revs = unfi.revs('::(%ln - null)', pullop.common) |
865
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
3688 |
common = [nullid] |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
3689 |
if remote.capable('_evoext_obshash_0'): |
1033
908273755215
evolve: move OBSEXC message in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1032
diff
changeset
|
3690 |
obsexcmsg(repo.ui, "looking for common markers in %i nodes\n" |
908273755215
evolve: move OBSEXC message in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1032
diff
changeset
|
3691 |
% len(revs)) |
865
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
3692 |
common = findcommonobsmarkers(repo.ui, repo, remote, revs) |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
3693 |
return {'heads': pullop.pulledsubset, 'common': common} |
825
7671717afef8
exchange: extract computation of pulled markers boundary in a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
824
diff
changeset
|
3694 |
|
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3695 |
@eh.uisetup |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3696 |
def addgetbundleargs(self): |
1097
580a2d838996
pull: use discovery to pull less obsmarkers through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1096
diff
changeset
|
3697 |
gboptsmap['evo_obscommon'] = 'nodes' |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3698 |
|
1097
580a2d838996
pull: use discovery to pull less obsmarkers through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1096
diff
changeset
|
3699 |
@eh.wrapfunction(exchange, '_pullbundle2extraprepare') |
580a2d838996
pull: use discovery to pull less obsmarkers through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1096
diff
changeset
|
3700 |
def _addobscommontob2pull(orig, pullop, kwargs): |
580a2d838996
pull: use discovery to pull less obsmarkers through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1096
diff
changeset
|
3701 |
ret = orig(pullop, kwargs) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3702 |
if ('obsmarkers' in kwargs and |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3703 |
pullop.remote.capable('_evoext_getbundle_obscommon')): |
1097
580a2d838996
pull: use discovery to pull less obsmarkers through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1096
diff
changeset
|
3704 |
boundaries = _buildpullobsmarkersboundaries(pullop) |
580a2d838996
pull: use discovery to pull less obsmarkers through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1096
diff
changeset
|
3705 |
common = boundaries['common'] |
580a2d838996
pull: use discovery to pull less obsmarkers through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1096
diff
changeset
|
3706 |
if common != [nullid]: |
580a2d838996
pull: use discovery to pull less obsmarkers through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1096
diff
changeset
|
3707 |
kwargs['evo_obscommon'] = common |
580a2d838996
pull: use discovery to pull less obsmarkers through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1096
diff
changeset
|
3708 |
return ret |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3709 |
|
1301
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3710 |
@eh.wrapfunction(exchange, '_getbundleobsmarkerpart') |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3711 |
def _getbundleobsmarkerpart(orig, bundler, repo, source, **kwargs): |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3712 |
if 'evo_obscommon' not in kwargs: |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3713 |
return orig(bundler, repo, source, **kwargs) |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3714 |
|
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3715 |
heads = kwargs.get('heads') |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3716 |
if kwargs.get('obsmarkers', False): |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3717 |
if heads is None: |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3718 |
heads = repo.heads() |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3719 |
obscommon = kwargs.get('evo_obscommon', ()) |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3720 |
assert obscommon |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3721 |
obsset = repo.unfiltered().set('::%ln - ::%ln', heads, obscommon) |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3722 |
subset = [c.node() for c in obsset] |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3723 |
markers = repo.obsstore.relevantmarkers(subset) |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3724 |
exchange.buildobsmarkerspart(bundler, markers) |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3725 |
|
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3726 |
@eh.uisetup |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3727 |
def installgetbundlepartgen(ui): |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3728 |
origfunc = exchange.getbundle2partsmapping['obsmarkers'] |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3729 |
def newfunc(*args, **kwargs): |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3730 |
return _getbundleobsmarkerpart(origfunc, *args, **kwargs) |
896d66841f7f
evolve: stop conditional wrapping of _getbundleobsmarkerpart
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1300
diff
changeset
|
3731 |
exchange.getbundle2partsmapping['obsmarkers'] = newfunc |
825
7671717afef8
exchange: extract computation of pulled markers boundary in a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
824
diff
changeset
|
3732 |
|
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3733 |
@eh.wrapfunction(exchange, '_pullobsolete') |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3734 |
def _pullobsolete(orig, pullop): |
1214
4b10e2c6f7e3
config: remove uses of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1213
diff
changeset
|
3735 |
if not obsolete.isenabled(pullop.repo, obsolete.exchangeopt): |
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3736 |
return None |
1132
7a1784a1c642
pullobsolete: handle migration from todosteps to donesteps
Augie Fackler <raf@durin42.com>
parents:
1131
diff
changeset
|
3737 |
if 'obsmarkers' not in getattr(pullop, 'todosteps', ['obsmarkers']): |
7a1784a1c642
pullobsolete: handle migration from todosteps to donesteps
Augie Fackler <raf@durin42.com>
parents:
1131
diff
changeset
|
3738 |
return None |
7a1784a1c642
pullobsolete: handle migration from todosteps to donesteps
Augie Fackler <raf@durin42.com>
parents:
1131
diff
changeset
|
3739 |
if 'obsmarkers' in getattr(pullop, 'stepsdone', []): |
1093
a49f2e7a2755
obsexch: respect todosteps when using the old push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1091
diff
changeset
|
3740 |
return None |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3741 |
wirepull = pullop.remote.capable('_evoext_pullobsmarkers_0') |
1082
74bc8a0c2c02
pull: drop the custom bundle2 part
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1081
diff
changeset
|
3742 |
if not wirepull: |
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3743 |
return orig(pullop) |
883
d2fa1061df16
evolve: do not exchange obsolescence markers when server refuse it
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
880
diff
changeset
|
3744 |
if 'obsolete' not in pullop.remote.listkeys('namespaces'): |
d2fa1061df16
evolve: do not exchange obsolescence markers when server refuse it
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
880
diff
changeset
|
3745 |
return None # remote opted out of obsolescence marker exchange |
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3746 |
tr = None |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3747 |
ui = pullop.repo.ui |
1095
26334cfd4e95
evolve: fix a typo in a long function name
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1094
diff
changeset
|
3748 |
boundaries = _buildpullobsmarkersboundaries(pullop) |
1041
7632f1f79946
evolve: do not even try to pull if all remote markers are known
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1040
diff
changeset
|
3749 |
if not set(boundaries['heads']) - set(boundaries['common']): |
7632f1f79946
evolve: do not even try to pull if all remote markers are known
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1040
diff
changeset
|
3750 |
obsexcmsg(ui, "nothing to pull\n") |
7632f1f79946
evolve: do not even try to pull if all remote markers are known
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1040
diff
changeset
|
3751 |
return None |
7632f1f79946
evolve: do not even try to pull if all remote markers are known
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1040
diff
changeset
|
3752 |
|
1042
86bd794f6037
evolve: stop pretending we are pulling markers when we don't
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1041
diff
changeset
|
3753 |
obsexcmsg(ui, "pull obsolescence markers\n", True) |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3754 |
new = 0 |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3755 |
|
1082
74bc8a0c2c02
pull: drop the custom bundle2 part
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1081
diff
changeset
|
3756 |
if wirepull: |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3757 |
obsdata = pullop.remote.evoext_pullobsmarkers_0(**boundaries) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3758 |
obsdata = obsdata.read() |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3759 |
if len(obsdata) > 5: |
1033
908273755215
evolve: move OBSEXC message in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1032
diff
changeset
|
3760 |
obsexcmsg(ui, "merging obsolescence markers (%i bytes)\n" |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3761 |
% len(obsdata)) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3762 |
tr = pullop.gettransaction() |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3763 |
old = len(pullop.repo.obsstore._all) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3764 |
pullop.repo.obsstore.mergemarkers(tr, obsdata) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3765 |
new = len(pullop.repo.obsstore._all) - old |
1040
640f3280559e
evolve: add "obsolescence" in front of marked in the previous message
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1039
diff
changeset
|
3766 |
obsexcmsg(ui, "%i obsolescence markers added\n" % new, True) |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3767 |
else: |
1033
908273755215
evolve: move OBSEXC message in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1032
diff
changeset
|
3768 |
obsexcmsg(ui, "no unknown remote markers\n") |
908273755215
evolve: move OBSEXC message in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1032
diff
changeset
|
3769 |
obsexcmsg(ui, "DONE\n") |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3770 |
if new: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
3771 |
pullop.repo.invalidatevolatilesets() |
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3772 |
return tr |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3773 |
|
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3774 |
def _getobsmarkersstream(repo, heads=None, common=None): |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3775 |
revset = '' |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3776 |
args = [] |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3777 |
repo = repo.unfiltered() |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3778 |
if heads is None: |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3779 |
revset = 'all()' |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3780 |
elif heads: |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3781 |
revset += "(::%ln)" |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3782 |
args.append(heads) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3783 |
else: |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3784 |
assert False, 'pulling no heads?' |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3785 |
if common: |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3786 |
revset += ' - (::%ln)' |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3787 |
args.append(common) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3788 |
nodes = [c.node() for c in repo.set(revset, *args)] |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3789 |
markers = repo.obsstore.relevantmarkers(nodes) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3790 |
obsdata = StringIO() |
1091
236a8e81551e
compat: use in-core encodemarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1090
diff
changeset
|
3791 |
for chunk in obsolete.encodemarkers(markers, True): |
236a8e81551e
compat: use in-core encodemarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1090
diff
changeset
|
3792 |
obsdata.write(chunk) |
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3793 |
obsdata.seek(0) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3794 |
return obsdata |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3795 |
|
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3796 |
@eh.addattr(wireproto.wirepeer, 'evoext_pullobsmarkers_0') |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3797 |
def client_pullobsmarkers(self, heads=None, common=None): |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3798 |
self.requirecap('_evoext_pullobsmarkers_0', _('look up remote obsmarkers')) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3799 |
opts = {} |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3800 |
if heads is not None: |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3801 |
opts['heads'] = wireproto.encodelist(heads) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3802 |
if common is not None: |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3803 |
opts['common'] = wireproto.encodelist(common) |
897
b5227608d9dd
evolve: use new api _callcompressable
Olle Lundberg <geek@nerd.sh>
parents:
896
diff
changeset
|
3804 |
if util.safehasattr(self, '_callcompressable'): |
b5227608d9dd
evolve: use new api _callcompressable
Olle Lundberg <geek@nerd.sh>
parents:
896
diff
changeset
|
3805 |
f = self._callcompressable("evoext_pullobsmarkers_0", **opts) |
b5227608d9dd
evolve: use new api _callcompressable
Olle Lundberg <geek@nerd.sh>
parents:
896
diff
changeset
|
3806 |
else: |
b5227608d9dd
evolve: use new api _callcompressable
Olle Lundberg <geek@nerd.sh>
parents:
896
diff
changeset
|
3807 |
f = self._callstream("evoext_pullobsmarkers_0", **opts) |
b5227608d9dd
evolve: use new api _callcompressable
Olle Lundberg <geek@nerd.sh>
parents:
896
diff
changeset
|
3808 |
f = self._decompress(f) |
898
934b6f0feffd
evolve: small white space change
Olle Lundberg <geek@nerd.sh>
parents:
897
diff
changeset
|
3809 |
length = int(f.read(20)) |
853
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
3810 |
chunk = 4096 |
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
3811 |
current = 0 |
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
3812 |
data = StringIO() |
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
3813 |
ui = self.ui |
1624
081605c2e9b6
evolve: mark progress units for translation
Anton Shestakov <av6@dwimlabs.net>
parents:
1623
diff
changeset
|
3814 |
obsexcprg(ui, current, unit=_("bytes"), total=length) |
853
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
3815 |
while current < length: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3816 |
readsize = min(length - current, chunk) |
853
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
3817 |
data.write(f.read(readsize)) |
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
3818 |
current += readsize |
1624
081605c2e9b6
evolve: mark progress units for translation
Anton Shestakov <av6@dwimlabs.net>
parents:
1623
diff
changeset
|
3819 |
obsexcprg(ui, current, unit=_("bytes"), total=length) |
1034
5fd28e46e8f5
evolve: move OBSEXC progress in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1033
diff
changeset
|
3820 |
obsexcprg(ui, None) |
870
1a23c7c52a43
exchange: fix pull over wire protocol
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
869
diff
changeset
|
3821 |
data.seek(0) |
853
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
3822 |
return data |
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3823 |
|
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3824 |
@eh.addattr(localrepo.localpeer, 'evoext_pullobsmarkers_0') |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3825 |
def local_pullobsmarkers(self, heads=None, common=None): |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3826 |
return _getobsmarkersstream(self._repo, heads=heads, common=common) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3827 |
|
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3828 |
def srv_pullobsmarkers(repo, proto, others): |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3829 |
opts = wireproto.options('', ['heads', 'common'], others) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3830 |
for k, v in opts.iteritems(): |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3831 |
if k in ('heads', 'common'): |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3832 |
opts[k] = wireproto.decodelist(v) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3833 |
obsdata = _getobsmarkersstream(repo, **opts) |
877
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
3834 |
finaldata = StringIO() |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
3835 |
obsdata = obsdata.getvalue() |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
3836 |
finaldata.write('%20i' % len(obsdata)) |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
3837 |
finaldata.write(obsdata) |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
3838 |
finaldata.seek(0) |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
3839 |
return wireproto.streamres(proto.groupchunks(finaldata)) |
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3840 |
|
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3841 |
def _obsrelsethashtreefm0(repo): |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3842 |
return _obsrelsethashtree(repo, obsolete._fm0encodeonemarker) |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3843 |
|
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3844 |
def _obsrelsethashtreefm1(repo): |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3845 |
return _obsrelsethashtree(repo, obsolete._fm1encodeonemarker) |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3846 |
|
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3847 |
def _obsrelsethashtree(repo, encodeonemarker): |
863
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3848 |
cache = [] |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3849 |
unfi = repo.unfiltered() |
1203
936aa82884ab
evolve: cache marker encoding to avoid performance degradation
Mathias De Maré <mathias.demare@gmail.com>
parents:
1202
diff
changeset
|
3850 |
markercache = {} |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3851 |
repo.ui.progress(_("preparing locally"), 0, total=len(unfi)) |
863
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3852 |
for i in unfi: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3853 |
ctx = unfi[i] |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3854 |
entry = 0 |
1713
00612a019547
evolve: use hashlib to compute sha1 hashes
Jeroen Vaelen <jeroen@fb.com>
parents:
1710
diff
changeset
|
3855 |
sha = hashlib.sha1() |
863
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3856 |
# add data from p1 |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3857 |
for p in ctx.parents(): |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3858 |
p = p.rev() |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3859 |
if p < 0: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3860 |
p = nullid |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3861 |
else: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3862 |
p = cache[p][1] |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3863 |
if p != nullid: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3864 |
entry += 1 |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3865 |
sha.update(p) |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3866 |
tmarkers = repo.obsstore.relevantmarkers([ctx.node()]) |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3867 |
if tmarkers: |
1203
936aa82884ab
evolve: cache marker encoding to avoid performance degradation
Mathias De Maré <mathias.demare@gmail.com>
parents:
1202
diff
changeset
|
3868 |
bmarkers = [] |
936aa82884ab
evolve: cache marker encoding to avoid performance degradation
Mathias De Maré <mathias.demare@gmail.com>
parents:
1202
diff
changeset
|
3869 |
for m in tmarkers: |
936aa82884ab
evolve: cache marker encoding to avoid performance degradation
Mathias De Maré <mathias.demare@gmail.com>
parents:
1202
diff
changeset
|
3870 |
if not m in markercache: |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3871 |
markercache[m] = encodeonemarker(m) |
1203
936aa82884ab
evolve: cache marker encoding to avoid performance degradation
Mathias De Maré <mathias.demare@gmail.com>
parents:
1202
diff
changeset
|
3872 |
bmarkers.append(markercache[m]) |
863
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3873 |
bmarkers.sort() |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3874 |
for m in bmarkers: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3875 |
entry += 1 |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3876 |
sha.update(m) |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3877 |
if entry: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3878 |
cache.append((ctx.node(), sha.digest())) |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3879 |
else: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3880 |
cache.append((ctx.node(), nullid)) |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3881 |
repo.ui.progress(_("preparing locally"), i, total=len(unfi)) |
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3882 |
repo.ui.progress(_("preparing locally"), None) |
863
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3883 |
return cache |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3884 |
|
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3885 |
@command('debugobsrelsethashtree', |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3886 |
[('', 'v0', None, 'hash on marker format "0"'), |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3887 |
('', 'v1', None, 'hash on marker format "1" (default)')] , _('')) |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3888 |
def debugobsrelsethashtree(ui, repo, v0=False, v1=False): |
863
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3889 |
"""display Obsolete markers, Relevant Set, Hash Tree |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3890 |
changeset-node obsrelsethashtree-node |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3891 |
|
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3892 |
It computed form the "orsht" of its parent and markers |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3893 |
relevant to the changeset itself.""" |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3894 |
if v0 and v1: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3895 |
raise error.Abort('cannot only specify one format') |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3896 |
elif v0: |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3897 |
treefunc = _obsrelsethashtreefm0 |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3898 |
else: |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3899 |
treefunc = _obsrelsethashtreefm1 |
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3900 |
|
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3901 |
for chg, obs in treefunc(repo): |
863
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3902 |
ui.status('%s %s\n' % (node.hex(chg), node.hex(obs))) |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3903 |
|
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3904 |
_bestformat = max(obsolete.formats.keys()) |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3905 |
|
1202
4099b087f672
evolve: handle invalid obsmarkers in the `debugobsconvert`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1198
diff
changeset
|
3906 |
|
1302
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3907 |
@eh.wrapfunction(obsolete, '_checkinvalidmarkers') |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3908 |
def _checkinvalidmarkers(orig, markers): |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3909 |
"""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
|
3910 |
|
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3911 |
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
|
3912 |
subtle handling. |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3913 |
""" |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3914 |
if 'debugobsconvert' in sys.argv: |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3915 |
return |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3916 |
for mark in markers: |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3917 |
if node.nullid in mark[1]: |
1547
425c0700aabd
check-code: make evolve.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1536
diff
changeset
|
3918 |
raise error.Abort(_('bad obsolescence marker detected: ' |
1302
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3919 |
'invalid successors nullid'), |
ebcf23fe3032
evolve: stop conditional wrapping of _checkinvalidmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1301
diff
changeset
|
3920 |
hint=_('You should run `hg debugobsconvert`')) |
1202
4099b087f672
evolve: handle invalid obsmarkers in the `debugobsconvert`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1198
diff
changeset
|
3921 |
|
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3922 |
@command( |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3923 |
'debugobsconvert', |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3924 |
[('', 'new-format', _bestformat, _('Destination format for markers.'))], |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3925 |
'') |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3926 |
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
|
3927 |
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
|
3928 |
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
|
3929 |
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
|
3930 |
raise error.Abort(msg) |
1465
777e5c369d99
compat: use svfs instead of sopener
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1464
diff
changeset
|
3931 |
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
|
3932 |
known = set() |
6f08a8f6bb1d
debugobsconvert: also deduplicate markers in the process
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
3933 |
markers = [] |
1172
8d28bb4fc127
debugobsconvert: fix 6f08a8f6bb1d and add proper test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1171
diff
changeset
|
3934 |
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
|
3935 |
# filter out invalid markers |
4099b087f672
evolve: handle invalid obsmarkers in the `debugobsconvert`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1198
diff
changeset
|
3936 |
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
|
3937 |
m = list(m) |
4099b087f672
evolve: handle invalid obsmarkers in the `debugobsconvert`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1198
diff
changeset
|
3938 |
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
|
3939 |
m = tuple(m) |
1169
6f08a8f6bb1d
debugobsconvert: also deduplicate markers in the process
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
3940 |
if m in known: |
6f08a8f6bb1d
debugobsconvert: also deduplicate markers in the process
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
3941 |
continue |
1172
8d28bb4fc127
debugobsconvert: fix 6f08a8f6bb1d and add proper test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1171
diff
changeset
|
3942 |
known.add(m) |
1169
6f08a8f6bb1d
debugobsconvert: also deduplicate markers in the process
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
3943 |
markers.append(m) |
1170
4697f23e0ede
debugobsconvert: fix a typo on "version"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1169
diff
changeset
|
3944 |
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
|
3945 |
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
|
3946 |
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
|
3947 |
f.close() |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
1157
diff
changeset
|
3948 |
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
|
3949 |
|
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3950 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3951 |
@eh.wrapfunction(wireproto, 'capabilities') |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3952 |
def capabilities(orig, repo, proto): |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3953 |
"""wrapper to advertise new capability""" |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3954 |
caps = orig(repo, proto) |
1214
4b10e2c6f7e3
config: remove uses of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1213
diff
changeset
|
3955 |
if obsolete.isenabled(repo, obsolete.exchangeopt): |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3956 |
caps += ' _evoext_pushobsmarkers_0' |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3957 |
caps += ' _evoext_pullobsmarkers_0' |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3958 |
caps += ' _evoext_obshash_0' |
1244
3249814dabd1
discovery: introduce a obshash1 function using fm1 during hashing (issue4587)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1230
diff
changeset
|
3959 |
caps += ' _evoext_obshash_1' |
1096
661f3a112f7a
pull: run obsmarker discovery only on the common set
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1095
diff
changeset
|
3960 |
caps += ' _evoext_getbundle_obscommon' |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
3961 |
return caps |
863
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3962 |
|
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
3963 |
|
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3964 |
@eh.extsetup |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3965 |
def _installwireprotocol(ui): |
941
576d3a198269
evolve: drop some pre-3.0 compatibility code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
940
diff
changeset
|
3966 |
localrepo.moderncaps.add('_evoext_pullobsmarkers_0') |
869
e9eeef0d07ec
exchange: enforce permission on new wireprotocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
868
diff
changeset
|
3967 |
hgweb_mod.perms['evoext_pushobsmarkers_0'] = 'push' |
e9eeef0d07ec
exchange: enforce permission on new wireprotocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
868
diff
changeset
|
3968 |
hgweb_mod.perms['evoext_pullobsmarkers_0'] = 'pull' |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
3969 |
wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '') |
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
3970 |
wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*') |
875
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
871
diff
changeset
|
3971 |
# wrap command content |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
871
diff
changeset
|
3972 |
oldcap, args = wireproto.commands['capabilities'] |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
871
diff
changeset
|
3973 |
def newcap(repo, proto): |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
871
diff
changeset
|
3974 |
return capabilities(oldcap, repo, proto) |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
871
diff
changeset
|
3975 |
wireproto.commands['capabilities'] = (newcap, args) |
1414
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3976 |
|
1509
405be3783fbc
evolve: ignore ui argument passed to help loader
Yuya Nishihara <yuya@tcha.org>
parents:
1507
diff
changeset
|
3977 |
# Mercurial >= 3.6 passes ui |
405be3783fbc
evolve: ignore ui argument passed to help loader
Yuya Nishihara <yuya@tcha.org>
parents:
1507
diff
changeset
|
3978 |
def _helploader(ui=None): |
1414
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3979 |
return help.gettext(evolutionhelptext) |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3980 |
|
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3981 |
@eh.uisetup |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3982 |
def _setuphelp(ui): |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3983 |
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
|
3984 |
if entry[0] == "evolution": |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3985 |
break |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3986 |
else: |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3987 |
help.helptable.append((["evolution"], _("Safely Rewriting History"), |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3988 |
_helploader)) |
4198e2fad6ba
evolve: add an help topic about evolution
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1413
diff
changeset
|
3989 |
help.helptable.sort() |
1567
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3990 |
|
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3991 |
def _relocatecommit(repo, orig, commitmsg): |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3992 |
if commitmsg is None: |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3993 |
commitmsg = orig.description() |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3994 |
extra = dict(orig.extra()) |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3995 |
if 'branch' in extra: |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3996 |
del extra['branch'] |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3997 |
extra['rebase_source'] = orig.hex() |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3998 |
|
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
3999 |
backup = repo.ui.backupconfig('phases', 'new-commit') |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
4000 |
try: |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
4001 |
targetphase = max(orig.phase(), phases.draft) |
1636
13f830540a14
config: report evolve as origin for config
timeless@gmail.com
parents:
1635
diff
changeset
|
4002 |
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
|
4003 |
# Commit might fail if unresolved files exist |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
4004 |
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
|
4005 |
date=orig.date(), extra=extra) |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
4006 |
finally: |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
4007 |
repo.ui.restoreconfig(backup) |
536fdfa3c48b
evolve: extract logic to new method _relocatecommit
Shusen LIU <liushusen@fb.com>
parents:
1566
diff
changeset
|
4008 |
return nodenew |
1568
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4009 |
|
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4010 |
def _finalizerelocate(repo, orig, dest, nodenew, tr): |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4011 |
destbookmarks = repo.nodebookmarks(dest.node()) |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4012 |
nodesrc = orig.node() |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4013 |
destphase = repo[nodesrc].phase() |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4014 |
oldbookmarks = repo.nodebookmarks(nodesrc) |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4015 |
if nodenew is not None: |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4016 |
phases.retractboundary(repo, tr, destphase, [nodenew]) |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4017 |
obsolete.createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))]) |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4018 |
for book in oldbookmarks: |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4019 |
repo._bookmarks[book] = nodenew |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4020 |
else: |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4021 |
obsolete.createmarkers(repo, [(repo[nodesrc], ())]) |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4022 |
# Behave like rebase, move bookmarks to dest |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4023 |
for book in oldbookmarks: |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4024 |
repo._bookmarks[book] = dest.node() |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4025 |
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
|
4026 |
repo._bookmarks[book] = dest.node() |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4027 |
if oldbookmarks or destbookmarks: |
52c276d2ddb2
evolve: extract logic to new method _finalizerelocate
Shusen LIU <liushusen@fb.com>
parents:
1567
diff
changeset
|
4028 |
repo._bookmarks.recordchange(tr) |
1592
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4029 |
|
1597
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4030 |
evolvestateversion = 0 |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4031 |
|
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4032 |
@eh.uisetup |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4033 |
def setupevolveunfinished(ui): |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4034 |
data = ('evolvestate', True, False, _('evolve in progress'), |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4035 |
_("use 'hg evolve --continue' or 'hg update' to abort")) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4036 |
cmdutil.unfinishedstates.append(data) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4037 |
|
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4038 |
@eh.wrapfunction(hg, 'clean') |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4039 |
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
|
4040 |
ret = orig(repo, *args, **kwargs) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4041 |
util.unlinkpath(repo.join('evolvestate'), ignoremissing=True) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4042 |
return ret |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4043 |
|
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4044 |
def _evolvestatewrite(repo, state): |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4045 |
# [version] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4046 |
# [type][length][content] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4047 |
# |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4048 |
# `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
|
4049 |
# `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
|
4050 |
# `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
|
4051 |
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
|
4052 |
try: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4053 |
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
|
4054 |
current = state['current'] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4055 |
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
|
4056 |
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
|
4057 |
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
|
4058 |
finally: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4059 |
f.close() |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4060 |
|
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4061 |
def _evolvestateread(repo): |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4062 |
try: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4063 |
f = repo.vfs('evolvestate') |
1679
6103f6ac8110
py3: change except from two comma to as notation
timeless@gmail.com
parents:
1678
diff
changeset
|
4064 |
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
|
4065 |
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
|
4066 |
raise |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4067 |
return None |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4068 |
try: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4069 |
versionblob = f.read(4) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4070 |
if len(versionblob) < 4: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4071 |
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
|
4072 |
% len(versionblob)) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4073 |
return None |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4074 |
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
|
4075 |
if version != evolvestateversion: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4076 |
raise error.Abort(_('unknown evolvestate version %i') |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4077 |
% version, hint=_('upgrade your evolve')) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4078 |
records = [] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4079 |
data = f.read() |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4080 |
off = 0 |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4081 |
end = len(data) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4082 |
while off < end: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4083 |
rtype = data[off] |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4084 |
off += 1 |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4085 |
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
|
4086 |
off += 4 |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4087 |
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
|
4088 |
off += length |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4089 |
if rtype == 't': |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4090 |
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
|
4091 |
records.append((rtype, record)) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4092 |
state = {} |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4093 |
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
|
4094 |
if rtype == 'C': |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4095 |
state['current'] = rdata |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4096 |
elif rtype.lower(): |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4097 |
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
|
4098 |
else: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4099 |
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
|
4100 |
% 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
|
4101 |
return state |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4102 |
finally: |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4103 |
f.close() |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4104 |
|
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4105 |
def _evolvestatedelete(repo): |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4106 |
util.unlinkpath(repo.join('evolvestate'), ignoremissing=True) |
7876ed4fceb7
evolve: write our own custom evolvestate file
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1594
diff
changeset
|
4107 |
|
1592
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4108 |
def _evolvemerge(repo, orig, dest, pctx, keepbranch): |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4109 |
"""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
|
4110 |
return the same tuple as merge.graft""" |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4111 |
if repo['.'].rev() != dest.rev(): |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4112 |
merge.update(repo, dest, False, True, False) |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4113 |
if bmactive(repo): |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4114 |
repo.ui.status(_("(leaving bookmark %s)\n") % bmactive(repo)) |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4115 |
bmdeactivate(repo) |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4116 |
if keepbranch: |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4117 |
repo.dirstate.setbranch(orig.branch()) |
1627
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
4118 |
if util.safehasattr(repo, 'currenttopic'): |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
4119 |
# uurrgs |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
4120 |
# there no other topic setter yet |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
4121 |
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
|
4122 |
repo.vfs.unlink('topic') |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
4123 |
else: |
a91115687a7e
topic: preserve topic during evolve
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1626
diff
changeset
|
4124 |
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
|
4125 |
f.write(orig.topic()) |
1592
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4126 |
|
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4127 |
try: |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4128 |
r = merge.graft(repo, orig, pctx, ['local', 'graft'], True) |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4129 |
except TypeError: |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4130 |
# not using recent enough mercurial |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4131 |
if len(orig.parents()) == 2: |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4132 |
raise error.Abort( |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4133 |
_("no support for evolving merge changesets yet"), |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4134 |
hint=_("Redo the merge and use `hg prune <old> --succ " |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4135 |
"<new>` to obsolete the old one")) |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4136 |
|
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4137 |
r = merge.graft(repo, orig, pctx, ['local', 'graft']) |
f157ef7b1741
evolve: extract logic to new method _evolvemerge
Shusen LIU <liushusen@fb.com>
parents:
1589
diff
changeset
|
4138 |
return r |