Show More
@@ -55,7 +55,8 b" configitem('experimental', 'uncommit.kee" | |||||
55 | # leave the attribute unspecified. |
|
55 | # leave the attribute unspecified. | |
56 | testedwith = 'ships-with-hg-core' |
|
56 | testedwith = 'ships-with-hg-core' | |
57 |
|
57 | |||
58 |
def _commitfiltered(repo, ctx, match, keepcommit |
|
58 | def _commitfiltered(repo, ctx, match, keepcommit, message=None, user=None, | |
|
59 | date=None): | |||
59 | """Recommit ctx with changed files not in match. Return the new |
|
60 | """Recommit ctx with changed files not in match. Return the new | |
60 | node identifier, or None if nothing changed. |
|
61 | node identifier, or None if nothing changed. | |
61 | """ |
|
62 | """ | |
@@ -90,13 +91,20 b' def _commitfiltered(repo, ctx, match, ke' | |||||
90 | if not files: |
|
91 | if not files: | |
91 | repo.ui.status(_("note: keeping empty commit\n")) |
|
92 | repo.ui.status(_("note: keeping empty commit\n")) | |
92 |
|
93 | |||
|
94 | if message is None: | |||
|
95 | message = ctx.description() | |||
|
96 | if not user: | |||
|
97 | user = ctx.user() | |||
|
98 | if not date: | |||
|
99 | date = ctx.date() | |||
|
100 | ||||
93 | new = context.memctx(repo, |
|
101 | new = context.memctx(repo, | |
94 | parents=[base.node(), node.nullid], |
|
102 | parents=[base.node(), node.nullid], | |
95 |
text= |
|
103 | text=message, | |
96 | files=files, |
|
104 | files=files, | |
97 | filectxfn=filectxfn, |
|
105 | filectxfn=filectxfn, | |
98 |
user= |
|
106 | user=user, | |
99 |
date= |
|
107 | date=date, | |
100 | extra=ctx.extra()) |
|
108 | extra=ctx.extra()) | |
101 | return repo.commitctx(new) |
|
109 | return repo.commitctx(new) | |
102 |
|
110 | |||
@@ -104,7 +112,7 b' def _commitfiltered(repo, ctx, match, ke' | |||||
104 | [('', 'keep', None, _('allow an empty commit after uncommiting')), |
|
112 | [('', 'keep', None, _('allow an empty commit after uncommiting')), | |
105 | ('', 'allow-dirty-working-copy', False, |
|
113 | ('', 'allow-dirty-working-copy', False, | |
106 | _('allow uncommit with outstanding changes')) |
|
114 | _('allow uncommit with outstanding changes')) | |
107 | ] + commands.walkopts, |
|
115 | ] + commands.walkopts + commands.commitopts + commands.commitopts2, | |
108 | _('[OPTION]... [FILE]...'), |
|
116 | _('[OPTION]... [FILE]...'), | |
109 | helpcategory=command.CATEGORY_CHANGE_MANAGEMENT) |
|
117 | helpcategory=command.CATEGORY_CHANGE_MANAGEMENT) | |
110 | def uncommit(ui, repo, *pats, **opts): |
|
118 | def uncommit(ui, repo, *pats, **opts): | |
@@ -162,13 +170,19 b' def uncommit(ui, repo, *pats, **opts):' | |||||
162 | % scmutil.getuipathfn(repo)(f), hint=hint) |
|
170 | % scmutil.getuipathfn(repo)(f), hint=hint) | |
163 |
|
171 | |||
164 | with repo.transaction('uncommit'): |
|
172 | with repo.transaction('uncommit'): | |
|
173 | if not (opts[b'message'] or opts[b'logfile']): | |||
|
174 | opts[b'message'] = old.description() | |||
|
175 | message = cmdutil.logmessage(ui, pycompat.byteskwargs(opts)) | |||
|
176 | ||||
165 | keepcommit = pats |
|
177 | keepcommit = pats | |
166 | if not keepcommit: |
|
178 | if not keepcommit: | |
167 | if opts.get('keep') is not None: |
|
179 | if opts.get('keep') is not None: | |
168 | keepcommit = opts.get('keep') |
|
180 | keepcommit = opts.get('keep') | |
169 | else: |
|
181 | else: | |
170 | keepcommit = ui.configbool('experimental', 'uncommit.keep') |
|
182 | keepcommit = ui.configbool('experimental', 'uncommit.keep') | |
171 |
newid = _commitfiltered(repo, old, match, keepcommit |
|
183 | newid = _commitfiltered(repo, old, match, keepcommit, | |
|
184 | message=message, user=opts.get(b'user'), | |||
|
185 | date=opts.get(b'date')) | |||
172 | if newid is None: |
|
186 | if newid is None: | |
173 | ui.status(_("nothing to uncommit\n")) |
|
187 | ui.status(_("nothing to uncommit\n")) | |
174 | return 1 |
|
188 | return 1 |
@@ -38,6 +38,10 b' Help for uncommit' | |||||
38 | --allow-dirty-working-copy allow uncommit with outstanding changes |
|
38 | --allow-dirty-working-copy allow uncommit with outstanding changes | |
39 | -I --include PATTERN [+] include names matching the given patterns |
|
39 | -I --include PATTERN [+] include names matching the given patterns | |
40 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
40 | -X --exclude PATTERN [+] exclude names matching the given patterns | |
|
41 | -m --message TEXT use text as commit message | |||
|
42 | -l --logfile FILE read commit message from file | |||
|
43 | -d --date DATE record the specified date as commit date | |||
|
44 | -u --user USER record the specified user as committer | |||
41 |
|
45 | |||
42 | (some details hidden, use --verbose to show complete help) |
|
46 | (some details hidden, use --verbose to show complete help) | |
43 |
|
47 | |||
@@ -531,9 +535,18 b' can be uncommitted.' | |||||
531 | $ mkdir dir |
|
535 | $ mkdir dir | |
532 | $ echo 1 > dir/file.txt |
|
536 | $ echo 1 > dir/file.txt | |
533 | $ hg ci -Aqm 'add file in directory' |
|
537 | $ hg ci -Aqm 'add file in directory' | |
534 | $ hg uncommit dir |
|
538 | $ hg uncommit dir -m 'uncommit with message' -u 'different user' \ | |
|
539 | > -d 'Jun 30 12:12:12 1980 +0000' | |||
535 | $ hg status |
|
540 | $ hg status | |
536 | A dir/file.txt |
|
541 | A dir/file.txt | |
|
542 | $ hg log -r . | |||
|
543 | changeset: 8:b4dd26dc42e0 | |||
|
544 | tag: tip | |||
|
545 | parent: 6:2278a4c24330 | |||
|
546 | user: different user | |||
|
547 | date: Mon Jun 30 12:12:12 1980 +0000 | |||
|
548 | summary: uncommit with message | |||
|
549 | ||||
537 |
|
550 | |||
538 | `uncommit <dir>` and `cd <dir> && uncommit .` behave the same... |
|
551 | `uncommit <dir>` and `cd <dir> && uncommit .` behave the same... | |
539 |
|
552 |
General Comments 0
You need to be logged in to leave comments.
Login now