annotate hgext/evolve.py @ 545:31932df8309a stable

pkg: proper debian version
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Fri, 31 Aug 2012 11:50:37 +0200
parents 8c5da9e75ae0
children 415540dee2bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1 # Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
2 # Logilab SA <contact@logilab.fr>
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
3 # Pierre-Yves David <pierre-yves.david@ens-lyon.org>
519
9825c7da5b54 ensure all file have a copyright notice
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 517
diff changeset
4 # Patrick Mezard <patrick@mezard.eu>
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
5 #
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
6 # This software may be used and distributed according to the terms of the
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
7 # GNU General Public License version 2 or any later version.
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
8
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
9 '''Extends Mercurial feature related to Changeset Evolution
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
481
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
22 import random
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
23
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
24 from mercurial import util
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
25
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
26 try:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
27 from mercurial import obsolete
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
28 if not obsolete._enabled:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
29 obsolete._enabled = True
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
30 except ImportError:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
31 raise util.Abort('Obsolete extension requires Mercurial 2.3 (or later)')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
32
490
8096833e9226 sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 485
diff changeset
33 from mercurial import bookmarks
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
34 from mercurial import cmdutil
490
8096833e9226 sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 485
diff changeset
35 from mercurial import commands
8096833e9226 sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 485
diff changeset
36 from mercurial import context
8096833e9226 sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 485
diff changeset
37 from mercurial import copies
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
38 from mercurial import discovery
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
39 from mercurial import error
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
40 from mercurial import extensions
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
41 from mercurial import hg
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
42 from mercurial import localrepo
514
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
43 from mercurial import lock as lockmod
490
8096833e9226 sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 485
diff changeset
44 from mercurial import merge
8096833e9226 sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 485
diff changeset
45 from mercurial import node
113
3bdabdbb4140 adapt evolution to phase in core.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 108
diff changeset
46 from mercurial import phases
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
47 from mercurial import revset
490
8096833e9226 sort import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 485
diff changeset
48 from mercurial import scmutil
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
49 from mercurial import templatekw
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
50 from mercurial.i18n import _
455
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
51 from mercurial.commands import walkopts, commitopts, commitopts2
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
52 from mercurial.node import nullid
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
53
539
9555231a66b2 hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 534
diff changeset
54 import mercurial.hgweb.hgweb_mod
9555231a66b2 hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 534
diff changeset
55
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
56
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
57
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
58 # This extension contains the following code
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
59 #
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
60 # - Extension Helper code
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
61 # - Obsolescence cache
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
62 # - ...
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
63 # - Older format compat
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
64
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
65
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
66
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
67 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
68 ### Extension helper ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
69 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
70
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
71 class exthelper(object):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
72 """Helper for modular extension setup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
73
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
74 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
75 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
76
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
77 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
78 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
79
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
80 def __init__(self):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
81 self._uicallables = []
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
82 self._extcallables = []
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
83 self._repocallables = []
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
84 self._revsetsymbols = []
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
85 self._templatekws = []
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
86 self._commandwrappers = []
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
87 self._extcommandwrappers = []
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
88 self._functionwrappers = []
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
89 self._duckpunchers = []
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 def final_uisetup(self, ui):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
92 """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
93
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
94 The following operations belong here:
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 - 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
97 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
98 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
99 passed to runcommand
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
100 - Command wraps (extensions.wrapcommand)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
101 - 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
102 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
103 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
104 during extsetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
105 - 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
106 module members
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
107 - Setup of pre-* and post-* hooks
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
108 - pushkey setup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
109 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
110 for cont, funcname, func in self._duckpunchers:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
111 setattr(cont, funcname, func)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
112 for command, wrapper in self._commandwrappers:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
113 extensions.wrapcommand(commands.table, command, wrapper)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
114 for cont, funcname, wrapper in self._functionwrappers:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
115 extensions.wrapfunction(cont, funcname, wrapper)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
116 for c in self._uicallables:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
117 c(ui)
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_extsetup(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 a the extension extsetup
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 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
125 extensions.find('mq'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
126 - Add a global option to all commands
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
127 - Register revset functions
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
128 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
129 knownexts = {}
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
130 for name, symbol in self._revsetsymbols:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
131 revset.symbols[name] = symbol
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
132 for name, kw in self._templatekws:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
133 templatekw.keywords[name] = kw
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
134 for ext, command, wrapper in self._extcommandwrappers:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
135 if ext not in knownexts:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
136 e = extensions.find(ext)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
137 if e is None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
138 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
139 knownexts[ext] = e.cmdtable
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
140 extensions.wrapcommand(knownexts[ext], commands, wrapper)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
141 for c in self._extcallables:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
142 c(ui)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
143
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
144 def final_reposetup(self, ui, repo):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
145 """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
146
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
147 The following operations belong here:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
148
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
149 - All hooks but pre-* and post-*
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
150 - Modify configuration variables
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
151 - Changes to repo.__class__, repo.dirstate.__class__
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
152 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
153 for c in self._repocallables:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
154 c(ui, repo)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
155
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
156 def uisetup(self, call):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
157 """Decorated function will be executed during uisetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
158
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
159 example::
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
160
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
161 @eh.uisetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
162 def setupbabar(ui):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
163 print 'this is uisetup!'
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
164 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
165 self._uicallables.append(call)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
166 return call
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
167
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
168 def extsetup(self, call):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
169 """Decorated function will be executed during extsetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
170
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
171 example::
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
172
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
173 @eh.extsetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
174 def setupcelestine(ui):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
175 print 'this is extsetup!'
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 self._uicallables.append(call)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
178 return call
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
179
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
180 def reposetup(self, call):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
181 """Decorated function will be executed during reposetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
182
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
183 example::
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
184
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
185 @eh.reposetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
186 def setupzephir(ui, repo):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
187 print 'this is reposetup!'
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 self._repocallables.append(call)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
190 return call
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
191
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
192 def revset(self, symbolname):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
193 """Decorated function is a revset symbol
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
194
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
195 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
196 The symbol is added during `extsetup`.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
197
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
198 example::
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
199
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
200 @eh.revset('hidden')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
201 def revsetbabar(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
202 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
203 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
204 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
205 def dec(symbol):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
206 self._revsetsymbols.append((symbolname, symbol))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
207 return symbol
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
208 return dec
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
209
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 def templatekw(self, keywordname):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
212 """Decorated function is a revset keyword
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
213
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
214 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
215 The symbol is added during `extsetup`.
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 example::
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
218
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
219 @eh.templatekw('babar')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
220 def kwbabar(ctx):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
221 return 'babar'
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 def dec(keyword):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
224 self._templatekws.append((keywordname, keyword))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
225 return keyword
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
226 return dec
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 def wrapcommand(self, command, extension=None):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
229 """Decorated function is a command wrapper
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
230
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
231 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
232 The wrapping is installed during `uisetup`.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
233
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
234 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
235 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
236 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
237 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
238 installed during `extsetup`
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
239
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
240 example::
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 @eh.wrapcommand('summary')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
243 def wrapsummary(orig, ui, repo, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
244 ui.note('Barry!')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
245 return orig(ui, repo, *args, **kwargs)
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 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
248 def dec(wrapper):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
249 if extension is None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
250 self._commandwrappers.append((command, wrapper))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
251 else:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
252 self._extcommandwrappers.append((extension, command, wrapper))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
253 return wrapper
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 wrapfunction(self, container, funcname):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
257 """Decorated function is a function 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 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
260 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
261 (there is no extension support)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
262
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
263 example::
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
264
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
265 @eh.function(discovery, 'checkheads')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
266 def wrapfunction(orig, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
267 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
268 return orig(*args, **kwargs)
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 def dec(wrapper):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
271 self._functionwrappers.append((container, funcname, wrapper))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
272 return wrapper
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
273 return dec
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 def addattr(self, container, funcname):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
276 """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
277
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
278 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
279 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
280
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
281 example::
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
282
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
283 @eh.function(context.changectx, 'babar')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
284 def babar(ctx):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
285 return 'babar' in ctx.description
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 def dec(func):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
288 self._duckpunchers.append((container, funcname, func))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
289 return func
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
290 return dec
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
291
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
292 eh = exthelper()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
293 uisetup = eh.final_uisetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
294 extsetup = eh.final_extsetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
295 reposetup = eh.final_reposetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
296
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 ### Obsolescence Caching Logic ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
299 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
300
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
301 # Obsolescence related logic can be very slow if we don't have efficient cache.
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 # This section implements a cache mechanism that did not make it into core for
517
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
304 # time reason. It stores meaningful set of revisions related to obsolescence
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
305 # (obsolete, unstable, etc.)
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
306 #
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
307 # Here is:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
308 #
517
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
309 # - Computation of meaningful sets
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
310 # - Cache access logic,
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
311 # - Cache invalidation logic,
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
312 # - revset and ctx using this cache.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
313 #
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
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
316 ### Computation of meaningful set
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
317 #
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
318 # Most set can be computed with "simple" revset.
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 #: { set name -> function to compute this set } mapping
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
321 #: function take a single "repo" argument.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
322 #:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
323 #: Use the `cachefor` decorator to register new cache function
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
324 cachefuncs = {}
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
325 def cachefor(name):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
326 """Decorator to register a function as computing the cache for a set"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
327 def decorator(func):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
328 assert name not in cachefuncs
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
329 cachefuncs[name] = func
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
330 return func
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
331 return decorator
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
332
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
333 @cachefor('obsolete')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
334 def _computeobsoleteset(repo):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
335 """the set of obsolete revisions"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
336 obs = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
337 nm = repo.changelog.nodemap
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
338 for prec in repo.obsstore.precursors:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
339 rev = nm.get(prec)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
340 if rev is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
341 obs.add(rev)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
342 return set(repo.revs('%ld - public()', obs))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
343
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
344 @cachefor('unstable')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
345 def _computeunstableset(repo):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
346 """the set of non obsolete revisions with obsolete parents"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
347 return set(repo.revs('(obsolete()::) - obsolete()'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
348
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
349 @cachefor('suspended')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
350 def _computesuspendedset(repo):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
351 """the set of obsolete parents with non obsolete descendants"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
352 return set(repo.revs('obsolete() and obsolete()::unstable()'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
353
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
354 @cachefor('extinct')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
355 def _computeextinctset(repo):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
356 """the set of obsolete parents without non obsolete descendants"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
357 return set(repo.revs('obsolete() - obsolete()::unstable()'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
358
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
359 @eh.wrapfunction(obsolete.obsstore, '__init__')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
360 def _initobsstorecache(orig, obsstore, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
361 """add a cache attribute to obsstore"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
362 obsstore.caches = {}
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
363 return orig(obsstore, *args, **kwargs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
364
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
365 ### Cache access
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
366
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
367 def getobscache(repo, name):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
368 """Return the set of revision that belong to the <name> set
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
369
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
370 Such access may compute the set and cache it for future use"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
371 if not repo.obsstore:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
372 return ()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
373 if name not in repo.obsstore.caches:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
374 repo.obsstore.caches[name] = cachefuncs[name](repo)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
375 return repo.obsstore.caches[name]
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
376
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
377 ### Cache clean up
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
378 #
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
379 # To be simple we need to invalidate obsolescence cache when:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
380 #
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
381 # - new changeset is added:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
382 # - public phase is changed
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
383 # - obsolescence marker are added
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
384 # - strip is used a repo
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
385
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
386
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
387 def clearobscaches(repo):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
388 """Remove all obsolescence related cache from a repo
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
389
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
390 This remove all cache in obsstore is the obsstore already exist on the
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
391 repo.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
392
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
393 (We could be smarter here)"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
394 if 'obsstore' in repo._filecache:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
395 repo.obsstore.caches.clear()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
396
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
397 @eh.wrapfunction(localrepo.localrepository, 'addchangegroup') # new changeset
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
398 @eh.wrapfunction(phases, 'retractboundary') # phase movement
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
399 @eh.wrapfunction(phases, 'advanceboundary') # phase movement
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
400 @eh.wrapfunction(localrepo.localrepository, 'destroyed') # strip
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
401 def wrapclearcache(orig, repo, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
402 try:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
403 return orig(repo, *args, **kwargs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
404 finally:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
405 # we are a bit wide here
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
406 # we could restrict to:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
407 # advanceboundary + phase==public
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
408 # retractboundary + phase==draft
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
409 clearobscaches(repo)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
410
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
411 @eh.wrapfunction(obsolete.obsstore, 'add') # new marker
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
412 def clearonadd(orig, obsstore, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
413 try:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
414 return orig(obsstore, *args, **kwargs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
415 finally:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
416 obsstore.caches.clear()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
417
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
418 ### Use the case
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
419 # Function in core that could benefic from the cache are overwritten by cache using version
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 # changectx method
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 @eh.addattr(context.changectx, 'unstable')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
424 def unstable(ctx):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
425 """is the changeset unstable (have obsolete ancestor)"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
426 if ctx.node() is None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
427 return False
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
428 return ctx.rev() in getobscache(ctx._repo, 'unstable')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
429
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
430
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
431 @eh.addattr(context.changectx, 'extinct')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
432 def extinct(ctx):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
433 """is the changeset extinct by other"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
434 if ctx.node() is None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
435 return False
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
436 return ctx.rev() in getobscache(ctx._repo, 'extinct')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
437
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
438 # revset
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
439
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
440 @eh.revset('obsolete')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
441 def revsetobsolete(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
442 """``obsolete()``
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
443 Changeset is obsolete.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
444 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
445 args = revset.getargs(x, 0, 0, 'obsolete takes no argument')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
446 obsoletes = getobscache(repo, 'obsolete')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
447 return [r for r in subset if r in obsoletes]
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
448
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
449 @eh.revset('unstable')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
450 def revsetunstable(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
451 """``unstable()``
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
452 Unstable changesets are non-obsolete with obsolete ancestors.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
453 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
454 args = revset.getargs(x, 0, 0, 'unstable takes no arguments')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
455 unstables = getobscache(repo, 'unstable')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
456 return [r for r in subset if r in unstables]
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
457
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
458 @eh.revset('extinct')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
459 def revsetextinct(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
460 """``extinct()``
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
461 Obsolete changesets with obsolete descendants only.
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 args = revset.getargs(x, 0, 0, 'extinct takes no arguments')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
464 extincts = getobscache(repo, 'extinct')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
465 return [r for r in subset if r in extincts]
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 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
468 ### Complete troubles computation logic ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
469 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
470
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
471 # there is two kind of trouble not handled by core right now:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
472 # - latecomer: (successors for public changeset)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
473 # - conflicting: (two changeset try to succeed to the same precursors)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
474 #
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
475 # This section add support for those two addition trouble
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
476 #
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
477 # - Cache computation
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
478 # - revset and ctx method
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
479 # - push warning
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
480
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
481 ### Cache computation
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
482 latediff = 1 # flag to prevent taking late comer fix into account
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
483
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
484 @cachefor('latecomer')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
485 def _computelatecomerset(repo):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
486 """the set of rev trying to obsolete public revision"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
487 candidates = _allsuccessors(repo, repo.revs('public()'),
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
488 haltonflags=latediff)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
489 query = '%ld - obsolete() - public()'
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
490 return set(repo.revs(query, candidates))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
492 @cachefor('conflicting')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
493 def _computeconflictingset(repo):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
494 """the set of rev trying to obsolete public revision"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
495 conflicting = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
496 obsstore = repo.obsstore
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
497 newermap = {}
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
498 for ctx in repo.set('(not public()) - obsolete()'):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
499 prec = obsstore.successors.get(ctx.node(), ())
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
500 toprocess = set(prec)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
501 while toprocess:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
502 prec = toprocess.pop()[0]
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
503 if prec not in newermap:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
504 newermap[prec] = newerversion(repo, prec)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
505 newer = [n for n in newermap[prec] if n] # filter kill
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
506 if len(newer) > 1:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
507 conflicting.add(ctx.rev())
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
508 break
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
509 toprocess.update(obsstore.successors.get(prec, ()))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
510 return conflicting
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 ### changectx method
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
513
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
514 @eh.addattr(context.changectx, 'latecomer')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
515 def latecomer(ctx):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
516 """is the changeset latecomer (Try to succeed to public change)"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
517 if ctx.node() is None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
518 return False
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
519 return ctx.rev() in getobscache(ctx._repo, 'latecomer')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
520
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
521 @eh.addattr(context.changectx, 'conflicting')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
522 def conflicting(ctx):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
523 """is the changeset conflicting (Try to succeed to public change)"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
524 if ctx.node() is None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
525 return False
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
526 return ctx.rev() in getobscache(ctx._repo, 'conflicting')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
527
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
528 ### revset symbol
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
529
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
530 @eh.revset('latecomer')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
531 def revsetlatecomer(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
532 """``latecomer()``
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
533 Changesets marked as successors of public changesets.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
534 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
535 args = revset.getargs(x, 0, 0, 'latecomer takes no arguments')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
536 lates = getobscache(repo, 'latecomer')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
537 return [r for r in subset if r in lates]
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 @eh.revset('conflicting')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
540 def revsetconflicting(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
541 """``conflicting()``
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
542 Changesets marked as successors of a same changeset.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
543 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
544 args = revset.getargs(x, 0, 0, 'conflicting takes no arguments')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
545 conf = getobscache(repo, 'conflicting')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
546 return [r for r in subset if r in conf]
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
547
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
548
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
549 ### Discovery wrapping
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
550
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
551 @eh.wrapfunction(discovery, 'checkheads')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
552 def wrapcheckheads(orig, repo, remote, outgoing, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
553 """wrap mercurial.discovery.checkheads
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
554
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
555 * prevent latecomer and unstable to be pushed
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
556 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
557 # do not push instability
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
558 for h in outgoing.missingheads:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
559 # Checking heads is enough, obsolete descendants are either
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
560 # obsolete or unstable.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
561 ctx = repo[h]
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
562 if ctx.latecomer():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
563 raise util.Abort(_("push includes a latecomer changeset: %s!")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
564 % ctx)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
565 if ctx.conflicting():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
566 raise util.Abort(_("push includes a conflicting changeset: %s!")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
567 % ctx)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
568 return orig(repo, remote, outgoing, *args, **kwargs)
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 #####################################################################
517
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
571 ### Filter extinct changesets from common operations ###
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
572 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
573
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
574 @eh.wrapfunction(merge, 'update')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
575 def wrapmergeupdate(orig, repo, node, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
576 """ensure we don't automatically update on hidden changeset"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
577 if node is None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
578 # tip of current branch
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
579 branch = repo[None].branch()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
580 node = repo.revs('last((.:: and branch(%s)) - hidden())', branch)[0]
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
581 return orig(repo, node, *args, **kwargs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
582
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
583 @eh.wrapfunction(localrepo.localrepository, 'branchtip')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
584 def obsbranchtip(orig, repo, branch):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
585 """ensure "stable" reference does not end on a hidden changeset"""
539
9555231a66b2 hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 534
diff changeset
586 if not getattr(repo, '_dofilterbranchtip', True):
9555231a66b2 hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 534
diff changeset
587 return orig(repo, branch)
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
588 result = ()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
589 heads = repo.branchmap().get(branch, ())
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
590 if heads:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
591 result = list(repo.set('last(heads(branch(%n) - hidden()))', heads[0]))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
592 if not result:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
593 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
594 return result[0].node()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
595
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
596
539
9555231a66b2 hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 534
diff changeset
597 @eh.wrapfunction(mercurial.hgweb.hgweb_mod.hgweb, '__init__')
9555231a66b2 hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 534
diff changeset
598 @eh.wrapfunction(mercurial.hgweb.hgweb_mod.hgweb, 'refresh')
9555231a66b2 hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 534
diff changeset
599 def nofilter(orig, hgweb, *args, **kwargs):
9555231a66b2 hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 534
diff changeset
600 orig(hgweb, *args, **kwargs)
9555231a66b2 hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 534
diff changeset
601 hgweb.repo._dofilterbranchtip = False
9555231a66b2 hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 534
diff changeset
602
9555231a66b2 hgweb: disable branchtip filtering for hgweb
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 534
diff changeset
603
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
604 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
605 ### Additional Utilities ###
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
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
608 # 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
609
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
610 # - Function to create markers
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
611 # - 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
612 # - "troubles" method on changectx
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
613 # - function to travel throught the obsolescence graph
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
614 # - function to find useful changeset to stabilize
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
615
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
616 ### Marker Create
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
617
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
618 def createmarkers(repo, relations, metadata=None, flag=0):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
619 """Add obsolete markers between changeset in a repo
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
620
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
621 <relations> must be an iterable of (<old>, (<new>, ...)) tuple.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
622 `old` and `news` are changectx.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
623
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
624 Current user and date are used except if specified otherwise in the
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
625 metadata attribute.
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 /!\ assume the repo have been locked by the user /!\
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
628 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
629 # prepare metadata
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
630 if metadata is None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
631 metadata = {}
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
632 if 'date' not in metadata:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
633 metadata['date'] = '%i %i' % util.makedate()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
634 if 'user' not in metadata:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
635 metadata['user'] = repo.ui.username()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
636 # check future marker
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
637 tr = repo.transaction('add-obsolescence-marker')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
638 try:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
639 for prec, sucs in relations:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
640 if not prec.mutable():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
641 raise util.Abort("Cannot obsolete immutable changeset: %s" % prec)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
642 nprec = prec.node()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
643 nsucs = tuple(s.node() for s in sucs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
644 if nprec in nsucs:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
645 raise util.Abort("Changeset %s cannot obsolete himself" % prec)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
646 repo.obsstore.create(tr, nprec, nsucs, flag, metadata)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
647 clearobscaches(repo)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
648 tr.close()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
649 finally:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
650 tr.release()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
651
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
652
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
653 ### Useful alias
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
654
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
655 @eh.uisetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
656 def _installalias(ui):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
657 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
658 ui.setconfig('alias', 'pstatus', 'status --rev .^')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
659 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
660 ui.setconfig('alias', 'pdiff', 'diff --rev .^')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
661 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
662 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
663 if ui.config('alias', 'odiff', None) is None:
43e1b2cab789 evolve: add the odiff alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 492
diff changeset
664 ui.setconfig('alias', 'odiff', "diff --rev 'limit(precursors(.),1)' --rev .")
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
665
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
666 # - "troubles" method on changectx
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
667
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
668 @eh.addattr(context.changectx, 'troubles')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
669 def troubles(ctx):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
670 """Return a tuple listing all the troubles that affect a changeset
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
671
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
672 Troubles may be "unstable", "latecomer" or "conflicting".
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
673 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
674 troubles = []
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
675 if ctx.unstable():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
676 troubles.append('unstable')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
677 if ctx.latecomer():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
678 troubles.append('latecomer')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
679 if ctx.conflicting():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
680 troubles.append('conflicting')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
681 return tuple(troubles)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
682
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
683 ### Troubled revset symbol
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
684
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
685 @eh.revset('troubled')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
686 def revsetlatecomer(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
687 """``troubled()``
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
688 Changesets with troubles.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
689 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
690 _ = revset.getargs(x, 0, 0, 'troubled takes no arguments')
511
ddeb71df916d evolve: localrepo.revs() already returns a list
Patrick Mezard <patrick@mezard.eu>
parents: 510
diff changeset
691 return repo.revs('%ld and (unstable() + latecomer() + conflicting())',
ddeb71df916d evolve: localrepo.revs() already returns a list
Patrick Mezard <patrick@mezard.eu>
parents: 510
diff changeset
692 subset)
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
693
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
694
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
695 ### Obsolescence graph
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
696
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
697 # 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
698
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
699 def _precursors(repo, s):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
700 """Precursor of a changeset"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
701 cs = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
702 nm = repo.changelog.nodemap
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
703 markerbysubj = repo.obsstore.successors
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
704 for r in s:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
705 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
706 pr = nm.get(p[0])
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
707 if pr is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
708 cs.add(pr)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
709 return cs
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
710
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
711 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
712 """transitive precursors of a subset"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
713 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
714 seen = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
715 allsubjects = repo.obsstore.successors
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
716 while toproceed:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
717 nc = toproceed.pop()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
718 for mark in allsubjects.get(nc, ()):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
719 np = mark[0]
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
720 if np not in seen:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
721 seen.add(np)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
722 toproceed.append(np)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
723 nm = repo.changelog.nodemap
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
724 cs = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
725 for p in seen:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
726 pr = nm.get(p)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
727 if pr is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
728 cs.add(pr)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
729 return cs
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
730
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
731 def _successors(repo, s):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
732 """Successors of a changeset"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
733 cs = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
734 nm = repo.changelog.nodemap
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
735 markerbyobj = repo.obsstore.precursors
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
736 for r in s:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
737 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
738 for sub in p[1]:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
739 sr = nm.get(sub)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
740 if sr is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
741 cs.add(sr)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
742 return cs
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
743
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
744 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
745 """transitive successors of a subset
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
746
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
747 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
748 marker. """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
749 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
750 seen = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
751 allobjects = repo.obsstore.precursors
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
752 while toproceed:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
753 nc = toproceed.pop()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
754 for mark in allobjects.get(nc, ()):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
755 if mark[2] & haltonflags:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
756 continue
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
757 for sub in mark[1]:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
758 if sub == nullid:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
759 continue # should not be here!
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
760 if sub not in seen:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
761 seen.add(sub)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
762 toproceed.append(sub)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
763 nm = repo.changelog.nodemap
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
764 cs = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
765 for s in seen:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
766 sr = nm.get(s)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
767 if sr is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
768 cs.add(sr)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
769 return cs
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
770
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
771
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
772
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
773 def newerversion(repo, obs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
774 """Return the newer version of an obsolete changeset"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
775 toproceed = set([(obs,)])
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
776 # XXX known optimization available
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
777 newer = set()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
778 objectrels = repo.obsstore.precursors
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
779 while toproceed:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
780 current = toproceed.pop()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
781 assert len(current) <= 1, 'splitting not handled yet. %r' % current
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
782 current = [n for n in current if n != nullid]
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
783 if current:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
784 n, = current
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
785 if n in objectrels:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
786 markers = objectrels[n]
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
787 for mark in markers:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
788 toproceed.add(tuple(mark[1]))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
789 else:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
790 newer.add(tuple(current))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
791 else:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
792 newer.add(())
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
793 return sorted(newer)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
794
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
795
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
796 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
797 ### Extending revset and template ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
798 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
799
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
800 # 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
801 # they are subject to changes
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
802
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
803
520
a426301ab306 Conditionnaly add the `hidden` revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 519
diff changeset
804 if 'hidden' not in revset.symbols:
a426301ab306 Conditionnaly add the `hidden` revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 519
diff changeset
805 # in 2.3+
a426301ab306 Conditionnaly add the `hidden` revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 519
diff changeset
806 @eh.revset('hidden')
a426301ab306 Conditionnaly add the `hidden` revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 519
diff changeset
807 def revsethidden(repo, subset, x):
a426301ab306 Conditionnaly add the `hidden` revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 519
diff changeset
808 """``hidden()``
a426301ab306 Conditionnaly add the `hidden` revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 519
diff changeset
809 Changeset is hidden.
a426301ab306 Conditionnaly add the `hidden` revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 519
diff changeset
810 """
a426301ab306 Conditionnaly add the `hidden` revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 519
diff changeset
811 args = revset.getargs(x, 0, 0, 'hidden takes no argument')
a426301ab306 Conditionnaly add the `hidden` revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 519
diff changeset
812 return [r for r in subset if r in repo.hiddenrevs]
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
813
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
814 ### 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
815 @eh.revset('suspended')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
816 def revsetsuspended(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
817 """``suspended()``
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
818 Obsolete changesets with non-obsolete descendants.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
819 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
820 args = revset.getargs(x, 0, 0, 'suspended takes no arguments')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
821 suspended = getobscache(repo, 'suspended')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
822 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
823
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
824
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
825 @eh.revset('precursors')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
826 def revsetprecursors(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
827 """``precursors(set)``
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
828 Immediate precursors of changesets in set.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
829 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
830 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
831 cs = _precursors(repo, s)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
832 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
833
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
834
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
835 @eh.revset('allprecursors')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
836 def revsetallprecursors(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
837 """``allprecursors(set)``
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
838 Transitive precursors of changesets in set.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
839 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
840 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
841 cs = _allprecursors(repo, s)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
842 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
843
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
844
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
845 @eh.revset('successors')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
846 def revsetsuccessors(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
847 """``successors(set)``
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
848 Immediate successors of changesets in set.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
849 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
850 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
851 cs = _successors(repo, s)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
852 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
853
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
854 @eh.revset('allsuccessors')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
855 def revsetallsuccessors(repo, subset, x):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
856 """``allsuccessors(set)``
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
857 Transitive successors of changesets in set.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
858 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
859 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
860 cs = _allsuccessors(repo, s)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
861 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
862
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
863 ### template keywords
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
864 # XXX it does not handle troubles well :-/
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
865
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
866 @eh.templatekw('obsolete')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
867 def obsoletekw(repo, ctx, templ, **args):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
868 """: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
869 ``stable``, ``unstable``, ``suspended`` or ``extinct``.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
870 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
871 rev = ctx.rev()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
872 if ctx.obsolete():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
873 if ctx.extinct():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
874 return 'extinct'
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
875 else:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
876 return 'suspended'
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
877 elif ctx.unstable():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
878 return 'unstable'
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
879 return 'stable'
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
880
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
881 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
882 ### Various trouble warning ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
883 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
884
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
885 # 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
886
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
887 @eh.wrapcommand("update")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
888 @eh.wrapcommand("pull")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
889 def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
890 """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
891 res = origfn(ui, repo, *args, **opts)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
892 if repo['.'].obsolete():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
893 ui.warn(_('Working directory parent is obsolete\n'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
894 return res
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
895
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
896 # XXX this could wrap transaction code
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
897 # 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
898 @eh.wrapcommand("commit")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
899 @eh.wrapcommand("push")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
900 @eh.wrapcommand("pull")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
901 @eh.wrapcommand("graft")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
902 @eh.wrapcommand("phase")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
903 @eh.wrapcommand("unbundle")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
904 def warnobserrors(orig, ui, repo, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
905 """display warning is the command resulted in more instable changeset"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
906 priorunstables = len(repo.revs('unstable()'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
907 priorlatecomers = len(repo.revs('latecomer()'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
908 priorconflictings = len(repo.revs('conflicting()'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
909 ret = orig(ui, repo, *args, **kwargs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
910 newunstables = len(repo.revs('unstable()')) - priorunstables
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
911 newlatecomers = len(repo.revs('latecomer()')) - priorlatecomers
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
912 newconflictings = len(repo.revs('conflicting()')) - priorconflictings
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
913 if newunstables > 0:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
914 ui.warn(_('%i new unstable changesets\n') % newunstables)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
915 if newlatecomers > 0:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
916 ui.warn(_('%i new latecomer changesets\n') % newlatecomers)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
917 if newconflictings > 0:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
918 ui.warn(_('%i new conflicting changesets\n') % newconflictings)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
919 return ret
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
920
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
921 @eh.reposetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
922 def _repostabilizesetup(ui, repo):
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
923 """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
924 """
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
925 if not repo.local():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
926 return
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
927
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
928 opush = repo.push
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
929
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
930 class evolvingrepo(repo.__class__):
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
931 def push(self, remote, *args, **opts):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
932 """wrapper around pull that pull obsolete relation"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
933 try:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
934 result = opush(remote, *args, **opts)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
935 except util.Abort, ex:
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
936 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
937 "or --force to ignore warnings")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
938 if (len(ex.args) >= 1
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
939 and ex.args[0].startswith('push includes ')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
940 and ex.hint is None):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
941 ex.hint = hint
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
942 raise
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
943 return result
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
944 repo.__class__ = evolvingrepo
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
945
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
946 @eh.wrapcommand("summary")
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
947 def obssummary(orig, ui, repo, *args, **kwargs):
513
4602104b190d evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents: 512
diff changeset
948 def write(fmt, count):
4602104b190d evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents: 512
diff changeset
949 s = fmt % count
4602104b190d evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents: 512
diff changeset
950 if count:
4602104b190d evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents: 512
diff changeset
951 ui.write(s)
4602104b190d evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents: 512
diff changeset
952 else:
4602104b190d evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents: 512
diff changeset
953 ui.note(s)
4602104b190d evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents: 512
diff changeset
954
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
955 ret = orig(ui, repo, *args, **kwargs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
956 nbunstable = len(getobscache(repo, 'unstable'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
957 nblatecomer = len(getobscache(repo, 'latecomer'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
958 nbconflicting = len(getobscache(repo, 'unstable'))
513
4602104b190d evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents: 512
diff changeset
959 write('unstable: %i changesets\n', nbunstable)
4602104b190d evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents: 512
diff changeset
960 write('latecomer: %i changesets\n', nblatecomer)
4602104b190d evolve: factor out copy/paste in obssummary()
Patrick Mezard <patrick@mezard.eu>
parents: 512
diff changeset
961 write('conflicting: %i changesets\n', nbconflicting)
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
962 return ret
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
963
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
964
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
965 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
966 ### Core Other extension compat ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
967 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
968
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
969 # This section make official history rewritter create obsolete marker
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
970
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
971
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
972 ### commit --amend
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
973 # make commit --amend create obsolete marker
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
974 #
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
975 # The precursor is still strip from the repository.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
976
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
977 @eh.wrapfunction(cmdutil, 'amend')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
978 def wrapcmdutilamend(orig, ui, repo, commitfunc, old, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
979 oldnode = old.node()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
980 new = orig(ui, repo, commitfunc, old, *args, **kwargs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
981 if new != oldnode:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
982 lock = repo.lock()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
983 try:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
984 tr = repo.transaction('post-amend-obst')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
985 try:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
986 meta = {
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
987 'date': '%i %i' % util.makedate(),
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
988 'user': ui.username(),
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
989 }
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
990 repo.obsstore.create(tr, oldnode, [new], 0, meta)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
991 tr.close()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
992 clearobscaches(repo)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
993 finally:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
994 tr.release()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
995 finally:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
996 lock.release()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
997 return new
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
998
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
999 ### rebase
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1000 #
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1001 # - ignore obsolete changeset
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1002 # - create obsolete marker *instead of* striping
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1003
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1004 def buildstate(orig, repo, dest, rebaseset, *ags, **kws):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1005 """wrapper for rebase 's buildstate that exclude obsolete changeset"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1006
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1007 rebaseset = repo.revs('%ld - extinct()', rebaseset)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1008 if not rebaseset:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1009 repo.ui.warn(_('whole rebase set is extinct and ignored.\n'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1010 return {}
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1011 root = min(rebaseset)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1012 if not repo._rebasekeep and not repo[root].mutable():
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1013 raise util.Abort(_("can't rebase immutable changeset %s") % repo[root],
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1014 hint=_('see hg help phases for details'))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1015 return orig(repo, dest, rebaseset, *ags, **kws)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1016
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1017 def defineparents(orig, repo, rev, target, state, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1018 rebasestate = getattr(repo, '_rebasestate', None)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1019 if rebasestate is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1020 repo._rebasestate = dict(state)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1021 repo._rebasetarget = target
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1022 return orig(repo, rev, target, state, *args, **kwargs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1023
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1024 def concludenode(orig, repo, rev, p1, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1025 """wrapper for rebase 's concludenode that set obsolete relation"""
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1026 newrev = orig(repo, rev, p1, *args, **kwargs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1027 rebasestate = getattr(repo, '_rebasestate', None)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1028 if rebasestate is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1029 if newrev is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1030 nrev = repo[newrev].rev()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1031 else:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1032 nrev = p1
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1033 repo._rebasestate[rev] = nrev
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1034 return newrev
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1035
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1036 def cmdrebase(orig, ui, repo, *args, **kwargs):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1037
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1038 reallykeep = kwargs.get('keep', False)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1039 kwargs = dict(kwargs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1040 kwargs['keep'] = True
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1041 repo._rebasekeep = reallykeep
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1042
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1043 # We want to mark rebased revision as obsolete and set their
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1044 # replacements if any. Doing it in concludenode() prevents
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1045 # aborting the rebase, and is not called with all relevant
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1046 # revisions in --collapse case. Instead, we try to track the
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1047 # rebase state structure by sampling/updating it in
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1048 # defineparents() and concludenode(). The obsolete markers are
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1049 # added from this state after a successful call.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1050 repo._rebasestate = {}
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1051 repo._rebasetarget = None
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1052 try:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1053 l = repo.lock()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1054 try:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1055 res = orig(ui, repo, *args, **kwargs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1056 if not reallykeep:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1057 # Filter nullmerge or unrebased entries
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1058 repo._rebasestate = dict(p for p in repo._rebasestate.iteritems()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1059 if p[1] >= 0)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1060 if not res and not kwargs.get('abort') and repo._rebasestate:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1061 # Rebased revisions are assumed to be descendants of
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1062 # targetrev. If a source revision is mapped to targetrev
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1063 # or to another rebased revision, it must have been
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1064 # removed.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1065 markers = []
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1066 if kwargs.get('collapse'):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1067 # collapse assume revision disapear because they are all
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1068 # in the created revision
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1069 newrevs = set(repo._rebasestate.values())
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1070 newrevs.remove(repo._rebasetarget)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1071 if newrevs:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1072 # we create new revision.
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1073 # A single one by --collapse design
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1074 assert len(newrevs) == 1
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1075 new = tuple(repo[n] for n in newrevs)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1076 else:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1077 # every body died. no new changeset created
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1078 new = (repo[repo._rebasetarget],)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1079 for rev, newrev in sorted(repo._rebasestate.items()):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1080 markers.append((repo[rev], new))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1081 else:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1082 # no collapse assume revision disapear because they are
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1083 # contained in parent
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1084 for rev, newrev in sorted(repo._rebasestate.items()):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1085 markers.append((repo[rev], (repo[newrev],)))
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1086 createmarkers(repo, markers)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1087 return res
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1088 finally:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1089 l.release()
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1090 finally:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1091 delattr(repo, '_rebasestate')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1092 delattr(repo, '_rebasetarget')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1093
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1094 @eh.extsetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1095 def _rebasewrapping(ui):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1096 # warning about more obsolete
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1097 try:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1098 rebase = extensions.find('rebase')
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1099 if rebase:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1100 entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1101 extensions.wrapfunction(rebase, 'buildstate', buildstate)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1102 extensions.wrapfunction(rebase, 'defineparents', defineparents)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1103 extensions.wrapfunction(rebase, 'concludenode', concludenode)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1104 extensions.wrapcommand(rebase.cmdtable, "rebase", cmdrebase)
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1105 except KeyError:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1106 pass # rebase not found
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1107
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1108
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1109 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1110 ### Old Evolve extension content ###
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1111 #####################################################################
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1112
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1113 # 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
1114
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1115 ### util function
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1116 #############################
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1117
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1118 def noderange(repo, revsets):
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1119 """The same as revrange but return node"""
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1120 return map(repo.changelog.node,
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1121 scmutil.revrange(repo, revsets))
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1122
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1123 ### changeset rewriting logic
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1124 #############################
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1125
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1126 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
1127 """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
1128 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
1129 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
1130 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
1131 """
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1132 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
1133 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
1134 base = old.p1()
313
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1135 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
1136
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1137 wlock = repo.wlock()
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1138 try:
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1139
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1140 # 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
1141 # 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
1142 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
1143 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
1144 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
1145
cfdab01ca8a0 evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 211
diff changeset
1146 # 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
1147 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
1148
cfdab01ca8a0 evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 211
diff changeset
1149
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1150 # 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
1151 def samefile(f):
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1152 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
1153 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
1154 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
1155 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
1156 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
1157 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
1158 else:
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1159 return False
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1160 else:
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1161 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
1162 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
1163 # 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
1164 headmf = head.manifest()
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1165 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
1166 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
1167 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
1168 flags = fctx.flags()
cfdab01ca8a0 evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 211
diff changeset
1169 mctx = context.memfilectx(fctx.path(), fctx.data(),
cfdab01ca8a0 evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 211
diff changeset
1170 islink='l' in flags,
cfdab01ca8a0 evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 211
diff changeset
1171 isexec='x' in flags,
cfdab01ca8a0 evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 211
diff changeset
1172 copied=copied.get(path))
cfdab01ca8a0 evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 211
diff changeset
1173 return mctx
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1174 raise IOError()
104
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
1175 if commitopts.get('message') and commitopts.get('logfile'):
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
1176 raise util.Abort(_('options --message and --logfile are mutually'
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
1177 ' exclusive'))
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
1178 if commitopts.get('logfile'):
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
1179 message= open(commitopts['logfile']).read()
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
1180 elif commitopts.get('message'):
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
1181 message = commitopts['message']
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
1182 else:
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
1183 message = old.description()
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
1184
142
c2f7a8530e51 overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 141
diff changeset
1185 user = commitopts.get('user') or old.user()
c2f7a8530e51 overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 141
diff changeset
1186 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
1187 extra = dict(commitopts.get('extra', {}))
de62daaf2054 amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents: 260
diff changeset
1188 extra['branch'] = head.branch()
118
06fe05256a79 edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 117
diff changeset
1189
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1190 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
1191 parents=newbases,
104
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
1192 text=message,
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1193 files=files,
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1194 filectxfn=filectxfn,
142
c2f7a8530e51 overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 141
diff changeset
1195 user=user,
c2f7a8530e51 overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 141
diff changeset
1196 date=date,
263
de62daaf2054 amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents: 260
diff changeset
1197 extra=extra)
118
06fe05256a79 edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 117
diff changeset
1198
06fe05256a79 edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 117
diff changeset
1199 if commitopts.get('edit'):
06fe05256a79 edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 117
diff changeset
1200 new._text = cmdutil.commitforceeditor(repo, new, [])
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
1201 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
1202 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
1203 new = repo[newid]
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
1204 created = len(repo) != revcount
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
1205 if created:
313
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1206 updatebookmarks(newid)
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
1207 # add evolution metadata
443
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 420
diff changeset
1208 markers = [(u, (new,)) for u in updates]
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 420
diff changeset
1209 markers.append((old, (new,)))
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1210 createmarkers(repo, markers)
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
1211 else:
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
1212 # newid is an existing revision. It could make sense to
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
1213 # replace revisions with existing ones but probably not by
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
1214 # default.
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
1215 pass
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1216 finally:
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1217 wlock.release()
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1218
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
1219 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
1220
463
3f91654713dd obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 455
diff changeset
1221 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
1222 pass
3f91654713dd obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 455
diff changeset
1223
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1224 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
1225 """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
1226 try:
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
1227 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
1228 # dummy state to trick rebase node
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1229 assert orig.p2().rev() == node.nullrev, 'no support yet'
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1230 destbookmarks = repo.nodebookmarks(dest.node())
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1231 cmdutil.duplicatecopies(repo, orig.node(), 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
1232 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
1233 destphase = repo[nodesrc].phase()
255
9852b3ef7234 evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 232
diff changeset
1234 if rebase.rebasenode.func_code.co_argcount == 5:
9852b3ef7234 evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 232
diff changeset
1235 # rebasenode collapse argument was introduced by
9852b3ef7234 evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 232
diff changeset
1236 # d1afbf03e69a (2.3)
9852b3ef7234 evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 232
diff changeset
1237 rebase.rebasenode(repo, orig.node(), dest.node(),
9852b3ef7234 evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 232
diff changeset
1238 {node.nullrev: node.nullrev}, False)
9852b3ef7234 evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 232
diff changeset
1239 else:
9852b3ef7234 evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 232
diff changeset
1240 rebase.rebasenode(repo, orig.node(), dest.node(),
9852b3ef7234 evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 232
diff changeset
1241 {node.nullrev: node.nullrev})
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
1242 try:
52c53e2d413b stabilize: clear error message than conflict during rebase offer no hope
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 319
diff changeset
1243 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
1244 node.nullid)
463
3f91654713dd obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 455
diff changeset
1245 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
1246 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
1247 pass
3f91654713dd obsolete Move merge failure handling into stabilize code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 455
diff changeset
1248 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
1249 raise
88
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
1250 oldbookmarks = repo.nodebookmarks(nodesrc)
284
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
1251 if nodenew is not None:
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
1252 phases.retractboundary(repo, destphase, [nodenew])
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1253 createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))])
284
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
1254 for book in oldbookmarks:
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
1255 repo._bookmarks[book] = nodenew
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
1256 else:
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1257 createmarkers(repo, [(repo[nodesrc], ())])
284
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
1258 # Behave like rebase, move bookmarks to dest
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
1259 for book in oldbookmarks:
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
1260 repo._bookmarks[book] = dest.node()
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1261 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
1262 repo._bookmarks[book] = dest.node()
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1263 if oldbookmarks or destbookmarks:
88
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
1264 bookmarks.write(repo)
469
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1265 return nodenew
88
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
1266 except util.Abort:
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
1267 # 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
1268 repo.dirstate.invalidate()
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
1269 raise
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
1270
313
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1271 def _bookmarksupdater(repo, oldid):
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1272 """Return a callable update(newid) updating the current bookmark
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1273 and bookmarks bound to oldid to newid.
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1274 """
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1275 bm = bookmarks.readcurrent(repo)
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1276 def updatebookmarks(newid):
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1277 dirty = False
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1278 if bm:
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1279 repo._bookmarks[bm] = newid
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1280 dirty = True
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1281 oldbookmarks = repo.nodebookmarks(oldid)
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1282 if oldbookmarks:
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1283 for b in oldbookmarks:
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1284 repo._bookmarks[b] = newid
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1285 dirty = True
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1286 if dirty:
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1287 bookmarks.write(repo)
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1288 return updatebookmarks
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1289
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1290 ### new command
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1291 #############################
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1292 cmdtable = {}
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1293 command = cmdutil.command(cmdtable)
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1294
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1295 @command('^evolve|stabilize|evolve|solve',
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1296 [('n', 'dry-run', False, 'do not perform actions, print what to be done'),
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1297 ('A', 'any', False, 'evolve any troubled changeset'),
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1298 ('c', 'continue', False, 'continue an interrupted evolution'), ],
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1299 _('[OPTIONS]...'))
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1300 def evolve(ui, repo, **opts):
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1301 """Solve trouble in your repository
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1302
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1303 - rebase unstable changeset to make it stable again,
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1304 - create proper diff from latecomer changeset,
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1305 - merge conflicting changeset.
145
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
1306
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1307 By default, take the first troubles changeset that looks relevant.
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1308
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1309 (The logic is still a bit fuzzy)
269
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
1310
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1311 - For unstable, that mean the first which could be rebased as child of the
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1312 working directory parent revision or one of its descendants and rebase
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1313 it.
269
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
1314
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1315 - For conflicting this mean "." if applicable.
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1316
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1317 With --any, evolve pick any troubled changeset to solve
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1318
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1319 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
1320 """
145
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
1321
465
4a039a8c1cf3 stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 464
diff changeset
1322 contopt = opts['continue']
4a039a8c1cf3 stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 464
diff changeset
1323 anyopt = opts['any']
145
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
1324
465
4a039a8c1cf3 stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 464
diff changeset
1325 if contopt:
4a039a8c1cf3 stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 464
diff changeset
1326 if anyopt:
4a039a8c1cf3 stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 464
diff changeset
1327 raise util.Abort('can not specify both "--any" and "--continue"')
4a039a8c1cf3 stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 464
diff changeset
1328 graftcmd = commands.table['graft'][0]
4a039a8c1cf3 stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 464
diff changeset
1329 return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
4a039a8c1cf3 stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 464
diff changeset
1330
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
1331 tr = _picknexttroubled(ui, repo, anyopt)
6b1b6d338478 stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 466
diff changeset
1332 if tr is None:
511
ddeb71df916d evolve: localrepo.revs() already returns a list
Patrick Mezard <patrick@mezard.eu>
parents: 510
diff changeset
1333 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
1334 if troubled:
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1335 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
1336 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
1337 % len(troubled))
145
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
1338 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
1339 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
1340 ui.write_err(_('no troubled changeset\n'))
145
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
1341 return 1
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1342 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
1343 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
1344 if 'unstable' in troubles:
469
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1345 return _solveunstable(ui, repo, tr, opts['dry_run'])
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
1346 elif 'latecomer' in troubles:
469
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1347 return _solvelatecomer(ui, repo, tr, opts['dry_run'])
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
1348 elif 'conflicting' in troubles:
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1349 return _solveconflicting(ui, repo, tr, opts['dry_run'])
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
1350 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
1351 assert False # WHAT? unknown troubles
269
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
1352
512
8b25e9cf76fd evolve: avoid 'any' argument name in _picknexttroubled()
Patrick Mezard <patrick@mezard.eu>
parents: 511
diff changeset
1353 def _picknexttroubled(ui, repo, pickany=False):
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
1354 """Pick a the next trouble changeset to solve"""
6b1b6d338478 stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 466
diff changeset
1355 tr = _stabilizableunstable(repo, repo['.'])
484
20e2f2dd71f1 stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 482
diff changeset
1356 if tr is None:
20e2f2dd71f1 stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 482
diff changeset
1357 wdp = repo['.']
20e2f2dd71f1 stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 482
diff changeset
1358 if 'conflicting' in wdp.troubles():
20e2f2dd71f1 stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 482
diff changeset
1359 tr = wdp
512
8b25e9cf76fd evolve: avoid 'any' argument name in _picknexttroubled()
Patrick Mezard <patrick@mezard.eu>
parents: 511
diff changeset
1360 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
1361 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
1362 if not 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
1363 troubled = list(repo.set('latecomer()'))
6b1b6d338478 stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 466
diff changeset
1364 if not 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
1365 troubled = list(repo.set('conflicting()'))
6b1b6d338478 stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 466
diff changeset
1366 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
1367 tr = troubled[0]
484
20e2f2dd71f1 stabilize: conflicting changeset are considered if "."
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 482
diff changeset
1368
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
1369 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
1370
509
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1371 def _stabilizableunstable(repo, pctx):
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1372 """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
1373 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
1374 can be found.
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1375 """
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1376 def selfanddescendants(repo, pctx):
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1377 yield pctx
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1378 for ctx in pctx.descendants():
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1379 yield ctx
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1380
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1381 # 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
1382 # 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
1383 for ctx in selfanddescendants(repo, pctx):
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1384 unstables = list(repo.set('unstable() and children(allprecursors(%d))',
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1385 ctx.rev()))
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1386 if unstables:
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1387 return unstables[0]
c072e559746d evolve: move _stabilizableunstable() with related functions
Patrick Mezard <patrick@mezard.eu>
parents: 507
diff changeset
1388 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
1389
469
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1390 def _solveunstable(ui, repo, orig, dryrun=False):
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
1391 """Stabilize a unstable changeset"""
464
d88c761f97c4 stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 463
diff changeset
1392 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
1393 if not obs.obsolete():
464
d88c761f97c4 stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 463
diff changeset
1394 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
1395 assert obs.obsolete()
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1396 newer = newerversion(repo, obs.node())
466
b98490b689a5 stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 465
diff changeset
1397 # search of a parent which is not killed
b98490b689a5 stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 465
diff changeset
1398 while newer == [()]:
b98490b689a5 stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 465
diff changeset
1399 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
1400 " 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
1401 obs = obs.parents()[0]
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1402 newer = newerversion(repo, obs.node())
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1403 if len(newer) > 1:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1404 ui.write_err(_("conflict rewriting. can't choose destination\n"))
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1405 return 2
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1406 targets = newer[0]
466
b98490b689a5 stabilize: handle killed changeset in stabilize.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 465
diff changeset
1407 assert targets
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1408 if len(targets) > 1:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1409 ui.write_err(_("does not handle splitted parent yet\n"))
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1410 return 2
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1411 target = targets[0]
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1412 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
1413 target = repo[target]
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1414 repo.ui.status(_('move:'))
146
e80a6c8ad452 stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 145
diff changeset
1415 if not ui.quiet:
464
d88c761f97c4 stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 463
diff changeset
1416 displayer.show(orig)
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1417 repo.ui.status(_('atop:'))
146
e80a6c8ad452 stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 145
diff changeset
1418 if not ui.quiet:
e80a6c8ad452 stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 145
diff changeset
1419 displayer.show(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
1420 todo = 'hg rebase -Dr %s -d %s\n' % (orig, target)
6b1b6d338478 stabilize: rework stabilize code to allow selection of latecomer and conflicting
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 466
diff changeset
1421 if dryrun:
146
e80a6c8ad452 stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 145
diff changeset
1422 repo.ui.write(todo)
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1423 else:
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1424 repo.ui.note(todo)
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1425 lock = repo.lock()
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1426 try:
464
d88c761f97c4 stabilize: rename "node" variable to "orig"
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 463
diff changeset
1427 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
1428 except MergeFailure:
465
4a039a8c1cf3 stabilize: --continue support !!!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 464
diff changeset
1429 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
1430 repo.ui.write_err(_('evolve failed!\n'))
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1431 repo.ui.write_err(_('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
1432 raise
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1433 finally:
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
1434 lock.release()
88
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
1435
469
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1436 def _solvelatecomer(ui, repo, latecomer, dryrun=False):
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1437 """Stabilize a latecomer changeset"""
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1438 # For now we deny latecomer merge
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1439 if len(latecomer.parents()) > 1:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1440 raise util.Abort('late comer stabilization is confused by latecomer'
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1441 ' %s being a merge' % latecomer)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1442 prec = repo.set('last(allprecursors(%d) and public())', latecomer).next()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1443 # For now we deny target merge
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1444 if len(prec.parents()) > 1:
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1445 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
1446 ' %s being a merge' % prec)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1447
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1448 displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1449 repo.ui.status(_('recreate:'))
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1450 if not ui.quiet:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1451 displayer.show(latecomer)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1452 repo.ui.status(_('atop:'))
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1453 if not ui.quiet:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1454 displayer.show(prec)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1455 if dryrun:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1456 todo = 'hg rebase --rev %s --detach %s;\n' % (latecomer, prec.p1())
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1457 repo.ui.write(todo)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1458 repo.ui.write('hg update %s;\n' % prec)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1459 repo.ui.write('hg revert --all --rev %s;\n' % latecomer)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1460 repo.ui.write('hg commit --msg "latecomer update to %s"')
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1461 return 0
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1462 wlock = repo.wlock()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1463 try:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1464 newid = tmpctx = None
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1465 tmpctx = latecomer
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1466 lock = repo.lock()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1467 try:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1468 bmupdate = _bookmarksupdater(repo, latecomer.node())
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1469 # Basic check for common parent. Far too complicated and fragile
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1470 tr = repo.transaction('latecomer-stabilize')
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1471 try:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1472 if not list(repo.set('parents(%d) and parents(%d)', latecomer, prec)):
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1473 # Need to rebase the changeset at the right place
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1474 repo.ui.status(_('rebasing to destination parent: %s\n') % prec.p1())
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1475 try:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1476 tmpid = relocate(repo, latecomer, prec.p1())
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1477 if tmpid is not None:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1478 tmpctx = repo[tmpid]
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1479 createmarkers(repo, [(latecomer, (tmpctx,))])
469
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1480 except MergeFailure:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1481 repo.opener.write('graftstate', latecomer.hex() + '\n')
492
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1482 repo.ui.write_err(_('evolution failed!\n'))
7ecd41520dae rename `stabilize` to `evolve`
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 491
diff changeset
1483 repo.ui.write_err(_('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
1484 raise
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1485 # Create the new commit context
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1486 repo.ui.status(_('computing new diff\n'))
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1487 files = set()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1488 copied = copies.pathcopies(prec, latecomer)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1489 precmanifest = prec.manifest()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1490 for key, val in latecomer.manifest().iteritems():
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1491 if precmanifest.pop(key, None) != val:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1492 files.add(key)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1493 files.update(precmanifest) # add missing files
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1494 # commit it
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1495 if files: # something to commit!
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1496 def filectxfn(repo, ctx, path):
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1497 if path in latecomer:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1498 fctx = latecomer[path]
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1499 flags = fctx.flags()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1500 mctx = context.memfilectx(fctx.path(), fctx.data(),
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1501 islink='l' in flags,
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1502 isexec='x' in flags,
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1503 copied=copied.get(path))
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1504 return mctx
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1505 raise IOError()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1506 text = 'latecomer update to %s:\n\n' % prec
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1507 text += latecomer.description()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1508
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1509 new = context.memctx(repo,
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1510 parents=[prec.node(), node.nullid],
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1511 text=text,
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1512 files=files,
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1513 filectxfn=filectxfn,
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1514 user=latecomer.user(),
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1515 date=latecomer.date(),
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1516 extra=latecomer.extra())
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1517
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1518 newid = repo.commitctx(new)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1519 if newid is None:
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1520 createmarkers(repo, [(tmpctx, ())])
469
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1521 newid = prec.node()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1522 else:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1523 phases.retractboundary(repo, latecomer.phase(), [newid])
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1524 createmarkers(repo, [(tmpctx, (repo[newid],))],
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1525 flag=latediff)
469
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1526 bmupdate(newid)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1527 tr.close()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1528 repo.ui.status(_('commited as %s\n') % node.short(newid))
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1529 finally:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1530 tr.release()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1531 finally:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1532 lock.release()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1533 # 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
1534 repo.dirstate.setparents(newid, node.nullid)
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1535 finally:
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1536 wlock.release()
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1537
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1538 def _solveconflicting(ui, repo, conflicting, dryrun=False):
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1539 base, others = conflictingdata(conflicting)
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1540 if len(others) > 1:
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1541 raise util.Abort("We do not handle split yet")
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1542 other = others[0]
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1543 if conflicting.phase() <= phases.public:
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1544 raise util.Abort("We can't resolve this conflict from the public side")
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1545 if len(other.parents()) > 1:
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1546 raise util.Abort("conflicting changeset can't be a merge (yet)")
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1547 if other.p1() not in conflicting.parents():
517
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
1548 raise util.Abort("parents are not common (not handled yet)")
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1549
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1550 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
1551 ui.status(_('merge:'))
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1552 if not ui.quiet:
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1553 displayer.show(conflicting)
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1554 ui.status(_('with: '))
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1555 if not ui.quiet:
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1556 displayer.show(other)
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1557 ui.status(_('base: '))
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1558 if not ui.quiet:
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1559 displayer.show(base)
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1560 if dryrun:
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1561 ui.write('hg update -c %s &&\n' % conflicting)
533
87c41ef95ebf test conflicting conflicting (sic) resolution
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 523
diff changeset
1562 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
1563 ui.write('hg commit -m "auto merge resolving conflict between '
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
1564 '%s and %s"&&\n' % (conflicting, other))
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1565 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
1566 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
1567 ui.write('hg commit -m "`hg log -r %s --template={desc}`";\n'
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
1568 % conflicting)
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1569 return
516
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1570 wlock = lock = None
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1571 try:
516
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1572 wlock = repo.wlock()
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1573 lock = repo.lock()
516
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1574 if conflicting not in repo[None].parents():
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1575 repo.ui.status(_('updating to "local" conflict\n'))
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1576 hg.update(repo, conflicting.rev())
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1577 repo.ui.note(_('merging conflicting changeset\n'))
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1578 stats = merge.update(repo,
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1579 other.node(),
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1580 branchmerge=True,
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1581 force=False,
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1582 partial=None,
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1583 ancestor=base.node(),
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1584 mergeancestor=True)
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1585 hg._showstats(repo, stats)
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1586 if stats[3]:
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1587 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
1588 "or 'hg update -C .' to abandon\n"))
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1589 if stats[3] > 0:
534
45ccaba212f9 a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 533
diff changeset
1590 raise util.Abort('Merge conflict between several amendments, and this is not yet automated',
45ccaba212f9 a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 533
diff changeset
1591 hint="""/!\ You can try:
45ccaba212f9 a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 533
diff changeset
1592 /!\ * manual merge + resolve => new cset X
45ccaba212f9 a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 533
diff changeset
1593 /!\ * 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
1594 /!\ * hg revert --all -r X
45ccaba212f9 a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 533
diff changeset
1595 /!\ * 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
1596 /!\ * hg kill -n Y W Z
45ccaba212f9 a better msg for this tricky situation
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 533
diff changeset
1597 """)
516
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1598 tr = repo.transaction('stabilize-conflicting')
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1599 try:
516
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1600 repo.dirstate.setparents(conflicting.node(), node.nullid)
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1601 oldlen = len(repo)
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1602 amend(ui, repo)
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1603 if oldlen == len(repo):
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1604 new = conflicting
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1605 # no changes
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1606 else:
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1607 new = repo['.']
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1608 createmarkers(repo, [(other, (new,))])
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1609 phases.retractboundary(repo, other.phase(), [new.node()])
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1610 tr.close()
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1611 finally:
516
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1612 tr.release()
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1613 finally:
516
18854dbc92e7 evolve: simplify locking in _solveconflicting()
Patrick Mezard <patrick@mezard.eu>
parents: 515
diff changeset
1614 lockmod.release(lock, wlock)
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1615
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1616
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1617 def conflictingdata(ctx):
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1618 """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
1619
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1620 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
1621
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1622 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
1623 """
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1624 for base in ctx._repo.set('reverse(precursors(%d))', ctx):
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1625 newer = newerversion(ctx._repo, base.node())
485
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1626 # 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
1627 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
1628 if newer:
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1629 return base, tuple(ctx._repo[o] for o in newer[0])
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1630 raise KeyError('Base seem unknown. This case is not handled yet.')
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1631
41bf6c27a122 evolve: stabilize now handle conflicting changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 484
diff changeset
1632
469
abeb17a9e313 stabilize: handle latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 468
diff changeset
1633
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
1634 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
1635
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 @command('^gdown',
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1637 [],
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1638 '')
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
1639 def cmdgdown(ui, repo):
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1640 """update to parent an 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
1641 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
1642 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
1643 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
1644 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
1645
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
1646 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
1647 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
1648 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
1649 p = parents[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
1650 hg.update(repo, p.rev())
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 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
1652 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
1653 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
1654 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
1655 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
1656 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
1657 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
1658
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
1659 @command('^gup',
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1660 [],
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1661 '')
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
1662 def cmdup(ui, repo):
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1663 """update to child an 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
1664 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
1665 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
1666 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
1667 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
1668
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
1669 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
1670 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
1671 if not 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
1672 ui.warn(_('No non-obsolete children\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
1673 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
1674 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
1675 c = children[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
1676 hg.update(repo, c.rev())
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
1677 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
1678 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
1679 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
1680 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
1681 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
1682 ui.warn(_('Multiple non-obsolete children, 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
1683 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
1684
365
9f6a77ec66cb evolve: switch the official name for "kill" to prune
Pierre-Yves.David@ens-lyon.org
parents: 362
diff changeset
1685 @command('^prune|obsolete|kill',
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1686 [('n', 'new', [], _("successor changeset"))],
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1687 _('[OPTION] REV...'))
130
b70fadbccc2a evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 127
diff changeset
1688 def kill(ui, repo, *revs, **opts):
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1689 """mark a changeset as obsolete
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1690
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1691 This update the parent directory to a not-killed parent if the current
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1692 working directory parent are killed.
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1693
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1694 XXX bookmark support
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1695 XXX handle merge
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1696 XXX check immutable first
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1697 """
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1698 wlock = repo.wlock()
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1699 try:
444
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1700 lock = repo.lock()
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1701 try:
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1702 new = set(noderange(repo, opts['new']))
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1703 targetnodes = set(noderange(repo, revs))
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1704 if new:
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1705 sucs = tuple(repo[n] for n in new)
130
b70fadbccc2a evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 127
diff changeset
1706 else:
444
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1707 sucs = ()
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1708 markers = []
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1709 for n in targetnodes:
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1710 markers.append((repo[n], sucs))
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1711 createmarkers(repo, markers)
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1712
444
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1713 # update to an unkilled parent
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1714 wdp = repo['.']
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1715 newnode = wdp
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1716 while newnode.obsolete():
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1717 newnode = newnode.parents()[0]
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1718 if newnode.node() != wdp.node():
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1719 commands.update(ui, repo, newnode.rev())
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1720 ui.status(_('working directory now at %s\n') % newnode)
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1721 finally:
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1722 lock.release()
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1723 finally:
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1724 wlock.release()
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
1725
151
e73944b6be8f evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 147
diff changeset
1726 @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
1727 [('A', 'addremove', None,
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1728 _('mark new/missing files as added/removed before committing')),
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1729 ('n', 'note', '', _('use text as commit message for this update')),
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1730 ('c', 'change', '', _('specifies the changesets to amend'), _('REV')),
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1731 ('e', 'edit', False, _('invoke editor on commit messages')),
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1732 ] + walkopts + commitopts + commitopts2,
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1733 _('[OPTION]... [FILE]...'))
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1734 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
1735 """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
1736
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1737 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
1738 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
1739
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1740 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
1741
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1742 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
1743
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1744 If you specify --change, amend additionally considers all
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1745 changesets between the indicated changeset and the working copy
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
1746 parent as updates to be subsumed.
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1747
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1748 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
1749 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
1750 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
1751 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
1752 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
1753
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1754 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
1755 """
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1756
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1757 # determine updates to subsume
295
a5894bb97909 evolve: remove --change . == --change .^ crazyness
Patrick Mezard <patrick@mezard.eu>
parents: 294
diff changeset
1758 old = scmutil.revsingle(repo, opts.get('change') or '.')
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1759
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
1760 lock = repo.lock()
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1761 try:
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
1762 wlock = repo.wlock()
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
1763 try:
475
9f69a5e41ab0 [evolve] amend: check phase before starting the transition
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 418
diff changeset
1764 if old.phase() == phases.public:
9f69a5e41ab0 [evolve] amend: check phase before starting the transition
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 418
diff changeset
1765 raise util.Abort(_("can not rewrite immutable changeset %s")
9f69a5e41ab0 [evolve] amend: check phase before starting the transition
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 418
diff changeset
1766 % old)
476
f17a0f801e0b [evolve] amend: display proper error message while trying to amend non ancestor
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 475
diff changeset
1767 if not repo.revs('%d and (::.)', old):
f17a0f801e0b [evolve] amend: display proper error message while trying to amend non ancestor
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 475
diff changeset
1768 raise error.Abort(_('cannot amend non ancestor changeset'))
410
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1769 tr = repo.transaction('amend')
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1770 try:
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1771 oldphase = old.phase()
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1772 # commit current changes as update
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1773 # code copied from commands.commit to avoid noisy messages
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1774 ciopts = dict(opts)
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1775 ciopts.pop('message', None)
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1776 ciopts.pop('logfile', None)
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1777 ciopts['message'] = opts.get('note') or ('amends %s' % old.hex())
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1778 e = cmdutil.commiteditor
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1779 def commitfunc(ui, repo, message, match, opts):
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1780 return repo.commit(message, opts.get('user'), opts.get('date'),
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1781 match, editor=e)
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1782 revcount = len(repo)
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1783 tempid = cmdutil.commit(ui, repo, commitfunc, pats, ciopts)
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1784 if len(repo) == revcount:
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1785 # No revision created
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1786 tempid = None
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1787
410
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1788 # find all changesets to be considered updates
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1789 head = repo['.']
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1790 updatenodes = set(repo.changelog.nodesbetween(
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1791 roots=[old.node()], heads=[head.node()])[0])
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1792 updatenodes.remove(old.node())
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1793 okoptions = ['message', 'logfile', 'edit', 'user']
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1794 if not updatenodes:
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1795 for o in okoptions:
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1796 if opts.get(o):
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1797 break
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1798 else:
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1799 raise error.Abort(_('no updates found'))
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1800 updates = [repo[n] for n in updatenodes]
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1801
410
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1802 # perform amend
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1803 if opts.get('edit'):
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1804 opts['force_editor'] = True
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1805 newid, created = rewrite(repo, old, updates, head,
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1806 [old.p1().node(), old.p2().node()], opts)
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1807 if created:
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1808 # reroute the working copy parent to the new changeset
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1809 phases.retractboundary(repo, oldphase, [newid])
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1810 repo.dirstate.setparents(newid, node.nullid)
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1811 else:
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1812 # rewrite() recreated an existing revision, discard
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1813 # the intermediate revision if any. No need to update
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1814 # phases or parents.
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1815 if tempid is not None:
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1816 createmarkers(repo, [(repo[tempid], ())])
410
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1817 # XXX: need another message in collapse case.
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1818 tr.close()
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1819 raise error.Abort(_('no updates found'))
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1820 tr.close()
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1821 finally:
598ff1df3b92 amend: wrap the whole process in a single transaction.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 365
diff changeset
1822 tr.release()
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
1823 finally:
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
1824 wlock.release()
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
1825 finally:
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
1826 lock.release()
116
64ca29eef349 Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 113
diff changeset
1827
312
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1828 def _commitfiltered(repo, ctx, match):
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1829 """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
1830 node identifier, or None if nothing changed.
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1831 """
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1832 base = ctx.p1()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1833 m, a, r = repo.status(base, ctx)[:3]
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1834 allfiles = set(m + a + r)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1835 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
1836 if files == allfiles:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1837 return None
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1838
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1839 # Filter copies
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1840 copied = copies.pathcopies(base, ctx)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1841 copied = dict((src, dst) for src, dst in copied.iteritems()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1842 if dst in files)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1843 def filectxfn(repo, memctx, path):
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1844 if path not in ctx:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1845 raise IOError()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1846 fctx = ctx[path]
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1847 flags = fctx.flags()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1848 mctx = context.memfilectx(fctx.path(), fctx.data(),
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1849 islink='l' in flags,
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1850 isexec='x' in flags,
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1851 copied=copied.get(path))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1852 return mctx
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1853
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1854 new = context.memctx(repo,
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1855 parents=[base.node(), node.nullid],
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1856 text=ctx.description(),
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1857 files=files,
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1858 filectxfn=filectxfn,
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1859 user=ctx.user(),
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1860 date=ctx.date(),
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1861 extra=ctx.extra())
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1862 # commitctx always create a new revision, no need to check
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1863 newid = repo.commitctx(new)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1864 return newid
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1865
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1866 def _uncommitdirstate(repo, oldctx, match):
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1867 """Fix the dirstate after switching the working directory from
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1868 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
1869 match.
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1870 """
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1871 ctx = repo['.']
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1872 ds = repo.dirstate
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1873 copies = dict(ds.copies())
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1874 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
1875 for f in m:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1876 if ds[f] == 'r':
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1877 # modified + removed -> removed
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1878 continue
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1879 ds.normallookup(f)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1880
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1881 for f in a:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1882 if ds[f] == 'r':
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1883 # added + removed -> unknown
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1884 ds.drop(f)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1885 elif ds[f] != 'a':
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1886 ds.add(f)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1887
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1888 for f in r:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1889 if ds[f] == 'a':
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1890 # removed + added -> normal
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1891 ds.normallookup(f)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1892 elif ds[f] != 'r':
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1893 ds.remove(f)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1894
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1895 # Merge old parent and old working dir copies
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1896 oldcopies = {}
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1897 for f in (m + a):
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1898 src = oldctx[f].renamed()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1899 if src:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1900 oldcopies[f] = src[0]
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1901 oldcopies.update(copies)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1902 copies = dict((dst, oldcopies.get(src, src))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1903 for dst, src in oldcopies.iteritems())
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1904 # Adjust the dirstate copies
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1905 for dst, src in copies.iteritems():
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1906 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
1907 src = None
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1908 ds.copy(src, dst)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1909
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1910 @command('^uncommit',
314
ebd286f06879 uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents: 313
diff changeset
1911 [('a', 'all', None, _('uncommit all changes when no arguments given')),
ebd286f06879 uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents: 313
diff changeset
1912 ] + commands.walkopts,
312
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1913 _('[OPTION]... [NAME]'))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1914 def uncommit(ui, repo, *pats, **opts):
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1915 """move changes from parent revision to working directory
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1916
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1917 Changes to selected files in parent revision appear again as
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1918 uncommitted changed in the working directory. A new revision
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1919 without selected changes is created, becomes the new parent and
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1920 obsoletes the previous one.
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1921
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1922 The --include option specify pattern to uncommit
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1923 The --exclude option specify pattern to keep in the commit
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1924
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1925 Return 0 if changed files are uncommitted.
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1926 """
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1927 lock = repo.lock()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1928 try:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1929 wlock = repo.wlock()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1930 try:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1931 wctx = repo[None]
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1932 if len(wctx.parents()) <= 0:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1933 raise util.Abort(_("cannot uncommit null changeset"))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1934 if len(wctx.parents()) > 1:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1935 raise util.Abort(_("cannot uncommit while merging"))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1936 old = repo['.']
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1937 if old.phase() == phases.public:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1938 raise util.Abort(_("cannot rewrite immutable changeset"))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1939 if len(old.parents()) > 1:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1940 raise util.Abort(_("cannot uncommit merge changeset"))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1941 oldphase = old.phase()
313
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1942 updatebookmarks = _bookmarksupdater(repo, old.node())
312
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1943 # Recommit the filtered changeset
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1944 newid = None
314
ebd286f06879 uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents: 313
diff changeset
1945 if (pats or opts.get('include') or opts.get('exclude')
ebd286f06879 uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents: 313
diff changeset
1946 or opts.get('all')):
312
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1947 match = scmutil.match(old, pats, opts)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1948 newid = _commitfiltered(repo, old, match)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1949 if newid is None:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1950 raise util.Abort(_('nothing to uncommit'))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1951 # Move local changes on filtered changeset
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1952 createmarkers(repo, [(old, (repo[newid],))])
312
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1953 phases.retractboundary(repo, oldphase, [newid])
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1954 repo.dirstate.setparents(newid, node.nullid)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1955 _uncommitdirstate(repo, old, match)
313
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
1956 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
1957 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
1958 ui.warn(_("new changeset is empty\n"))
da7509e7b50c evolve: warn when uncommit leave an empty changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 315
diff changeset
1959 ui.status(_('(use "hg kill ." to remove it)\n'))
312
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1960 finally:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1961 wlock.release()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1962 finally:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1963 lock.release()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
1964
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1965 @eh.wrapcommand('commit')
116
64ca29eef349 Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 113
diff changeset
1966 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
1967 if kwargs.get('amend', False):
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1968 lock = None
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1969 else:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1970 lock = repo.lock()
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1971 try:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1972 obsoleted = kwargs.get('obsolete', [])
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1973 if obsoleted:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1974 obsoleted = repo.set('%lr', obsoleted)
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1975 result = orig(ui, repo, *arg, **kwargs)
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1976 if not result: # commit successed
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1977 new = repo['-1']
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1978 oldbookmarks = []
444
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1979 markers = []
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1980 for old in obsoleted:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1981 oldbookmarks.extend(repo.nodebookmarks(old.node()))
444
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1982 markers.append((old, (new,)))
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
1983 if markers:
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1984 createmarkers(repo, markers)
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1985 for book in oldbookmarks:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1986 repo._bookmarks[book] = new.node()
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1987 if oldbookmarks:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1988 bookmarks.write(repo)
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1989 return result
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
1990 finally:
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1991 if lock is not None:
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
1992 lock.release()
116
64ca29eef349 Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 113
diff changeset
1993
481
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
1994 @command('^touch',
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
1995 [('r', 'rev', [], 'revision to update'),],
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
1996 # allow to choose the seed ?
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
1997 _('[-r] revs'))
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
1998 def touch(ui, repo, *revs, **opts):
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
1999 """Create successors with exact same property but hash
517
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
2000
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
2001 This is used to "resurrect" changesets
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
2002 """
481
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2003 revs = list(revs)
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2004 revs.extend(opts['rev'])
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2005 if not revs:
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2006 revs = ['.']
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2007 revs = scmutil.revrange(repo, revs)
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2008 if not revs:
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2009 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
2010 return 1
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2011 if repo.revs('public() and %ld', revs):
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2012 raise util.Abort("can't touch public revision")
514
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2013 wlock = lock = None
481
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2014 try:
514
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2015 wlock = repo.wlock()
481
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2016 lock = repo.lock()
514
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2017 tr = repo.transaction('touch')
481
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2018 try:
514
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2019 for r in revs:
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2020 ctx = repo[r]
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2021 extra = ctx.extra().copy()
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2022 extra['__touch-noise__'] = random.randint(0, 0xffffffff)
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2023 new, _ = rewrite(repo, ctx, [], ctx,
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2024 [ctx.p1().node(), ctx.p2().node()],
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2025 commitopts={'extra': extra})
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2026 createmarkers(repo, [(ctx, (repo[new],))])
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2027 phases.retractboundary(repo, ctx.phase(), [new])
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2028 if ctx in repo[None].parents():
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2029 repo.dirstate.setparents(new, node.nullid)
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2030 tr.close()
481
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2031 finally:
514
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2032 tr.release()
481
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2033 finally:
514
ea667749ccd1 touch: simplify locking pattern
Patrick Mezard <patrick@mezard.eu>
parents: 513
diff changeset
2034 lockmod.release(lock, wlock)
481
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2035
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2036 @command('^fold',
517
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
2037 [('r', 'rev', [], 'revisions to fold'),],
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2038 # allow to choose the seed ?
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2039 _('[-r] revs'))
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2040 def fold(ui, repo, *revs, **opts):
517
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
2041 """Fold multiple revisions into a single one"""
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2042 revs = list(revs)
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2043 revs.extend(opts['rev'])
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2044 if not revs:
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2045 revs = ['.']
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2046 revs = scmutil.revrange(repo, revs)
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2047 if not revs:
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2048 ui.write_err('no revision to fold\n')
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2049 return 1
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2050 roots = repo.revs('roots(%ld)', revs)
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2051 if len(roots) > 1:
517
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
2052 raise util.Abort("set has multiple roots")
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2053 root = repo[roots[0]]
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2054 if root.phase() <= phases.public:
517
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
2055 raise util.Abort("can't fold public revisions")
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2056 heads = repo.revs('heads(%ld)', revs)
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2057 if len(heads) > 1:
517
0bc0c9edcb15 evolve: usual syntax/grammar errors/long lines cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 516
diff changeset
2058 raise util.Abort("set has multiple heads")
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2059 head = repo[heads[0]]
515
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2060 wlock = lock = None
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2061 try:
515
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2062 wlock = repo.wlock()
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2063 lock = repo.lock()
515
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2064 tr = repo.transaction('touch')
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2065 try:
515
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2066 allctx = [repo[r] for r in revs]
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2067 targetphase = max(c.phase() for c in allctx)
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2068 msg = '\n\n***\n\n'.join(c.description() for c in allctx)
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2069 newid, _ = rewrite(repo, root, allctx, head,
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2070 [root.p1().node(), root.p2().node()],
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2071 commitopts={'message': msg})
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2072 phases.retractboundary(repo, targetphase, [newid])
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2073 createmarkers(repo, [(ctx, (repo[newid],))
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2074 for ctx in allctx])
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2075 tr.close()
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2076 finally:
515
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2077 tr.release()
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2078 ui.status('%i changesets folded\n' % len(revs))
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2079 if repo.revs('. and %ld', revs):
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2080 repo.dirstate.setparents(newid, node.nullid)
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2081 finally:
515
0b60c28d9c43 fold: simplify locking
Patrick Mezard <patrick@mezard.eu>
parents: 514
diff changeset
2082 lockmod.release(lock, wlock)
482
d2531a747ff5 evolve: fold command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 481
diff changeset
2083
481
4e0f1aae8d24 evolve: touch command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 477
diff changeset
2084
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
2085 @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
2086 def graftwrapper(orig, ui, repo, *revs, **kwargs):
419
03672e955bc8 evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents: 410
diff changeset
2087 kwargs = dict(kwargs)
03672e955bc8 evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents: 410
diff changeset
2088 revs = list(revs) + kwargs.get('rev', [])
03672e955bc8 evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents: 410
diff changeset
2089 kwargs['rev'] = []
417
a1fb18ad29a1 evolve: avoid duplication in graft wrapper
Patrick Mezard <patrick@mezard.eu>
parents: 416
diff changeset
2090 obsoleted = kwargs.setdefault('obsolete', [])
419
03672e955bc8 evolve: make graft wrapper handle --rev
Patrick Mezard <patrick@mezard.eu>
parents: 410
diff changeset
2091
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
2092 lock = repo.lock()
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
2093 try:
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
2094 if kwargs.get('old_obsolete'):
418
18a0d96ed559 evolve: graft --continue is optional, test
Patrick Mezard <patrick@mezard.eu>
parents: 417
diff changeset
2095 if kwargs.get('continue'):
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
2096 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
2097 else:
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
2098 obsoleted.extend(revs)
151
e73944b6be8f evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 147
diff changeset
2099 # 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
2100 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
2101 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
2102
e73944b6be8f evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 147
diff changeset
2103 raise error.Abort(_('Can not graft multiple revision while '
e73944b6be8f evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 147
diff changeset
2104 'obsoleting (for now).'))
e73944b6be8f evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 147
diff changeset
2105
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
2106 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
2107 finally:
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
2108 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
2109
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
2110 @eh.extsetup
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
2111 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
2112 try:
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
2113 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
2114 except KeyError:
416
22f348c25d25 obsolete/evolve: fix grammar in prerequisite messages
Patrick Mezard <patrick@mezard.eu>
parents: 414
diff changeset
2115 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
2116
507
4b1797518abe evolve: add touch and fold to command that may create troubles
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 497
diff changeset
2117 for cmd in ['amend', '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
2118 entry = extensions.wrapcommand(cmdtable, cmd,
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
2119 warnobserrors)
356
56d4c6207ef9 Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 355
diff changeset
2120
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
2121 entry = cmdutil.findcmd('commit', commands.table)[1]
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
2122 entry[1].append(('o', 'obsolete', [],
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
2123 _("make commit obsolete this revision")))
491
6989d8fe4ed2 merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 490
diff changeset
2124 entry = cmdutil.findcmd('graft', commands.table)[1]
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
2125 entry[1].append(('o', 'obsolete', [],
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
2126 _("make graft obsoletes this revision")))
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
2127 entry[1].append(('O', 'old-obsolete', False,
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
2128 _("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
2129