Show More
@@ -1,248 +1,256 b'' | |||||
1 | # uncommit - undo the actions of a commit |
|
1 | # uncommit - undo the actions of a commit | |
2 | # |
|
2 | # | |
3 | # Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
|
3 | # Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com> | |
4 | # Logilab SA <contact@logilab.fr> |
|
4 | # Logilab SA <contact@logilab.fr> | |
5 | # Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
|
5 | # Pierre-Yves David <pierre-yves.david@ens-lyon.org> | |
6 | # Patrick Mezard <patrick@mezard.eu> |
|
6 | # Patrick Mezard <patrick@mezard.eu> | |
7 | # Copyright 2016 Facebook, Inc. |
|
7 | # Copyright 2016 Facebook, Inc. | |
8 | # |
|
8 | # | |
9 | # This software may be used and distributed according to the terms of the |
|
9 | # This software may be used and distributed according to the terms of the | |
10 | # GNU General Public License version 2 or any later version. |
|
10 | # GNU General Public License version 2 or any later version. | |
11 |
|
11 | |||
12 | """uncommit part or all of a local changeset (EXPERIMENTAL) |
|
12 | """uncommit part or all of a local changeset (EXPERIMENTAL) | |
13 |
|
13 | |||
14 | This command undoes the effect of a local commit, returning the affected |
|
14 | This command undoes the effect of a local commit, returning the affected | |
15 | files to their uncommitted state. This means that files modified, added or |
|
15 | files to their uncommitted state. This means that files modified, added or | |
16 | removed in the changeset will be left unchanged, and so will remain modified, |
|
16 | removed in the changeset will be left unchanged, and so will remain modified, | |
17 | added and removed in the working directory. |
|
17 | added and removed in the working directory. | |
18 | """ |
|
18 | """ | |
19 |
|
19 | |||
20 | from __future__ import absolute_import |
|
20 | from __future__ import absolute_import | |
21 |
|
21 | |||
22 | from mercurial.i18n import _ |
|
22 | from mercurial.i18n import _ | |
23 |
|
23 | |||
24 | from mercurial import ( |
|
24 | from mercurial import ( | |
25 | cmdutil, |
|
25 | cmdutil, | |
26 | commands, |
|
26 | commands, | |
27 | context, |
|
27 | context, | |
28 | copies as copiesmod, |
|
28 | copies as copiesmod, | |
29 | error, |
|
29 | error, | |
30 | node, |
|
30 | node, | |
31 | obsutil, |
|
31 | obsutil, | |
32 | pycompat, |
|
32 | pycompat, | |
33 | registrar, |
|
33 | registrar, | |
34 | rewriteutil, |
|
34 | rewriteutil, | |
35 | scmutil, |
|
35 | scmutil, | |
36 | ) |
|
36 | ) | |
37 |
|
37 | |||
38 | cmdtable = {} |
|
38 | cmdtable = {} | |
39 | command = registrar.command(cmdtable) |
|
39 | command = registrar.command(cmdtable) | |
40 |
|
40 | |||
41 | configtable = {} |
|
41 | configtable = {} | |
42 | configitem = registrar.configitem(configtable) |
|
42 | configitem = registrar.configitem(configtable) | |
43 |
|
43 | |||
44 | configitem('experimental', 'uncommitondirtywdir', |
|
44 | configitem('experimental', 'uncommitondirtywdir', | |
45 | default=False, |
|
45 | default=False, | |
46 | ) |
|
46 | ) | |
|
47 | configitem('experimental', 'uncommit.keep', | |||
|
48 | default=False, | |||
|
49 | ) | |||
47 |
|
50 | |||
48 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
51 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | |
49 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
|
52 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | |
50 | # be specifying the version(s) of Mercurial they are tested with, or |
|
53 | # be specifying the version(s) of Mercurial they are tested with, or | |
51 | # leave the attribute unspecified. |
|
54 | # leave the attribute unspecified. | |
52 | testedwith = 'ships-with-hg-core' |
|
55 | testedwith = 'ships-with-hg-core' | |
53 |
|
56 | |||
54 | def _commitfiltered(repo, ctx, match, keepcommit): |
|
57 | def _commitfiltered(repo, ctx, match, keepcommit): | |
55 | """Recommit ctx with changed files not in match. Return the new |
|
58 | """Recommit ctx with changed files not in match. Return the new | |
56 | node identifier, or None if nothing changed. |
|
59 | node identifier, or None if nothing changed. | |
57 | """ |
|
60 | """ | |
58 | base = ctx.p1() |
|
61 | base = ctx.p1() | |
59 | # ctx |
|
62 | # ctx | |
60 | initialfiles = set(ctx.files()) |
|
63 | initialfiles = set(ctx.files()) | |
61 | exclude = set(f for f in initialfiles if match(f)) |
|
64 | exclude = set(f for f in initialfiles if match(f)) | |
62 |
|
65 | |||
63 | # No files matched commit, so nothing excluded |
|
66 | # No files matched commit, so nothing excluded | |
64 | if not exclude: |
|
67 | if not exclude: | |
65 | return None |
|
68 | return None | |
66 |
|
69 | |||
67 | # return the p1 so that we don't create an obsmarker later |
|
70 | # return the p1 so that we don't create an obsmarker later | |
68 | if not keepcommit: |
|
71 | if not keepcommit: | |
69 | return ctx.p1().node() |
|
72 | return ctx.p1().node() | |
70 |
|
73 | |||
71 | files = (initialfiles - exclude) |
|
74 | files = (initialfiles - exclude) | |
72 | # Filter copies |
|
75 | # Filter copies | |
73 | copied = copiesmod.pathcopies(base, ctx) |
|
76 | copied = copiesmod.pathcopies(base, ctx) | |
74 | copied = dict((dst, src) for dst, src in copied.iteritems() |
|
77 | copied = dict((dst, src) for dst, src in copied.iteritems() | |
75 | if dst in files) |
|
78 | if dst in files) | |
76 | def filectxfn(repo, memctx, path, contentctx=ctx, redirect=()): |
|
79 | def filectxfn(repo, memctx, path, contentctx=ctx, redirect=()): | |
77 | if path not in contentctx: |
|
80 | if path not in contentctx: | |
78 | return None |
|
81 | return None | |
79 | fctx = contentctx[path] |
|
82 | fctx = contentctx[path] | |
80 | mctx = context.memfilectx(repo, memctx, fctx.path(), fctx.data(), |
|
83 | mctx = context.memfilectx(repo, memctx, fctx.path(), fctx.data(), | |
81 | fctx.islink(), |
|
84 | fctx.islink(), | |
82 | fctx.isexec(), |
|
85 | fctx.isexec(), | |
83 | copied=copied.get(path)) |
|
86 | copied=copied.get(path)) | |
84 | return mctx |
|
87 | return mctx | |
85 |
|
88 | |||
86 | if not files: |
|
89 | if not files: | |
87 | repo.ui.status(_("note: keeping empty commit\n")) |
|
90 | repo.ui.status(_("note: keeping empty commit\n")) | |
88 |
|
91 | |||
89 | new = context.memctx(repo, |
|
92 | new = context.memctx(repo, | |
90 | parents=[base.node(), node.nullid], |
|
93 | parents=[base.node(), node.nullid], | |
91 | text=ctx.description(), |
|
94 | text=ctx.description(), | |
92 | files=files, |
|
95 | files=files, | |
93 | filectxfn=filectxfn, |
|
96 | filectxfn=filectxfn, | |
94 | user=ctx.user(), |
|
97 | user=ctx.user(), | |
95 | date=ctx.date(), |
|
98 | date=ctx.date(), | |
96 | extra=ctx.extra()) |
|
99 | extra=ctx.extra()) | |
97 | return repo.commitctx(new) |
|
100 | return repo.commitctx(new) | |
98 |
|
101 | |||
99 | def _fixdirstate(repo, oldctx, newctx, match=None): |
|
102 | def _fixdirstate(repo, oldctx, newctx, match=None): | |
100 | """ fix the dirstate after switching the working directory from oldctx to |
|
103 | """ fix the dirstate after switching the working directory from oldctx to | |
101 | newctx which can be result of either unamend or uncommit. |
|
104 | newctx which can be result of either unamend or uncommit. | |
102 | """ |
|
105 | """ | |
103 | ds = repo.dirstate |
|
106 | ds = repo.dirstate | |
104 | ds.setparents(newctx.node(), node.nullid) |
|
107 | ds.setparents(newctx.node(), node.nullid) | |
105 | copies = dict(ds.copies()) |
|
108 | copies = dict(ds.copies()) | |
106 | s = newctx.status(oldctx, match=match) |
|
109 | s = newctx.status(oldctx, match=match) | |
107 | for f in s.modified: |
|
110 | for f in s.modified: | |
108 | if ds[f] == 'r': |
|
111 | if ds[f] == 'r': | |
109 | # modified + removed -> removed |
|
112 | # modified + removed -> removed | |
110 | continue |
|
113 | continue | |
111 | ds.normallookup(f) |
|
114 | ds.normallookup(f) | |
112 |
|
115 | |||
113 | for f in s.added: |
|
116 | for f in s.added: | |
114 | if ds[f] == 'r': |
|
117 | if ds[f] == 'r': | |
115 | # added + removed -> unknown |
|
118 | # added + removed -> unknown | |
116 | ds.drop(f) |
|
119 | ds.drop(f) | |
117 | elif ds[f] != 'a': |
|
120 | elif ds[f] != 'a': | |
118 | ds.add(f) |
|
121 | ds.add(f) | |
119 |
|
122 | |||
120 | for f in s.removed: |
|
123 | for f in s.removed: | |
121 | if ds[f] == 'a': |
|
124 | if ds[f] == 'a': | |
122 | # removed + added -> normal |
|
125 | # removed + added -> normal | |
123 | ds.normallookup(f) |
|
126 | ds.normallookup(f) | |
124 | elif ds[f] != 'r': |
|
127 | elif ds[f] != 'r': | |
125 | ds.remove(f) |
|
128 | ds.remove(f) | |
126 |
|
129 | |||
127 | # Merge old parent and old working dir copies |
|
130 | # Merge old parent and old working dir copies | |
128 | oldcopies = copiesmod.pathcopies(newctx, oldctx, match) |
|
131 | oldcopies = copiesmod.pathcopies(newctx, oldctx, match) | |
129 | oldcopies.update(copies) |
|
132 | oldcopies.update(copies) | |
130 | copies = dict((dst, oldcopies.get(src, src)) |
|
133 | copies = dict((dst, oldcopies.get(src, src)) | |
131 | for dst, src in oldcopies.iteritems()) |
|
134 | for dst, src in oldcopies.iteritems()) | |
132 | # Adjust the dirstate copies |
|
135 | # Adjust the dirstate copies | |
133 | for dst, src in copies.iteritems(): |
|
136 | for dst, src in copies.iteritems(): | |
134 | if (src not in newctx or dst in newctx or ds[dst] != 'a'): |
|
137 | if (src not in newctx or dst in newctx or ds[dst] != 'a'): | |
135 | src = None |
|
138 | src = None | |
136 | ds.copy(src, dst) |
|
139 | ds.copy(src, dst) | |
137 |
|
140 | |||
138 | @command('uncommit', |
|
141 | @command('uncommit', | |
139 |
[('', 'keep', |
|
142 | [('', 'keep', None, _('allow an empty commit after uncommiting')), | |
140 | ] + commands.walkopts, |
|
143 | ] + commands.walkopts, | |
141 | _('[OPTION]... [FILE]...'), |
|
144 | _('[OPTION]... [FILE]...'), | |
142 | helpcategory=command.CATEGORY_CHANGE_MANAGEMENT) |
|
145 | helpcategory=command.CATEGORY_CHANGE_MANAGEMENT) | |
143 | def uncommit(ui, repo, *pats, **opts): |
|
146 | def uncommit(ui, repo, *pats, **opts): | |
144 | """uncommit part or all of a local changeset |
|
147 | """uncommit part or all of a local changeset | |
145 |
|
148 | |||
146 | This command undoes the effect of a local commit, returning the affected |
|
149 | This command undoes the effect of a local commit, returning the affected | |
147 | files to their uncommitted state. This means that files modified or |
|
150 | files to their uncommitted state. This means that files modified or | |
148 | deleted in the changeset will be left unchanged, and so will remain |
|
151 | deleted in the changeset will be left unchanged, and so will remain | |
149 | modified in the working directory. |
|
152 | modified in the working directory. | |
150 |
|
153 | |||
151 | If no files are specified, the commit will be pruned, unless --keep is |
|
154 | If no files are specified, the commit will be pruned, unless --keep is | |
152 | given. |
|
155 | given. | |
153 | """ |
|
156 | """ | |
154 | opts = pycompat.byteskwargs(opts) |
|
157 | opts = pycompat.byteskwargs(opts) | |
155 |
|
158 | |||
156 | with repo.wlock(), repo.lock(): |
|
159 | with repo.wlock(), repo.lock(): | |
157 |
|
160 | |||
158 | if not pats and not repo.ui.configbool('experimental', |
|
161 | if not pats and not repo.ui.configbool('experimental', | |
159 | 'uncommitondirtywdir'): |
|
162 | 'uncommitondirtywdir'): | |
160 | cmdutil.bailifchanged(repo) |
|
163 | cmdutil.bailifchanged(repo) | |
161 | old = repo['.'] |
|
164 | old = repo['.'] | |
162 | rewriteutil.precheck(repo, [old.rev()], 'uncommit') |
|
165 | rewriteutil.precheck(repo, [old.rev()], 'uncommit') | |
163 | if len(old.parents()) > 1: |
|
166 | if len(old.parents()) > 1: | |
164 | raise error.Abort(_("cannot uncommit merge changeset")) |
|
167 | raise error.Abort(_("cannot uncommit merge changeset")) | |
165 |
|
168 | |||
166 | with repo.transaction('uncommit'): |
|
169 | with repo.transaction('uncommit'): | |
167 | match = scmutil.match(old, pats, opts) |
|
170 | match = scmutil.match(old, pats, opts) | |
168 |
keepcommit = |
|
171 | keepcommit = pats | |
|
172 | if not keepcommit: | |||
|
173 | if opts.get('keep') is not None: | |||
|
174 | keepcommit = opts.get('keep') | |||
|
175 | else: | |||
|
176 | keepcommit = ui.configbool('experimental', 'uncommit.keep') | |||
169 | newid = _commitfiltered(repo, old, match, keepcommit) |
|
177 | newid = _commitfiltered(repo, old, match, keepcommit) | |
170 | if newid is None: |
|
178 | if newid is None: | |
171 | ui.status(_("nothing to uncommit\n")) |
|
179 | ui.status(_("nothing to uncommit\n")) | |
172 | return 1 |
|
180 | return 1 | |
173 |
|
181 | |||
174 | mapping = {} |
|
182 | mapping = {} | |
175 | if newid != old.p1().node(): |
|
183 | if newid != old.p1().node(): | |
176 | # Move local changes on filtered changeset |
|
184 | # Move local changes on filtered changeset | |
177 | mapping[old.node()] = (newid,) |
|
185 | mapping[old.node()] = (newid,) | |
178 | else: |
|
186 | else: | |
179 | # Fully removed the old commit |
|
187 | # Fully removed the old commit | |
180 | mapping[old.node()] = () |
|
188 | mapping[old.node()] = () | |
181 |
|
189 | |||
182 | with repo.dirstate.parentchange(): |
|
190 | with repo.dirstate.parentchange(): | |
183 | _fixdirstate(repo, old, repo[newid], match) |
|
191 | _fixdirstate(repo, old, repo[newid], match) | |
184 |
|
192 | |||
185 | scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True) |
|
193 | scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True) | |
186 |
|
194 | |||
187 | def predecessormarkers(ctx): |
|
195 | def predecessormarkers(ctx): | |
188 | """yields the obsolete markers marking the given changeset as a successor""" |
|
196 | """yields the obsolete markers marking the given changeset as a successor""" | |
189 | for data in ctx.repo().obsstore.predecessors.get(ctx.node(), ()): |
|
197 | for data in ctx.repo().obsstore.predecessors.get(ctx.node(), ()): | |
190 | yield obsutil.marker(ctx.repo(), data) |
|
198 | yield obsutil.marker(ctx.repo(), data) | |
191 |
|
199 | |||
192 | @command('unamend', [], helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, |
|
200 | @command('unamend', [], helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, | |
193 | helpbasic=True) |
|
201 | helpbasic=True) | |
194 | def unamend(ui, repo, **opts): |
|
202 | def unamend(ui, repo, **opts): | |
195 | """undo the most recent amend operation on a current changeset |
|
203 | """undo the most recent amend operation on a current changeset | |
196 |
|
204 | |||
197 | This command will roll back to the previous version of a changeset, |
|
205 | This command will roll back to the previous version of a changeset, | |
198 | leaving working directory in state in which it was before running |
|
206 | leaving working directory in state in which it was before running | |
199 | `hg amend` (e.g. files modified as part of an amend will be |
|
207 | `hg amend` (e.g. files modified as part of an amend will be | |
200 | marked as modified `hg status`) |
|
208 | marked as modified `hg status`) | |
201 | """ |
|
209 | """ | |
202 |
|
210 | |||
203 | unfi = repo.unfiltered() |
|
211 | unfi = repo.unfiltered() | |
204 | with repo.wlock(), repo.lock(), repo.transaction('unamend'): |
|
212 | with repo.wlock(), repo.lock(), repo.transaction('unamend'): | |
205 |
|
213 | |||
206 | # identify the commit from which to unamend |
|
214 | # identify the commit from which to unamend | |
207 | curctx = repo['.'] |
|
215 | curctx = repo['.'] | |
208 |
|
216 | |||
209 | rewriteutil.precheck(repo, [curctx.rev()], 'unamend') |
|
217 | rewriteutil.precheck(repo, [curctx.rev()], 'unamend') | |
210 |
|
218 | |||
211 | # identify the commit to which to unamend |
|
219 | # identify the commit to which to unamend | |
212 | markers = list(predecessormarkers(curctx)) |
|
220 | markers = list(predecessormarkers(curctx)) | |
213 | if len(markers) != 1: |
|
221 | if len(markers) != 1: | |
214 | e = _("changeset must have one predecessor, found %i predecessors") |
|
222 | e = _("changeset must have one predecessor, found %i predecessors") | |
215 | raise error.Abort(e % len(markers)) |
|
223 | raise error.Abort(e % len(markers)) | |
216 |
|
224 | |||
217 | prednode = markers[0].prednode() |
|
225 | prednode = markers[0].prednode() | |
218 | predctx = unfi[prednode] |
|
226 | predctx = unfi[prednode] | |
219 |
|
227 | |||
220 | # add an extra so that we get a new hash |
|
228 | # add an extra so that we get a new hash | |
221 | # note: allowing unamend to undo an unamend is an intentional feature |
|
229 | # note: allowing unamend to undo an unamend is an intentional feature | |
222 | extras = predctx.extra() |
|
230 | extras = predctx.extra() | |
223 | extras['unamend_source'] = curctx.hex() |
|
231 | extras['unamend_source'] = curctx.hex() | |
224 |
|
232 | |||
225 | def filectxfn(repo, ctx_, path): |
|
233 | def filectxfn(repo, ctx_, path): | |
226 | try: |
|
234 | try: | |
227 | return predctx.filectx(path) |
|
235 | return predctx.filectx(path) | |
228 | except KeyError: |
|
236 | except KeyError: | |
229 | return None |
|
237 | return None | |
230 |
|
238 | |||
231 | # Make a new commit same as predctx |
|
239 | # Make a new commit same as predctx | |
232 | newctx = context.memctx(repo, |
|
240 | newctx = context.memctx(repo, | |
233 | parents=(predctx.p1(), predctx.p2()), |
|
241 | parents=(predctx.p1(), predctx.p2()), | |
234 | text=predctx.description(), |
|
242 | text=predctx.description(), | |
235 | files=predctx.files(), |
|
243 | files=predctx.files(), | |
236 | filectxfn=filectxfn, |
|
244 | filectxfn=filectxfn, | |
237 | user=predctx.user(), |
|
245 | user=predctx.user(), | |
238 | date=predctx.date(), |
|
246 | date=predctx.date(), | |
239 | extra=extras) |
|
247 | extra=extras) | |
240 | newprednode = repo.commitctx(newctx) |
|
248 | newprednode = repo.commitctx(newctx) | |
241 | newpredctx = repo[newprednode] |
|
249 | newpredctx = repo[newprednode] | |
242 | dirstate = repo.dirstate |
|
250 | dirstate = repo.dirstate | |
243 |
|
251 | |||
244 | with dirstate.parentchange(): |
|
252 | with dirstate.parentchange(): | |
245 | _fixdirstate(repo, curctx, newpredctx) |
|
253 | _fixdirstate(repo, curctx, newpredctx) | |
246 |
|
254 | |||
247 | mapping = {curctx.node(): (newprednode,)} |
|
255 | mapping = {curctx.node(): (newprednode,)} | |
248 | scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True) |
|
256 | scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True) |
@@ -1,443 +1,465 b'' | |||||
1 | Test uncommit - set up the config |
|
1 | Test uncommit - set up the config | |
2 |
|
2 | |||
3 | $ cat >> $HGRCPATH <<EOF |
|
3 | $ cat >> $HGRCPATH <<EOF | |
4 | > [experimental] |
|
4 | > [experimental] | |
5 | > evolution.createmarkers=True |
|
5 | > evolution.createmarkers=True | |
6 | > evolution.allowunstable=True |
|
6 | > evolution.allowunstable=True | |
7 | > [extensions] |
|
7 | > [extensions] | |
8 | > uncommit = |
|
8 | > uncommit = | |
9 | > drawdag=$TESTDIR/drawdag.py |
|
9 | > drawdag=$TESTDIR/drawdag.py | |
10 | > EOF |
|
10 | > EOF | |
11 |
|
11 | |||
12 | Build up a repo |
|
12 | Build up a repo | |
13 |
|
13 | |||
14 | $ hg init repo |
|
14 | $ hg init repo | |
15 | $ cd repo |
|
15 | $ cd repo | |
16 | $ hg bookmark foo |
|
16 | $ hg bookmark foo | |
17 |
|
17 | |||
18 | Help for uncommit |
|
18 | Help for uncommit | |
19 |
|
19 | |||
20 | $ hg help uncommit |
|
20 | $ hg help uncommit | |
21 | hg uncommit [OPTION]... [FILE]... |
|
21 | hg uncommit [OPTION]... [FILE]... | |
22 |
|
22 | |||
23 | uncommit part or all of a local changeset |
|
23 | uncommit part or all of a local changeset | |
24 |
|
24 | |||
25 | This command undoes the effect of a local commit, returning the affected |
|
25 | This command undoes the effect of a local commit, returning the affected | |
26 | files to their uncommitted state. This means that files modified or |
|
26 | files to their uncommitted state. This means that files modified or | |
27 | deleted in the changeset will be left unchanged, and so will remain |
|
27 | deleted in the changeset will be left unchanged, and so will remain | |
28 | modified in the working directory. |
|
28 | modified in the working directory. | |
29 |
|
29 | |||
30 | If no files are specified, the commit will be pruned, unless --keep is |
|
30 | If no files are specified, the commit will be pruned, unless --keep is | |
31 | given. |
|
31 | given. | |
32 |
|
32 | |||
33 | (use 'hg help -e uncommit' to show help for the uncommit extension) |
|
33 | (use 'hg help -e uncommit' to show help for the uncommit extension) | |
34 |
|
34 | |||
35 | options ([+] can be repeated): |
|
35 | options ([+] can be repeated): | |
36 |
|
36 | |||
37 | --keep allow an empty commit after uncommiting |
|
37 | --keep allow an empty commit after uncommiting | |
38 | -I --include PATTERN [+] include names matching the given patterns |
|
38 | -I --include PATTERN [+] include names matching the given patterns | |
39 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
39 | -X --exclude PATTERN [+] exclude names matching the given patterns | |
40 |
|
40 | |||
41 | (some details hidden, use --verbose to show complete help) |
|
41 | (some details hidden, use --verbose to show complete help) | |
42 |
|
42 | |||
43 | Uncommit with no commits should fail |
|
43 | Uncommit with no commits should fail | |
44 |
|
44 | |||
45 | $ hg uncommit |
|
45 | $ hg uncommit | |
46 | abort: cannot uncommit null changeset |
|
46 | abort: cannot uncommit null changeset | |
47 | (no changeset checked out) |
|
47 | (no changeset checked out) | |
48 | [255] |
|
48 | [255] | |
49 |
|
49 | |||
50 | Create some commits |
|
50 | Create some commits | |
51 |
|
51 | |||
52 | $ touch files |
|
52 | $ touch files | |
53 | $ hg add files |
|
53 | $ hg add files | |
54 | $ for i in a ab abc abcd abcde; do echo $i > files; echo $i > file-$i; hg add file-$i; hg commit -m "added file-$i"; done |
|
54 | $ for i in a ab abc abcd abcde; do echo $i > files; echo $i > file-$i; hg add file-$i; hg commit -m "added file-$i"; done | |
55 | $ ls |
|
55 | $ ls | |
56 | file-a |
|
56 | file-a | |
57 | file-ab |
|
57 | file-ab | |
58 | file-abc |
|
58 | file-abc | |
59 | file-abcd |
|
59 | file-abcd | |
60 | file-abcde |
|
60 | file-abcde | |
61 | files |
|
61 | files | |
62 |
|
62 | |||
63 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
63 | $ hg log -G -T '{rev}:{node} {desc}' --hidden | |
64 | @ 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde |
|
64 | @ 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde | |
65 | | |
|
65 | | | |
66 | o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd |
|
66 | o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd | |
67 | | |
|
67 | | | |
68 | o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc |
|
68 | o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc | |
69 | | |
|
69 | | | |
70 | o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab |
|
70 | o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab | |
71 | | |
|
71 | | | |
72 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a |
|
72 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a | |
73 |
|
73 | |||
74 | Simple uncommit off the top, also moves bookmark |
|
74 | Simple uncommit off the top, also moves bookmark | |
75 |
|
75 | |||
76 | $ hg bookmark |
|
76 | $ hg bookmark | |
77 | * foo 4:6c4fd43ed714 |
|
77 | * foo 4:6c4fd43ed714 | |
78 | $ hg uncommit |
|
78 | $ hg uncommit | |
79 | $ hg status |
|
79 | $ hg status | |
80 | M files |
|
80 | M files | |
81 | A file-abcde |
|
81 | A file-abcde | |
82 | $ hg bookmark |
|
82 | $ hg bookmark | |
83 | * foo 3:6db330d65db4 |
|
83 | * foo 3:6db330d65db4 | |
84 |
|
84 | |||
85 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
85 | $ hg log -G -T '{rev}:{node} {desc}' --hidden | |
86 | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde |
|
86 | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde | |
87 | | |
|
87 | | | |
88 | @ 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd |
|
88 | @ 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd | |
89 | | |
|
89 | | | |
90 | o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc |
|
90 | o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc | |
91 | | |
|
91 | | | |
92 | o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab |
|
92 | o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab | |
93 | | |
|
93 | | | |
94 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a |
|
94 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a | |
95 |
|
95 | |||
96 |
|
96 | |||
97 | Recommit |
|
97 | Recommit | |
98 |
|
98 | |||
99 | $ hg commit -m 'new change abcde' |
|
99 | $ hg commit -m 'new change abcde' | |
100 | $ hg status |
|
100 | $ hg status | |
101 | $ hg heads -T '{rev}:{node} {desc}' |
|
101 | $ hg heads -T '{rev}:{node} {desc}' | |
102 | 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde (no-eol) |
|
102 | 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde (no-eol) | |
103 |
|
103 | |||
104 | Uncommit of non-existent and unchanged files has no effect |
|
104 | Uncommit of non-existent and unchanged files has no effect | |
105 | $ hg uncommit nothinghere |
|
105 | $ hg uncommit nothinghere | |
106 | nothing to uncommit |
|
106 | nothing to uncommit | |
107 | [1] |
|
107 | [1] | |
108 | $ hg status |
|
108 | $ hg status | |
109 | $ hg uncommit file-abc |
|
109 | $ hg uncommit file-abc | |
110 | nothing to uncommit |
|
110 | nothing to uncommit | |
111 | [1] |
|
111 | [1] | |
112 | $ hg status |
|
112 | $ hg status | |
113 |
|
113 | |||
114 | Try partial uncommit, also moves bookmark |
|
114 | Try partial uncommit, also moves bookmark | |
115 |
|
115 | |||
116 | $ hg bookmark |
|
116 | $ hg bookmark | |
117 | * foo 5:0c07a3ccda77 |
|
117 | * foo 5:0c07a3ccda77 | |
118 | $ hg uncommit files |
|
118 | $ hg uncommit files | |
119 | $ hg status |
|
119 | $ hg status | |
120 | M files |
|
120 | M files | |
121 | $ hg bookmark |
|
121 | $ hg bookmark | |
122 | * foo 6:3727deee06f7 |
|
122 | * foo 6:3727deee06f7 | |
123 | $ hg heads -T '{rev}:{node} {desc}' |
|
123 | $ hg heads -T '{rev}:{node} {desc}' | |
124 | 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde (no-eol) |
|
124 | 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde (no-eol) | |
125 | $ hg log -r . -p -T '{rev}:{node} {desc}' |
|
125 | $ hg log -r . -p -T '{rev}:{node} {desc}' | |
126 | 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcdediff -r 6db330d65db4 -r 3727deee06f7 file-abcde |
|
126 | 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcdediff -r 6db330d65db4 -r 3727deee06f7 file-abcde | |
127 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
127 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
128 | +++ b/file-abcde Thu Jan 01 00:00:00 1970 +0000 |
|
128 | +++ b/file-abcde Thu Jan 01 00:00:00 1970 +0000 | |
129 | @@ -0,0 +1,1 @@ |
|
129 | @@ -0,0 +1,1 @@ | |
130 | +abcde |
|
130 | +abcde | |
131 |
|
131 | |||
132 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
132 | $ hg log -G -T '{rev}:{node} {desc}' --hidden | |
133 | @ 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde |
|
133 | @ 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde | |
134 | | |
|
134 | | | |
135 | | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde |
|
135 | | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde | |
136 | |/ |
|
136 | |/ | |
137 | | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde |
|
137 | | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde | |
138 | |/ |
|
138 | |/ | |
139 | o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd |
|
139 | o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd | |
140 | | |
|
140 | | | |
141 | o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc |
|
141 | o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc | |
142 | | |
|
142 | | | |
143 | o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab |
|
143 | o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab | |
144 | | |
|
144 | | | |
145 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a |
|
145 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a | |
146 |
|
146 | |||
147 | $ hg commit -m 'update files for abcde' |
|
147 | $ hg commit -m 'update files for abcde' | |
148 |
|
148 | |||
149 | Uncommit with dirty state |
|
149 | Uncommit with dirty state | |
150 |
|
150 | |||
151 | $ echo "foo" >> files |
|
151 | $ echo "foo" >> files | |
152 | $ cat files |
|
152 | $ cat files | |
153 | abcde |
|
153 | abcde | |
154 | foo |
|
154 | foo | |
155 | $ hg status |
|
155 | $ hg status | |
156 | M files |
|
156 | M files | |
157 | $ hg uncommit |
|
157 | $ hg uncommit | |
158 | abort: uncommitted changes |
|
158 | abort: uncommitted changes | |
159 | [255] |
|
159 | [255] | |
160 | $ hg uncommit files |
|
160 | $ hg uncommit files | |
161 | note: keeping empty commit |
|
161 | note: keeping empty commit | |
162 | $ cat files |
|
162 | $ cat files | |
163 | abcde |
|
163 | abcde | |
164 | foo |
|
164 | foo | |
165 | $ hg commit --amend -m "files abcde + foo" |
|
165 | $ hg commit --amend -m "files abcde + foo" | |
166 |
|
166 | |||
167 | Testing the 'experimental.uncommitondirtywdir' config |
|
167 | Testing the 'experimental.uncommitondirtywdir' config | |
168 |
|
168 | |||
169 | $ echo "bar" >> files |
|
169 | $ echo "bar" >> files | |
170 | $ hg uncommit |
|
170 | $ hg uncommit | |
171 | abort: uncommitted changes |
|
171 | abort: uncommitted changes | |
172 | [255] |
|
172 | [255] | |
173 | $ hg uncommit --config experimental.uncommitondirtywdir=True |
|
173 | $ hg uncommit --config experimental.uncommitondirtywdir=True | |
174 | $ hg commit -m "files abcde + foo" |
|
174 | $ hg commit -m "files abcde + foo" | |
175 |
|
175 | |||
176 | Uncommit in the middle of a stack, does not move bookmark |
|
176 | Uncommit in the middle of a stack, does not move bookmark | |
177 |
|
177 | |||
178 | $ hg checkout '.^^^' |
|
178 | $ hg checkout '.^^^' | |
179 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
179 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
180 | (leaving bookmark foo) |
|
180 | (leaving bookmark foo) | |
181 | $ hg log -r . -p -T '{rev}:{node} {desc}' |
|
181 | $ hg log -r . -p -T '{rev}:{node} {desc}' | |
182 | 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abcdiff -r 69a232e754b0 -r abf2df566fc1 file-abc |
|
182 | 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abcdiff -r 69a232e754b0 -r abf2df566fc1 file-abc | |
183 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
183 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
184 | +++ b/file-abc Thu Jan 01 00:00:00 1970 +0000 |
|
184 | +++ b/file-abc Thu Jan 01 00:00:00 1970 +0000 | |
185 | @@ -0,0 +1,1 @@ |
|
185 | @@ -0,0 +1,1 @@ | |
186 | +abc |
|
186 | +abc | |
187 | diff -r 69a232e754b0 -r abf2df566fc1 files |
|
187 | diff -r 69a232e754b0 -r abf2df566fc1 files | |
188 | --- a/files Thu Jan 01 00:00:00 1970 +0000 |
|
188 | --- a/files Thu Jan 01 00:00:00 1970 +0000 | |
189 | +++ b/files Thu Jan 01 00:00:00 1970 +0000 |
|
189 | +++ b/files Thu Jan 01 00:00:00 1970 +0000 | |
190 | @@ -1,1 +1,1 @@ |
|
190 | @@ -1,1 +1,1 @@ | |
191 | -ab |
|
191 | -ab | |
192 | +abc |
|
192 | +abc | |
193 |
|
193 | |||
194 | $ hg bookmark |
|
194 | $ hg bookmark | |
195 | foo 10:48e5bd7cd583 |
|
195 | foo 10:48e5bd7cd583 | |
196 | $ hg uncommit |
|
196 | $ hg uncommit | |
197 | 3 new orphan changesets |
|
197 | 3 new orphan changesets | |
198 | $ hg status |
|
198 | $ hg status | |
199 | M files |
|
199 | M files | |
200 | A file-abc |
|
200 | A file-abc | |
201 | $ hg heads -T '{rev}:{node} {desc}' |
|
201 | $ hg heads -T '{rev}:{node} {desc}' | |
202 | 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo (no-eol) |
|
202 | 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo (no-eol) | |
203 | $ hg bookmark |
|
203 | $ hg bookmark | |
204 | foo 10:48e5bd7cd583 |
|
204 | foo 10:48e5bd7cd583 | |
205 | $ hg commit -m 'new abc' |
|
205 | $ hg commit -m 'new abc' | |
206 | created new head |
|
206 | created new head | |
207 |
|
207 | |||
208 | Partial uncommit in the middle, does not move bookmark |
|
208 | Partial uncommit in the middle, does not move bookmark | |
209 |
|
209 | |||
210 | $ hg checkout '.^' |
|
210 | $ hg checkout '.^' | |
211 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
211 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
212 | $ hg log -r . -p -T '{rev}:{node} {desc}' |
|
212 | $ hg log -r . -p -T '{rev}:{node} {desc}' | |
213 | 1:69a232e754b08d568c4899475faf2eb44b857802 added file-abdiff -r 3004d2d9b508 -r 69a232e754b0 file-ab |
|
213 | 1:69a232e754b08d568c4899475faf2eb44b857802 added file-abdiff -r 3004d2d9b508 -r 69a232e754b0 file-ab | |
214 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
214 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
215 | +++ b/file-ab Thu Jan 01 00:00:00 1970 +0000 |
|
215 | +++ b/file-ab Thu Jan 01 00:00:00 1970 +0000 | |
216 | @@ -0,0 +1,1 @@ |
|
216 | @@ -0,0 +1,1 @@ | |
217 | +ab |
|
217 | +ab | |
218 | diff -r 3004d2d9b508 -r 69a232e754b0 files |
|
218 | diff -r 3004d2d9b508 -r 69a232e754b0 files | |
219 | --- a/files Thu Jan 01 00:00:00 1970 +0000 |
|
219 | --- a/files Thu Jan 01 00:00:00 1970 +0000 | |
220 | +++ b/files Thu Jan 01 00:00:00 1970 +0000 |
|
220 | +++ b/files Thu Jan 01 00:00:00 1970 +0000 | |
221 | @@ -1,1 +1,1 @@ |
|
221 | @@ -1,1 +1,1 @@ | |
222 | -a |
|
222 | -a | |
223 | +ab |
|
223 | +ab | |
224 |
|
224 | |||
225 | $ hg bookmark |
|
225 | $ hg bookmark | |
226 | foo 10:48e5bd7cd583 |
|
226 | foo 10:48e5bd7cd583 | |
227 | $ hg uncommit file-ab |
|
227 | $ hg uncommit file-ab | |
228 | 1 new orphan changesets |
|
228 | 1 new orphan changesets | |
229 | $ hg status |
|
229 | $ hg status | |
230 | A file-ab |
|
230 | A file-ab | |
231 |
|
231 | |||
232 | $ hg heads -T '{rev}:{node} {desc}\n' |
|
232 | $ hg heads -T '{rev}:{node} {desc}\n' | |
233 | 12:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab |
|
233 | 12:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab | |
234 | 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc |
|
234 | 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | |
235 | 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo |
|
235 | 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo | |
236 |
|
236 | |||
237 | $ hg bookmark |
|
237 | $ hg bookmark | |
238 | foo 10:48e5bd7cd583 |
|
238 | foo 10:48e5bd7cd583 | |
239 | $ hg commit -m 'update ab' |
|
239 | $ hg commit -m 'update ab' | |
240 | $ hg status |
|
240 | $ hg status | |
241 | $ hg heads -T '{rev}:{node} {desc}\n' |
|
241 | $ hg heads -T '{rev}:{node} {desc}\n' | |
242 | 13:f21039c59242b085491bb58f591afc4ed1c04c09 update ab |
|
242 | 13:f21039c59242b085491bb58f591afc4ed1c04c09 update ab | |
243 | 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc |
|
243 | 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | |
244 | 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo |
|
244 | 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo | |
245 |
|
245 | |||
246 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
246 | $ hg log -G -T '{rev}:{node} {desc}' --hidden | |
247 | @ 13:f21039c59242b085491bb58f591afc4ed1c04c09 update ab |
|
247 | @ 13:f21039c59242b085491bb58f591afc4ed1c04c09 update ab | |
248 | | |
|
248 | | | |
249 | o 12:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab |
|
249 | o 12:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab | |
250 | | |
|
250 | | | |
251 | | * 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc |
|
251 | | * 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | |
252 | | | |
|
252 | | | | |
253 | | | * 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo |
|
253 | | | * 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo | |
254 | | | | |
|
254 | | | | | |
255 | | | | x 9:8a6b58c173ca6a2e3745d8bd86698718d664bc6c files abcde + foo |
|
255 | | | | x 9:8a6b58c173ca6a2e3745d8bd86698718d664bc6c files abcde + foo | |
256 | | | |/ |
|
256 | | | |/ | |
257 | | | | x 8:39ad452c7f684a55d161c574340c5766c4569278 update files for abcde |
|
257 | | | | x 8:39ad452c7f684a55d161c574340c5766c4569278 update files for abcde | |
258 | | | |/ |
|
258 | | | |/ | |
259 | | | | x 7:0977fa602c2fd7d8427ed4e7ee15ea13b84c9173 update files for abcde |
|
259 | | | | x 7:0977fa602c2fd7d8427ed4e7ee15ea13b84c9173 update files for abcde | |
260 | | | |/ |
|
260 | | | |/ | |
261 | | | * 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde |
|
261 | | | * 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde | |
262 | | | | |
|
262 | | | | | |
263 | | | | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde |
|
263 | | | | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde | |
264 | | | |/ |
|
264 | | | |/ | |
265 | | | | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde |
|
265 | | | | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde | |
266 | | | |/ |
|
266 | | | |/ | |
267 | | | * 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd |
|
267 | | | * 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd | |
268 | | | | |
|
268 | | | | | |
269 | | | x 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc |
|
269 | | | x 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc | |
270 | | |/ |
|
270 | | |/ | |
271 | | x 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab |
|
271 | | x 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab | |
272 | |/ |
|
272 | |/ | |
273 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a |
|
273 | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a | |
274 |
|
274 | |||
275 | Uncommit with draft parent |
|
275 | Uncommit with draft parent | |
276 |
|
276 | |||
277 | $ hg uncommit |
|
277 | $ hg uncommit | |
278 | $ hg phase -r . |
|
278 | $ hg phase -r . | |
279 | 12: draft |
|
279 | 12: draft | |
280 | $ hg commit -m 'update ab again' |
|
280 | $ hg commit -m 'update ab again' | |
281 |
|
281 | |||
282 | Phase is preserved |
|
282 | Phase is preserved | |
283 |
|
283 | |||
284 | $ hg uncommit --keep --config phases.new-commit=secret |
|
284 | $ hg uncommit --keep --config phases.new-commit=secret | |
285 | note: keeping empty commit |
|
285 | note: keeping empty commit | |
286 | $ hg phase -r . |
|
286 | $ hg phase -r . | |
287 | 15: draft |
|
287 | 15: draft | |
288 | $ hg commit --amend -m 'update ab again' |
|
288 | $ hg commit --amend -m 'update ab again' | |
289 |
|
289 | |||
290 | Uncommit with public parent |
|
290 | Uncommit with public parent | |
291 |
|
291 | |||
292 | $ hg phase -p "::.^" |
|
292 | $ hg phase -p "::.^" | |
293 | $ hg uncommit |
|
293 | $ hg uncommit | |
294 | $ hg phase -r . |
|
294 | $ hg phase -r . | |
295 | 12: public |
|
295 | 12: public | |
296 |
|
296 | |||
297 | Partial uncommit with public parent |
|
297 | Partial uncommit with public parent | |
298 |
|
298 | |||
299 | $ echo xyz > xyz |
|
299 | $ echo xyz > xyz | |
300 | $ hg add xyz |
|
300 | $ hg add xyz | |
301 | $ hg commit -m "update ab and add xyz" |
|
301 | $ hg commit -m "update ab and add xyz" | |
302 | $ hg uncommit xyz |
|
302 | $ hg uncommit xyz | |
303 | $ hg status |
|
303 | $ hg status | |
304 | A xyz |
|
304 | A xyz | |
305 | $ hg phase -r . |
|
305 | $ hg phase -r . | |
306 | 18: draft |
|
306 | 18: draft | |
307 | $ hg phase -r ".^" |
|
307 | $ hg phase -r ".^" | |
308 | 12: public |
|
308 | 12: public | |
309 |
|
309 | |||
310 | Uncommit leaving an empty changeset |
|
310 | Uncommit with --keep or experimental.uncommit.keep leaves an empty changeset | |
311 |
|
311 | |||
312 | $ cd $TESTTMP |
|
312 | $ cd $TESTTMP | |
313 | $ hg init repo1 |
|
313 | $ hg init repo1 | |
314 | $ cd repo1 |
|
314 | $ cd repo1 | |
315 | $ hg debugdrawdag <<'EOS' |
|
315 | $ hg debugdrawdag <<'EOS' | |
316 | > Q |
|
316 | > Q | |
317 | > | |
|
317 | > | | |
318 | > P |
|
318 | > P | |
319 | > EOS |
|
319 | > EOS | |
320 | $ hg up Q -q |
|
320 | $ hg up Q -q | |
321 | $ hg uncommit --keep |
|
321 | $ hg uncommit --keep | |
322 | note: keeping empty commit |
|
322 | note: keeping empty commit | |
323 | $ hg log -G -T '{desc} FILES: {files}' |
|
323 | $ hg log -G -T '{desc} FILES: {files}' | |
324 | @ Q FILES: |
|
324 | @ Q FILES: | |
325 | | |
|
325 | | | |
326 | | x Q FILES: Q |
|
326 | | x Q FILES: Q | |
327 | |/ |
|
327 | |/ | |
328 | o P FILES: P |
|
328 | o P FILES: P | |
329 |
|
329 | |||
|
330 | $ cat >> .hg/hgrc <<EOF | |||
|
331 | > [experimental] | |||
|
332 | > uncommit.keep=True | |||
|
333 | > EOF | |||
|
334 | $ hg ci --amend | |||
|
335 | $ hg uncommit | |||
|
336 | note: keeping empty commit | |||
|
337 | $ hg log -G -T '{desc} FILES: {files}' | |||
|
338 | @ Q FILES: | |||
|
339 | | | |||
|
340 | | x Q FILES: Q | |||
|
341 | |/ | |||
|
342 | o P FILES: P | |||
|
343 | ||||
330 | $ hg status |
|
344 | $ hg status | |
331 | A Q |
|
345 | A Q | |
332 |
|
346 | $ hg ci --amend | ||
|
347 | $ hg uncommit --no-keep | |||
|
348 | $ hg log -G -T '{desc} FILES: {files}' | |||
|
349 | x Q FILES: Q | |||
|
350 | | | |||
|
351 | @ P FILES: P | |||
|
352 | ||||
|
353 | $ hg status | |||
|
354 | A Q | |||
333 | $ cd .. |
|
355 | $ cd .. | |
334 | $ rm -rf repo1 |
|
356 | $ rm -rf repo1 | |
335 |
|
357 | |||
336 | Testing uncommit while merge |
|
358 | Testing uncommit while merge | |
337 |
|
359 | |||
338 | $ hg init repo2 |
|
360 | $ hg init repo2 | |
339 | $ cd repo2 |
|
361 | $ cd repo2 | |
340 |
|
362 | |||
341 | Create some history |
|
363 | Create some history | |
342 |
|
364 | |||
343 | $ touch a |
|
365 | $ touch a | |
344 | $ hg add a |
|
366 | $ hg add a | |
345 | $ for i in 1 2 3; do echo $i > a; hg commit -m "a $i"; done |
|
367 | $ for i in 1 2 3; do echo $i > a; hg commit -m "a $i"; done | |
346 | $ hg checkout 0 |
|
368 | $ hg checkout 0 | |
347 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
369 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
348 | $ touch b |
|
370 | $ touch b | |
349 | $ hg add b |
|
371 | $ hg add b | |
350 |
$ for i in 1 2 3; |
|
372 | $ for i in 1 2 3; do echo $i > b; hg commit -m "b $i"; done | |
351 | created new head |
|
373 | created new head | |
352 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
374 | $ hg log -G -T '{rev}:{node} {desc}' --hidden | |
353 | @ 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3 |
|
375 | @ 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3 | |
354 | | |
|
376 | | | |
355 | o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2 |
|
377 | o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2 | |
356 | | |
|
378 | | | |
357 | o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1 |
|
379 | o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1 | |
358 | | |
|
380 | | | |
359 | | o 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3 |
|
381 | | o 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3 | |
360 | | | |
|
382 | | | | |
361 | | o 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2 |
|
383 | | o 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2 | |
362 | |/ |
|
384 | |/ | |
363 | o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1 |
|
385 | o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1 | |
364 |
|
386 | |||
365 |
|
387 | |||
366 | Add and expect uncommit to fail on both merge working dir and merge changeset |
|
388 | Add and expect uncommit to fail on both merge working dir and merge changeset | |
367 |
|
389 | |||
368 | $ hg merge 2 |
|
390 | $ hg merge 2 | |
369 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
391 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
370 | (branch merge, don't forget to commit) |
|
392 | (branch merge, don't forget to commit) | |
371 |
|
393 | |||
372 | $ hg uncommit |
|
394 | $ hg uncommit | |
373 | abort: outstanding uncommitted merge |
|
395 | abort: outstanding uncommitted merge | |
374 | [255] |
|
396 | [255] | |
375 |
|
397 | |||
376 | $ hg uncommit --config experimental.uncommitondirtywdir=True |
|
398 | $ hg uncommit --config experimental.uncommitondirtywdir=True | |
377 | abort: cannot uncommit while merging |
|
399 | abort: cannot uncommit while merging | |
378 | [255] |
|
400 | [255] | |
379 |
|
401 | |||
380 | $ hg status |
|
402 | $ hg status | |
381 | M a |
|
403 | M a | |
382 | $ hg commit -m 'merge a and b' |
|
404 | $ hg commit -m 'merge a and b' | |
383 |
|
405 | |||
384 | $ hg uncommit |
|
406 | $ hg uncommit | |
385 | abort: cannot uncommit merge changeset |
|
407 | abort: cannot uncommit merge changeset | |
386 | [255] |
|
408 | [255] | |
387 |
|
409 | |||
388 | $ hg status |
|
410 | $ hg status | |
389 | $ hg log -G -T '{rev}:{node} {desc}' --hidden |
|
411 | $ hg log -G -T '{rev}:{node} {desc}' --hidden | |
390 | @ 6:c03b9c37bc67bf504d4912061cfb527b47a63c6e merge a and b |
|
412 | @ 6:c03b9c37bc67bf504d4912061cfb527b47a63c6e merge a and b | |
391 | |\ |
|
413 | |\ | |
392 | | o 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3 |
|
414 | | o 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3 | |
393 | | | |
|
415 | | | | |
394 | | o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2 |
|
416 | | o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2 | |
395 | | | |
|
417 | | | | |
396 | | o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1 |
|
418 | | o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1 | |
397 | | | |
|
419 | | | | |
398 | o | 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3 |
|
420 | o | 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3 | |
399 | | | |
|
421 | | | | |
400 | o | 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2 |
|
422 | o | 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2 | |
401 | |/ |
|
423 | |/ | |
402 | o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1 |
|
424 | o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1 | |
403 |
|
425 | |||
404 |
|
426 | |||
405 | Rename a->b, then remove b in working copy. Result should remove a. |
|
427 | Rename a->b, then remove b in working copy. Result should remove a. | |
406 |
|
428 | |||
407 | $ hg co -q 0 |
|
429 | $ hg co -q 0 | |
408 | $ hg mv a b |
|
430 | $ hg mv a b | |
409 | $ hg ci -qm 'move a to b' |
|
431 | $ hg ci -qm 'move a to b' | |
410 | $ hg rm b |
|
432 | $ hg rm b | |
411 | $ hg uncommit --config experimental.uncommitondirtywdir=True |
|
433 | $ hg uncommit --config experimental.uncommitondirtywdir=True | |
412 | $ hg st --copies |
|
434 | $ hg st --copies | |
413 | R a |
|
435 | R a | |
414 | $ hg revert a |
|
436 | $ hg revert a | |
415 |
|
437 | |||
416 | Rename a->b, then rename b->c in working copy. Result should rename a->c. |
|
438 | Rename a->b, then rename b->c in working copy. Result should rename a->c. | |
417 |
|
439 | |||
418 | $ hg co -q 0 |
|
440 | $ hg co -q 0 | |
419 | $ hg mv a b |
|
441 | $ hg mv a b | |
420 | $ hg ci -qm 'move a to b' |
|
442 | $ hg ci -qm 'move a to b' | |
421 | $ hg mv b c |
|
443 | $ hg mv b c | |
422 | $ hg uncommit --config experimental.uncommitondirtywdir=True |
|
444 | $ hg uncommit --config experimental.uncommitondirtywdir=True | |
423 | $ hg st --copies |
|
445 | $ hg st --copies | |
424 | A c |
|
446 | A c | |
425 | a |
|
447 | a | |
426 | R a |
|
448 | R a | |
427 | $ hg revert a |
|
449 | $ hg revert a | |
428 | $ hg forget c |
|
450 | $ hg forget c | |
429 | $ rm c |
|
451 | $ rm c | |
430 |
|
452 | |||
431 | Copy a->b1 and a->b2, then rename b1->c in working copy. Result should copy a->b2 and a->c. |
|
453 | Copy a->b1 and a->b2, then rename b1->c in working copy. Result should copy a->b2 and a->c. | |
432 |
|
454 | |||
433 | $ hg co -q 0 |
|
455 | $ hg co -q 0 | |
434 | $ hg cp a b1 |
|
456 | $ hg cp a b1 | |
435 | $ hg cp a b2 |
|
457 | $ hg cp a b2 | |
436 | $ hg ci -qm 'move a to b1 and b2' |
|
458 | $ hg ci -qm 'move a to b1 and b2' | |
437 | $ hg mv b1 c |
|
459 | $ hg mv b1 c | |
438 | $ hg uncommit --config experimental.uncommitondirtywdir=True |
|
460 | $ hg uncommit --config experimental.uncommitondirtywdir=True | |
439 | $ hg st --copies |
|
461 | $ hg st --copies | |
440 | A b2 |
|
462 | A b2 | |
441 | a |
|
463 | a | |
442 | A c |
|
464 | A c | |
443 | a |
|
465 | a |
General Comments 0
You need to be logged in to leave comments.
Login now