Mercurial > hg-stable
annotate hgext/uncommit.py @ 41754:83d294c71f1e
uncommit: inform user if the commit is empty after uncommit
Differential Revision: https://phab.mercurial-scm.org/D5969
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 15 Feb 2019 10:49:12 -0800 |
parents | 0bd56c291359 |
children | 1040d54eb7eb |
rev | line source |
---|---|
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
1 # uncommit - undo the actions of a commit |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
2 # |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
4 # Logilab SA <contact@logilab.fr> |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
5 # Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
6 # Patrick Mezard <patrick@mezard.eu> |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
7 # Copyright 2016 Facebook, Inc. |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
8 # |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
9 # This software may be used and distributed according to the terms of the |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
10 # GNU General Public License version 2 or any later version. |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
11 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
12 """uncommit part or all of a local changeset (EXPERIMENTAL) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
13 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
14 This command undoes the effect of a local commit, returning the affected |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
15 files to their uncommitted state. This means that files modified, added or |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
16 removed in the changeset will be left unchanged, and so will remain modified, |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
17 added and removed in the working directory. |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
18 """ |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
19 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
20 from __future__ import absolute_import |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
21 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
22 from mercurial.i18n import _ |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
23 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
24 from mercurial import ( |
34291
624c53e4121d
uncommit: don't allow bare uncommit on dirty working directory
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34290
diff
changeset
|
25 cmdutil, |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
26 commands, |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
27 context, |
41364
7be231f5a4ad
unamend: import "copies" module as "copiesmod" to avoid shadowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
40295
diff
changeset
|
28 copies as copiesmod, |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
29 error, |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
30 node, |
35193
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
31 obsutil, |
35045
3ebae3ec4664
py3: handle keyword arguments in hgext/uncommit.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34758
diff
changeset
|
32 pycompat, |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
33 registrar, |
35253
98f97eb20597
rewriteutil: use precheck() in uncommit and amend commands
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35210
diff
changeset
|
34 rewriteutil, |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
35 scmutil, |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
36 ) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
37 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
38 cmdtable = {} |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
39 command = registrar.command(cmdtable) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
40 |
34758
9ea416a4b4f7
configitems: register the 'experimental.uncommitondirtywdir' config
Boris Feld <boris.feld@octobus.net>
parents:
34292
diff
changeset
|
41 configtable = {} |
9ea416a4b4f7
configitems: register the 'experimental.uncommitondirtywdir' config
Boris Feld <boris.feld@octobus.net>
parents:
34292
diff
changeset
|
42 configitem = registrar.configitem(configtable) |
9ea416a4b4f7
configitems: register the 'experimental.uncommitondirtywdir' config
Boris Feld <boris.feld@octobus.net>
parents:
34292
diff
changeset
|
43 |
9ea416a4b4f7
configitems: register the 'experimental.uncommitondirtywdir' config
Boris Feld <boris.feld@octobus.net>
parents:
34292
diff
changeset
|
44 configitem('experimental', 'uncommitondirtywdir', |
9ea416a4b4f7
configitems: register the 'experimental.uncommitondirtywdir' config
Boris Feld <boris.feld@octobus.net>
parents:
34292
diff
changeset
|
45 default=False, |
9ea416a4b4f7
configitems: register the 'experimental.uncommitondirtywdir' config
Boris Feld <boris.feld@octobus.net>
parents:
34292
diff
changeset
|
46 ) |
9ea416a4b4f7
configitems: register the 'experimental.uncommitondirtywdir' config
Boris Feld <boris.feld@octobus.net>
parents:
34292
diff
changeset
|
47 |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
48 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
49 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
50 # be specifying the version(s) of Mercurial they are tested with, or |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
51 # leave the attribute unspecified. |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
52 testedwith = 'ships-with-hg-core' |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
53 |
36980
435b8b05affd
uncommit: simplify condition for keeping commit
Martin von Zweigbergk <martinvonz@google.com>
parents:
36979
diff
changeset
|
54 def _commitfiltered(repo, ctx, match, keepcommit): |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
55 """Recommit ctx with changed files not in match. Return the new |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
56 node identifier, or None if nothing changed. |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
57 """ |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
58 base = ctx.p1() |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
59 # ctx |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
60 initialfiles = set(ctx.files()) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
61 exclude = set(f for f in initialfiles if match(f)) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
62 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
63 # No files matched commit, so nothing excluded |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
64 if not exclude: |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
65 return None |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
66 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
67 # return the p1 so that we don't create an obsmarker later |
36980
435b8b05affd
uncommit: simplify condition for keeping commit
Martin von Zweigbergk <martinvonz@google.com>
parents:
36979
diff
changeset
|
68 if not keepcommit: |
41419
0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
Martin von Zweigbergk <martinvonz@google.com>
parents:
41367
diff
changeset
|
69 return ctx.p1().node() |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
70 |
41754
83d294c71f1e
uncommit: inform user if the commit is empty after uncommit
Martin von Zweigbergk <martinvonz@google.com>
parents:
41419
diff
changeset
|
71 files = (initialfiles - exclude) |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
72 # Filter copies |
41364
7be231f5a4ad
unamend: import "copies" module as "copiesmod" to avoid shadowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
40295
diff
changeset
|
73 copied = copiesmod.pathcopies(base, ctx) |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
74 copied = dict((dst, src) for dst, src in copied.iteritems() |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
75 if dst in files) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
76 def filectxfn(repo, memctx, path, contentctx=ctx, redirect=()): |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
77 if path not in contentctx: |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
78 return None |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
79 fctx = contentctx[path] |
35407
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35253
diff
changeset
|
80 mctx = context.memfilectx(repo, memctx, fctx.path(), fctx.data(), |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
81 fctx.islink(), |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
82 fctx.isexec(), |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
83 copied=copied.get(path)) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
84 return mctx |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
85 |
41754
83d294c71f1e
uncommit: inform user if the commit is empty after uncommit
Martin von Zweigbergk <martinvonz@google.com>
parents:
41419
diff
changeset
|
86 if not files: |
83d294c71f1e
uncommit: inform user if the commit is empty after uncommit
Martin von Zweigbergk <martinvonz@google.com>
parents:
41419
diff
changeset
|
87 repo.ui.status(_("note: keeping empty commit\n")) |
83d294c71f1e
uncommit: inform user if the commit is empty after uncommit
Martin von Zweigbergk <martinvonz@google.com>
parents:
41419
diff
changeset
|
88 |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
89 new = context.memctx(repo, |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
90 parents=[base.node(), node.nullid], |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
91 text=ctx.description(), |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
92 files=files, |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
93 filectxfn=filectxfn, |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
94 user=ctx.user(), |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
95 date=ctx.date(), |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
96 extra=ctx.extra()) |
38429
32fba6fe893d
scmutil: make cleanupnodes optionally also fix the phase
Martin von Zweigbergk <martinvonz@google.com>
parents:
36980
diff
changeset
|
97 return repo.commitctx(new) |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
98 |
41366
19c590ce8661
unamend: fix unamending of renamed rename
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
99 def _fixdirstate(repo, oldctx, newctx, match=None): |
35194
9dadcb99cc17
uncommit: unify functions _uncommitdirstate and _unamenddirstate to one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35193
diff
changeset
|
100 """ fix the dirstate after switching the working directory from oldctx to |
9dadcb99cc17
uncommit: unify functions _uncommitdirstate and _unamenddirstate to one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35193
diff
changeset
|
101 newctx which can be result of either unamend or uncommit. |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
102 """ |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
103 ds = repo.dirstate |
41367
fe83040400b7
uncommit: set dirstateparents from within _fixdirstate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
41366
diff
changeset
|
104 ds.setparents(newctx.node(), node.nullid) |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
105 copies = dict(ds.copies()) |
41366
19c590ce8661
unamend: fix unamending of renamed rename
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
106 s = newctx.status(oldctx, match=match) |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
107 for f in s.modified: |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
108 if ds[f] == 'r': |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
109 # modified + removed -> removed |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
110 continue |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
111 ds.normallookup(f) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
112 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
113 for f in s.added: |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
114 if ds[f] == 'r': |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
115 # added + removed -> unknown |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
116 ds.drop(f) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
117 elif ds[f] != 'a': |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
118 ds.add(f) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
119 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
120 for f in s.removed: |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
121 if ds[f] == 'a': |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
122 # removed + added -> normal |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
123 ds.normallookup(f) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
124 elif ds[f] != 'r': |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
125 ds.remove(f) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
126 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
127 # Merge old parent and old working dir copies |
41366
19c590ce8661
unamend: fix unamending of renamed rename
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
128 oldcopies = copiesmod.pathcopies(newctx, oldctx, match) |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
129 oldcopies.update(copies) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
130 copies = dict((dst, oldcopies.get(src, src)) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
131 for dst, src in oldcopies.iteritems()) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
132 # Adjust the dirstate copies |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
133 for dst, src in copies.iteritems(): |
35194
9dadcb99cc17
uncommit: unify functions _uncommitdirstate and _unamenddirstate to one
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35193
diff
changeset
|
134 if (src not in newctx or dst in newctx or ds[dst] != 'a'): |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
135 src = None |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
136 ds.copy(src, dst) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
137 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
138 @command('uncommit', |
34290
f94442d46984
uncommit: rename the flag 'empty' to 'keep' which retains empty changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34204
diff
changeset
|
139 [('', 'keep', False, _('allow an empty commit after uncommiting')), |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
140 ] + commands.walkopts, |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
38812
diff
changeset
|
141 _('[OPTION]... [FILE]...'), |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
38812
diff
changeset
|
142 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT) |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
143 def uncommit(ui, repo, *pats, **opts): |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
144 """uncommit part or all of a local changeset |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
145 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
146 This command undoes the effect of a local commit, returning the affected |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
147 files to their uncommitted state. This means that files modified or |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
148 deleted in the changeset will be left unchanged, and so will remain |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
149 modified in the working directory. |
36979
d63c5c651183
uncommit: document when the commit will be pruned
Martin von Zweigbergk <martinvonz@google.com>
parents:
36978
diff
changeset
|
150 |
d63c5c651183
uncommit: document when the commit will be pruned
Martin von Zweigbergk <martinvonz@google.com>
parents:
36978
diff
changeset
|
151 If no files are specified, the commit will be pruned, unless --keep is |
d63c5c651183
uncommit: document when the commit will be pruned
Martin von Zweigbergk <martinvonz@google.com>
parents:
36978
diff
changeset
|
152 given. |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
153 """ |
35045
3ebae3ec4664
py3: handle keyword arguments in hgext/uncommit.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34758
diff
changeset
|
154 opts = pycompat.byteskwargs(opts) |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
155 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
156 with repo.wlock(), repo.lock(): |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
157 |
34292
7b1e524ad73f
uncommit: add an experimental.uncommitondirtywdir config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34291
diff
changeset
|
158 if not pats and not repo.ui.configbool('experimental', |
36953
3d0178bf1039
uncommit: fix unaligned indentation
Martin von Zweigbergk <martinvonz@google.com>
parents:
35809
diff
changeset
|
159 'uncommitondirtywdir'): |
34291
624c53e4121d
uncommit: don't allow bare uncommit on dirty working directory
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34290
diff
changeset
|
160 cmdutil.bailifchanged(repo) |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
161 old = repo['.'] |
35253
98f97eb20597
rewriteutil: use precheck() in uncommit and amend commands
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35210
diff
changeset
|
162 rewriteutil.precheck(repo, [old.rev()], 'uncommit') |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
163 if len(old.parents()) > 1: |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
164 raise error.Abort(_("cannot uncommit merge changeset")) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
165 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
166 with repo.transaction('uncommit'): |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
167 match = scmutil.match(old, pats, opts) |
36980
435b8b05affd
uncommit: simplify condition for keeping commit
Martin von Zweigbergk <martinvonz@google.com>
parents:
36979
diff
changeset
|
168 keepcommit = opts.get('keep') or pats |
435b8b05affd
uncommit: simplify condition for keeping commit
Martin von Zweigbergk <martinvonz@google.com>
parents:
36979
diff
changeset
|
169 newid = _commitfiltered(repo, old, match, keepcommit) |
34204
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
170 if newid is None: |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
171 ui.status(_("nothing to uncommit\n")) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
172 return 1 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
173 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
174 mapping = {} |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
175 if newid != old.p1().node(): |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
176 # Move local changes on filtered changeset |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
177 mapping[old.node()] = (newid,) |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
178 else: |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
179 # Fully removed the old commit |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
180 mapping[old.node()] = () |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
181 |
da2f5f19312c
uncommit: move fb-extension to core which uncommits a changeset
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
182 with repo.dirstate.parentchange(): |
41366
19c590ce8661
unamend: fix unamending of renamed rename
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
183 _fixdirstate(repo, old, repo[newid], match) |
35193
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
184 |
41365
c9f1fd82a826
uncommit: mark old node obsolete after updating dirstate
Martin von Zweigbergk <martinvonz@google.com>
parents:
41364
diff
changeset
|
185 scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True) |
c9f1fd82a826
uncommit: mark old node obsolete after updating dirstate
Martin von Zweigbergk <martinvonz@google.com>
parents:
41364
diff
changeset
|
186 |
35193
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
187 def predecessormarkers(ctx): |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
188 """yields the obsolete markers marking the given changeset as a successor""" |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
189 for data in ctx.repo().obsstore.predecessors.get(ctx.node(), ()): |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
190 yield obsutil.marker(ctx.repo(), data) |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
191 |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
192 @command('unamend', [], helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, |
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
193 helpbasic=True) |
35193
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
194 def unamend(ui, repo, **opts): |
35809
f9a82b9b2c36
unamend: fix command summary line
Martin von Zweigbergk <martinvonz@google.com>
parents:
35439
diff
changeset
|
195 """undo the most recent amend operation on a current changeset |
35193
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
196 |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
197 This command will roll back to the previous version of a changeset, |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
198 leaving working directory in state in which it was before running |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
199 `hg amend` (e.g. files modified as part of an amend will be |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
200 marked as modified `hg status`) |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
201 """ |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
202 |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
203 unfi = repo.unfiltered() |
35210
9e339c97fabb
unamend: drop unused vars, query after taking lock, use ctx.hex() for extras
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35194
diff
changeset
|
204 with repo.wlock(), repo.lock(), repo.transaction('unamend'): |
35193
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
205 |
35210
9e339c97fabb
unamend: drop unused vars, query after taking lock, use ctx.hex() for extras
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35194
diff
changeset
|
206 # identify the commit from which to unamend |
9e339c97fabb
unamend: drop unused vars, query after taking lock, use ctx.hex() for extras
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35194
diff
changeset
|
207 curctx = repo['.'] |
35193
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
208 |
35439
f01101100043
unamend: allow unamending if allowunstable is set
Martin von Zweigbergk <martinvonz@google.com>
parents:
35407
diff
changeset
|
209 rewriteutil.precheck(repo, [curctx.rev()], 'unamend') |
35193
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
210 |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
211 # identify the commit to which to unamend |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
212 markers = list(predecessormarkers(curctx)) |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
213 if len(markers) != 1: |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
214 e = _("changeset must have one predecessor, found %i predecessors") |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
215 raise error.Abort(e % len(markers)) |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
216 |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
217 prednode = markers[0].prednode() |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
218 predctx = unfi[prednode] |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
219 |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
220 # add an extra so that we get a new hash |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
221 # note: allowing unamend to undo an unamend is an intentional feature |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
222 extras = predctx.extra() |
35210
9e339c97fabb
unamend: drop unused vars, query after taking lock, use ctx.hex() for extras
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35194
diff
changeset
|
223 extras['unamend_source'] = curctx.hex() |
35193
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
224 |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
225 def filectxfn(repo, ctx_, path): |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
226 try: |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
227 return predctx.filectx(path) |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
228 except KeyError: |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
229 return None |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
230 |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
231 # Make a new commit same as predctx |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
232 newctx = context.memctx(repo, |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
233 parents=(predctx.p1(), predctx.p2()), |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
234 text=predctx.description(), |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
235 files=predctx.files(), |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
236 filectxfn=filectxfn, |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
237 user=predctx.user(), |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
238 date=predctx.date(), |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
239 extra=extras) |
38429
32fba6fe893d
scmutil: make cleanupnodes optionally also fix the phase
Martin von Zweigbergk <martinvonz@google.com>
parents:
36980
diff
changeset
|
240 newprednode = repo.commitctx(newctx) |
35193
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
241 newpredctx = repo[newprednode] |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
242 dirstate = repo.dirstate |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
243 |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
244 with dirstate.parentchange(): |
41366
19c590ce8661
unamend: fix unamending of renamed rename
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
245 _fixdirstate(repo, curctx, newpredctx) |
35193
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
246 |
867990238dc6
unamend: move fb extension unamend to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35045
diff
changeset
|
247 mapping = {curctx.node(): (newprednode,)} |
38429
32fba6fe893d
scmutil: make cleanupnodes optionally also fix the phase
Martin von Zweigbergk <martinvonz@google.com>
parents:
36980
diff
changeset
|
248 scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True) |