hgext/evolve.py
author Patrick Mezard <patrick@mezard.eu>
Sat, 23 Jun 2012 19:24:37 +0200
changeset 314 ebd286f06879
parent 313 47d10459fa24
child 315 4bbc17716f5a
permissions -rw-r--r--
uncommit: add --all option Convenient when combined with --exclude.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     1
# states.py - introduce the state concept for mercurial changeset
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     2
#
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     3
# Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     4
#                Logilab SA        <contact@logilab.fr>
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     5
#                Pierre-Yves David <pierre-yves.david@ens-lyon.org>
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     6
#
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     7
# 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
     8
# 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
     9
228
5a17c0d41a00 proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 219
diff changeset
    10
'''a set of commands to handle changeset mutation'''
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    11
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    12
from mercurial import cmdutil
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    13
from mercurial import scmutil
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    14
from mercurial import node
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    15
from mercurial import error
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    16
from mercurial import extensions
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    17
from mercurial import commands
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    18
from mercurial import bookmarks
113
3bdabdbb4140 adapt evolution to phase in core.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 108
diff changeset
    19
from mercurial import phases
219
cfdab01ca8a0 evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 211
diff changeset
    20
from mercurial import commands
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    21
from mercurial import context
219
cfdab01ca8a0 evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 211
diff changeset
    22
from mercurial import copies
88
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
    23
from mercurial import util
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    24
from mercurial.i18n import _
178
3f18a6580d14 evolve: logopts was called logopt.
Arne Babenhauserheide <bab@draketo.de>
parents: 151
diff changeset
    25
from mercurial.commands import walkopts, commitopts, commitopts2, logopts
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
    26
from mercurial import hg
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    27
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    28
### util function
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    29
#############################
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
    30
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    31
def noderange(repo, revsets):
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    32
    """The same as revrange but return node"""
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    33
    return map(repo.changelog.node,
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    34
               scmutil.revrange(repo, revsets))
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    35
309
de21685d22d1 evolve: warn when latecomer changeset are created
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 303
diff changeset
    36
def warnobserrors(orig, ui, repo, *args, **kwargs):
211
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    37
    """display warning is the command resulted in more instable changeset"""
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    38
    priorunstables = len(repo.revs('unstable()'))
309
de21685d22d1 evolve: warn when latecomer changeset are created
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 303
diff changeset
    39
    priorlatecomers = len(repo.revs('latecomer()'))
211
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    40
    #print orig, priorunstables
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    41
    #print len(repo.revs('secret() - obsolete()'))
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    42
    try:
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    43
        return orig(ui, repo, *args, **kwargs)
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    44
    finally:
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    45
        newunstables = len(repo.revs('unstable()')) - priorunstables
309
de21685d22d1 evolve: warn when latecomer changeset are created
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 303
diff changeset
    46
        newlatecomers = len(repo.revs('latecomer()')) - priorlatecomers
211
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    47
        #print orig, newunstables
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    48
        #print len(repo.revs('secret() - obsolete()'))
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    49
        if newunstables > 0:
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    50
            ui.warn(_('%i new unstables changesets\n') % newunstables)
309
de21685d22d1 evolve: warn when latecomer changeset are created
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 303
diff changeset
    51
        if newlatecomers > 0:
de21685d22d1 evolve: warn when latecomer changeset are created
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 303
diff changeset
    52
            ui.warn(_('%i new latecomers changesets\n') % newlatecomers)
211
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
    53
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    54
### changeset rewriting logic
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    55
#############################
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    56
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    57
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
    58
    """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
    59
    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
    60
    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
    61
    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
    62
    """
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    63
    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
    64
        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
    65
    base = old.p1()
313
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
    66
    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
    67
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    68
    wlock = repo.wlock()
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    69
    try:
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    70
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    71
        # 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
    72
        # 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
    73
        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
    74
        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
    75
            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
    76
cfdab01ca8a0 evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 211
diff changeset
    77
        # 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
    78
        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
    79
cfdab01ca8a0 evolve-amend: properly handle amending file renames and additions.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 211
diff changeset
    80
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    81
        # 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
    82
        def samefile(f):
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    83
            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
    84
                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
    85
                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
    86
                    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
    87
                    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
    88
                            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
    89
                else:
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    90
                    return False
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    91
            else:
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    92
                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
    93
        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
    94
        # 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
    95
        headmf = head.manifest()
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
    96
        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
    97
            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
    98
                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
    99
                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
   100
                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
   101
                                          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
   102
                                          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
   103
                                          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
   104
                return mctx
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   105
            raise IOError()
104
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
   106
        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
   107
            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
   108
                               ' exclusive'))
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
   109
        if commitopts.get('logfile'):
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
   110
            message= open(commitopts['logfile']).read()
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
   111
        elif commitopts.get('message'):
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
   112
            message = commitopts['message']
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
   113
        else:
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
   114
            message = old.description()
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
   115
142
c2f7a8530e51 overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 141
diff changeset
   116
        user = commitopts.get('user') or old.user()
c2f7a8530e51 overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 141
diff changeset
   117
        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
   118
        extra = dict(commitopts.get('extra', {}))
de62daaf2054 amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents: 260
diff changeset
   119
        extra['branch'] = head.branch()
118
06fe05256a79 edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 117
diff changeset
   120
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   121
        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
   122
                             parents=newbases,
104
6c3c7a18f079 propertly handle -m and -l option
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 103
diff changeset
   123
                             text=message,
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   124
                             files=files,
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   125
                             filectxfn=filectxfn,
142
c2f7a8530e51 overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 141
diff changeset
   126
                             user=user,
c2f7a8530e51 overwrite user not date
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 141
diff changeset
   127
                             date=date,
263
de62daaf2054 amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents: 260
diff changeset
   128
                             extra=extra)
118
06fe05256a79 edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 117
diff changeset
   129
06fe05256a79 edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 117
diff changeset
   130
        if commitopts.get('edit'):
06fe05256a79 edit option \o/
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 117
diff changeset
   131
            new._text = cmdutil.commitforceeditor(repo, new, [])
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   132
        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
   133
        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
   134
        new = repo[newid]
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   135
        created = len(repo) != revcount
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   136
        if created:
313
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   137
            updatebookmarks(newid)
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   138
            # add evolution metadata
298
f597421662f7 obsolete: unify collapsed revisions markers handling
Patrick Mezard <patrick@mezard.eu>
parents: 295
diff changeset
   139
            collapsed = set([u.node() for u in updates] + [old.node()])
f597421662f7 obsolete: unify collapsed revisions markers handling
Patrick Mezard <patrick@mezard.eu>
parents: 295
diff changeset
   140
            repo.addcollapsedobsolete(collapsed, new.node())
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   141
        else:
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   142
            # 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
   143
            # 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
   144
            # default.
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   145
            pass
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   146
    finally:
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   147
        wlock.release()
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   148
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   149
    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
   150
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   151
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
   152
    """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
   153
    try:
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
   154
        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
   155
        # 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
   156
        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
   157
        destbookmarks = repo.nodebookmarks(dest.node())
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   158
        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
   159
        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
   160
        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
   161
        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
   162
            # 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
   163
            # 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
   164
            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
   165
                              {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
   166
        else:
9852b3ef7234 evolve: update rebase usage to match 2.3
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 232
diff changeset
   167
            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
   168
                              {node.nullrev: node.nullrev})
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   169
        nodenew = rebase.concludenode(repo, orig.node(), dest.node(),
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   170
                                      node.nullid)
88
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
   171
        oldbookmarks = repo.nodebookmarks(nodesrc)
284
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
   172
        if nodenew is not None:
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
   173
            phases.retractboundary(repo, destphase, [nodenew])
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
   174
            repo.addobsolete(nodenew, nodesrc)
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
   175
            for book in oldbookmarks:
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
   176
                repo._bookmarks[book] = nodenew
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
   177
        else:
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
   178
            repo.addobsolete(node.nullid, nodesrc)
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
   179
            # Behave like rebase, move bookmarks to dest
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
   180
            for book in oldbookmarks:
88a851a54f26 evolve: fix relocate() with removed revision
Patrick Mezard <patrick@mezard.eu>
parents: 272
diff changeset
   181
                repo._bookmarks[book] = dest.node()
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   182
        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
   183
            repo._bookmarks[book] = dest.node()
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   184
        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
   185
            bookmarks.write(repo)
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
   186
    except util.Abort:
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
   187
        # 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
   188
        repo.dirstate.invalidate()
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
   189
        raise
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
   190
269
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   191
def stabilizableunstable(repo, pctx):
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   192
    """Return a changectx for an unstable changeset which can be
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   193
    stabilized on top of pctx or one of its descendants. None if none
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   194
    can be found.
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   195
    """
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   196
    def selfanddescendants(repo, pctx):
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   197
        yield pctx
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   198
        for ctx in pctx.descendants():
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   199
            yield ctx
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   200
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   201
    # Look for an unstable which can be stabilized as a child of
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   202
    # node. The unstable must be a child of one of node predecessors.
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   203
    for ctx in selfanddescendants(repo, pctx):
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   204
        unstables = list(repo.set('unstable() and children(obsancestors(%d))',
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   205
                                  ctx.rev()))
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   206
        if unstables:
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   207
            return unstables[0]
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   208
    return None
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   209
313
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   210
def _bookmarksupdater(repo, oldid):
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   211
    """Return a callable update(newid) updating the current bookmark
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   212
    and bookmarks bound to oldid to newid.
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   213
    """
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   214
    bm = bookmarks.readcurrent(repo)
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   215
    def updatebookmarks(newid):
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   216
        dirty = False
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   217
        if bm:
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   218
            repo._bookmarks[bm] = newid
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   219
            dirty = True
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   220
        oldbookmarks = repo.nodebookmarks(oldid)
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   221
        if oldbookmarks:
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   222
            for b in oldbookmarks:
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   223
                repo._bookmarks[b] = newid
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   224
            dirty = True
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   225
        if dirty:
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   226
            bookmarks.write(repo)
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   227
    return updatebookmarks
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   228
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   229
### new command
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   230
#############################
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   231
cmdtable = {}
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   232
command = cmdutil.command(cmdtable)
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   233
272
78d01e341438 evolve: add alias for kill and stabilize
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 269
diff changeset
   234
@command('^stabilize|evolve',
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   235
    [('n', 'dry-run', False, 'do not perform actions, print what to be done'),
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   236
    ('A', 'any', False, 'stabilize any unstable changeset'),],
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   237
    _('[OPTIONS]...'))
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   238
def stabilize(ui, repo, **opts):
269
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   239
    """rebase an unstable changeset to make it stable again
145
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
   240
269
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   241
    By default, take the first unstable changeset which could be
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   242
    rebased as child of the working directory parent revision or one
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   243
    of its descendants and rebase it.
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   244
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   245
    With --any, stabilize any unstable changeset.
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   246
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   247
    The working directory is updated to the rebased revision.
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   248
    """
145
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
   249
87
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 82
diff changeset
   250
    obsolete = extensions.find('obsolete')
145
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
   251
269
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   252
    node = None
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   253
    if not opts['any']:
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   254
        node = stabilizableunstable(repo, repo['.'])
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   255
    if node is None:
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   256
        unstables = list(repo.set('unstable()'))
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   257
        if unstables and not opts['any']:
145
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
   258
            ui.write_err(_('nothing to stabilize here\n'))
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
   259
            ui.status(_('(%i unstable changesets, do you want --any ?)\n')
269
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   260
                      % len(unstables))
145
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
   261
            return 2
269
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   262
        elif not unstables:
145
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
   263
            ui.write_err(_('no unstable changeset\n'))
928f217c1701 stabilize: stabilize my topological branch only
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 142
diff changeset
   264
            return 1
269
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   265
        node = unstables[0]
6c6bb7a23bb5 stabilize: improve unstable selection heuristic
Patrick Mezard <patrick@mezard.eu>
parents: 268
diff changeset
   266
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   267
    obs = node.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
   268
    if not obs.obsolete():
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   269
        obs = node.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
   270
    assert obs.obsolete()
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 82
diff changeset
   271
    newer = obsolete.newerversion(repo, obs.node())
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   272
    if len(newer) > 1:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   273
        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
   274
        return 2
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   275
    targets = newer[0]
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   276
    if not targets:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   277
        ui.write_err(_("does not handle kill parent yet\n"))
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   278
        return 2
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   279
    if len(targets) > 1:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   280
        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
   281
        return 2
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   282
    target = targets[0]
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   283
    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
   284
    target = repo[target]
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   285
    repo.ui.status(_('move:'))
146
e80a6c8ad452 stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 145
diff changeset
   286
    if not ui.quiet:
e80a6c8ad452 stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 145
diff changeset
   287
        displayer.show(node)
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   288
    repo.ui.status(_('atop:'))
146
e80a6c8ad452 stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 145
diff changeset
   289
    if not ui.quiet:
e80a6c8ad452 stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 145
diff changeset
   290
        displayer.show(target)
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   291
    todo= 'hg rebase -Dr %s -d %s\n' % (node, target)
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   292
    if opts['dry_run']:
146
e80a6c8ad452 stabilize: proper --quiet behavior
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 145
diff changeset
   293
        repo.ui.write(todo)
139
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   294
    else:
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   295
        repo.ui.note(todo)
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   296
        lock = repo.lock()
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   297
        try:
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   298
            relocate(repo, node, target)
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   299
        finally:
9b9500175ae5 evolve that does something \o/
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 137
diff changeset
   300
            lock.release()
88
64fe5a4f877e [evolution] first workign draft of a relocate function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
   301
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
   302
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
   303
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
   304
@command('^gdown',
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   305
         [],
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   306
         '')
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
   307
def cmdgdown(ui, repo):
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   308
    """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
   309
    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
   310
    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
   311
    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
   312
        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
   313
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
   314
    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
   315
    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
   316
    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
   317
        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
   318
        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
   319
        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
   320
        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
   321
    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
   322
        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
   323
            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
   324
        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
   325
        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
   326
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
   327
@command('^gup',
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   328
         [],
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   329
         '')
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
   330
def cmdup(ui, repo):
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   331
    """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
   332
    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
   333
    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
   334
    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
   335
        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
   336
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
   337
    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
   338
    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
   339
    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
   340
        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
   341
        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
   342
    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
   343
        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
   344
        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
   345
        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
   346
        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
   347
    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
   348
        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
   349
            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
   350
        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
   351
        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
   352
272
78d01e341438 evolve: add alias for kill and stabilize
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 269
diff changeset
   353
@command('^kill|obsolete',
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   354
    [('n', 'new', [], _("successor changeset"))],
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   355
    _('[OPTION] REV...'))
130
b70fadbccc2a evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 127
diff changeset
   356
def kill(ui, repo, *revs, **opts):
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   357
    """mark a changeset as obsolete
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   358
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   359
    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
   360
    working directory parent are killed.
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   361
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   362
    XXX bookmark support
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   363
    XXX handle merge
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   364
    XXX check immutable first
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   365
    """
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   366
    wlock = repo.wlock()
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   367
    try:
147
b0b23d9eede5 kill: properly get revision pointed by --new
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 146
diff changeset
   368
        new = set(noderange(repo, opts['new']))
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   369
        targetnodes = set(noderange(repo, revs))
130
b70fadbccc2a evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 127
diff changeset
   370
        if not new:
b70fadbccc2a evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 127
diff changeset
   371
            new = [node.nullid]
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   372
        for n in targetnodes:
130
b70fadbccc2a evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 127
diff changeset
   373
            if not repo[n].mutable():
b70fadbccc2a evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 127
diff changeset
   374
                ui.warn(_("Can't kill immutable changeset %s") % repo[n])
b70fadbccc2a evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 127
diff changeset
   375
            else:
b70fadbccc2a evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 127
diff changeset
   376
                for ne in new:
b70fadbccc2a evolution: add a --new argument for kill
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 127
diff changeset
   377
                    repo.addobsolete(ne, n)
81
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   378
        # update to an unkilled parent
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   379
        wdp = repo['.']
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   380
        newnode = wdp
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   381
        while newnode.obsolete():
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   382
            newnode = newnode.parents()[0]
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   383
        if newnode.node() != wdp.node():
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   384
            commands.update(ui, repo, newnode.rev())
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   385
            ui.status(_('working directory now at %s\n') % newnode)
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   386
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   387
    finally:
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   388
        wlock.release()
5cec25ce019c Basic kill command
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
   389
151
e73944b6be8f evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 147
diff changeset
   390
@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
   391
    [('A', 'addremove', None,
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   392
     _('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
   393
    ('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
   394
    ('c', 'change', '', _('specifies the changesets to amend'), _('REV')),
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   395
    ('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
   396
    ] + walkopts + commitopts + commitopts2,
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   397
    _('[OPTION]... [FILE]...'))
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   398
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
   399
    """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
   400
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   401
    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
   402
    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
   403
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   404
    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
   405
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   406
    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
   407
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   408
    If you specify --change, amend additionally considers all
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   409
    changesets between the indicated changeset and the working copy
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   410
    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
   411
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   412
    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
   413
    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
   414
    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
   415
    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
   416
    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
   417
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   418
    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
   419
    """
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   420
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   421
    # determine updates to subsume
295
a5894bb97909 evolve: remove --change . == --change .^ crazyness
Patrick Mezard <patrick@mezard.eu>
parents: 294
diff changeset
   422
    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
   423
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   424
    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
   425
    try:
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   426
        wlock = repo.wlock()
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   427
        try:
294
98c9c69c311d evolve: use explicit phase constants
Patrick Mezard <patrick@mezard.eu>
parents: 284
diff changeset
   428
            if old.phase() == phases.public:
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   429
                raise util.Abort(_("can not rewrite immutable changeset %s")
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   430
                                 % old)
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
   431
            oldphase = old.phase()
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   432
            # commit current changes as update
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   433
            # code copied from commands.commit to avoid noisy messages
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   434
            ciopts = dict(opts)
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   435
            ciopts.pop('message', None)
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   436
            ciopts.pop('logfile', None)
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   437
            ciopts['message'] = opts.get('note') or ('amends %s' % old.hex())
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   438
            e = cmdutil.commiteditor
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   439
            def commitfunc(ui, repo, message, match, opts):
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   440
                return repo.commit(message, opts.get('user'), opts.get('date'),
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   441
                                   match, editor=e)
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   442
            revcount = len(repo)
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   443
            tempid = cmdutil.commit(ui, repo, commitfunc, pats, ciopts)
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   444
            if len(repo) == revcount:
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   445
                # No revision created
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   446
                tempid = None
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   447
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   448
            # find all changesets to be considered updates
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   449
            head = repo['.']
268
2da5af3dadeb amend: remove useless repo.changelog alias
Patrick Mezard <patrick@mezard.eu>
parents: 265
diff changeset
   450
            updatenodes = set(repo.changelog.nodesbetween(
2da5af3dadeb amend: remove useless repo.changelog alias
Patrick Mezard <patrick@mezard.eu>
parents: 265
diff changeset
   451
                    roots=[old.node()], heads=[head.node()])[0])
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   452
            updatenodes.remove(old.node())
263
de62daaf2054 amend: drop --branches, pick it from working directory
Patrick Mezard <patrick@mezard.eu>
parents: 260
diff changeset
   453
            okoptions = ['message', 'logfile', 'edit', 'user']
140
462d52ae7fb7 add user to the list of option prevent the "no change found" message to show up
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 139
diff changeset
   454
            if not updatenodes:
462d52ae7fb7 add user to the list of option prevent the "no change found" message to show up
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 139
diff changeset
   455
                for o in okoptions:
462d52ae7fb7 add user to the list of option prevent the "no change found" message to show up
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 139
diff changeset
   456
                    if opts.get(o):
462d52ae7fb7 add user to the list of option prevent the "no change found" message to show up
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 139
diff changeset
   457
                        break
462d52ae7fb7 add user to the list of option prevent the "no change found" message to show up
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 139
diff changeset
   458
                else:
462d52ae7fb7 add user to the list of option prevent the "no change found" message to show up
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 139
diff changeset
   459
                    raise error.Abort(_('no updates found'))
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   460
            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
   461
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   462
            # perform amend
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   463
            if opts.get('edit'):
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   464
                opts['force_editor'] = True
265
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   465
            newid, created = rewrite(repo, old, updates, head,
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   466
                                     [old.p1().node(), old.p2().node()], opts)
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   467
            if created:
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   468
                # reroute the working copy parent to the new changeset
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   469
                phases.retractboundary(repo, oldphase, [newid])
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   470
                repo.dirstate.setparents(newid, node.nullid)
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   471
            else:
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   472
                # rewrite() recreated an existing revision, discard
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   473
                # the intermediate revision if any. No need to update
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   474
                # phases or parents.
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   475
                if tempid is not None:
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   476
                    repo.addobsolete(node.nullid, tempid)
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   477
                # XXX: need another message in collapse case.
24943df310d4 amend: do not traceback on no-ops
Patrick Mezard <patrick@mezard.eu>
parents: 264
diff changeset
   478
                raise error.Abort(_('no updates found'))
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   479
        finally:
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   480
            wlock.release()
82
8108d566a8b5 [evolution] imported hg amend from parren works
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 81
diff changeset
   481
    finally:
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   482
        lock.release()
116
64ca29eef349 Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 113
diff changeset
   483
312
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   484
def _commitfiltered(repo, ctx, match):
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   485
    """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
   486
    node identifier, or None if nothing changed.
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   487
    """
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   488
    base = ctx.p1()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   489
    m, a, r = repo.status(base, ctx)[:3]
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   490
    allfiles = set(m + a + r)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   491
    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
   492
    if files == allfiles:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   493
        return None
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   494
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   495
    # Filter copies
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   496
    copied = copies.pathcopies(base, ctx)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   497
    copied = dict((src, dst) for src, dst in copied.iteritems()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   498
                  if dst in files)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   499
    def filectxfn(repo, memctx, path):
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   500
        if path not in ctx:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   501
            raise IOError()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   502
        fctx = ctx[path]
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   503
        flags = fctx.flags()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   504
        mctx = context.memfilectx(fctx.path(), fctx.data(),
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   505
                                  islink='l' in flags,
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   506
                                  isexec='x' in flags,
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   507
                                  copied=copied.get(path))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   508
        return mctx
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   509
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   510
    new = context.memctx(repo,
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   511
                         parents=[base.node(), node.nullid],
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   512
                         text=ctx.description(),
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   513
                         files=files,
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   514
                         filectxfn=filectxfn,
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   515
                         user=ctx.user(),
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   516
                         date=ctx.date(),
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   517
                         extra=ctx.extra())
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   518
    # commitctx always create a new revision, no need to check
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   519
    newid = repo.commitctx(new)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   520
    return newid
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   521
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   522
def _uncommitdirstate(repo, oldctx, match):
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   523
    """Fix the dirstate after switching the working directory from
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   524
    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
   525
    match.
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   526
    """
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   527
    ctx = repo['.']
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   528
    ds = repo.dirstate
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   529
    copies = dict(ds.copies())
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   530
    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
   531
    for f in m:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   532
        if ds[f] == 'r':
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   533
            # modified + removed -> removed
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   534
            continue
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   535
        ds.normallookup(f)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   536
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   537
    for f in a:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   538
        if ds[f] == 'r':
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   539
            # added + removed -> unknown
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   540
            ds.drop(f)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   541
        elif ds[f] != 'a':
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   542
            ds.add(f)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   543
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   544
    for f in r:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   545
        if ds[f] == 'a':
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   546
            # removed + added -> normal
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   547
            ds.normallookup(f)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   548
        elif ds[f] != 'r':
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   549
            ds.remove(f)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   550
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   551
    # Merge old parent and old working dir copies
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   552
    oldcopies = {}
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   553
    for f in (m + a):
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   554
        src = oldctx[f].renamed()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   555
        if src:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   556
            oldcopies[f] = src[0]
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   557
    oldcopies.update(copies)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   558
    copies = dict((dst, oldcopies.get(src, src))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   559
                  for dst, src in oldcopies.iteritems())
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   560
    # Adjust the dirstate copies
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   561
    for dst, src in copies.iteritems():
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   562
        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
   563
            src = None
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   564
        ds.copy(src, dst)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   565
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   566
@command('^uncommit',
314
ebd286f06879 uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents: 313
diff changeset
   567
    [('a', 'all', None, _('uncommit all changes when no arguments given')),
ebd286f06879 uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents: 313
diff changeset
   568
     ] + commands.walkopts,
312
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   569
    _('[OPTION]... [NAME]'))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   570
def uncommit(ui, repo, *pats, **opts):
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   571
    """move changes from parent revision to working directory
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   572
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   573
    Changes to selected files in parent revision appear again as
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   574
    uncommitted changed in the working directory. A new revision
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   575
    without selected changes is created, becomes the new parent and
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   576
    obsoletes the previous one.
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   577
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   578
    The --include option specify pattern to uncommit
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   579
    The --exclude option specify pattern to keep in the commit
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   580
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   581
    Return 0 if changed files are uncommitted.
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   582
    """
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   583
    lock = repo.lock()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   584
    try:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   585
        wlock = repo.wlock()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   586
        try:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   587
            wctx = repo[None]
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   588
            if len(wctx.parents()) <= 0:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   589
                raise util.Abort(_("cannot uncommit null changeset"))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   590
            if len(wctx.parents()) > 1:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   591
                raise util.Abort(_("cannot uncommit while merging"))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   592
            old = repo['.']
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   593
            if old.phase() == phases.public:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   594
                raise util.Abort(_("cannot rewrite immutable changeset"))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   595
            if len(old.parents()) > 1:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   596
                raise util.Abort(_("cannot uncommit merge changeset"))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   597
            oldphase = old.phase()
313
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   598
            updatebookmarks = _bookmarksupdater(repo, old.node())
312
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   599
            # Recommit the filtered changeset
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   600
            newid = None
314
ebd286f06879 uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents: 313
diff changeset
   601
            if (pats or opts.get('include') or opts.get('exclude')
ebd286f06879 uncommit: add --all option
Patrick Mezard <patrick@mezard.eu>
parents: 313
diff changeset
   602
                or opts.get('all')):
312
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   603
                match = scmutil.match(old, pats, opts)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   604
                newid = _commitfiltered(repo, old, match)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   605
            if newid is None:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   606
                raise util.Abort(_('nothing to uncommit'))
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   607
            # Move local changes on filtered changeset
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   608
            repo.addobsolete(newid, old.node())
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   609
            phases.retractboundary(repo, oldphase, [newid])
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   610
            repo.dirstate.setparents(newid, node.nullid)
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   611
            _uncommitdirstate(repo, old, match)
313
47d10459fa24 uncommit: handle bookmarks
Patrick Mezard <patrick@mezard.eu>
parents: 312
diff changeset
   612
            updatebookmarks(newid)
312
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   613
        finally:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   614
            wlock.release()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   615
    finally:
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   616
        lock.release()
a7b5989d1d92 evolve: add uncommit command
Patrick Mezard <patrick@mezard.eu>
parents: 309
diff changeset
   617
116
64ca29eef349 Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 113
diff changeset
   618
def commitwrapper(orig, ui, repo, *arg, **kwargs):
137
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   619
    lock = repo.lock()
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   620
    try:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   621
        obsoleted = kwargs.get('obsolete', [])
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   622
        if obsoleted:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   623
            obsoleted = repo.set('%lr', obsoleted)
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   624
        result = orig(ui, repo, *arg, **kwargs)
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   625
        if not result: # commit successed
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   626
            new = repo['-1']
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   627
            oldbookmarks = []
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   628
            for old in obsoleted:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   629
                oldbookmarks.extend(repo.nodebookmarks(old.node()))
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   630
                repo.addobsolete(new.node(), old.node())
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   631
            for book in oldbookmarks:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   632
                repo._bookmarks[book] = new.node()
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   633
            if oldbookmarks:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   634
                bookmarks.write(repo)
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   635
        return result
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   636
    finally:
bbc653876876 fix evolve test
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 133
diff changeset
   637
        lock.release()
116
64ca29eef349 Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 113
diff changeset
   638
117
438fe133b068 Add a -o and -O option to graft.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 116
diff changeset
   639
def graftwrapper(orig, ui, repo, *revs, **kwargs):
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   640
    lock = repo.lock()
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   641
    try:
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   642
        if kwargs.get('old_obsolete'):
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   643
            obsoleted = kwargs.setdefault('obsolete', [])
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   644
            if kwargs['continue']:
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   645
                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
   646
            else:
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   647
                obsoleted.extend(revs)
151
e73944b6be8f evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 147
diff changeset
   648
        # 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
   649
        obsoleted = kwargs.setdefault('obsolete', [])
e73944b6be8f evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 147
diff changeset
   650
        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
   651
        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
   652
e73944b6be8f evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 147
diff changeset
   653
            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
   654
                                'obsoleting (for now).'))
e73944b6be8f evolve: improve graft handling of -O
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 147
diff changeset
   655
119
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   656
        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
   657
    finally:
22f2b700bd59 evolution: proper locking scheme
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 118
diff changeset
   658
        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
   659
116
64ca29eef349 Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 113
diff changeset
   660
def extsetup(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
   661
    try:
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   662
        obsolete = extensions.find('obsolete')
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   663
    except KeyError:
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   664
        raise error.Abort(_('evolution extension require obsolete extension.'))
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   665
    try:
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   666
        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
   667
    except KeyError:
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   668
        rebase = None
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   669
        raise error.Abort(_('evolution extension require rebase extension.'))
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   670
116
64ca29eef349 Add a -o option to commit
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 113
diff changeset
   671
    entry = extensions.wrapcommand(commands.table, 'commit', commitwrapper)
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   672
    entry[1].append(('o', 'obsolete', [],
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   673
                     _("make commit obsolete this revision")))
117
438fe133b068 Add a -o and -O option to graft.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 116
diff changeset
   674
    entry = extensions.wrapcommand(commands.table, 'graft', graftwrapper)
303
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   675
    entry[1].append(('o', 'obsolete', [],
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   676
                     _("make graft obsoletes this revision")))
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   677
    entry[1].append(('O', 'old-obsolete', False,
8529b4b95f5d evolve: tidy up a bit
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
   678
                     _("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
   679
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   680
    # warning about more obsolete
309
de21685d22d1 evolve: warn when latecomer changeset are created
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 303
diff changeset
   681
    for cmd in ['commit', 'push', 'pull', 'graft', 'phase', 'unbundle']:
de21685d22d1 evolve: warn when latecomer changeset are created
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 303
diff changeset
   682
        entry = extensions.wrapcommand(commands.table, cmd, warnobserrors)
211
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   683
    for cmd in ['kill', 'amend']:
309
de21685d22d1 evolve: warn when latecomer changeset are created
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 303
diff changeset
   684
        entry = extensions.wrapcommand(cmdtable, cmd, warnobserrors)
211
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   685
69a37d56c7fb evolve: issue the "%i new unstable changeset" in more place
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 196
diff changeset
   686
    if rebase is not None:
309
de21685d22d1 evolve: warn when latecomer changeset are created
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 303
diff changeset
   687
        entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors)