author | Pierre-Yves David <pierre-yves.david@fb.com> |
Fri, 25 Jul 2014 17:13:54 +0200 | |
changeset 1007 | 1d8ba8244001 |
parent 1006 | deba3a063c63 |
child 1008 | a010ba5a0ffb |
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 |
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
12 |
issues it may raise. |
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 |
|
540
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
16 |
- enables the "Changeset Obsolescence" feature of mercurial, |
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, |
8c5da9e75ae0
evolve: fixing syntax/grammar
Patrick Mezard <patrick@mezard.eu>
parents:
539
diff
changeset
|
19 |
- improves some aspect of the early implementation in 2.3 |
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 |
|
1004
808a33826700
evolve: update the tested with statement
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1002
diff
changeset
|
22 |
testedwith = '3.0.1 3.1' |
584
af3b0d696e7f
evolve: add tested with info
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
577
diff
changeset
|
23 |
buglink = 'https://bitbucket.org/marmoute/mutable-history/issues' |
af3b0d696e7f
evolve: add tested with info
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
577
diff
changeset
|
24 |
|
675
af9cc1e861a4
add an explicite warning when repo contains invalid obsolescence markers
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
674
diff
changeset
|
25 |
import sys |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
26 |
import random |
854
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
27 |
from StringIO import StringIO |
820
a9a66143e2ec
exchange: actually use _pushkeyescape fallback
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
819
diff
changeset
|
28 |
import struct |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
29 |
import urllib |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
30 |
|
670
97ce1f801309
evolve: drop unused import
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
663
diff
changeset
|
31 |
import mercurial |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
32 |
from mercurial import util |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
33 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
34 |
try: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
35 |
from mercurial import obsolete |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
36 |
if not obsolete._enabled: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
37 |
obsolete._enabled = True |
952
f83f46411b09
evolve: bump requirement to 3.0.1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
950
diff
changeset
|
38 |
from mercurial import wireproto |
f83f46411b09
evolve: bump requirement to 3.0.1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
950
diff
changeset
|
39 |
gboptslist = getattr(wireproto, 'gboptslist', None) |
955
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
40 |
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
|
41 |
except (ImportError, AttributeError): |
955
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
42 |
gboptslist = gboptsmap = None |
585
f013ca072bd9
evolve: detect and abort if 2.4 is detected
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
584
diff
changeset
|
43 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
44 |
|
820
a9a66143e2ec
exchange: actually use _pushkeyescape fallback
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
819
diff
changeset
|
45 |
from mercurial import base85 |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
46 |
from mercurial import bookmarks |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
47 |
from mercurial import cmdutil |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
48 |
from mercurial import commands |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
49 |
from mercurial import context |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
50 |
from mercurial import copies |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
51 |
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
|
52 |
from mercurial import exchange |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
53 |
from mercurial import extensions |
880
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
54 |
from mercurial import httppeer |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
55 |
from mercurial import hg |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
56 |
from mercurial import lock as lockmod |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
57 |
from mercurial import merge |
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
58 |
from mercurial import node |
113
3bdabdbb4140
adapt evolution to phase in core.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
108
diff
changeset
|
59 |
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
|
60 |
from mercurial import patch |
1007
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
61 |
from mercurial import pushkey |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
62 |
from mercurial import revset |
490
8096833e9226
sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
485
diff
changeset
|
63 |
from mercurial import scmutil |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
64 |
from mercurial import templatekw |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
65 |
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
|
66 |
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
|
67 |
from mercurial.node import nullid |
820
a9a66143e2ec
exchange: actually use _pushkeyescape fallback
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
819
diff
changeset
|
68 |
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
|
69 |
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
|
70 |
from mercurial.hgweb import hgweb_mod |
957
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
71 |
from mercurial import bundle2 |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
72 |
|
820
a9a66143e2ec
exchange: actually use _pushkeyescape fallback
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
819
diff
changeset
|
73 |
_pack = struct.pack |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
74 |
|
955
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
75 |
if gboptsmap is not None: |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
76 |
memfilectx = context.memfilectx |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
77 |
elif gboptslist is not None: |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
78 |
oldmemfilectx = context.memfilectx |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
79 |
def memfilectx(repo, *args, **kwargs): |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
80 |
return oldmemfilectx(*args, **kwargs) |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
81 |
else: |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
82 |
raise util.Abort('Your Mercurial is too old for this version of Evolve\n' |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
83 |
'requires version 3.0.1 or above') |
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
84 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
85 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
86 |
# This extension contains the following code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
87 |
# |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
88 |
# - Extension Helper code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
89 |
# - Obsolescence cache |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
90 |
# - ... |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
91 |
# - Older format compat |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
92 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
93 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
94 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
95 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
96 |
### Extension helper ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
97 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
98 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
99 |
class exthelper(object): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
100 |
"""Helper for modular extension setup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
101 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
102 |
A single helper should be instanciated for each extension. Helper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
103 |
methods are then used as decorator for various purpose. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
104 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
105 |
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
|
106 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
107 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
108 |
def __init__(self): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
109 |
self._uicallables = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
110 |
self._extcallables = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
111 |
self._repocallables = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
112 |
self._revsetsymbols = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
113 |
self._templatekws = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
114 |
self._commandwrappers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
115 |
self._extcommandwrappers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
116 |
self._functionwrappers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
117 |
self._duckpunchers = [] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
118 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
119 |
def final_uisetup(self, ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
120 |
"""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
|
121 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
122 |
The following operations belong here: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
123 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
124 |
- 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
|
125 |
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
|
126 |
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
|
127 |
passed to runcommand |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
128 |
- Command wraps (extensions.wrapcommand) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
129 |
- 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
|
130 |
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
|
131 |
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
|
132 |
during extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
133 |
- 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
|
134 |
module members |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
135 |
- Setup of pre-* and post-* hooks |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
136 |
- pushkey setup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
137 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
138 |
for cont, funcname, func in self._duckpunchers: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
139 |
setattr(cont, funcname, func) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
140 |
for command, wrapper in self._commandwrappers: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
141 |
extensions.wrapcommand(commands.table, command, wrapper) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
142 |
for cont, funcname, wrapper in self._functionwrappers: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
143 |
extensions.wrapfunction(cont, funcname, wrapper) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
144 |
for c in self._uicallables: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
145 |
c(ui) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
146 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
147 |
def final_extsetup(self, ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
148 |
"""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
|
149 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
150 |
The following operations belong here: |
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 |
- 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
|
153 |
extensions.find('mq')) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
154 |
- Add a global option to all commands |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
155 |
- Register revset functions |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
156 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
157 |
knownexts = {} |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
158 |
for name, symbol in self._revsetsymbols: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
159 |
revset.symbols[name] = symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
160 |
for name, kw in self._templatekws: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
161 |
templatekw.keywords[name] = kw |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
162 |
for ext, command, wrapper in self._extcommandwrappers: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
163 |
if ext not in knownexts: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
164 |
e = extensions.find(ext) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
165 |
if e is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
166 |
raise util.Abort('extension %s not found' % ext) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
167 |
knownexts[ext] = e.cmdtable |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
168 |
extensions.wrapcommand(knownexts[ext], commands, wrapper) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
169 |
for c in self._extcallables: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
170 |
c(ui) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
171 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
172 |
def final_reposetup(self, ui, repo): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
173 |
"""Method to be used as a the extension reposetup |
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 |
The following operations belong here: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
176 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
177 |
- All hooks but pre-* and post-* |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
178 |
- Modify configuration variables |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
179 |
- Changes to repo.__class__, repo.dirstate.__class__ |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
180 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
181 |
for c in self._repocallables: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
182 |
c(ui, repo) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
183 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
184 |
def uisetup(self, call): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
185 |
"""Decorated function will be executed during uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
186 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
187 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
188 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
189 |
@eh.uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
190 |
def setupbabar(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
191 |
print 'this is uisetup!' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
192 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
193 |
self._uicallables.append(call) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
194 |
return call |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
195 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
196 |
def extsetup(self, call): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
197 |
"""Decorated function will be executed during extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
198 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
199 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
200 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
201 |
@eh.extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
202 |
def setupcelestine(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
203 |
print 'this is extsetup!' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
204 |
""" |
672
f7834b360f8f
evolve: fix extsetup extension helper
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
671
diff
changeset
|
205 |
self._extcallables.append(call) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
206 |
return call |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
207 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
208 |
def reposetup(self, call): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
209 |
"""Decorated function will be executed during reposetup |
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 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
212 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
213 |
@eh.reposetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
214 |
def setupzephir(ui, repo): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
215 |
print 'this is reposetup!' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
216 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
217 |
self._repocallables.append(call) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
218 |
return call |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
219 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
220 |
def revset(self, symbolname): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
221 |
"""Decorated function is a revset symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
222 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
223 |
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
|
224 |
The symbol is added during `extsetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
225 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
226 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
227 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
228 |
@eh.revset('hidden') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
229 |
def revsetbabar(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
230 |
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
|
231 |
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
|
232 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
233 |
def dec(symbol): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
234 |
self._revsetsymbols.append((symbolname, symbol)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
235 |
return symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
236 |
return dec |
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 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
239 |
def templatekw(self, keywordname): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
240 |
"""Decorated function is a revset keyword |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
241 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
242 |
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
|
243 |
The symbol is added during `extsetup`. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
244 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
245 |
example:: |
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 |
@eh.templatekw('babar') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
248 |
def kwbabar(ctx): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
249 |
return 'babar' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
250 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
251 |
def dec(keyword): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
252 |
self._templatekws.append((keywordname, keyword)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
253 |
return keyword |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
254 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
255 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
256 |
def wrapcommand(self, command, extension=None): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
257 |
"""Decorated function is a command wrapper |
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 |
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
|
260 |
The wrapping is installed during `uisetup`. |
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 |
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
|
263 |
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
|
264 |
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
|
265 |
Abort error is raised. If the wrapping applies to an extension, it is |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
266 |
installed during `extsetup` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
267 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
268 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
269 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
270 |
@eh.wrapcommand('summary') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
271 |
def wrapsummary(orig, ui, repo, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
272 |
ui.note('Barry!') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
273 |
return orig(ui, repo, *args, **kwargs) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
274 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
275 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
276 |
def dec(wrapper): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
277 |
if extension is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
278 |
self._commandwrappers.append((command, wrapper)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
279 |
else: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
280 |
self._extcommandwrappers.append((extension, command, wrapper)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
281 |
return wrapper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
282 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
283 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
284 |
def wrapfunction(self, container, funcname): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
285 |
"""Decorated function is a function wrapper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
286 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
287 |
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
|
288 |
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
|
289 |
(there is no extension support) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
290 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
291 |
example:: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
292 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
293 |
@eh.function(discovery, 'checkheads') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
294 |
def wrapfunction(orig, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
295 |
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
|
296 |
return orig(*args, **kwargs) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
297 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
298 |
def dec(wrapper): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
299 |
self._functionwrappers.append((container, funcname, wrapper)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
300 |
return wrapper |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
301 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
302 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
303 |
def addattr(self, container, funcname): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
304 |
"""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
|
305 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
306 |
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
|
307 |
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
|
308 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
309 |
example:: |
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 |
@eh.function(context.changectx, 'babar') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
312 |
def babar(ctx): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
313 |
return 'babar' in ctx.description |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
314 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
315 |
def dec(func): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
316 |
self._duckpunchers.append((container, funcname, func)) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
317 |
return func |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
318 |
return dec |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
319 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
320 |
eh = exthelper() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
321 |
uisetup = eh.final_uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
322 |
extsetup = eh.final_extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
323 |
reposetup = eh.final_reposetup |
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 |
##################################################################### |
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
|
326 |
### 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
|
327 |
##################################################################### |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
328 |
|
976
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
329 |
commitopts3 = [ |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
330 |
('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
|
331 |
_('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
|
332 |
('U', 'current-user', None, |
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
333 |
_('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
|
334 |
] |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
335 |
|
985
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
336 |
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
|
337 |
"""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
|
338 |
|
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
339 |
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
|
340 |
-d was supplied. |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
341 |
""" |
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
342 |
# 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
|
343 |
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
|
344 |
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
|
345 |
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
|
346 |
opts['user'] = ui.username() |
976
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
347 |
|
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
|
348 |
@eh.wrapfunction(mercurial.obsolete, 'createmarkers') |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
349 |
def _createmarkers(orig, repo, relations, *args, **kwargs): |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
350 |
"""register parent information at prune time""" |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
351 |
# every time this test is run, a kitten is slain. |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
352 |
# Change it as soon as possible |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
353 |
if '[,{metadata}]' in orig.__doc__: |
973
6d691fefdbd1
evolve: fix createmarkers() wrapper to accept an iterable
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
354 |
relations = list(relations) |
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
|
355 |
for idx, rel in enumerate(relations): |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
356 |
prec = rel[0] |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
357 |
sucs = rel[1] |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
358 |
if not sucs: |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
359 |
meta = {} |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
360 |
if 2 < len(rel): |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
361 |
meta.update(rel[2]) |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
362 |
for i, p in enumerate(prec.parents(), 1): |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
363 |
meta['p%i' % i] = p.hex() |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
364 |
relations[idx] = (prec, sucs, meta) |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
365 |
return orig(repo, relations, *args, **kwargs) |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
366 |
|
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
367 |
def createmarkers(*args, **kwargs): |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
368 |
return obsolete.createmarkers(*args, **kwargs) |
66c02a2e8e2f
prune: wrap mercurial internal to add parent information in prune marker
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
804
diff
changeset
|
369 |
|
806
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
370 |
class pruneobsstore(obsolete.obsstore): |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
371 |
|
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
372 |
def __init__(self, *args, **kwargs): |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
373 |
self.prunedchildren = {} |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
374 |
return super(pruneobsstore, self).__init__(*args, **kwargs) |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
375 |
|
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
376 |
def _load(self, markers): |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
377 |
markers = self._prunedetectingmarkers(markers) |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
378 |
return super(pruneobsstore, self)._load(markers) |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
379 |
|
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
380 |
|
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
381 |
def _prunedetectingmarkers(self, markers): |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
382 |
for m in markers: |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
383 |
if not m[1]: # no successors |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
384 |
meta = obsolete.decodemeta(m[3]) |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
385 |
if 'p1' in meta: |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
386 |
p1 = node.bin(meta['p1']) |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
387 |
self.prunedchildren.setdefault(p1, set()).add(m) |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
388 |
if 'p2' in meta: |
808
81a3d9a24e6b
evolve: fix creation of prunedchildren for merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
807
diff
changeset
|
389 |
p2 = node.bin(meta['p2']) |
806
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
390 |
self.prunedchildren.setdefault(p2, set()).add(m) |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
391 |
yield m |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
392 |
|
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
393 |
obsolete.obsstore = pruneobsstore |
895fadf6ba3e
evolve: extend obsstore object to use prune parent information
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
805
diff
changeset
|
394 |
|
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
|
395 |
##################################################################### |
577
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
396 |
### Critical fix ### |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
397 |
##################################################################### |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
398 |
|
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
399 |
@eh.wrapfunction(mercurial.obsolete, '_readmarkers') |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
400 |
def safereadmarkers(orig, data): |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
401 |
"""safe maker wrapper to remove nullid succesors |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
402 |
|
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
403 |
Nullid successors was created by older version of evolve. |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
404 |
""" |
675
af9cc1e861a4
add an explicite warning when repo contains invalid obsolescence markers
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
674
diff
changeset
|
405 |
nb = 0 |
577
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
406 |
for marker in orig(data): |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
407 |
if nullid in marker[1]: |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
408 |
marker = (marker[0], |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
409 |
tuple(s for s in marker[1] if s != nullid), |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
410 |
marker[2], |
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
411 |
marker[3]) |
675
af9cc1e861a4
add an explicite warning when repo contains invalid obsolescence markers
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
674
diff
changeset
|
412 |
nb += 1 |
577
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
413 |
yield marker |
675
af9cc1e861a4
add an explicite warning when repo contains invalid obsolescence markers
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
674
diff
changeset
|
414 |
if nb: |
af9cc1e861a4
add an explicite warning when repo contains invalid obsolescence markers
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
674
diff
changeset
|
415 |
e = sys.stderr |
af9cc1e861a4
add an explicite warning when repo contains invalid obsolescence markers
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
674
diff
changeset
|
416 |
print >> e, 'repo contains %i invalid obsolescence markers' % nb |
577
2cd2ee20d9fa
evolve: filter nullid successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
576
diff
changeset
|
417 |
|
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
418 |
getrevs = obsolete.getrevs |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
419 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
420 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
421 |
### Additional Utilities ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
422 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
423 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
424 |
# 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
|
425 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
426 |
# - Function to create markers |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
427 |
# - 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
|
428 |
# - "troubles" method on changectx |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
429 |
# - function to travel throught the obsolescence graph |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
430 |
# - function to find useful changeset to stabilize |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
431 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
432 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
433 |
### Useful alias |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
434 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
435 |
@eh.uisetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
436 |
def _installalias(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
437 |
if ui.config('alias', 'pstatus', None) is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
438 |
ui.setconfig('alias', 'pstatus', 'status --rev .^') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
439 |
if ui.config('alias', 'pdiff', None) is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
440 |
ui.setconfig('alias', 'pdiff', 'diff --rev .^') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
441 |
if ui.config('alias', 'olog', None) is None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
442 |
ui.setconfig('alias', 'olog', "log -r 'precursors(.)' --hidden") |
497
43e1b2cab789
evolve: add the odiff alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
492
diff
changeset
|
443 |
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
|
444 |
ui.setconfig('alias', 'odiff', |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
445 |
"diff --hidden --rev 'limit(precursors(.),1)' --rev .") |
696
121e2d265e85
alias: add a grab alias
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
695
diff
changeset
|
446 |
if ui.config('alias', 'grab', None) is None: |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
447 |
ui.setconfig('alias', 'grab', |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
448 |
"! $HG rebase --dest . --rev $@ && $HG up tip") |
696
121e2d265e85
alias: add a grab alias
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
695
diff
changeset
|
449 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
450 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
451 |
### Troubled revset symbol |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
452 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
453 |
@eh.revset('troubled') |
594 | 454 |
def revsettroubled(repo, subset, x): |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
455 |
"""``troubled()`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
456 |
Changesets with troubles. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
457 |
""" |
993
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
458 |
revset.getargs(x, 0, 0, 'troubled takes no arguments') |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
459 |
return repo.revs('%ld and (unstable() + bumped() + divergent())', |
511
ddeb71df916d
evolve: localrepo.revs() already returns a list
Patrick Mezard <patrick@mezard.eu>
parents:
510
diff
changeset
|
460 |
subset) |
491
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 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
463 |
### Obsolescence graph |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
464 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
465 |
# 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
|
466 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
467 |
def _precursors(repo, s): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
468 |
"""Precursor of a changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
469 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
470 |
nm = repo.changelog.nodemap |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
471 |
markerbysubj = repo.obsstore.precursors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
472 |
for r in s: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
473 |
for p in markerbysubj.get(repo[r].node(), ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
474 |
pr = nm.get(p[0]) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
475 |
if pr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
476 |
cs.add(pr) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
477 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
478 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
479 |
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
|
480 |
"""transitive precursors of a subset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
481 |
toproceed = [repo[r].node() for r in s] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
482 |
seen = set() |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
483 |
allsubjects = repo.obsstore.precursors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
484 |
while toproceed: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
485 |
nc = toproceed.pop() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
486 |
for mark in allsubjects.get(nc, ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
487 |
np = mark[0] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
488 |
if np not in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
489 |
seen.add(np) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
490 |
toproceed.append(np) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
491 |
nm = repo.changelog.nodemap |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
492 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
493 |
for p in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
494 |
pr = nm.get(p) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
495 |
if pr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
496 |
cs.add(pr) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
497 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
498 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
499 |
def _successors(repo, s): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
500 |
"""Successors of a changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
501 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
502 |
nm = repo.changelog.nodemap |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
503 |
markerbyobj = repo.obsstore.successors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
504 |
for r in s: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
505 |
for p in markerbyobj.get(repo[r].node(), ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
506 |
for sub in p[1]: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
507 |
sr = nm.get(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
508 |
if sr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
509 |
cs.add(sr) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
510 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
511 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
512 |
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
|
513 |
"""transitive successors of a subset |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
514 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
515 |
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
|
516 |
marker. """ |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
517 |
toproceed = [repo[r].node() for r in s] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
518 |
seen = set() |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
519 |
allobjects = repo.obsstore.successors |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
520 |
while toproceed: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
521 |
nc = toproceed.pop() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
522 |
for mark in allobjects.get(nc, ()): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
523 |
if mark[2] & haltonflags: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
524 |
continue |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
525 |
for sub in mark[1]: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
526 |
if sub == nullid: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
527 |
continue # should not be here! |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
528 |
if sub not in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
529 |
seen.add(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
530 |
toproceed.append(sub) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
531 |
nm = repo.changelog.nodemap |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
532 |
cs = set() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
533 |
for s in seen: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
534 |
sr = nm.get(s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
535 |
if sr is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
536 |
cs.add(sr) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
537 |
return cs |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
538 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
539 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
540 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
541 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
542 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
543 |
### Extending revset and template ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
544 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
545 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
546 |
# 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
|
547 |
# they are subject to changes |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
548 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
549 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
550 |
### 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
|
551 |
@eh.revset('suspended') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
552 |
def revsetsuspended(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
553 |
"""``suspended()`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
554 |
Obsolete changesets with non-obsolete descendants. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
555 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
556 |
args = revset.getargs(x, 0, 0, 'suspended takes no arguments') |
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
557 |
suspended = getrevs(repo, 'suspended') |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
558 |
return [r for r in subset if r in suspended] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
559 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
560 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
561 |
@eh.revset('precursors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
562 |
def revsetprecursors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
563 |
"""``precursors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
564 |
Immediate precursors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
565 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
566 |
s = revset.getset(repo, range(len(repo)), x) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
567 |
cs = _precursors(repo, s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
568 |
return [r for r in subset if r in cs] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
569 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
570 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
571 |
@eh.revset('allprecursors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
572 |
def revsetallprecursors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
573 |
"""``allprecursors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
574 |
Transitive precursors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
575 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
576 |
s = revset.getset(repo, range(len(repo)), x) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
577 |
cs = _allprecursors(repo, s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
578 |
return [r for r in subset if r in cs] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
579 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
580 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
581 |
@eh.revset('successors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
582 |
def revsetsuccessors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
583 |
"""``successors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
584 |
Immediate successors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
585 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
586 |
s = revset.getset(repo, range(len(repo)), x) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
587 |
cs = _successors(repo, s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
588 |
return [r for r in subset if r in cs] |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
589 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
590 |
@eh.revset('allsuccessors') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
591 |
def revsetallsuccessors(repo, subset, x): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
592 |
"""``allsuccessors(set)`` |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
593 |
Transitive successors of changesets in set. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
594 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
595 |
s = revset.getset(repo, range(len(repo)), x) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
596 |
cs = _allsuccessors(repo, s) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
597 |
return [r for r in subset if r in cs] |
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 |
### template keywords |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
600 |
# XXX it does not handle troubles well :-/ |
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 |
@eh.templatekw('obsolete') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
603 |
def obsoletekw(repo, ctx, templ, **args): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
604 |
""":obsolete: String. The obsolescence level of the node, could be |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
605 |
``stable``, ``unstable``, ``suspended`` or ``extinct``. |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
606 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
607 |
rev = ctx.rev() |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
608 |
if ctx.obsolete(): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
609 |
if ctx.extinct(): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
610 |
return 'extinct' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
611 |
else: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
612 |
return 'suspended' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
613 |
elif ctx.unstable(): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
614 |
return 'unstable' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
615 |
return 'stable' |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
616 |
|
982
1c7b73739a0d
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
976
diff
changeset
|
617 |
@eh.templatekw('troubles') |
1c7b73739a0d
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
976
diff
changeset
|
618 |
def showtroubles(repo, ctx, **args): |
1c7b73739a0d
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
976
diff
changeset
|
619 |
""":troubles: List of strings. Evolution troubles affecting the changeset |
1c7b73739a0d
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
976
diff
changeset
|
620 |
(zero or more of "unstable", "divergent" or "bumped").""" |
1c7b73739a0d
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
976
diff
changeset
|
621 |
return templatekw.showlist('trouble', ctx.troubles(), plural='troubles', |
1c7b73739a0d
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
976
diff
changeset
|
622 |
**args) |
1c7b73739a0d
template: add a troubles keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
976
diff
changeset
|
623 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
624 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
625 |
### Various trouble warning ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
626 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
627 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
628 |
# 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
|
629 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
630 |
@eh.wrapcommand("update") |
745
99e51aff724b
add obsolete parents wrapper to the 'parents' command
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
743
diff
changeset
|
631 |
@eh.wrapcommand("parents") |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
632 |
@eh.wrapcommand("pull") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
633 |
def wrapmayobsoletewc(origfn, ui, repo, *args, **opts): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
634 |
"""Warn that the working directory parent is an obsolete changeset""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
635 |
res = origfn(ui, repo, *args, **opts) |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
636 |
if repo['.'].obsolete(): |
743
af74a5cdf96b
conform to the Mercurial custom of lowercase messages
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
742
diff
changeset
|
637 |
ui.warn(_('working directory parent is obsolete!\n')) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
638 |
return res |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
639 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
640 |
# XXX this could wrap transaction code |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
641 |
# 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
|
642 |
@eh.wrapcommand("commit") |
763
966e2659e989
import: warn about new unstable changesets
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
762
diff
changeset
|
643 |
@eh.wrapcommand("import") |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
644 |
@eh.wrapcommand("push") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
645 |
@eh.wrapcommand("pull") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
646 |
@eh.wrapcommand("graft") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
647 |
@eh.wrapcommand("phase") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
648 |
@eh.wrapcommand("unbundle") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
649 |
def warnobserrors(orig, ui, repo, *args, **kwargs): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
650 |
"""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
|
651 |
# 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
|
652 |
# 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
|
653 |
filtered = repo.changelog.filteredrevs |
2a2b8c95bb43
evolve: remove revset calls in warnobserror
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
657
diff
changeset
|
654 |
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
|
655 |
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
|
656 |
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
|
657 |
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
|
658 |
# workaround phase stupidity |
649
d318fbb1cd67
evolve: stop working around phase limitation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
647
diff
changeset
|
659 |
#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
|
660 |
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
|
661 |
newunstables = \ |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
662 |
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
|
663 |
newbumpeds = \ |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
664 |
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
|
665 |
newdivergents = \ |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
666 |
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
|
667 |
if newunstables > 0: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
668 |
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
|
669 |
if newbumpeds > 0: |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
670 |
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
|
671 |
if newdivergents > 0: |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
672 |
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
|
673 |
return ret |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
674 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
675 |
@eh.reposetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
676 |
def _repostabilizesetup(ui, repo): |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
677 |
"""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
|
678 |
""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
679 |
if not repo.local(): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
680 |
return |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
681 |
|
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
682 |
class evolvingrepo(repo.__class__): |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
683 |
def push(self, remote, *args, **opts): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
684 |
"""wrapper around pull that pull obsolete relation""" |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
685 |
try: |
756
64c6bdfd0518
evolve: use super for calling parent class method
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
752
diff
changeset
|
686 |
result = super(evolvingrepo, self).push(remote, *args, **opts) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
687 |
except util.Abort, ex: |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
688 |
hint = _("use 'hg evolve' to get a stable history " |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
689 |
"or --force to ignore warnings") |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
690 |
if (len(ex.args) >= 1 |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
691 |
and ex.args[0].startswith('push includes ') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
692 |
and ex.hint is None): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
693 |
ex.hint = hint |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
694 |
raise |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
695 |
return result |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
696 |
repo.__class__ = evolvingrepo |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
697 |
|
788
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
698 |
def summaryhook(ui, repo): |
513
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
699 |
def write(fmt, count): |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
700 |
s = fmt % count |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
701 |
if count: |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
702 |
ui.write(s) |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
703 |
else: |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
704 |
ui.note(s) |
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
705 |
|
590
02cadd3dc9f4
evolve: adapt to 2.4 code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
589
diff
changeset
|
706 |
nbunstable = len(getrevs(repo, 'unstable')) |
594 | 707 |
nbbumped = len(getrevs(repo, 'bumped')) |
626 | 708 |
nbdivergent = len(getrevs(repo, 'divergent')) |
513
4602104b190d
evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents:
512
diff
changeset
|
709 |
write('unstable: %i changesets\n', nbunstable) |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
710 |
write('bumped: %i changesets\n', nbbumped) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
711 |
write('divergent: %i changesets\n', nbdivergent) |
788
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
712 |
|
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
713 |
@eh.extsetup |
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
714 |
def obssummarysetup(ui): |
e973dd5bf583
evolve: register a summary hook instead of wrapping the summary command
Simon Heimberg <simohe@besonet.ch>
parents:
776
diff
changeset
|
715 |
cmdutil.summaryhooks.add('evolve', summaryhook) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
716 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
717 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
718 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
719 |
### Core Other extension compat ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
720 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
721 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
722 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
723 |
@eh.extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
724 |
def _rebasewrapping(ui): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
725 |
# warning about more obsolete |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
726 |
try: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
727 |
rebase = extensions.find('rebase') |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
728 |
if rebase: |
572
dc107acd0bd2
adapt to core rebase support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
571
diff
changeset
|
729 |
extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
730 |
except KeyError: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
731 |
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
|
732 |
try: |
718262019c6f
evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
677
diff
changeset
|
733 |
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
|
734 |
if histedit: |
718262019c6f
evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
677
diff
changeset
|
735 |
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
|
736 |
except KeyError: |
718262019c6f
evolve: warn for troubles created by histedit too.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
677
diff
changeset
|
737 |
pass # rebase not found |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
738 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
739 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
740 |
### Old Evolve extension content ### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
741 |
##################################################################### |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
742 |
|
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
743 |
# 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
|
744 |
|
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
745 |
### util function |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
746 |
############################# |
303 | 747 |
|
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
748 |
### changeset rewriting logic |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
749 |
############################# |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
750 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
751 |
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
|
752 |
"""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
|
753 |
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
|
754 |
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
|
755 |
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
|
756 |
""" |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
757 |
if len(old.parents()) > 1: #XXX remove this unecessary limitation. |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
758 |
raise error.Abort(_('cannot amend merge changesets')) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
759 |
base = old.p1() |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
760 |
updatebookmarks = _bookmarksupdater(repo, old.node()) |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
761 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
762 |
wlock = repo.wlock() |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
763 |
try: |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
764 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
765 |
# commit a new version of the old changeset, including the update |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
766 |
# collect all files which might be affected |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
767 |
files = set(old.files()) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
768 |
for u in updates: |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
769 |
files.update(u.files()) |
219
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
770 |
|
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
771 |
# Recompute copies (avoid recording a -> b -> a) |
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
772 |
copied = copies.pathcopies(base, head) |
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
773 |
|
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
774 |
|
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
775 |
# prune files which were reverted by the updates |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
776 |
def samefile(f): |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
777 |
if f in head.manifest(): |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
778 |
a = head.filectx(f) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
779 |
if f in base.manifest(): |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
780 |
b = base.filectx(f) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
781 |
return (a.data() == b.data() |
219
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
782 |
and a.flags() == b.flags()) |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
783 |
else: |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
784 |
return False |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
785 |
else: |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
786 |
return f not in base.manifest() |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
787 |
files = [f for f in files if not samefile(f)] |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
788 |
# commit version of these files as defined by head |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
789 |
headmf = head.manifest() |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
790 |
def filectxfn(repo, ctx, path): |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
791 |
if path in headmf: |
219
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
792 |
fctx = head[path] |
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
793 |
flags = fctx.flags() |
955
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
794 |
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
|
795 |
islink='l' in flags, |
ef155e3ead8f
evolve: abstract access to context.memfilectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
953
diff
changeset
|
796 |
isexec='x' in flags, |
ef155e3ead8f
evolve: abstract access to context.memfilectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
953
diff
changeset
|
797 |
copied=copied.get(path)) |
219
cfdab01ca8a0
evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
211
diff
changeset
|
798 |
return mctx |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
799 |
raise IOError() |
909
ff71b83a4bbe
rewrite: use cmdutil.logmessage instead of ad-hoc methods
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
908
diff
changeset
|
800 |
|
ff71b83a4bbe
rewrite: use cmdutil.logmessage instead of ad-hoc methods
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
908
diff
changeset
|
801 |
message = cmdutil.logmessage(repo.ui, commitopts) |
ff71b83a4bbe
rewrite: use cmdutil.logmessage instead of ad-hoc methods
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
908
diff
changeset
|
802 |
if not message: |
104
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
803 |
message = old.description() |
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
804 |
|
142
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
805 |
user = commitopts.get('user') or old.user() |
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
806 |
date = commitopts.get('date') or None # old.date() |
263
de62daaf2054
amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents:
260
diff
changeset
|
807 |
extra = dict(commitopts.get('extra', {})) |
de62daaf2054
amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents:
260
diff
changeset
|
808 |
extra['branch'] = head.branch() |
118
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
809 |
|
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
810 |
new = context.memctx(repo, |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
811 |
parents=newbases, |
104
6c3c7a18f079
propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
103
diff
changeset
|
812 |
text=message, |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
813 |
files=files, |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
814 |
filectxfn=filectxfn, |
142
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
815 |
user=user, |
c2f7a8530e51
overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
141
diff
changeset
|
816 |
date=date, |
263
de62daaf2054
amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents:
260
diff
changeset
|
817 |
extra=extra) |
118
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
818 |
|
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
819 |
if commitopts.get('edit'): |
06fe05256a79
edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
117
diff
changeset
|
820 |
new._text = cmdutil.commitforceeditor(repo, new, []) |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
821 |
revcount = len(repo) |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
822 |
newid = repo.commitctx(new) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
823 |
new = repo[newid] |
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
824 |
created = len(repo) != revcount |
699
dba3ed9f2c4f
amend: prune replacement commit without sucessors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
696
diff
changeset
|
825 |
updatebookmarks(newid) |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
826 |
finally: |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
827 |
wlock.release() |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
828 |
|
265
24943df310d4
amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents:
264
diff
changeset
|
829 |
return newid, created |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
830 |
|
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
831 |
class MergeFailure(util.Abort): |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
832 |
pass |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
833 |
|
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
834 |
def relocate(repo, orig, dest): |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
835 |
"""rewrite <rev> on dest""" |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
836 |
try: |
911
3b7dfa9bb789
evolve: abort when trying to move a node on top of itself
Olle Lundberg <geek@nerd.sh>
parents:
901
diff
changeset
|
837 |
if orig.rev() == dest.rev(): |
946
dedd5359340f
evolve: fix a couple of typos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
945
diff
changeset
|
838 |
raise util.Abort(_('tried to relocate a node on top of itself'), |
911
3b7dfa9bb789
evolve: abort when trying to move a node on top of itself
Olle Lundberg <geek@nerd.sh>
parents:
901
diff
changeset
|
839 |
hint=_("This shouldn't happen. If you still " |
3b7dfa9bb789
evolve: abort when trying to move a node on top of itself
Olle Lundberg <geek@nerd.sh>
parents:
901
diff
changeset
|
840 |
"need to move changesets, please do so " |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
841 |
"manually with nothing to rebase - working " |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
842 |
"directory parent is also destination")) |
911
3b7dfa9bb789
evolve: abort when trying to move a node on top of itself
Olle Lundberg <geek@nerd.sh>
parents:
901
diff
changeset
|
843 |
|
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
844 |
rebase = extensions.find('rebase') |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
845 |
# dummy state to trick rebase node |
776
7eaad1101242
raise util.Abort instead of assertion when trying to evolve a merge changeset.
Arne Babenhauserheide <arne.babenhauserheide@kit.edu>
parents:
763
diff
changeset
|
846 |
if not orig.p2().rev() == node.nullrev: |
7eaad1101242
raise util.Abort instead of assertion when trying to evolve a merge changeset.
Arne Babenhauserheide <arne.babenhauserheide@kit.edu>
parents:
763
diff
changeset
|
847 |
raise util.Abort( |
947
9a6cc7e6f0dd
evolve: improve wording of a few of messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
946
diff
changeset
|
848 |
'no support for evolving merge changesets yet', |
776
7eaad1101242
raise util.Abort instead of assertion when trying to evolve a merge changeset.
Arne Babenhauserheide <arne.babenhauserheide@kit.edu>
parents:
763
diff
changeset
|
849 |
hint="Redo the merge a use `hg prune` to obsolete the old one") |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
850 |
destbookmarks = repo.nodebookmarks(dest.node()) |
258
8337bb3bb958
Fix amend and relocate who picked phases data after extinct wher made secret
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
255
diff
changeset
|
851 |
nodesrc = orig.node() |
8337bb3bb958
Fix amend and relocate who picked phases data after extinct wher made secret
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
255
diff
changeset
|
852 |
destphase = repo[nodesrc].phase() |
923
a94ce5400e1b
evolve: protect call to rebase within a wlock (#42, #35, #16)
Sean Farley <sean.michael.farley@gmail.com>
parents:
915
diff
changeset
|
853 |
wlock = lock = None |
326
52c53e2d413b
stabilize: clear error message than conflict during rebase offer no hope
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
319
diff
changeset
|
854 |
try: |
923
a94ce5400e1b
evolve: protect call to rebase within a wlock (#42, #35, #16)
Sean Farley <sean.michael.farley@gmail.com>
parents:
915
diff
changeset
|
855 |
wlock = repo.wlock() |
a94ce5400e1b
evolve: protect call to rebase within a wlock (#42, #35, #16)
Sean Farley <sean.michael.farley@gmail.com>
parents:
915
diff
changeset
|
856 |
lock = repo.lock() |
674
b3ce838a077e
evolve: remove pre 2.3 code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
673
diff
changeset
|
857 |
r = rebase.rebasenode(repo, orig.node(), dest.node(), |
b3ce838a077e
evolve: remove pre 2.3 code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
673
diff
changeset
|
858 |
{node.nullrev: node.nullrev}, False) |
550
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
859 |
if r[-1]: #some conflict |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
860 |
raise util.Abort( |
362e65fc6146
evolve-cmd: fix merge error detection for external tools.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
549
diff
changeset
|
861 |
'unresolved merge conflicts (see hg help resolve)') |
901
4f84b3307dc2
Fix preservation of rename information on evolve (#33)
Julien Cristau <julien.cristau@logilab.fr>
parents:
893
diff
changeset
|
862 |
cmdutil.duplicatecopies(repo, orig.node(), dest.node()) |
326
52c53e2d413b
stabilize: clear error message than conflict during rebase offer no hope
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
319
diff
changeset
|
863 |
nodenew = rebase.concludenode(repo, orig.node(), dest.node(), |
52c53e2d413b
stabilize: clear error message than conflict during rebase offer no hope
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
319
diff
changeset
|
864 |
node.nullid) |
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
865 |
except util.Abort, exc: |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
866 |
class LocalMergeFailure(MergeFailure, exc.__class__): |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
867 |
pass |
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
868 |
exc.__class__ = LocalMergeFailure |
326
52c53e2d413b
stabilize: clear error message than conflict during rebase offer no hope
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
319
diff
changeset
|
869 |
raise |
923
a94ce5400e1b
evolve: protect call to rebase within a wlock (#42, #35, #16)
Sean Farley <sean.michael.farley@gmail.com>
parents:
915
diff
changeset
|
870 |
finally: |
a94ce5400e1b
evolve: protect call to rebase within a wlock (#42, #35, #16)
Sean Farley <sean.michael.farley@gmail.com>
parents:
915
diff
changeset
|
871 |
lockmod.release(lock, wlock) |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
872 |
oldbookmarks = repo.nodebookmarks(nodesrc) |
284
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
873 |
if nodenew is not None: |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
874 |
phases.retractboundary(repo, destphase, [nodenew]) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
875 |
createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))]) |
284
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
876 |
for book in oldbookmarks: |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
877 |
repo._bookmarks[book] = nodenew |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
878 |
else: |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
879 |
createmarkers(repo, [(repo[nodesrc], ())]) |
284
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
880 |
# Behave like rebase, move bookmarks to dest |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
881 |
for book in oldbookmarks: |
88a851a54f26
evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents:
272
diff
changeset
|
882 |
repo._bookmarks[book] = dest.node() |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
883 |
for book in destbookmarks: # restore bookmark that rebase move |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
884 |
repo._bookmarks[book] = dest.node() |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
885 |
if oldbookmarks or destbookmarks: |
612
15299bfd0813
adapt to 7f5dab94e48c in crew
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
604
diff
changeset
|
886 |
repo._bookmarks.write() |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
887 |
return nodenew |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
888 |
except util.Abort: |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
889 |
# Invalidate the previous setparents |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
890 |
repo.dirstate.invalidate() |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
891 |
raise |
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
892 |
|
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
893 |
def _bookmarksupdater(repo, oldid): |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
894 |
"""Return a callable update(newid) updating the current bookmark |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
895 |
and bookmarks bound to oldid to newid. |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
896 |
""" |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
897 |
bm = bookmarks.readcurrent(repo) |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
898 |
def updatebookmarks(newid): |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
899 |
dirty = False |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
900 |
if bm: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
901 |
repo._bookmarks[bm] = newid |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
902 |
dirty = True |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
903 |
oldbookmarks = repo.nodebookmarks(oldid) |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
904 |
if oldbookmarks: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
905 |
for b in oldbookmarks: |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
906 |
repo._bookmarks[b] = newid |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
907 |
dirty = True |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
908 |
if dirty: |
612
15299bfd0813
adapt to 7f5dab94e48c in crew
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
604
diff
changeset
|
909 |
repo._bookmarks.write() |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
910 |
return updatebookmarks |
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
911 |
|
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
912 |
### new command |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
913 |
############################# |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
914 |
cmdtable = {} |
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
915 |
command = cmdutil.command(cmdtable) |
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
916 |
metadataopts = [ |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
917 |
('d', 'date', '', |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
918 |
_('record the specified date in metadata'), _('DATE')), |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
919 |
('u', 'user', '', |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
920 |
_('record the specified user in metadata'), _('USER')), |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
921 |
] |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
922 |
|
953
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
923 |
@eh.uisetup |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
924 |
def _installimportobsolete(ui): |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
925 |
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
|
926 |
entry[1].append(('', 'obsolete', False, |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
927 |
_('mark the old node as obsoleted by' |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
928 |
'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
|
929 |
|
953
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
930 |
@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
|
931 |
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
|
932 |
extracted = patch.extract(ui, hunk) |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
933 |
expected = extracted[5] |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
934 |
oldextract = patch.extract |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
935 |
try: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
936 |
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
|
937 |
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
|
938 |
finally: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
939 |
patch.extract = oldextract |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
940 |
created = ret[1] |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
941 |
if opts['obsolete'] and created is not None and created != expected: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
942 |
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
|
943 |
try: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
944 |
metadata = {'user': ui.username()} |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
945 |
repo.obsstore.create(tr, node.bin(expected), (created,), |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
946 |
metadata=metadata) |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
947 |
tr.close() |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
948 |
finally: |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
949 |
tr.release() |
a02e5916a7e3
import: drop version check for ``import --obsolete``
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
952
diff
changeset
|
950 |
return ret |
930
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
927
diff
changeset
|
951 |
|
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
952 |
|
894
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
953 |
def _deprecatealias(oldalias, newalias): |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
954 |
'''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
|
955 |
|
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
956 |
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
|
957 |
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
|
958 |
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
|
959 |
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
|
960 |
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
|
961 |
|
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
962 |
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
|
963 |
''' |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
964 |
aliases, entry = cmdutil.findcmd(newalias, cmdtable) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
965 |
for alias, e in cmdtable.iteritems(): |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
966 |
if e is entry: |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
967 |
break |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
968 |
|
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
969 |
synopsis = '(DEPRECATED)' |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
970 |
if len(entry) > 2: |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
971 |
fn, opts, _syn = entry |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
972 |
else: |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
973 |
fn, opts, = entry |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
974 |
deprecationwarning = _('%s have been deprecated in favor of %s\n' % ( |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
975 |
oldalias, newalias)) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
976 |
def newfn(*args, **kwargs): |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
977 |
ui = args[0] |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
978 |
ui.warn(deprecationwarning) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
979 |
util.checksignature(fn)(*args, **kwargs) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
980 |
newfn.__doc__ = deprecationwarning |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
981 |
cmdwrapper = command(oldalias, opts, synopsis) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
982 |
cmdwrapper(newfn) |
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
983 |
|
895
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
984 |
@eh.extsetup |
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
985 |
def deprecatealiases(ui): |
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
986 |
_deprecatealias('gup', 'next') |
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
987 |
_deprecatealias('gdown', 'previous') |
894
4f21a3279a60
evolve: add function to deprecate an alias
Olle Lundberg <geek@nerd.sh>
parents:
890
diff
changeset
|
988 |
|
811
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
989 |
@command('debugrecordpruneparents', [], '') |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
990 |
def cmddebugrecordpruneparents(ui, repo): |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
991 |
"""add parents data to prune markers when possible |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
992 |
|
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
993 |
This commands search the repo for prune markers without parent information. |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
994 |
If the pruned node is locally known, a new markers with parent data is |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
995 |
created.""" |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
996 |
pgop = 'reading markers' |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
997 |
|
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
998 |
# 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
|
999 |
wlock = lock = tr = None |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1000 |
try: |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1001 |
wlock = repo.wlock() |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1002 |
lock = repo.lock() |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1003 |
tr = repo.transaction('recordpruneparents') |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1004 |
unfi = repo.unfiltered() |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1005 |
nm = unfi.changelog.nodemap |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1006 |
store = repo.obsstore |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1007 |
pgtotal = len(store._all) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1008 |
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
|
1009 |
if not mark[1]: |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1010 |
rev = nm.get(mark[0]) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1011 |
if rev is not None: |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1012 |
ctx = unfi[rev] |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1013 |
meta = obsolete.decodemeta(mark[3]) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1014 |
for i, p in enumerate(ctx.parents(), 1): |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1015 |
meta['p%i' % i] = p.hex() |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1016 |
before = len(store._all) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1017 |
store.create(tr, mark[0], mark[1], mark[2], meta) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1018 |
if len(store._all) - before: |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1019 |
ui.write('created new markers for %i\n' % rev) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1020 |
ui.progress(pgop, idx, total=pgtotal) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1021 |
tr.close() |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1022 |
ui.progress(pgop, None) |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1023 |
finally: |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1024 |
if tr is not None: |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1025 |
tr.release() |
acfa2b67cff6
evolve: add a cmddebugrecordpruneparents command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
809
diff
changeset
|
1026 |
lockmod.release(lock, wlock) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1027 |
|
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1028 |
@command('debugobsstorestat', [], '') |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1029 |
def cmddebugobsstorestat(ui, repo): |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1030 |
"""print statistic about obsolescence markers in the repo""" |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1031 |
store = repo.obsstore |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1032 |
unfi = repo.unfiltered() |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1033 |
nm = unfi.changelog.nodemap |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1034 |
ui.write('markers total: %9i\n' % len(store._all)) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1035 |
sucscount = [0, 0 , 0, 0] |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1036 |
known = 0 |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1037 |
parentsdata = 0 |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1038 |
metatotallenght = 0 |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1039 |
metakeys = {} |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1040 |
# node -> cluster mapping |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1041 |
# 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
|
1042 |
clustersmap = {} |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1043 |
# same data using parent information |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1044 |
pclustersmap= {} |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1045 |
for mark in store: |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1046 |
if mark[0] in nm: |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1047 |
known += 1 |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1048 |
nbsucs = len(mark[1]) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1049 |
sucscount[min(nbsucs, 3)] += 1 |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1050 |
metatotallenght += len(mark[3]) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1051 |
meta = obsolete.decodemeta(mark[3]) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1052 |
for key in meta: |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1053 |
metakeys.setdefault(key, 0) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1054 |
metakeys[key] += 1 |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1055 |
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
|
1056 |
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
|
1057 |
if parents: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1058 |
parentsdata += 1 |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1059 |
# cluster handling |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1060 |
nodes = set() |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1061 |
nodes.add(mark[0]) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1062 |
nodes.update(mark[1]) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1063 |
c = (set(nodes), set([mark])) |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1064 |
|
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1065 |
toproceed = set(nodes) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1066 |
while toproceed: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1067 |
n = toproceed.pop() |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1068 |
other = clustersmap.get(n) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1069 |
if (other is not None |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1070 |
and other is not c): |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1071 |
other[0].update(c[0]) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1072 |
other[1].update(c[1]) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1073 |
for on in c[0]: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1074 |
if on in toproceed: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1075 |
continue |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1076 |
clustersmap[on] = other |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1077 |
c = other |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1078 |
clustersmap[n] = c |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1079 |
# same with parent data |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1080 |
nodes.update(parents) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1081 |
c = (set(nodes), set([mark])) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1082 |
toproceed = set(nodes) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1083 |
while toproceed: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1084 |
n = toproceed.pop() |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1085 |
other = pclustersmap.get(n) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1086 |
if (other is not None |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1087 |
and other is not c): |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1088 |
other[0].update(c[0]) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1089 |
other[1].update(c[1]) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1090 |
for on in c[0]: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1091 |
if on in toproceed: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1092 |
continue |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1093 |
pclustersmap[on] = other |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1094 |
c = other |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1095 |
pclustersmap[n] = c |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1096 |
|
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1097 |
# freezing the result |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1098 |
for c in clustersmap.values(): |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1099 |
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
|
1100 |
for n in fc[0]: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1101 |
clustersmap[n] = fc |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1102 |
# same with parent data |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1103 |
for c in pclustersmap.values(): |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1104 |
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
|
1105 |
for n in fc[0]: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1106 |
pclustersmap[n] = fc |
807
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1107 |
ui.write(' for known precursors: %9i\n' % known) |
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1108 |
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
|
1109 |
# successors data |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1110 |
ui.write('markers with no successors: %9i\n' % sucscount[0]) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1111 |
ui.write(' 1 successors: %9i\n' % sucscount[1]) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1112 |
ui.write(' 2 successors: %9i\n' % sucscount[2]) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1113 |
ui.write(' more than 2 successors: %9i\n' % sucscount[3]) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1114 |
# meta data info |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1115 |
ui.write('average meta length: %9i\n' |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1116 |
% (metatotallenght/len(store._all))) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1117 |
ui.write(' available keys:\n') |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1118 |
for key in sorted(metakeys): |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1119 |
ui.write(' %15s: %9i\n' % (key, metakeys[key])) |
4dd1cda16fd0
evolve: add a debugobsstorestat command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
806
diff
changeset
|
1120 |
|
809
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1121 |
allclusters = list(set(clustersmap.values())) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1122 |
allclusters.sort(key=lambda x: len(x[1])) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1123 |
ui.write('disconnected clusters: %9i\n' % len(allclusters)) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1124 |
|
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1125 |
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
|
1126 |
% len([c for c in allclusters |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1127 |
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
|
1128 |
if allclusters: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1129 |
nbcluster = len(allclusters) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1130 |
ui.write(' smallest length: %9i\n' % len(allclusters[0][1])) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1131 |
ui.write(' longer length: %9i\n' % len(allclusters[-1][1])) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1132 |
median = len(allclusters[nbcluster//2][1]) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1133 |
ui.write(' median length: %9i\n' % median) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1134 |
mean = sum(len(x[1]) for x in allclusters) // nbcluster |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1135 |
ui.write(' mean length: %9i\n' % mean) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1136 |
allpclusters = list(set(pclustersmap.values())) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1137 |
allpclusters.sort(key=lambda x: len(x[1])) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1138 |
ui.write(' using parents data: %9i\n' % len(allpclusters)) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1139 |
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
|
1140 |
% len([c for c in allclusters |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1141 |
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
|
1142 |
if allpclusters: |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1143 |
nbcluster = len(allpclusters) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1144 |
ui.write(' smallest length: %9i\n' % len(allpclusters[0][1])) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1145 |
ui.write(' longer length: %9i\n' % len(allpclusters[-1][1])) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1146 |
median = len(allpclusters[nbcluster//2][1]) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1147 |
ui.write(' median length: %9i\n' % median) |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1148 |
mean = sum(len(x[1]) for x in allpclusters) // nbcluster |
5d3ddede6ccf
debugobsstorestat: add information about cluster
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
808
diff
changeset
|
1149 |
ui.write(' mean length: %9i\n' % mean) |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1150 |
|
714
3867f7b1fe6e
evolve: remove duplicate alias.
Levi Bard <levi@unity3d.com>
parents:
710
diff
changeset
|
1151 |
@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
|
1152 |
[('n', 'dry-run', False, |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1153 |
'do not perform actions, just print what would be done'), |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1154 |
('A', 'any', False, 'evolve any troubled changeset'), |
704 | 1155 |
('a', 'all', False, 'evolve all troubled changesets'), |
986
c1f8ece4182d
evolve: add --tool option so we don't have to use HGMERGE
Greg Ward <greg@gerg.ca>
parents:
985
diff
changeset
|
1156 |
('c', 'continue', False, 'continue an interrupted evolution'), |
c1f8ece4182d
evolve: add --tool option so we don't have to use HGMERGE
Greg Ward <greg@gerg.ca>
parents:
985
diff
changeset
|
1157 |
] + mergetoolopts, |
303 | 1158 |
_('[OPTIONS]...')) |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1159 |
def evolve(ui, repo, **opts): |
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1160 |
"""Solve trouble in your repository |
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1161 |
|
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1162 |
- rebase unstable changesets to make them stable again, |
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1163 |
- create proper diffs from bumped changesets, |
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1164 |
- merge divergent changesets, |
750
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1165 |
- update to a successor if the working directory parent is |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1166 |
obsolete |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1167 |
|
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1168 |
By default, takes the first troubled changeset that looks relevant. |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1169 |
|
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1170 |
(The logic is still a bit fuzzy) |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
1171 |
|
708 | 1172 |
- For unstable, this means taking the first which could be rebased as a |
1173 |
child of the working directory parent revision or one of its descendants |
|
1174 |
and rebasing it. |
|
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
1175 |
|
708 | 1176 |
- For divergent, this means taking "." if applicable. |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1177 |
|
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1178 |
With --any, evolve picks any troubled changeset to repair. |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1179 |
|
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1180 |
The working directory is updated to the newly created revision. |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
1181 |
""" |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1182 |
|
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1183 |
contopt = opts['continue'] |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1184 |
anyopt = opts['any'] |
704 | 1185 |
allopt = opts['all'] |
703
a246b02499d9
evolve: extract evolve --any implementation into a function.
Levi Bard <levi@unity3d.com>
parents:
663
diff
changeset
|
1186 |
dryrunopt = opts['dry_run'] |
986
c1f8ece4182d
evolve: add --tool option so we don't have to use HGMERGE
Greg Ward <greg@gerg.ca>
parents:
985
diff
changeset
|
1187 |
ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'evolve') |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1188 |
|
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1189 |
if contopt: |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1190 |
if anyopt: |
947
9a6cc7e6f0dd
evolve: improve wording of a few of messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
946
diff
changeset
|
1191 |
raise util.Abort('cannot specify both "--any" and "--continue"') |
704 | 1192 |
if allopt: |
947
9a6cc7e6f0dd
evolve: improve wording of a few of messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
946
diff
changeset
|
1193 |
raise util.Abort('cannot specify both "--all" and "--continue"') |
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1194 |
graftcmd = commands.table['graft'][0] |
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1195 |
return graftcmd(ui, repo, old_obsolete=True, **{'continue': True}) |
703
a246b02499d9
evolve: extract evolve --any implementation into a function.
Levi Bard <levi@unity3d.com>
parents:
663
diff
changeset
|
1196 |
|
706
90f0a1ede70a
evolve: clean up evolve implementation.
Levi Bard <levi@unity3d.com>
parents:
704
diff
changeset
|
1197 |
tr = _picknexttroubled(ui, repo, anyopt or allopt) |
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
|
1198 |
if tr is None: |
750
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1199 |
if repo['.'].obsolete(): |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1200 |
displayer = cmdutil.show_changeset( |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1201 |
ui, repo, {'template': shorttemplate}) |
750
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1202 |
successors = set() |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1203 |
|
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1204 |
for successorsset in obsolete.successorssets(repo, repo['.'].node()): |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1205 |
for nodeid in successorsset: |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1206 |
successors.add(repo[nodeid]) |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1207 |
|
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1208 |
if not successors: |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1209 |
ui.warn(_('parent is obsolete without successors; ' + |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1210 |
'likely killed\n')) |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1211 |
return 2 |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1212 |
|
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1213 |
elif len(successors) > 1: |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1214 |
ui.warn(_('parent is obsolete with multiple successors:\n')) |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1215 |
|
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1216 |
for ctx in sorted(successors, key=lambda ctx: ctx.rev()): |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1217 |
displayer.show(ctx) |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1218 |
|
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1219 |
return 2 |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1220 |
|
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1221 |
else: |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1222 |
ctx = successors.pop() |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1223 |
|
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1224 |
ui.status(_('update:')) |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1225 |
if not ui.quiet: |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1226 |
displayer.show(ctx) |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1227 |
|
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1228 |
if dryrunopt: |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1229 |
print 'hg update %s' % ctx.rev() |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1230 |
return 0 |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1231 |
else: |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1232 |
return hg.update(repo, ctx.rev()) |
ddbea2fdee5e
evolve: allow updating to the successor if the parent is obsolete
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
749
diff
changeset
|
1233 |
|
511
ddeb71df916d
evolve: localrepo.revs() already returns a list
Patrick Mezard <patrick@mezard.eu>
parents:
510
diff
changeset
|
1234 |
troubled = repo.revs('troubled()') |
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
|
1235 |
if troubled: |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1236 |
ui.write_err(_('nothing to evolve here\n')) |
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
|
1237 |
ui.status(_('(%i troubled changesets, do you want --any ?)\n') |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1238 |
% len(troubled)) |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1239 |
return 2 |
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
|
1240 |
else: |
722
4e7e7a7d8500
evolve: remove trailing spaces
AndréSintzoff <andre.sintzoff@gmail.com>
parents:
716
diff
changeset
|
1241 |
ui.write_err(_('no troubled changesets\n')) |
145
928f217c1701
stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
142
diff
changeset
|
1242 |
return 1 |
706
90f0a1ede70a
evolve: clean up evolve implementation.
Levi Bard <levi@unity3d.com>
parents:
704
diff
changeset
|
1243 |
|
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1244 |
def progresscb(): |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1245 |
if allopt: |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1246 |
ui.progress('evolve', seen, unit='changesets', total=count) |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1247 |
seen = 1 |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1248 |
count = allopt and _counttroubled(ui, repo) or 1 |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1249 |
|
706
90f0a1ede70a
evolve: clean up evolve implementation.
Levi Bard <levi@unity3d.com>
parents:
704
diff
changeset
|
1250 |
while tr is not None: |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1251 |
progresscb() |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1252 |
result = _evolveany(ui, repo, tr, dryrunopt, progresscb=progresscb) |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1253 |
progresscb() |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1254 |
seen += 1 |
707
f914e315b717
evolve: remove magic return values from utility functions
Levi Bard <levi@unity3d.com>
parents:
706
diff
changeset
|
1255 |
if not allopt: |
706
90f0a1ede70a
evolve: clean up evolve implementation.
Levi Bard <levi@unity3d.com>
parents:
704
diff
changeset
|
1256 |
return result |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1257 |
progresscb() |
706
90f0a1ede70a
evolve: clean up evolve implementation.
Levi Bard <levi@unity3d.com>
parents:
704
diff
changeset
|
1258 |
tr = _picknexttroubled(ui, repo, anyopt or allopt) |
722
4e7e7a7d8500
evolve: remove trailing spaces
AndréSintzoff <andre.sintzoff@gmail.com>
parents:
716
diff
changeset
|
1259 |
|
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1260 |
if allopt: |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1261 |
ui.progress('evolve', None) |
706
90f0a1ede70a
evolve: clean up evolve implementation.
Levi Bard <levi@unity3d.com>
parents:
704
diff
changeset
|
1262 |
|
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1263 |
|
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1264 |
def _evolveany(ui, repo, tr, dryrunopt, progresscb): |
651
609faf10d307
evolve: ensure evolve command run unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
649
diff
changeset
|
1265 |
repo = repo.unfiltered() |
609faf10d307
evolve: ensure evolve command run unfiltered
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
649
diff
changeset
|
1266 |
tr = repo[tr.rev()] |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1267 |
cmdutil.bailifchanged(repo) |
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
|
1268 |
troubles = tr.troubles() |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1269 |
if 'unstable' in troubles: |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1270 |
return _solveunstable(ui, repo, tr, dryrunopt, progresscb) |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1271 |
elif 'bumped' in troubles: |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1272 |
return _solvebumped(ui, repo, tr, dryrunopt, progresscb) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1273 |
elif 'divergent' in troubles: |
625
e291e5271694
prepare for Full scale filtering !!!
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
622
diff
changeset
|
1274 |
repo = repo.unfiltered() |
e291e5271694
prepare for Full scale filtering !!!
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
622
diff
changeset
|
1275 |
tr = repo[tr.rev()] |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1276 |
return _solvedivergent(ui, repo, tr, dryrunopt, progresscb) |
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
|
1277 |
else: |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1278 |
assert False # WHAT? unknown troubles |
269
6c6bb7a23bb5
stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents:
268
diff
changeset
|
1279 |
|
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1280 |
def _counttroubled(ui, repo): |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1281 |
"""Count the amount of troubled changesets""" |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1282 |
troubled = set() |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1283 |
troubled.update(getrevs(repo, 'unstable')) |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1284 |
troubled.update(getrevs(repo, 'bumped')) |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1285 |
troubled.update(getrevs(repo, 'divergent')) |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1286 |
return len(troubled) |
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1287 |
|
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1288 |
def _picknexttroubled(ui, repo, pickany=False, progresscb=None): |
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
|
1289 |
"""Pick a the next trouble changeset to solve""" |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1290 |
if progresscb: progresscb() |
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
|
1291 |
tr = _stabilizableunstable(repo, repo['.']) |
484
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
1292 |
if tr is None: |
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
1293 |
wdp = repo['.'] |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1294 |
if 'divergent' in wdp.troubles(): |
484
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
1295 |
tr = wdp |
512
8b25e9cf76fd
evolve: avoid 'any' argument name in _picknexttroubled()
Patrick Mezard <patrick@mezard.eu>
parents:
511
diff
changeset
|
1296 |
if tr is None and pickany: |
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
|
1297 |
troubled = list(repo.set('unstable()')) |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1298 |
if not troubled: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1299 |
troubled = list(repo.set('bumped()')) |
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
|
1300 |
if not troubled: |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1301 |
troubled = list(repo.set('divergent()')) |
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
|
1302 |
if troubled: |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1303 |
tr = troubled[0] |
484
20e2f2dd71f1
stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
482
diff
changeset
|
1304 |
|
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
|
1305 |
return tr |
6b1b6d338478
stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
466
diff
changeset
|
1306 |
|
509
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1307 |
def _stabilizableunstable(repo, pctx): |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1308 |
"""Return a changectx for an unstable changeset which can be |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1309 |
stabilized on top of pctx or one of its descendants. None if none |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1310 |
can be found. |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1311 |
""" |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1312 |
def selfanddescendants(repo, pctx): |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1313 |
yield pctx |
636
27c890b4f864
evolve: make evolve smarter
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
626
diff
changeset
|
1314 |
for prec in repo.set('allprecursors(%d)', pctx): |
27c890b4f864
evolve: make evolve smarter
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
626
diff
changeset
|
1315 |
yield prec |
509
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1316 |
for ctx in pctx.descendants(): |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1317 |
yield ctx |
636
27c890b4f864
evolve: make evolve smarter
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
626
diff
changeset
|
1318 |
for prec in repo.set('allprecursors(%d)', ctx): |
27c890b4f864
evolve: make evolve smarter
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
626
diff
changeset
|
1319 |
yield prec |
509
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1320 |
|
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1321 |
# Look for an unstable which can be stabilized as a child of |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1322 |
# node. The unstable must be a child of one of node predecessors. |
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1323 |
for ctx in selfanddescendants(repo, pctx): |
636
27c890b4f864
evolve: make evolve smarter
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
626
diff
changeset
|
1324 |
for child in ctx.children(): |
27c890b4f864
evolve: make evolve smarter
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
626
diff
changeset
|
1325 |
if child.unstable(): |
27c890b4f864
evolve: make evolve smarter
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
626
diff
changeset
|
1326 |
return child |
509
c072e559746d
evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents:
507
diff
changeset
|
1327 |
return None |
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
|
1328 |
|
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1329 |
def _solveunstable(ui, repo, orig, dryrun=False, progresscb=None): |
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
|
1330 |
"""Stabilize a unstable changeset""" |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
1331 |
obs = orig.parents()[0] |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
82
diff
changeset
|
1332 |
if not obs.obsolete(): |
636
27c890b4f864
evolve: make evolve smarter
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
626
diff
changeset
|
1333 |
print obs.rev(), orig.parents() |
27c890b4f864
evolve: make evolve smarter
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
626
diff
changeset
|
1334 |
print orig.rev() |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
1335 |
obs = orig.parents()[1] |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
82
diff
changeset
|
1336 |
assert obs.obsolete() |
630
722b52c75f02
compat: adapt to upstreaming of divergent logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
622
diff
changeset
|
1337 |
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
|
1338 |
# 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
|
1339 |
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
|
1340 |
ui.debug("stabilize target %s is plain dead," |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1341 |
" trying to stabilize on its parent") |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1342 |
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
|
1343 |
newer = obsolete.successorssets(repo, obs.node()) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1344 |
if len(newer) > 1: |
707
f914e315b717
evolve: remove magic return values from utility functions
Levi Bard <levi@unity3d.com>
parents:
706
diff
changeset
|
1345 |
raise util.Abort(_("conflict rewriting. can't choose destination\n")) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1346 |
targets = newer[0] |
466
b98490b689a5
stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
465
diff
changeset
|
1347 |
assert targets |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1348 |
if len(targets) > 1: |
707
f914e315b717
evolve: remove magic return values from utility functions
Levi Bard <levi@unity3d.com>
parents:
706
diff
changeset
|
1349 |
raise util.Abort(_("does not handle split parents yet\n")) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1350 |
return 2 |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
1351 |
target = targets[0] |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1352 |
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
|
1353 |
target = repo[target] |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
1354 |
if not ui.quiet: |
983
914255564352
evolve: minor reorganisation of code responsible for evolve output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
982
diff
changeset
|
1355 |
repo.ui.status(_('move:')) |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
1356 |
displayer.show(orig) |
983
914255564352
evolve: minor reorganisation of code responsible for evolve output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
982
diff
changeset
|
1357 |
repo.ui.status(_('atop:')) |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
1358 |
displayer.show(target) |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1359 |
if progresscb: progresscb() |
546
415540dee2bd
fix missing --dest evolve output in dryrun
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
540
diff
changeset
|
1360 |
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
|
1361 |
if dryrun: |
146
e80a6c8ad452
stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
145
diff
changeset
|
1362 |
repo.ui.write(todo) |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1363 |
else: |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1364 |
repo.ui.note(todo) |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1365 |
if progresscb: progresscb() |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1366 |
lock = repo.lock() |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1367 |
try: |
464
d88c761f97c4
stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
463
diff
changeset
|
1368 |
relocate(repo, orig, target) |
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
1369 |
except MergeFailure: |
465
4a039a8c1cf3
stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
464
diff
changeset
|
1370 |
repo.opener.write('graftstate', orig.hex() + '\n') |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1371 |
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
|
1372 |
repo.ui.write_err( |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1373 |
_('fix conflict and run "hg evolve --continue"\n')) |
463
3f91654713dd
obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
455
diff
changeset
|
1374 |
raise |
139
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1375 |
finally: |
9b9500175ae5
evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
137
diff
changeset
|
1376 |
lock.release() |
88
64fe5a4f877e
[evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
1377 |
|
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1378 |
def _solvebumped(ui, repo, bumped, dryrun=False, progresscb=None): |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1379 |
"""Stabilize a bumped changeset""" |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1380 |
# For now we deny bumped merge |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1381 |
if len(bumped.parents()) > 1: |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1382 |
raise util.Abort('late comer stabilization is confused by bumped' |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1383 |
' %s being a merge' % bumped) |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1384 |
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
|
1385 |
# For now we deny target merge |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1386 |
if len(prec.parents()) > 1: |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1387 |
raise util.Abort('late comer evolution is confused by precursors' |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1388 |
' %s being a merge' % prec) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1389 |
|
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1390 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1391 |
repo.ui.status(_('recreate:')) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1392 |
if not ui.quiet: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1393 |
displayer.show(bumped) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1394 |
repo.ui.status(_('atop:')) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1395 |
if not ui.quiet: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1396 |
displayer.show(prec) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1397 |
if dryrun: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1398 |
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
|
1399 |
repo.ui.write(todo) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1400 |
repo.ui.write('hg update %s;\n' % prec) |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1401 |
repo.ui.write('hg revert --all --rev %s;\n' % bumped) |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1402 |
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
|
1403 |
return 0 |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1404 |
if progresscb: progresscb() |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1405 |
wlock = repo.wlock() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1406 |
try: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1407 |
newid = tmpctx = None |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1408 |
tmpctx = bumped |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1409 |
lock = repo.lock() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1410 |
try: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1411 |
bmupdate = _bookmarksupdater(repo, bumped.node()) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1412 |
# Basic check for common parent. Far too complicated and fragile |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1413 |
tr = repo.transaction('bumped-stabilize') |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1414 |
try: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1415 |
if not list(repo.set('parents(%d) and parents(%d)', bumped, prec)): |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1416 |
# Need to rebase the changeset at the right place |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1417 |
repo.ui.status( |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1418 |
_('rebasing to destination parent: %s\n') % prec.p1()) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1419 |
try: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1420 |
tmpid = relocate(repo, bumped, prec.p1()) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1421 |
if tmpid is not None: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1422 |
tmpctx = repo[tmpid] |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1423 |
createmarkers(repo, [(bumped, (tmpctx,))]) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1424 |
except MergeFailure: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1425 |
repo.opener.write('graftstate', bumped.hex() + '\n') |
492
7ecd41520dae
rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
491
diff
changeset
|
1426 |
repo.ui.write_err(_('evolution failed!\n')) |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1427 |
repo.ui.write_err( |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1428 |
_('fix conflict and run "hg evolve --continue"\n')) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1429 |
raise |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1430 |
# Create the new commit context |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1431 |
repo.ui.status(_('computing new diff\n')) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1432 |
files = set() |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1433 |
copied = copies.pathcopies(prec, bumped) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1434 |
precmanifest = prec.manifest() |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1435 |
for key, val in bumped.manifest().iteritems(): |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1436 |
if precmanifest.pop(key, None) != val: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1437 |
files.add(key) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1438 |
files.update(precmanifest) # add missing files |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1439 |
# commit it |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1440 |
if files: # something to commit! |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1441 |
def filectxfn(repo, ctx, path): |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1442 |
if path in bumped: |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1443 |
fctx = bumped[path] |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1444 |
flags = fctx.flags() |
955
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
1445 |
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
|
1446 |
islink='l' in flags, |
ef155e3ead8f
evolve: abstract access to context.memfilectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
953
diff
changeset
|
1447 |
isexec='x' in flags, |
ef155e3ead8f
evolve: abstract access to context.memfilectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
953
diff
changeset
|
1448 |
copied=copied.get(path)) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1449 |
return mctx |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1450 |
raise IOError() |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1451 |
text = 'bumped update to %s:\n\n' % prec |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1452 |
text += bumped.description() |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1453 |
|
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1454 |
new = context.memctx(repo, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1455 |
parents=[prec.node(), node.nullid], |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1456 |
text=text, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1457 |
files=files, |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1458 |
filectxfn=filectxfn, |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1459 |
user=bumped.user(), |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1460 |
date=bumped.date(), |
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1461 |
extra=bumped.extra()) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1462 |
|
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1463 |
newid = repo.commitctx(new) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1464 |
if newid is None: |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1465 |
createmarkers(repo, [(tmpctx, ())]) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1466 |
newid = prec.node() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1467 |
else: |
593
26f76b38f879
evolve: Rename latecomer into bumped
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
588
diff
changeset
|
1468 |
phases.retractboundary(repo, bumped.phase(), [newid]) |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1469 |
createmarkers(repo, [(tmpctx, (repo[newid],))], |
857
c479e24ebddf
evolve: use flag value from core for bumped fix
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
855
diff
changeset
|
1470 |
flag=obsolete.bumpedfix) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1471 |
bmupdate(newid) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1472 |
tr.close() |
945 | 1473 |
repo.ui.status(_('committed as %s\n') % node.short(newid)) |
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1474 |
finally: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1475 |
tr.release() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1476 |
finally: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1477 |
lock.release() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1478 |
# reroute the working copy parent to the new changeset |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1479 |
repo.dirstate.setparents(newid, node.nullid) |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1480 |
finally: |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1481 |
wlock.release() |
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1482 |
|
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1483 |
def _solvedivergent(ui, repo, divergent, dryrun=False, progresscb=None): |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1484 |
base, others = divergentdata(divergent) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1485 |
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
|
1486 |
othersstr = "[%s]" % (','.join([str(i) for i in others])) |
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
|
1487 |
hint = ("changeset %d is divergent with a changeset that got splitted " |
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
|
1488 |
"| into multiple ones:\n[%s]\n" |
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
|
1489 |
"| This is not handled by automatic evolution yet\n" |
947
9a6cc7e6f0dd
evolve: improve wording of a few of messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
946
diff
changeset
|
1490 |
"| You have to fallback to manual handling with commands " |
9a6cc7e6f0dd
evolve: improve wording of a few of messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
946
diff
changeset
|
1491 |
"such as:\n" |
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
|
1492 |
"| - hg touch -D\n" |
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
|
1493 |
"| - hg prune\n" |
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
|
1494 |
"| \n" |
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
|
1495 |
"| You should contact your local evolution Guru for help.\n" |
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
|
1496 |
% (divergent, othersstr)) |
948
b2b3d5aa16bc
evolve: start all util.Abort messages with lower case
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
947
diff
changeset
|
1497 |
raise util.Abort("we do not handle divergence with split yet", |
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
|
1498 |
hint='') |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1499 |
other = others[0] |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1500 |
if divergent.phase() <= phases.public: |
948
b2b3d5aa16bc
evolve: start all util.Abort messages with lower case
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
947
diff
changeset
|
1501 |
raise util.Abort("we can't resolve this conflict from the public side", |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1502 |
hint="%s is public, try from %s" % (divergent, other)) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1503 |
if len(other.parents()) > 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
|
1504 |
raise util.Abort("divergent changeset can't be a merge (yet)", |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1505 |
hint="You have to fallback to solving this by hand...\n" |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1506 |
"| This probably means redoing the merge and using " |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1507 |
"| `hg prune` to kill older version.") |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1508 |
if other.p1() not in divergent.parents(): |
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
|
1509 |
raise util.Abort("parents are not common (not handled yet)", |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1510 |
hint="| %(d)s, %(o)s are not based on the same changeset." |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1511 |
"| With the current state of its implementation, " |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1512 |
"| evolve does not work in that case.\n" |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1513 |
"| rebase one of them next to the other and run " |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1514 |
"| this command again.\n" |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1515 |
"| - either: hg rebase -dest 'p1(%(d)s)' -r %(o)s" |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1516 |
"| - or: hg rebase -dest 'p1(%(d)s)' -r %(o)s" |
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
|
1517 |
% {'d': divergent, 'o': other}) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1518 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1519 |
displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1520 |
ui.status(_('merge:')) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1521 |
if not ui.quiet: |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1522 |
displayer.show(divergent) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1523 |
ui.status(_('with: ')) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1524 |
if not ui.quiet: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1525 |
displayer.show(other) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1526 |
ui.status(_('base: ')) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1527 |
if not ui.quiet: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1528 |
displayer.show(base) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1529 |
if dryrun: |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1530 |
ui.write('hg update -c %s &&\n' % divergent) |
533
87c41ef95ebf
test conflicting conflicting (sic) resolution
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
523
diff
changeset
|
1531 |
ui.write('hg merge %s &&\n' % other) |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1532 |
ui.write('hg commit -m "auto merge resolving conflict between ' |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1533 |
'%s and %s"&&\n' % (divergent, other)) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1534 |
ui.write('hg up -C %s &&\n' % base) |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1535 |
ui.write('hg revert --all --rev tip &&\n') |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
1536 |
ui.write('hg commit -m "`hg log -r %s --template={desc}`";\n' |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1537 |
% divergent) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1538 |
return |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1539 |
wlock = lock = None |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1540 |
try: |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1541 |
wlock = repo.wlock() |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1542 |
lock = repo.lock() |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1543 |
if divergent not in repo[None].parents(): |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1544 |
repo.ui.status(_('updating to "local" conflict\n')) |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1545 |
hg.update(repo, divergent.rev()) |
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1546 |
repo.ui.note(_('merging divergent changeset\n')) |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1547 |
if progresscb: progresscb() |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1548 |
stats = merge.update(repo, |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1549 |
other.node(), |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1550 |
branchmerge=True, |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1551 |
force=False, |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1552 |
partial=None, |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1553 |
ancestor=base.node(), |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1554 |
mergeancestor=True) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1555 |
hg._showstats(repo, stats) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1556 |
if stats[3]: |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1557 |
repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1558 |
"or 'hg update -C .' to abandon\n")) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1559 |
if stats[3] > 0: |
947
9a6cc7e6f0dd
evolve: improve wording of a few of messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
946
diff
changeset
|
1560 |
raise util.Abort('merge conflict between several amendments ' |
9a6cc7e6f0dd
evolve: improve wording of a few of messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
946
diff
changeset
|
1561 |
'(this is not automated yet)', |
534
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1562 |
hint="""/!\ You can try: |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1563 |
/!\ * manual merge + resolve => new cset X |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1564 |
/!\ * 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
|
1565 |
/!\ * hg revert --all -r X |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1566 |
/!\ * hg ci -m "same message as the amended changeset" => new cset Y |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1567 |
/!\ * hg kill -n Y W Z |
45ccaba212f9
a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
533
diff
changeset
|
1568 |
""") |
762
942aabaa8a8e
evolve: show progress
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
760
diff
changeset
|
1569 |
if progresscb: progresscb() |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1570 |
tr = repo.transaction('stabilize-divergent') |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1571 |
try: |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1572 |
repo.dirstate.setparents(divergent.node(), node.nullid) |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1573 |
oldlen = len(repo) |
742
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
1574 |
amend(ui, repo, message='', logfile='') |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1575 |
if oldlen == len(repo): |
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1576 |
new = divergent |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1577 |
# no changes |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1578 |
else: |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1579 |
new = repo['.'] |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1580 |
createmarkers(repo, [(other, (new,))]) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1581 |
phases.retractboundary(repo, other.phase(), [new.node()]) |
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1582 |
tr.close() |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1583 |
finally: |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1584 |
tr.release() |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1585 |
finally: |
516
18854dbc92e7
evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents:
515
diff
changeset
|
1586 |
lockmod.release(lock, wlock) |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1587 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1588 |
|
586
f01721161532
evolve: rename conflicting into divergent
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
585
diff
changeset
|
1589 |
def divergentdata(ctx): |
485
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1590 |
"""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
|
1591 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1592 |
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
|
1593 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1594 |
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
|
1595 |
""" |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1596 |
for base in ctx._repo.set('reverse(precursors(%d))', ctx): |
630
722b52c75f02
compat: adapt to upstreaming of divergent logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
622
diff
changeset
|
1597 |
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
|
1598 |
# 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
|
1599 |
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
|
1600 |
if newer: |
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1601 |
return base, tuple(ctx._repo[o] for o in newer[0]) |
749
f728edc7fcd1
evolve: abort on unknown divergent changeset base
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
745
diff
changeset
|
1602 |
raise util.Abort('base of divergent changeset not found', |
f728edc7fcd1
evolve: abort on unknown divergent changeset base
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
745
diff
changeset
|
1603 |
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
|
1604 |
|
41bf6c27a122
evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
484
diff
changeset
|
1605 |
|
469
abeb17a9e313
stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
468
diff
changeset
|
1606 |
|
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
|
1607 |
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
|
1608 |
|
895
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
1609 |
@command('^previous', |
303 | 1610 |
[], |
1611 |
'') |
|
751
a5474648a9d2
gdown/gup: add next/previous alias
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
750
diff
changeset
|
1612 |
def cmdprevious(ui, repo): |
724 | 1613 |
"""update to parent and display summary lines""" |
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
|
1614 |
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
|
1615 |
wparents = wkctx.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
|
1616 |
if len(wparents) != 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
|
1617 |
raise util.Abort('merge in progress') |
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
|
1618 |
|
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
|
1619 |
parents = wparents[0].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
|
1620 |
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
|
1621 |
if len(parents) == 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
|
1622 |
p = parents[0] |
892
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1623 |
bm = bookmarks.readcurrent(repo) |
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1624 |
shouldmove = bm is not None and bookmarks.iscurrent(repo, bm) |
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1625 |
ret = hg.update(repo, p.rev()) |
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1626 |
if not ret and shouldmove: |
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1627 |
repo._bookmarks[bm] = p.node() |
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1628 |
repo._bookmarks.write() |
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
|
1629 |
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
|
1630 |
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
|
1631 |
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
|
1632 |
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
|
1633 |
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
|
1634 |
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
|
1635 |
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
|
1636 |
|
895
17ac69db9329
evolve: deprecate gup and gdown aliases
Olle Lundberg <geek@nerd.sh>
parents:
894
diff
changeset
|
1637 |
@command('^next', |
303 | 1638 |
[], |
1639 |
'') |
|
751
a5474648a9d2
gdown/gup: add next/previous alias
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
750
diff
changeset
|
1640 |
def cmdnext(ui, repo): |
724 | 1641 |
"""update to child and display summary lines""" |
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
|
1642 |
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
|
1643 |
wparents = wkctx.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
|
1644 |
if len(wparents) != 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
|
1645 |
raise util.Abort('merge in progress') |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
82
diff
changeset
|
1646 |
|
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
|
1647 |
children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()] |
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
|
1648 |
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
|
1649 |
if not children: |
743
af74a5cdf96b
conform to the Mercurial custom of lowercase messages
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
742
diff
changeset
|
1650 |
ui.warn(_('no non-obsolete children\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
|
1651 |
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
|
1652 |
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
|
1653 |
c = children[0] |
892
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1654 |
bm = bookmarks.readcurrent(repo) |
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1655 |
shouldmove = bm is not None and bookmarks.iscurrent(repo, bm) |
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1656 |
ret = hg.update(repo, c.rev()) |
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1657 |
if not ret and shouldmove: |
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1658 |
repo._bookmarks[bm] = c.node() |
947fb5b1915b
evolve: active bookmark should move when using prev/next (#37)
Olle Lundberg <geek@nerd.sh>
parents:
891
diff
changeset
|
1659 |
repo._bookmarks.write() |
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
|
1660 |
displayer.show(c) |
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
|
1661 |
return 0 |
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
|
1662 |
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
|
1663 |
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
|
1664 |
displayer.show(c) |
949
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1665 |
ui.warn(_('multiple non-obsolete children, ' |
2b2a4ab0eb68
evolve: make most line lenghts 80 characters or less
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
948
diff
changeset
|
1666 |
'explicitly update to one of them\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
|
1667 |
return 1 |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
82
diff
changeset
|
1668 |
|
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1669 |
def _reachablefrombookmark(repo, revs, mark): |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1670 |
"""filter revisions and bookmarks reachable from the given bookmark |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1671 |
yoinked from mq.py |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1672 |
""" |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1673 |
marks = repo._bookmarks |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1674 |
if mark not in marks: |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1675 |
raise util.Abort(_("bookmark '%s' not found") % mark) |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1676 |
|
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1677 |
# 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
|
1678 |
# 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
|
1679 |
# anything. revsets cannot detect that case. |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1680 |
uniquebm = True |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1681 |
for m, n in marks.iteritems(): |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1682 |
if m != mark and n == repo[mark].node(): |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1683 |
uniquebm = False |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1684 |
break |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1685 |
if uniquebm: |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1686 |
rsrevs = repo.revs("ancestors(bookmark(%s)) - " |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1687 |
"ancestors(head() and not bookmark(%s)) - " |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1688 |
"ancestors(bookmark() and not bookmark(%s)) - " |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1689 |
"obsolete()", |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1690 |
mark, mark, mark) |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1691 |
revs.update(set(rsrevs)) |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1692 |
return marks,revs |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1693 |
|
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1694 |
def _deletebookmark(ui, marks, mark): |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1695 |
del marks[mark] |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1696 |
marks.write() |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1697 |
ui.write(_("bookmark '%s' deleted\n") % mark) |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1698 |
|
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1699 |
|
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1700 |
|
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1701 |
def _getmetadata(**opts): |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1702 |
metadata = {} |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1703 |
date = opts.get('date') |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1704 |
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
|
1705 |
if date: |
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1706 |
metadata['date'] = '%i %i' % util.parsedate(date) |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1707 |
if user: |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1708 |
metadata['user'] = user |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1709 |
return metadata |
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1710 |
|
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1711 |
|
365
9f6a77ec66cb
evolve: switch the official name for "kill" to prune
Pierre-Yves.David@ens-lyon.org
parents:
362
diff
changeset
|
1712 |
@command('^prune|obsolete|kill', |
682
6cbb52a8401b
prune: rename --new to --succ
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
681
diff
changeset
|
1713 |
[('n', 'new', [], _("successor changeset (DEPRECATED)")), |
6cbb52a8401b
prune: rename --new to --succ
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
681
diff
changeset
|
1714 |
('s', 'succ', [], _("successor changeset")), |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1715 |
('r', 'rev', [], _("revisions to prune")), |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1716 |
('', 'biject', False, _("do a 1-1 map between rev and successor ranges")), |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1717 |
('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
|
1718 |
" bookmark"))] + metadataopts, |
644
8e41d5b78dff
support -r option in prune, add a test for this
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
636
diff
changeset
|
1719 |
_('[OPTION] [-r] REV...')) |
690
929d7617a13d
prune: more command switch idea
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
689
diff
changeset
|
1720 |
# -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
|
1721 |
def cmdprune(ui, repo, *revs, **opts): |
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1722 |
"""hide changesets by marking them obsolete |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1723 |
|
689
d48aae167b9d
prune: documentation update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
688
diff
changeset
|
1724 |
Obsolete changesets becomes invisible to all commands. |
d48aae167b9d
prune: documentation update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
688
diff
changeset
|
1725 |
|
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1726 |
Unpruned descendants of pruned changesets becomes "unstable". Use the |
689
d48aae167b9d
prune: documentation update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
688
diff
changeset
|
1727 |
:hg:`evolve` to handle such situation. |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1728 |
|
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1729 |
When the working directory parent is pruned, the repository is updated to a |
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1730 |
non-obsolete parent. |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1731 |
|
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1732 |
You can use the ``--succ`` option to inform mercurial that a newer version |
689
d48aae167b9d
prune: documentation update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
688
diff
changeset
|
1733 |
of the pruned changeset exists. |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1734 |
|
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1735 |
You can use the ``--biject`` option to specify a 1-1 (bijection) between |
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1736 |
revisions to prune and successor changesets. This option may be removed in |
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1737 |
a future release (with the functionality absorbed automatically). |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1738 |
|
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1739 |
""" |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1740 |
revs = set(scmutil.revrange(repo, list(revs) + opts.get('rev'))) |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1741 |
succs = opts['new'] + opts['succ'] |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1742 |
bookmark = opts.get('bookmark') |
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1743 |
metadata = _getmetadata(**opts) |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1744 |
biject = opts.get('biject') |
689
d48aae167b9d
prune: documentation update
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
688
diff
changeset
|
1745 |
|
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1746 |
if bookmark: |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1747 |
marks,revs = _reachablefrombookmark(repo, revs, bookmark) |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1748 |
if not revs: |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1749 |
# no revisions to prune - delete bookmark immediately |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1750 |
_deletebookmark(ui, marks, bookmark) |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1751 |
|
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1752 |
if not revs: |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1753 |
raise util.Abort(_('nothing to prune')) |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1754 |
|
683
6d24bd455f79
simplify locking in prune
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
682
diff
changeset
|
1755 |
wlock = lock = None |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1756 |
wlock = repo.wlock() |
685
7398f9729821
prune: add test and more robusness
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
684
diff
changeset
|
1757 |
sortedrevs = lambda specs: sorted(set(scmutil.revrange(repo, specs))) |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1758 |
try: |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
1759 |
lock = repo.lock() |
691
6e63b4185a5c
prune: update inline documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
690
diff
changeset
|
1760 |
# defines pruned changesets |
684
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
1761 |
precs = [] |
685
7398f9729821
prune: add test and more robusness
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
684
diff
changeset
|
1762 |
for p in sortedrevs(revs): |
684
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
1763 |
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
|
1764 |
if not cp.mutable(): |
927 | 1765 |
# note: createmarkers() would have raised something anyway |
687
6c1fbef2952e
prune: test and improve message of immutable aborting.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
685
diff
changeset
|
1766 |
raise util.Abort('cannot prune immutable changeset: %s' % cp, |
6c1fbef2952e
prune: test and improve message of immutable aborting.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
685
diff
changeset
|
1767 |
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
|
1768 |
precs.append(cp) |
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
1769 |
if not precs: |
683
6d24bd455f79
simplify locking in prune
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
682
diff
changeset
|
1770 |
raise util.Abort('nothing to prune') |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1771 |
|
691
6e63b4185a5c
prune: update inline documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
690
diff
changeset
|
1772 |
# defines successors changesets |
685
7398f9729821
prune: add test and more robusness
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
684
diff
changeset
|
1773 |
sucs = tuple(repo[n] for n in sortedrevs(succs)) |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1774 |
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
|
1775 |
msg = "Can't use multiple successors for multiple precursors" |
19a1a8f93c07
prune: detect bad input
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
683
diff
changeset
|
1776 |
raise util.Abort(msg) |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1777 |
|
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1778 |
if 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
|
1779 |
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
|
1780 |
% (len(sucs), len(precs)) |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1781 |
raise util.Abort(msg) |
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1782 |
|
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1783 |
relations = [(p, sucs) for p in precs] |
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1784 |
if biject: |
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1785 |
relations = [(p, (s,)) for p, s in zip(precs, sucs)] |
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1786 |
|
691
6e63b4185a5c
prune: update inline documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
690
diff
changeset
|
1787 |
# create markers |
789
0d2bb0282e78
prune: add biject option
Sean Farley <sean.michael.farley@gmail.com>
parents:
788
diff
changeset
|
1788 |
createmarkers(repo, relations, metadata=metadata) |
716
4c0f6d555032
prune: add --user and --date options
Levi Bard <levi@unity3d.com>
parents:
715
diff
changeset
|
1789 |
|
688
f2c3fd21fa63
prune: add an informative message about the number of pruned changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
687
diff
changeset
|
1790 |
# informs that changeset have been pruned |
f2c3fd21fa63
prune: add an informative message about the number of pruned changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
687
diff
changeset
|
1791 |
ui.status(_('%i changesets pruned\n') % len(precs)) |
931
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
1792 |
|
683
6d24bd455f79
simplify locking in prune
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
682
diff
changeset
|
1793 |
wdp = repo['.'] |
931
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
1794 |
|
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
1795 |
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
|
1796 |
# '.' 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
|
1797 |
newnode = sucs[0] |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
1798 |
else: |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
1799 |
# 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
|
1800 |
newnode = wdp |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
1801 |
|
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
1802 |
while newnode.obsolete(): |
32915143d448
prune: update to successor rather than parent when prune '.'
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
930
diff
changeset
|
1803 |
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
|
1804 |
|
683
6d24bd455f79
simplify locking in prune
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
682
diff
changeset
|
1805 |
if newnode.node() != wdp.node(): |
6d24bd455f79
simplify locking in prune
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
682
diff
changeset
|
1806 |
commands.update(ui, repo, newnode.rev()) |
6d24bd455f79
simplify locking in prune
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
682
diff
changeset
|
1807 |
ui.status(_('working directory now at %s\n') % newnode) |
715
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1808 |
# update bookmarks |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1809 |
if bookmark: |
070bbbb0e6f2
prune: add strip-like bookmark
Levi Bard <levi@unity3d.com>
parents:
714
diff
changeset
|
1810 |
_deletebookmark(ui, marks, bookmark) |
693
d3c1fe0035d1
prune: handle bookmark
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
691
diff
changeset
|
1811 |
for ctx in repo.unfiltered().set('bookmark() and %ld', precs): |
d3c1fe0035d1
prune: handle bookmark
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
691
diff
changeset
|
1812 |
ldest = list(repo.set('max((::%d) - obsolete())', ctx)) |
d3c1fe0035d1
prune: handle bookmark
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
691
diff
changeset
|
1813 |
if ldest: |
d3c1fe0035d1
prune: handle bookmark
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
691
diff
changeset
|
1814 |
dest = ldest[0] |
d3c1fe0035d1
prune: handle bookmark
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
691
diff
changeset
|
1815 |
updatebookmarks = _bookmarksupdater(repo, ctx.node()) |
d3c1fe0035d1
prune: handle bookmark
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
691
diff
changeset
|
1816 |
updatebookmarks(dest.node()) |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1817 |
finally: |
683
6d24bd455f79
simplify locking in prune
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
682
diff
changeset
|
1818 |
lockmod.release(lock, wlock) |
81
5cec25ce019c
Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
1819 |
|
673
761b5b266985
evolve: removes amend from the list of advertised function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
672
diff
changeset
|
1820 |
@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
|
1821 |
[('A', 'addremove', None, |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1822 |
_('mark new/missing files as added/removed before committing')), |
303 | 1823 |
('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
|
1824 |
('', 'close-branch', None, |
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
1825 |
_('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
|
1826 |
('s', 'secret', None, _('use the secret phase for committing')), |
976
bed842762447
amend: add -D/--current-date option, just like mq's qrefresh has
Greg Ward <greg@gerg.ca>
parents:
962
diff
changeset
|
1827 |
] + walkopts + commitopts + commitopts2 + commitopts3, |
82
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1828 |
_('[OPTION]... [FILE]...')) |
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1829 |
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
|
1830 |
"""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
|
1831 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1832 |
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
|
1833 |
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
|
1834 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1835 |
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
|
1836 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1837 |
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
|
1838 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1839 |
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
|
1840 |
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
|
1841 |
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
|
1842 |
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
|
1843 |
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
|
1844 |
|
8108d566a8b5
[evolution]Â imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
81
diff
changeset
|
1845 |
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
|
1846 |
""" |
742
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
1847 |
opts = opts.copy() |
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
1848 |
edit = opts.pop('edit', False) |
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
1849 |
opts['amend'] = True |
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
1850 |
if not (edit or opts['message']): |
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
1851 |
opts['message'] = repo['.'].description() |
985
6a37044ec0b3
amend: add -U/--current-user option (inspired by mq)
Greg Ward <greg@gerg.ca>
parents:
983
diff
changeset
|
1852 |
_resolveoptions(ui, opts) |
742
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
1853 |
_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
|
1854 |
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
|
1855 |
|
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1856 |
def _commitfiltered(repo, ctx, match): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1857 |
"""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
|
1858 |
node identifier, or None if nothing changed. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1859 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1860 |
base = ctx.p1() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1861 |
m, a, r = repo.status(base, ctx)[:3] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1862 |
allfiles = set(m + a + r) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1863 |
files = set(f for f in allfiles if not match(f)) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1864 |
if files == allfiles: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1865 |
return None |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1866 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1867 |
# Filter copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1868 |
copied = copies.pathcopies(base, ctx) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1869 |
copied = dict((src, dst) for src, dst in copied.iteritems() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1870 |
if dst in files) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1871 |
def filectxfn(repo, memctx, path): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1872 |
if path not in ctx: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1873 |
raise IOError() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1874 |
fctx = ctx[path] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1875 |
flags = fctx.flags() |
955
72670e282460
evolve: compatibility with memfilectx change
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
954
diff
changeset
|
1876 |
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
|
1877 |
islink='l' in flags, |
ef155e3ead8f
evolve: abstract access to context.memfilectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
953
diff
changeset
|
1878 |
isexec='x' in flags, |
ef155e3ead8f
evolve: abstract access to context.memfilectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
953
diff
changeset
|
1879 |
copied=copied.get(path)) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1880 |
return mctx |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1881 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1882 |
new = context.memctx(repo, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1883 |
parents=[base.node(), node.nullid], |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1884 |
text=ctx.description(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1885 |
files=files, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1886 |
filectxfn=filectxfn, |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1887 |
user=ctx.user(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1888 |
date=ctx.date(), |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1889 |
extra=ctx.extra()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1890 |
# commitctx always create a new revision, no need to check |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1891 |
newid = repo.commitctx(new) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1892 |
return newid |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1893 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1894 |
def _uncommitdirstate(repo, oldctx, match): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1895 |
"""Fix the dirstate after switching the working directory from |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1896 |
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
|
1897 |
match. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1898 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1899 |
ctx = repo['.'] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1900 |
ds = repo.dirstate |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1901 |
copies = dict(ds.copies()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1902 |
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
|
1903 |
for f in m: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1904 |
if ds[f] == 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1905 |
# modified + removed -> removed |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1906 |
continue |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1907 |
ds.normallookup(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1908 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1909 |
for f in a: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1910 |
if ds[f] == 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1911 |
# added + removed -> unknown |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1912 |
ds.drop(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1913 |
elif ds[f] != 'a': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1914 |
ds.add(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1915 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1916 |
for f in r: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1917 |
if ds[f] == 'a': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1918 |
# removed + added -> normal |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1919 |
ds.normallookup(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1920 |
elif ds[f] != 'r': |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1921 |
ds.remove(f) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1922 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1923 |
# Merge old parent and old working dir copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1924 |
oldcopies = {} |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1925 |
for f in (m + a): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1926 |
src = oldctx[f].renamed() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1927 |
if src: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1928 |
oldcopies[f] = src[0] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1929 |
oldcopies.update(copies) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1930 |
copies = dict((dst, oldcopies.get(src, src)) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1931 |
for dst, src in oldcopies.iteritems()) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1932 |
# Adjust the dirstate copies |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1933 |
for dst, src in copies.iteritems(): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1934 |
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
|
1935 |
src = None |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1936 |
ds.copy(src, dst) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1937 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1938 |
@command('^uncommit', |
314
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
1939 |
[('a', 'all', None, _('uncommit all changes when no arguments given')), |
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
1940 |
] + commands.walkopts, |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1941 |
_('[OPTION]... [NAME]')) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1942 |
def uncommit(ui, repo, *pats, **opts): |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1943 |
"""move changes from parent revision to working directory |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1944 |
|
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
1945 |
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
|
1946 |
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
|
1947 |
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
|
1948 |
revision, and obsoletes the previous one. |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1949 |
|
867
6a67606e1c34
evolve: fix typos in uncommit docstring
André Sintzoff <andre.sintzoff@gmail.com>
parents:
858
diff
changeset
|
1950 |
The --include option specifies patterns to uncommit. |
6a67606e1c34
evolve: fix typos in uncommit docstring
André Sintzoff <andre.sintzoff@gmail.com>
parents:
858
diff
changeset
|
1951 |
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
|
1952 |
|
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1953 |
Return 0 if changed files are uncommitted. |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1954 |
""" |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1955 |
lock = repo.lock() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1956 |
try: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1957 |
wlock = repo.wlock() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1958 |
try: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1959 |
wctx = repo[None] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1960 |
if len(wctx.parents()) <= 0: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1961 |
raise util.Abort(_("cannot uncommit null changeset")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1962 |
if len(wctx.parents()) > 1: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1963 |
raise util.Abort(_("cannot uncommit while merging")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1964 |
old = repo['.'] |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1965 |
if old.phase() == phases.public: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1966 |
raise util.Abort(_("cannot rewrite immutable changeset")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1967 |
if len(old.parents()) > 1: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1968 |
raise util.Abort(_("cannot uncommit merge changeset")) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1969 |
oldphase = old.phase() |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1970 |
updatebookmarks = _bookmarksupdater(repo, old.node()) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1971 |
# Recommit the filtered changeset |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1972 |
newid = None |
314
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
1973 |
if (pats or opts.get('include') or opts.get('exclude') |
ebd286f06879
uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents:
313
diff
changeset
|
1974 |
or opts.get('all')): |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1975 |
match = scmutil.match(old, pats, opts) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1976 |
newid = _commitfiltered(repo, old, match) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1977 |
if newid is None: |
1002
195642c1520b
uncommit: improve error message for use with no arguments
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
998
diff
changeset
|
1978 |
raise util.Abort(_('nothing to uncommit'), |
195642c1520b
uncommit: improve error message for use with no arguments
Nathan Goldbaum <ngoldbau@ucsc.edu>
parents:
998
diff
changeset
|
1979 |
hint=_("use --all to uncommit all files")) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1980 |
# Move local changes on filtered changeset |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1981 |
createmarkers(repo, [(old, (repo[newid],))]) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1982 |
phases.retractboundary(repo, oldphase, [newid]) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1983 |
repo.dirstate.setparents(newid, node.nullid) |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1984 |
_uncommitdirstate(repo, old, match) |
313
47d10459fa24
uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents:
312
diff
changeset
|
1985 |
updatebookmarks(newid) |
318
da7509e7b50c
evolve: warn when uncommit leave an empty changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
315
diff
changeset
|
1986 |
if not repo[newid].files(): |
da7509e7b50c
evolve: warn when uncommit leave an empty changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
315
diff
changeset
|
1987 |
ui.warn(_("new changeset is empty\n")) |
925
89b50258ad33
uncommit: change 'kill' to 'prune' in error message
Faheem Mitha <faheem@faheem.info>
parents:
923
diff
changeset
|
1988 |
ui.status(_('(use "hg prune ." to remove it)\n')) |
312
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1989 |
finally: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1990 |
wlock.release() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1991 |
finally: |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1992 |
lock.release() |
a7b5989d1d92
evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents:
309
diff
changeset
|
1993 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1994 |
@eh.wrapcommand('commit') |
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
1995 |
def commitwrapper(orig, ui, repo, *arg, **kwargs): |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1996 |
if kwargs.get('amend', False): |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1997 |
lock = None |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1998 |
else: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
1999 |
lock = repo.lock() |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2000 |
try: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2001 |
obsoleted = kwargs.get('obsolete', []) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2002 |
if obsoleted: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2003 |
obsoleted = repo.set('%lr', obsoleted) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2004 |
result = orig(ui, repo, *arg, **kwargs) |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2005 |
if not result: # commit successed |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2006 |
new = repo['-1'] |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2007 |
oldbookmarks = [] |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
2008 |
markers = [] |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2009 |
for old in obsoleted: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2010 |
oldbookmarks.extend(repo.nodebookmarks(old.node())) |
444
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
2011 |
markers.append((old, (new,))) |
aedb6b8ace86
drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
443
diff
changeset
|
2012 |
if markers: |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2013 |
createmarkers(repo, markers) |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2014 |
for book in oldbookmarks: |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2015 |
repo._bookmarks[book] = new.node() |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2016 |
if oldbookmarks: |
612
15299bfd0813
adapt to 7f5dab94e48c in crew
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
604
diff
changeset
|
2017 |
repo._bookmarks.write() |
137
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2018 |
return result |
bbc653876876
fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
133
diff
changeset
|
2019 |
finally: |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2020 |
if lock is not None: |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2021 |
lock.release() |
116
64ca29eef349
Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
113
diff
changeset
|
2022 |
|
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2023 |
@command('^touch', |
701
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2024 |
[('r', 'rev', [], 'revision to update'), |
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2025 |
('D', 'duplicate', False, |
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2026 |
'do not mark the new revision as successor of the old one')], |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2027 |
# allow to choose the seed ? |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2028 |
_('[-r] revs')) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2029 |
def touch(ui, repo, *revs, **opts): |
891
36c1c80e99a3
commands: small language fixes in help
Brendan Cully <brendan@kublai.com>
parents:
867
diff
changeset
|
2030 |
"""Create successors that are identical to their predecessors except for the changeset ID |
517
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
2031 |
|
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
2032 |
This is used to "resurrect" changesets |
0bc0c9edcb15
evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
516
diff
changeset
|
2033 |
""" |
701
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2034 |
duplicate = opts['duplicate'] |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2035 |
revs = list(revs) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2036 |
revs.extend(opts['rev']) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2037 |
if not revs: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2038 |
revs = ['.'] |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2039 |
revs = scmutil.revrange(repo, revs) |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2040 |
if not revs: |
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2041 |
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
|
2042 |
return 1 |
701
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2043 |
if not duplicate and repo.revs('public() and %ld', revs): |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2044 |
raise util.Abort("can't touch public revision") |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2045 |
wlock = lock = None |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2046 |
try: |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2047 |
wlock = repo.wlock() |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2048 |
lock = repo.lock() |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2049 |
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
|
2050 |
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
|
2051 |
newmapping = {} |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2052 |
try: |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2053 |
for r in revs: |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2054 |
ctx = repo[r] |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2055 |
extra = ctx.extra().copy() |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2056 |
extra['__touch-noise__'] = random.randint(0, 0xffffffff) |
702
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2057 |
# search for touched parent |
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2058 |
p1 = ctx.p1().node() |
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2059 |
p2 = ctx.p2().node() |
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2060 |
p1 = newmapping.get(p1, p1) |
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2061 |
p2 = newmapping.get(p2, p2) |
993
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
2062 |
new, unusedvariable = rewrite(repo, ctx, [], ctx, |
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
2063 |
[p1, p2], |
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
2064 |
commitopts={'extra': extra}) |
702
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2065 |
# store touched version to help potential children |
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2066 |
newmapping[ctx.node()] = new |
701
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2067 |
if not duplicate: |
f752089479ce
add a duplicate option in touch
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
699
diff
changeset
|
2068 |
createmarkers(repo, [(ctx, (repo[new],))]) |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2069 |
phases.retractboundary(repo, ctx.phase(), [new]) |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2070 |
if ctx in repo[None].parents(): |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2071 |
repo.dirstate.setparents(new, node.nullid) |
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2072 |
tr.close() |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2073 |
finally: |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2074 |
tr.release() |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2075 |
finally: |
514
ea667749ccd1
touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents:
513
diff
changeset
|
2076 |
lockmod.release(lock, wlock) |
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2077 |
|
934
f13facb01ac5
fold: add squash as a possible alias
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
933
diff
changeset
|
2078 |
@command('^fold|squash', |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2079 |
[('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
|
2080 |
('', '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
|
2081 |
] + commitopts + commitopts2, |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2082 |
_('hg fold [OPTION]... [-r] REV')) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2083 |
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
|
2084 |
"""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
|
2085 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2086 |
Folds a set of revisions with the parent of the working directory. |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2087 |
All revisions linearly between the given revisions and the parent |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2088 |
of the working directory will also be folded. |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2089 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2090 |
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
|
2091 |
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
|
2092 |
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
|
2093 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2094 |
.. container:: verbose |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2095 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2096 |
Some examples: |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2097 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2098 |
- 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
|
2099 |
|
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2100 |
hg fold .^ |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2101 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2102 |
- 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
|
2103 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2104 |
hg fold 'draft()' |
702
b5a85a8909d3
touch: properly handle touching multiple changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
701
diff
changeset
|
2105 |
|
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2106 |
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
|
2107 |
: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
|
2108 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2109 |
- Fold revisions 3, 4, 5, and 6 with the working directory parent:: |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2110 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2111 |
hg fold 3:6 |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2112 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2113 |
- 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
|
2114 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2115 |
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
|
2116 |
""" |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2117 |
revs = list(revs) |
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2118 |
revs.extend(opts['rev']) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2119 |
if not revs: |
994
debf44fa91a2
fold: clarify message for empty revision set and abort instead (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
993
diff
changeset
|
2120 |
raise util.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
|
2121 |
|
996
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2122 |
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
|
2123 |
|
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2124 |
if not opts['exact']: |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2125 |
# 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
|
2126 |
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
|
2127 |
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
|
2128 |
if discardedrevs: |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2129 |
raise util.Abort(_("cannot fold non-linear revisions"), |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2130 |
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
|
2131 |
"of working directory")) |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2132 |
revs = extrevs |
b98dd5d3065c
fold: overhaul handling of revisions with --rev (BC)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
995
diff
changeset
|
2133 |
|
995
0f3a7efd6ee9
fold: emit error message when folding a single revision
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
994
diff
changeset
|
2134 |
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
|
2135 |
ui.write_err(_('single revision specified, nothing to fold\n')) |
0f3a7efd6ee9
fold: emit error message when folding a single revision
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
994
diff
changeset
|
2136 |
return 1 |
0f3a7efd6ee9
fold: emit error message when folding a single revision
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
994
diff
changeset
|
2137 |
|
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2138 |
roots = repo.revs('roots(%ld)', revs) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2139 |
if len(roots) > 1: |
998
85ec2a55fe7c
fold: improve error messages for multiple heads and roots
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
997
diff
changeset
|
2140 |
raise util.Abort(_("cannot fold non-linear revisions " |
85ec2a55fe7c
fold: improve error messages for multiple heads and roots
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
997
diff
changeset
|
2141 |
"(multiple roots given)")) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2142 |
root = repo[roots[0]] |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2143 |
if root.phase() <= phases.public: |
997
f48cd2f48d14
fold: reword error message for public commits
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
996
diff
changeset
|
2144 |
raise util.Abort(_("cannot fold public revisions")) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2145 |
heads = repo.revs('heads(%ld)', revs) |
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2146 |
if len(heads) > 1: |
998
85ec2a55fe7c
fold: improve error messages for multiple heads and roots
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
997
diff
changeset
|
2147 |
raise util.Abort(_("cannot fold non-linear revisions " |
85ec2a55fe7c
fold: improve error messages for multiple heads and roots
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
997
diff
changeset
|
2148 |
"(multiple heads given)")) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2149 |
head = repo[heads[0]] |
515 | 2150 |
wlock = lock = None |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2151 |
try: |
515 | 2152 |
wlock = repo.wlock() |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2153 |
lock = repo.lock() |
515 | 2154 |
tr = repo.transaction('touch') |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2155 |
try: |
915
1ebe5c51919b
fold: enable --date and --user options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
912
diff
changeset
|
2156 |
commitopts = opts.copy() |
515 | 2157 |
allctx = [repo[r] for r in revs] |
2158 |
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
|
2159 |
|
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2160 |
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
|
2161 |
commitopts['edit'] = False |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2162 |
else: |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2163 |
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
|
2164 |
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
|
2165 |
(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
|
2166 |
commitopts['message'] = "\n".join(msgs) |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2167 |
commitopts['edit'] = True |
e5baeb8fefec
fold: add --message and --logfile options
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
931
diff
changeset
|
2168 |
|
993
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
2169 |
newid, unusedvariable = rewrite(repo, root, allctx, head, |
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
2170 |
[root.p1().node(), root.p2().node()], |
8a4a8fe50c26
evolve: do not use _ as an unused variable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
988
diff
changeset
|
2171 |
commitopts=commitopts) |
515 | 2172 |
phases.retractboundary(repo, targetphase, [newid]) |
2173 |
createmarkers(repo, [(ctx, (repo[newid],)) |
|
2174 |
for ctx in allctx]) |
|
2175 |
tr.close() |
|
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2176 |
finally: |
515 | 2177 |
tr.release() |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2178 |
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
|
2179 |
if repo['.'].rev() in revs: |
549
b047e9417d96
Properly update after fold
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
548
diff
changeset
|
2180 |
hg.update(repo, newid) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2181 |
finally: |
515 | 2182 |
lockmod.release(lock, wlock) |
482
d2531a747ff5
evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
481
diff
changeset
|
2183 |
|
587
8152fedbac65
evolve: smarter code for divergent changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
586
diff
changeset
|
2184 |
|
481
4e0f1aae8d24
evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
477
diff
changeset
|
2185 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2186 |
@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
|
2187 |
def graftwrapper(orig, ui, repo, *revs, **kwargs): |
419
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
2188 |
kwargs = dict(kwargs) |
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
2189 |
revs = list(revs) + kwargs.get('rev', []) |
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
2190 |
kwargs['rev'] = [] |
417
a1fb18ad29a1
evolve: avoid duplication in graft wrapper
Patrick Mezard <patrick@mezard.eu>
parents:
416
diff
changeset
|
2191 |
obsoleted = kwargs.setdefault('obsolete', []) |
419
03672e955bc8
evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents:
410
diff
changeset
|
2192 |
|
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
2193 |
lock = repo.lock() |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
2194 |
try: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
2195 |
if kwargs.get('old_obsolete'): |
418
18a0d96ed559
evolve: graft --continue is optional, test
Patrick Mezard <patrick@mezard.eu>
parents:
417
diff
changeset
|
2196 |
if kwargs.get('continue'): |
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
2197 |
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
|
2198 |
else: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
2199 |
obsoleted.extend(revs) |
151
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
2200 |
# 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
|
2201 |
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
|
2202 |
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
|
2203 |
|
743
af74a5cdf96b
conform to the Mercurial custom of lowercase messages
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
742
diff
changeset
|
2204 |
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
|
2205 |
'obsoleting (for now).')) |
e73944b6be8f
evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
147
diff
changeset
|
2206 |
|
119
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
2207 |
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
|
2208 |
finally: |
22f2b700bd59
evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
118
diff
changeset
|
2209 |
lock.release() |
117
438fe133b068
Add a -o and -O option to graft.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
116
diff
changeset
|
2210 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2211 |
@eh.extsetup |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2212 |
def oldevolveextsetup(ui): |
211
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
2213 |
try: |
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
2214 |
rebase = extensions.find('rebase') |
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
2215 |
except KeyError: |
416
22f348c25d25
obsolete/evolve: fix grammar in prerequisite messages
Patrick Mezard <patrick@mezard.eu>
parents:
414
diff
changeset
|
2216 |
raise error.Abort(_('evolution extension requires rebase extension.')) |
211
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
2217 |
|
742
760d01a549a6
amend: use core mechanism for amend
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
741
diff
changeset
|
2218 |
for cmd in ['kill', 'uncommit', 'touch', 'fold']: |
356
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
355
diff
changeset
|
2219 |
entry = extensions.wrapcommand(cmdtable, cmd, |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2220 |
warnobserrors) |
356
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
355
diff
changeset
|
2221 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2222 |
entry = cmdutil.findcmd('commit', commands.table)[1] |
303 | 2223 |
entry[1].append(('o', 'obsolete', [], |
2224 |
_("make commit obsolete this revision"))) |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
2225 |
entry = cmdutil.findcmd('graft', commands.table)[1] |
303 | 2226 |
entry[1].append(('o', 'obsolete', [], |
2227 |
_("make graft obsoletes this revision"))) |
|
2228 |
entry[1].append(('O', 'old-obsolete', False, |
|
2229 |
_("make graft obsoletes its source"))) |
|
211
69a37d56c7fb
evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
196
diff
changeset
|
2230 |
|
816
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2231 |
##################################################################### |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2232 |
### Obsolescence marker exchange experimenation ### |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2233 |
##################################################################### |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2234 |
|
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2235 |
@command('debugobsoleterelevant', |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2236 |
[], |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2237 |
'REVSET') |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2238 |
def debugobsoleterelevant(ui, repo, *revsets): |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2239 |
"""print allobsolescence marker relevant to a set of revision""" |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2240 |
nodes = [ctx.node() for ctx in repo.set('%lr', revsets)] |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2241 |
markers = repo.obsstore.relevantmarkers(nodes) |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2242 |
for rawmarker in sorted(markers): |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2243 |
marker = obsolete.marker(repo, rawmarker) |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2244 |
cmdutil.showmarker(ui, marker) |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2245 |
|
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2246 |
@eh.addattr(obsolete.obsstore, 'relevantmarkers') |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2247 |
def relevantmarkers(self, nodes): |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2248 |
"""return a set of all obsolescence marker relevant to a set of node. |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2249 |
|
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2250 |
"relevant" to a set of node mean: |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2251 |
|
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2252 |
- marker that use this changeset as successors |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2253 |
- prune marker of direct children on this changeset. |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2254 |
- recursive application of the two rules on precursors of these markers |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2255 |
|
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2256 |
It a set so you cannot rely on order""" |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2257 |
seennodes = set(nodes) |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2258 |
seenmarkers = set() |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2259 |
pendingnodes = set(nodes) |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2260 |
precursorsmarkers = self.precursors |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2261 |
prunedchildren = self.prunedchildren |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2262 |
while pendingnodes: |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2263 |
direct = set() |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2264 |
for current in pendingnodes: |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2265 |
direct.update(precursorsmarkers.get(current, ())) |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2266 |
direct.update(prunedchildren.get(current, ())) |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2267 |
direct -= seenmarkers |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2268 |
pendingnodes = set([m[0] for m in direct]) |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2269 |
seenmarkers |= direct |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2270 |
pendingnodes -= seennodes |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2271 |
seennodes |= pendingnodes |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2272 |
return seenmarkers |
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2273 |
|
03587920dfd9
evolve: add relevant marker exchange machinery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
811
diff
changeset
|
2274 |
|
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
|
2275 |
_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
|
2276 |
if _pushkeyescape is None: |
820
a9a66143e2ec
exchange: actually use _pushkeyescape fallback
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
819
diff
changeset
|
2277 |
_maxpayload = 5300 |
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
|
2278 |
def _pushkeyescape(markers): |
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
|
2279 |
"""encode markers into a dict suitable for pushkey exchange |
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
|
2280 |
|
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
|
2281 |
- binary data are base86 encoded |
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
|
2282 |
- splited in chunk less than 5300 bytes""" |
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
|
2283 |
parts = [] |
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
|
2284 |
currentlen = _maxpayload * 2 # ensure we create a new part |
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
|
2285 |
for marker in markers: |
820
a9a66143e2ec
exchange: actually use _pushkeyescape fallback
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
819
diff
changeset
|
2286 |
nextdata = obsolete._encodeonemarker(marker) |
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
|
2287 |
if (len(nextdata) + currentlen > _maxpayload): |
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
|
2288 |
currentpart = [] |
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
|
2289 |
currentlen = 0 |
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
|
2290 |
parts.append(currentpart) |
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
|
2291 |
currentpart.append(nextdata) |
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
|
2292 |
currentlen += len(nextdata) |
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
|
2293 |
keys = {} |
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
|
2294 |
for idx, part in enumerate(reversed(parts)): |
820
a9a66143e2ec
exchange: actually use _pushkeyescape fallback
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
819
diff
changeset
|
2295 |
data = ''.join([_pack('>B', 0)] + part) |
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
|
2296 |
keys['dump%i' % idx] = base85.b85encode(data) |
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
|
2297 |
return keys |
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
|
2298 |
|
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2299 |
def _encodemarkersstream(fp, markers): |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2300 |
fp.write(_pack('>B', 0)) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2301 |
for mark in markers: |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2302 |
fp.write(obsolete._encodeonemarker(mark)) |
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
|
2303 |
|
854
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
2304 |
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
|
2305 |
"""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
|
2306 |
|
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
2307 |
@util.propertycache |
879
85b3d54516a7
exchange: expose length of pushed markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
877
diff
changeset
|
2308 |
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
|
2309 |
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
|
2310 |
|
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
2311 |
def 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
|
2312 |
self.ui.progress('OBSEXC', self.tell(), unit="bytes", |
879
85b3d54516a7
exchange: expose length of pushed markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
877
diff
changeset
|
2313 |
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
|
2314 |
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
|
2315 |
|
961
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
2316 |
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
|
2317 |
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
|
2318 |
while d: |
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
2319 |
yield d |
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
2320 |
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
|
2321 |
|
1006
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2322 |
bundle2partsgenerators = getattr(exchange, 'bundle2partsgenerators', None) |
854
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
2323 |
|
1007
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2324 |
|
1006
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2325 |
if bundle2partsgenerators is not None: |
1007
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2326 |
|
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2327 |
def _pushb2phases(pushop, bundler): |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2328 |
"""adds phases update to the main bundle2 push""" |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2329 |
outgoing = pushop.outgoing |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2330 |
unfi = pushop.repo.unfiltered() |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2331 |
remotephases = pushop.remote.listkeys('phases') |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2332 |
publishing = remotephases.get('publishing', False) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2333 |
ana = phases.analyzeremotephases(pushop.repo, |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2334 |
outgoing.commonheads, |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2335 |
remotephases) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2336 |
pheads, droots = ana |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2337 |
revset = 'heads((%ln::%ln))' |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2338 |
if not publishing: |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2339 |
revset += ' and public()' |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2340 |
# Get the list of all revs draft on remote by public here. |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2341 |
# XXX Beware that revset break if droots is not strictly |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2342 |
# XXX root we may want to ensure it is but it is costly |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2343 |
fallback = list(unfi.set(revset, droots, outgoing.commonheads)) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2344 |
if not outgoing.missing: |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2345 |
future = fallback |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2346 |
else: |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2347 |
# adds changeset we are going to push as draft |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2348 |
# |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2349 |
# should not be necessary for pushblishing server, but because of |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2350 |
# an issue fixed in xxxxx we have to do it anyway. |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2351 |
fdroots = list(unfi.set('roots(%ln + %ln::)', outgoing.missing, droots)) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2352 |
fdroots = [f.node() for f in fdroots] |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2353 |
future = list(unfi.set(revset, fdroots, outgoing.missingheads)) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2354 |
|
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2355 |
b2caps = bundle2.bundle2caps(pushop.remote) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2356 |
if 'b2x:pushkey' not in b2caps: |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2357 |
return |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2358 |
pushop.stepsdone.add('phases') |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2359 |
part2node = [] |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2360 |
enc = pushkey.encode |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2361 |
for newremotehead in future: |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2362 |
part = bundler.newpart('b2x:pushkey') |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2363 |
part.addparam('namespace', enc('phases')) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2364 |
part.addparam('key', enc(newremotehead.hex())) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2365 |
part.addparam('old', enc(str(phases.draft))) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2366 |
part.addparam('new', enc(str(phases.public))) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2367 |
part2node.append((part.id, newremotehead)) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2368 |
def handlereply(op): |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2369 |
for partid, pnode in part2node: |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2370 |
partrep = op.records.getreplies(partid) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2371 |
results = partrep['pushkey'] |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2372 |
assert len(results) <= 1 |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2373 |
msg = None |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2374 |
if not results: |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2375 |
msg = _('server ignored update of %s to public!\n') % pnode |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2376 |
elif not int(results[0]['return']): |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2377 |
msg = _('updating %s to public failed!\n') % pnode |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2378 |
if msg is not None: |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2379 |
pushop.ui.warn(msg) |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2380 |
return handlereply |
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2381 |
|
1006
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2382 |
def _pushb2obsmarker(pushop, bundler): |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2383 |
"""adds obsmarker to the main bundle2 push""" |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2384 |
repo = pushop.repo |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2385 |
remote = pushop.remote |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2386 |
if ('obsmarkers' not in pushop.stepsdone |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2387 |
and (obsolete._enabled and repo.obsstore and |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2388 |
'obsolete' in remote.listkeys('namespaces')) |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2389 |
and remote.capable('_evoext_b2x_obsmarkers_0')): |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2390 |
# |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2391 |
pushop.stepsdone.add('obsmarkers') |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2392 |
markers = _obsmarkersdiscovery(pushop) |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2393 |
if not markers: |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2394 |
repo.ui.status("OBSEXC: no marker to push\n") |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2395 |
repo.ui.status("OBSEXC: DONE\n") |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2396 |
return |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2397 |
obsdata = pushobsmarkerStringIO() |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2398 |
_encodemarkersstream(obsdata, markers) |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2399 |
obsdata.seek(0) |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2400 |
obsdata.ui = repo.ui |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2401 |
repo.ui.status("OBSEXC: pushing %i markers (%i bytes)\n" |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2402 |
% (len(markers), len(obsdata.getvalue()))) |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2403 |
bundler.newpart('EVOLVE:B2X:OBSMARKERV1', data=obsdata) |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2404 |
def callback(op): |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2405 |
repo.ui.progress('OBSEXC', None) |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2406 |
repo.ui.status("OBSEXC: DONE\n") |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2407 |
return callback |
1007
1d8ba8244001
push: put phase in the same bundle2 than changegroup and obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1006
diff
changeset
|
2408 |
bundle2partsgenerators.append(_pushb2phases) |
1006
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2409 |
bundle2partsgenerators.append(_pushb2obsmarker) |
854
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
2410 |
|
1005
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2411 |
|
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2412 |
def _obsmarkersdiscovery(pushop): |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2413 |
"""return the list of marker that needs to be pushed to the server |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2414 |
|
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2415 |
When used before (or at the same time) the changegroup have been pushed, it |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2416 |
returns the value as if the planned changegroup was succesful. Othewise it |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2417 |
use te actual common heads to decide whats needs to be pushed. |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2418 |
""" |
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
|
2419 |
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
|
2420 |
remote = pushop.remote |
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
|
2421 |
unfi = repo.unfiltered() |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2422 |
cl = unfi.changelog |
1005
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2423 |
commonheads = pushop.commonheads |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2424 |
if commonheads is None: |
1006
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2425 |
if pushop.revs is None: |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2426 |
commonheads = pushop.outgoing.commonheads |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2427 |
sch = set(commonheads) |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2428 |
commonheads.extend(h for h in pushop.outgoing.missingheads |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2429 |
if h not in sch) |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2430 |
else: |
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2431 |
commonheads = pushop.outgoing.missingheads |
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
|
2432 |
if (obsolete._enabled and repo.obsstore and |
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
|
2433 |
'obsolete' in remote.listkeys('namespaces')): |
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
|
2434 |
repo.ui.status("OBSEXC: computing relevant nodes\n") |
1005
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2435 |
revs = unfi.revs('::%ln', commonheads) |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2436 |
common = [] |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2437 |
if remote.capable('_evoext_obshash_0'): |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2438 |
repo.ui.status("OBSEXC: looking for common markers in %i nodes\n" |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2439 |
% len(revs)) |
1006
deba3a063c63
push: put obsmarkers in the same bundle2 than changeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1005
diff
changeset
|
2440 |
common = findcommonobsmarkers(pushop.ui, unfi, remote, revs) |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2441 |
revs = list(unfi.revs('%ld - (::%ln)', revs, common)) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2442 |
nodes = [cl.node(r) for r in revs] |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2443 |
if nodes: |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2444 |
repo.ui.status("OBSEXC: computing markers relevant to %i nodes\n" |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2445 |
% len(nodes)) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2446 |
markers = repo.obsstore.relevantmarkers(nodes) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2447 |
else: |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2448 |
repo.ui.status("OBSEXC: markers already in sync\n") |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2449 |
markers = [] |
1005
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2450 |
return markers |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2451 |
|
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2452 |
@eh.wrapfunction(exchange, '_pushobsolete') |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2453 |
def _pushobsolete(orig, pushop): |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2454 |
"""utility function to push obsolete markers to a remote""" |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2455 |
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
|
2456 |
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
|
2457 |
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
|
2458 |
return |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2459 |
stepsdone.add('obsmarkers') |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2460 |
pushop.ui.debug('try to push obsolete markers to remote\n') |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2461 |
repo = pushop.repo |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2462 |
remote = pushop.remote |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2463 |
unfi = repo.unfiltered() |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2464 |
cl = unfi.changelog |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2465 |
if (obsolete._enabled and repo.obsstore and |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2466 |
'obsolete' in remote.listkeys('namespaces')): |
4fe159fdfc4c
push: extract obsmarkers discovery in a dedicated function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1004
diff
changeset
|
2467 |
markers = _obsmarkersdiscovery(pushop) |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2468 |
if not markers: |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2469 |
repo.ui.status("OBSEXC: no marker to push\n") |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2470 |
elif remote.capable('_evoext_b2x_obsmarkers_0'): |
961
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
2471 |
obsdata = pushobsmarkerStringIO() |
957
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2472 |
_encodemarkersstream(obsdata, markers) |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2473 |
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
|
2474 |
obsdata.ui = repo.ui |
957
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2475 |
repo.ui.status("OBSEXC: pushing %i markers (%i bytes)\n" |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2476 |
% (len(markers), len(obsdata.getvalue()))) |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2477 |
bundler = bundle2.bundle20(pushop.ui, {}) |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2478 |
capsblob = bundle2.encodecaps(pushop.repo.bundle2caps) |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2479 |
bundler.addpart(bundle2.bundlepart('b2x:replycaps', data=capsblob)) |
961
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
2480 |
cgpart = bundle2.bundlepart('EVOLVE:B2X:OBSMARKERV1', data=obsdata) |
957
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2481 |
bundler.addpart(cgpart) |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2482 |
stream = util.chunkbuffer(bundler.getchunks()) |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2483 |
try: |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2484 |
reply = pushop.remote.unbundle(stream, ['force'], 'push') |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2485 |
except bundle2.UnknownPartError, exc: |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2486 |
raise util.Abort('missing support for %s' % exc) |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2487 |
try: |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2488 |
op = bundle2.processbundle(pushop.repo, reply) |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2489 |
except bundle2.UnknownPartError, exc: |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2490 |
raise util.Abort('missing support for %s' % exc) |
961
8de88b323fb6
evolve: install progress support for the bundle2 push path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
960
diff
changeset
|
2491 |
repo.ui.progress('OBSEXC', None) |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2492 |
elif remote.capable('_evoext_pushobsmarkers_0'): |
854
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
2493 |
obsdata = pushobsmarkerStringIO() |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2494 |
_encodemarkersstream(obsdata, markers) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2495 |
obsdata.seek(0) |
854
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
2496 |
obsdata.ui = repo.ui |
944
b71b563b17de
evolve: more compact output in the wire protocol case
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
942
diff
changeset
|
2497 |
repo.ui.status("OBSEXC: pushing %i markers (%i bytes)\n" |
b71b563b17de
evolve: more compact output in the wire protocol case
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
942
diff
changeset
|
2498 |
% (len(markers), len(obsdata.getvalue()))) |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2499 |
remote.evoext_pushobsmarkers_0(obsdata) |
854
86b826399dfd
exchange: add progress bar when pushing using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
853
diff
changeset
|
2500 |
repo.ui.progress('OBSEXC', None) |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2501 |
else: |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2502 |
rslts = [] |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2503 |
remotedata = _pushkeyescape(markers).items() |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2504 |
totalbytes = sum(len(d) for k,d in remotedata) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2505 |
sentbytes = 0 |
956
b107f3549ec2
evolve: make exchange output compact in the old pushkey case too.
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
955
diff
changeset
|
2506 |
repo.ui.status("OBSEXC: pushing %i markers in %i pushkey payload (%i bytes)\n" |
b107f3549ec2
evolve: make exchange output compact in the old pushkey case too.
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
955
diff
changeset
|
2507 |
% (len(markers), len(remotedata), totalbytes)) |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2508 |
for key, data in remotedata: |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2509 |
repo.ui.progress('OBSEXC', sentbytes, item=key, unit="bytes", |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2510 |
total=totalbytes) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2511 |
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
|
2512 |
sentbytes += len(data) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2513 |
repo.ui.progress('OBSEXC', sentbytes, item=key, unit="bytes", |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2514 |
total=totalbytes) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2515 |
repo.ui.progress('OBSEXC', None) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2516 |
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
|
2517 |
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
|
2518 |
repo.ui.warn(msg) |
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
|
2519 |
repo.ui.status("OBSEXC: DONE\n") |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2520 |
|
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2521 |
|
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2522 |
@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
|
2523 |
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
|
2524 |
"""wireprotocol peer method""" |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2525 |
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
|
2526 |
_('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
|
2527 |
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
|
2528 |
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
|
2529 |
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
|
2530 |
return ret |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2531 |
|
880
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
2532 |
@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
|
2533 |
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
|
2534 |
"""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
|
2535 |
(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
|
2536 |
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
|
2537 |
_('push obsolete markers faster')) |
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
2538 |
ret, output = self._call('evoext_pushobsmarkers_0', data=obsfile) |
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
2539 |
for l in output.splitlines(True): |
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
2540 |
if l.strip(): |
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
2541 |
self.ui.status(_('remote: '), l) |
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
2542 |
return ret |
7fe06f32d1ad
exchange: fix push markers over wire protocol for http peer
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
879
diff
changeset
|
2543 |
|
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2544 |
|
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2545 |
def srv_pushobsmarkers(repo, proto): |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2546 |
"""wireprotocol command""" |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2547 |
fp = StringIO() |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2548 |
proto.redirect() |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2549 |
proto.getfile(fp) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2550 |
data = fp.getvalue() |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2551 |
fp.close() |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2552 |
lock = repo.lock() |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2553 |
try: |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2554 |
tr = repo.transaction('pushkey: obsolete markers') |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2555 |
try: |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2556 |
repo.obsstore.mergemarkers(tr, data) |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2557 |
tr.close() |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2558 |
finally: |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2559 |
tr.release() |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2560 |
finally: |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2561 |
lock.release() |
888
097ddcb0da25
evolve: add a hook related to the new pushobsmarkers command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
887
diff
changeset
|
2562 |
repo.hook('evolve_pushobsmarkers') |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2563 |
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
|
2564 |
|
957
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2565 |
@bundle2.parthandler('evolve:b2x:obsmarkerv1') |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2566 |
def handleobsmarkerv1(op, inpart): |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2567 |
"""add a stream of obsmarker to the repo""" |
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2568 |
tr = op.gettransaction() |
962
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2569 |
advparams = dict(inpart.advisoryparams) |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2570 |
length = advparams.get('totalbytes') |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2571 |
if length is None: |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2572 |
obsdata = inpart.read() |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2573 |
else: |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2574 |
length = int(length) |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2575 |
data = StringIO() |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2576 |
current = 0 |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2577 |
op.ui.progress('OBSEXC', current, unit="bytes", total=length) |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2578 |
while current < length: |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2579 |
readsize = min(length-current, 4096) |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2580 |
data.write(inpart.read(readsize)) |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2581 |
current += readsize |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2582 |
op.ui.progress('OBSEXC', current, unit="bytes", total=length) |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2583 |
op.ui.progress('OBSEXC', None) |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2584 |
obsdata = data.getvalue() |
958
6d18a1ab496c
evolve: add bytes and new marker data when processing part
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
957
diff
changeset
|
2585 |
totalsize = len(obsdata) |
6d18a1ab496c
evolve: add bytes and new marker data when processing part
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
957
diff
changeset
|
2586 |
old = len(op.repo.obsstore._all) |
6d18a1ab496c
evolve: add bytes and new marker data when processing part
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
957
diff
changeset
|
2587 |
op.repo.obsstore.mergemarkers(tr, obsdata) |
6d18a1ab496c
evolve: add bytes and new marker data when processing part
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
957
diff
changeset
|
2588 |
new = len(op.repo.obsstore._all) - old |
6d18a1ab496c
evolve: add bytes and new marker data when processing part
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
957
diff
changeset
|
2589 |
op.records.add('evo_obsmarkers', {'new': new, 'bytes': totalsize}) |
959
d39a5c8c82ad
evolve: advertise obsmarker creation in the transation hook
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
958
diff
changeset
|
2590 |
tr.hookargs['evolve_new_obsmarkers'] = str(new) |
957
2cde59f3cb5d
evolve: add a push pass using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
956
diff
changeset
|
2591 |
|
825
7671717afef8
exchange: extract computation of pulled markers boundary in a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
824
diff
changeset
|
2592 |
def _buildpullobsmerkersboundaries(pullop): |
7671717afef8
exchange: extract computation of pulled markers boundary in a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
824
diff
changeset
|
2593 |
"""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
|
2594 |
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
|
2595 |
|
7671717afef8
exchange: extract computation of pulled markers boundary in a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
824
diff
changeset
|
2596 |
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
|
2597 |
repo = pullop.repo |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
2598 |
cl = pullop.repo.changelog |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
2599 |
remote = pullop.remote |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
2600 |
unfi = repo.unfiltered() |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
2601 |
revs = unfi.revs('::%ln', pullop.pulledsubset) |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
2602 |
common = [nullid] |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
2603 |
if remote.capable('_evoext_obshash_0'): |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
2604 |
repo.ui.status("OBSEXC: looking for common markers in %i nodes\n" |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
2605 |
% len(revs)) |
5c40b2a4b52f
discovery: use the discovery process for pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
864
diff
changeset
|
2606 |
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
|
2607 |
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
|
2608 |
|
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2609 |
@eh.uisetup |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2610 |
def addgetbundleargs(self): |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2611 |
if gboptsmap is not None: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2612 |
gboptsmap['evo_obsmarker'] = 'plain' |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2613 |
gboptsmap['evo_obscommon'] = 'plain' |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2614 |
gboptsmap['evo_obsheads'] = 'plain' |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2615 |
else: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2616 |
gboptslist.append('evo_obsheads') |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2617 |
gboptslist.append('evo_obscommon') |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2618 |
gboptslist.append('evo_obsmarker') |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2619 |
|
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2620 |
|
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2621 |
|
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2622 |
@eh.wrapfunction(exchange, '_getbundleextrapart') |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2623 |
def _getbundleextrapart(orig, bundler, repo, source, **kwargs): |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2624 |
if int(kwargs.pop('evo_obsmarker', False)): |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2625 |
common = kwargs.pop('evo_obscommon') |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2626 |
common = wireproto.decodelist(common) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2627 |
heads = kwargs.pop('evo_obsheads') |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2628 |
heads = wireproto.decodelist(heads) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2629 |
obsdata = _getobsmarkersstream(repo, common=common, heads=heads) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2630 |
if len(obsdata.getvalue()) > 5: |
962
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2631 |
advparams = [('totalbytes', str(len(obsdata.getvalue())))] |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2632 |
obspart = bundle2.bundlepart('EVOLVE:B2X:OBSMARKERV1', |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2633 |
advisoryparams=advparams, |
d04a52f40f41
evolve: install progress support for the bundle2 pull path
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
961
diff
changeset
|
2634 |
data=obsdata) |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2635 |
bundler.addpart(obspart) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2636 |
orig(bundler, repo, source) |
825
7671717afef8
exchange: extract computation of pulled markers boundary in a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
824
diff
changeset
|
2637 |
|
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2638 |
@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
|
2639 |
def _pullobsolete(orig, pullop): |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2640 |
if not obsolete._enabled: |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2641 |
return None |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2642 |
b2xpull = pullop.remote.capable('_evoext_b2x_obsmarkers_0') |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2643 |
wirepull = pullop.remote.capable('_evoext_pullobsmarkers_0') |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2644 |
if not (b2xpull or wirepull): |
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2645 |
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
|
2646 |
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
|
2647 |
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
|
2648 |
tr = None |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2649 |
ui = pullop.repo.ui |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2650 |
ui.status("OBSEXC: pull obsolescence markers\n") |
825
7671717afef8
exchange: extract computation of pulled markers boundary in a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
824
diff
changeset
|
2651 |
boundaries = _buildpullobsmerkersboundaries(pullop) |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2652 |
new = 0 |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2653 |
|
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2654 |
if b2xpull: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2655 |
kwargs = {'bundlecaps': set(['HG2X'])} |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2656 |
capsblob = bundle2.encodecaps(pullop.repo.bundle2caps) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2657 |
kwargs['bundlecaps'].add('bundle2=' + urllib.quote(capsblob)) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2658 |
kwargs['heads'] = [nullid] |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2659 |
kwargs['common'] = [nullid] |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2660 |
kwargs['evo_obsmarker'] = '1' |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2661 |
kwargs['evo_obscommon'] = wireproto.encodelist(boundaries['common']) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2662 |
kwargs['evo_obsheads'] = wireproto.encodelist(boundaries['heads']) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2663 |
bundle = pullop.remote.getbundle('pull', **kwargs) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2664 |
try: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2665 |
op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2666 |
except bundle2.UnknownPartError, exc: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2667 |
raise util.Abort('missing support for %s' % exc) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2668 |
bytes = new = 0 |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2669 |
for entry in op.records['evo_obsmarkers']: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2670 |
bytes += entry.get('bytes', 0) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2671 |
new += entry.get('new', 0) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2672 |
if 5 < bytes: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2673 |
ui.status("OBSEXC: merging obsolescence markers (%i bytes)\n" |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2674 |
% bytes) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2675 |
ui.status("OBSEXC: %i markers added\n" % new) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2676 |
tr = op.gettransaction() |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2677 |
else: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2678 |
ui.status("OBSEXC: no unknown remote markers\n") |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2679 |
ui.status("OBSEXC: DONE\n") |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2680 |
elif wirepull: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2681 |
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
|
2682 |
obsdata = obsdata.read() |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2683 |
if len(obsdata) > 5: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2684 |
ui.status("OBSEXC: merging obsolescence markers (%i bytes)\n" |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2685 |
% len(obsdata)) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2686 |
tr = pullop.gettransaction() |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2687 |
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
|
2688 |
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
|
2689 |
new = len(pullop.repo.obsstore._all) - old |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2690 |
ui.status("OBSEXC: %i markers added\n" % new) |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2691 |
else: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2692 |
ui.status("OBSEXC: no unknown remote markers\n") |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2693 |
ui.status("OBSEXC: DONE\n") |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2694 |
if new: |
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2695 |
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
|
2696 |
return tr |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2697 |
|
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2698 |
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
|
2699 |
revset = '' |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2700 |
args = [] |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2701 |
repo = repo.unfiltered() |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2702 |
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
|
2703 |
revset = 'all()' |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2704 |
elif heads: |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2705 |
revset += "(::%ln)" |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2706 |
args.append(heads) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2707 |
else: |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2708 |
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
|
2709 |
if common: |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2710 |
revset += ' - (::%ln)' |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2711 |
args.append(common) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2712 |
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
|
2713 |
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
|
2714 |
obsdata = StringIO() |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2715 |
_encodemarkersstream(obsdata, markers) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2716 |
obsdata.seek(0) |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2717 |
return obsdata |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2718 |
|
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2719 |
@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
|
2720 |
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
|
2721 |
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
|
2722 |
opts = {} |
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2723 |
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
|
2724 |
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
|
2725 |
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
|
2726 |
opts['common'] = wireproto.encodelist(common) |
897
b5227608d9dd
evolve: use new api _callcompressable
Olle Lundberg <geek@nerd.sh>
parents:
896
diff
changeset
|
2727 |
if util.safehasattr(self, '_callcompressable'): |
b5227608d9dd
evolve: use new api _callcompressable
Olle Lundberg <geek@nerd.sh>
parents:
896
diff
changeset
|
2728 |
f = self._callcompressable("evoext_pullobsmarkers_0", **opts) |
b5227608d9dd
evolve: use new api _callcompressable
Olle Lundberg <geek@nerd.sh>
parents:
896
diff
changeset
|
2729 |
else: |
b5227608d9dd
evolve: use new api _callcompressable
Olle Lundberg <geek@nerd.sh>
parents:
896
diff
changeset
|
2730 |
f = self._callstream("evoext_pullobsmarkers_0", **opts) |
b5227608d9dd
evolve: use new api _callcompressable
Olle Lundberg <geek@nerd.sh>
parents:
896
diff
changeset
|
2731 |
f = self._decompress(f) |
898
934b6f0feffd
evolve: small white space change
Olle Lundberg <geek@nerd.sh>
parents:
897
diff
changeset
|
2732 |
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
|
2733 |
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
|
2734 |
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
|
2735 |
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
|
2736 |
ui = self.ui |
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
2737 |
ui.progress('OBSEXC', current, unit="bytes", total=length) |
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
2738 |
while current < length: |
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
2739 |
readsize = min(length-current, chunk) |
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
2740 |
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
|
2741 |
current += readsize |
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
2742 |
ui.progress('OBSEXC', current, unit="bytes", total=length) |
b82b49189328
exchange: add progress bar when pulling using wire protocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
825
diff
changeset
|
2743 |
ui.progress('OBSEXC', None) |
870
1a23c7c52a43
exchange: fix pull over wire protocol
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
869
diff
changeset
|
2744 |
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
|
2745 |
return data |
823
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2746 |
|
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2747 |
@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
|
2748 |
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
|
2749 |
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
|
2750 |
|
9aa20585e158
exchange: add a new method to pull markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
821
diff
changeset
|
2751 |
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
|
2752 |
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
|
2753 |
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
|
2754 |
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
|
2755 |
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
|
2756 |
obsdata = _getobsmarkersstream(repo, **opts) |
877
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
2757 |
finaldata = StringIO() |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
2758 |
obsdata = obsdata.getvalue() |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
2759 |
finaldata.write('%20i' % len(obsdata)) |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
2760 |
finaldata.write(obsdata) |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
2761 |
finaldata.seek(0) |
cf35f38d6a10
exchange: fix changeset pulling over http
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
875
diff
changeset
|
2762 |
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
|
2763 |
|
863
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2764 |
def _obsrelsethashtree(repo): |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2765 |
cache = [] |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2766 |
unfi = repo.unfiltered() |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2767 |
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
|
2768 |
ctx = unfi[i] |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2769 |
entry = 0 |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2770 |
sha = util.sha1() |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2771 |
# 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
|
2772 |
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
|
2773 |
p = p.rev() |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2774 |
if p < 0: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2775 |
p = nullid |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2776 |
else: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2777 |
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
|
2778 |
if p != nullid: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2779 |
entry += 1 |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2780 |
sha.update(p) |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2781 |
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
|
2782 |
if tmarkers: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2783 |
bmarkers = [obsolete._encodeonemarker(m) for m in tmarkers] |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2784 |
bmarkers.sort() |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2785 |
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
|
2786 |
entry += 1 |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2787 |
sha.update(m) |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2788 |
if entry: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2789 |
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
|
2790 |
else: |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2791 |
cache.append((ctx.node(), nullid)) |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2792 |
return cache |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2793 |
|
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2794 |
@command('debugobsrelsethashtree', |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2795 |
[] , _('')) |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2796 |
def debugobsrelsethashtree(ui, repo): |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2797 |
"""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
|
2798 |
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
|
2799 |
|
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2800 |
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
|
2801 |
relevant to the changeset itself.""" |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2802 |
for chg, obs in _obsrelsethashtree(repo): |
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2803 |
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
|
2804 |
|
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2805 |
|
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2806 |
### Set discovery START |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2807 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2808 |
import random |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2809 |
from mercurial import dagutil |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2810 |
from mercurial import setdiscovery |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2811 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2812 |
def _obshash(repo, nodes): |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2813 |
hashs = _obsrelsethashtree(repo) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2814 |
nm = repo.changelog.nodemap |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2815 |
return [hashs[nm.get(n)][1] for n in nodes] |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2816 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2817 |
def srv_obshash(repo, proto, nodes): |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2818 |
return wireproto.encodelist(_obshash(repo, wireproto.decodelist(nodes))) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2819 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2820 |
@eh.addattr(localrepo.localpeer, 'evoext_obshash') |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2821 |
def local_obshash(peer, nodes): |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2822 |
return _obshash(peer._repo, nodes) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2823 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2824 |
@eh.addattr(wireproto.wirepeer, 'evoext_obshash') |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2825 |
def peer_obshash(self, nodes): |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2826 |
d = self._call("evoext_obshash", nodes=wireproto.encodelist(nodes)) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2827 |
try: |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2828 |
return wireproto.decodelist(d) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2829 |
except ValueError: |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2830 |
self._abort(error.ResponseError(_("unexpected response:"), d)) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2831 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2832 |
def findcommonobsmarkers(ui, local, remote, probeset, |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2833 |
initialsamplesize=100, |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2834 |
fullsamplesize=200): |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2835 |
# from discovery |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2836 |
roundtrips = 0 |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2837 |
cl = local.changelog |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2838 |
dag = dagutil.revlogdag(cl) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2839 |
localhash = _obsrelsethashtree(local) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2840 |
missing = set() |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2841 |
common = set() |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2842 |
undecided = set(probeset) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2843 |
_takefullsample = setdiscovery._takefullsample |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2844 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2845 |
while undecided: |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2846 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2847 |
ui.note(_("sampling from both directions\n")) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2848 |
sample = _takefullsample(dag, undecided, size=fullsamplesize) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2849 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2850 |
roundtrips += 1 |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2851 |
ui.debug("query %i; still undecided: %i, sample size is: %i\n" |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2852 |
% (roundtrips, len(undecided), len(sample))) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2853 |
# indices between sample and externalized version must match |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2854 |
sample = list(sample) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2855 |
remotehash = remote.evoext_obshash(dag.externalizeall(sample)) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2856 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2857 |
yesno = [localhash[ix][1] == remotehash[si] |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2858 |
for si, ix in enumerate(sample)] |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2859 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2860 |
commoninsample = set(n for i, n in enumerate(sample) if yesno[i]) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2861 |
common.update(dag.ancestorset(commoninsample, common)) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2862 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2863 |
missinginsample = [n for i, n in enumerate(sample) if not yesno[i]] |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2864 |
missing.update(dag.descendantset(missinginsample, missing)) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2865 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2866 |
undecided.difference_update(missing) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2867 |
undecided.difference_update(common) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2868 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2869 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2870 |
result = dag.headsetofconnecteds(common) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2871 |
ui.debug("%d total queries\n" % roundtrips) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2872 |
|
887
0ea9cecbbd28
exchange: dropping dead code (issue36)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
886
diff
changeset
|
2873 |
if not result: |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2874 |
return set([nullid]) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2875 |
return dag.externalizeall(result) |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2876 |
|
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2877 |
@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
|
2878 |
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
|
2879 |
"""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
|
2880 |
caps = 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
|
2881 |
if obsolete._enabled: |
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2882 |
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
|
2883 |
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
|
2884 |
caps += ' _evoext_obshash_0' |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2885 |
caps += ' _evoext_b2x_obsmarkers_0' |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2886 |
return caps |
863
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2887 |
|
e9693738f234
discovery: first version of the "hash tree" idea
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
861
diff
changeset
|
2888 |
|
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2889 |
@eh.extsetup |
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2890 |
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
|
2891 |
localrepo.moderncaps.add('_evoext_pullobsmarkers_0') |
960
0c1142059a82
evolve: add a pull path using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
959
diff
changeset
|
2892 |
localrepo.moderncaps.add('_evoext_b2x_obsmarkers_0') |
869
e9eeef0d07ec
exchange: enforce permission on new wireprotocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
868
diff
changeset
|
2893 |
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
|
2894 |
hgweb_mod.perms['evoext_pullobsmarkers_0'] = 'pull' |
e9eeef0d07ec
exchange: enforce permission on new wireprotocol command
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
868
diff
changeset
|
2895 |
hgweb_mod.perms['evoext_obshash'] = 'pull' |
821
202376586cf6
exchange: introduce a wireprotocol command to push markers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
820
diff
changeset
|
2896 |
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
|
2897 |
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
|
2898 |
# wrap command content |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
871
diff
changeset
|
2899 |
oldcap, args = wireproto.commands['capabilities'] |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
871
diff
changeset
|
2900 |
def newcap(repo, proto): |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
871
diff
changeset
|
2901 |
return capabilities(oldcap, repo, proto) |
10867a8e27c6
exchange: properly wrap wireprotocol capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
871
diff
changeset
|
2902 |
wireproto.commands['capabilities'] = (newcap, args) |
864
401da1b38cca
discovery: implement a discovery process and use it for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
863
diff
changeset
|
2903 |
wireproto.commands['evoext_obshash'] = (srv_obshash, 'nodes') |