##// END OF EJS Templates
uncommit: add support to modify the commit message and date...
Matt Harbison -
r43557:ff1ff2aa default
parent child Browse files
Show More
@@ -55,7 +55,8 b" configitem('experimental', 'uncommit.kee"
55 55 # leave the attribute unspecified.
56 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 60 """Recommit ctx with changed files not in match. Return the new
60 61 node identifier, or None if nothing changed.
61 62 """
@@ -90,13 +91,20 b' def _commitfiltered(repo, ctx, match, ke'
90 91 if not files:
91 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 101 new = context.memctx(repo,
94 102 parents=[base.node(), node.nullid],
95 text=ctx.description(),
103 text=message,
96 104 files=files,
97 105 filectxfn=filectxfn,
98 user=ctx.user(),
99 date=ctx.date(),
106 user=user,
107 date=date,
100 108 extra=ctx.extra())
101 109 return repo.commitctx(new)
102 110
@@ -104,7 +112,7 b' def _commitfiltered(repo, ctx, match, ke'
104 112 [('', 'keep', None, _('allow an empty commit after uncommiting')),
105 113 ('', 'allow-dirty-working-copy', False,
106 114 _('allow uncommit with outstanding changes'))
107 ] + commands.walkopts,
115 ] + commands.walkopts + commands.commitopts + commands.commitopts2,
108 116 _('[OPTION]... [FILE]...'),
109 117 helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
110 118 def uncommit(ui, repo, *pats, **opts):
@@ -162,13 +170,19 b' def uncommit(ui, repo, *pats, **opts):'
162 170 % scmutil.getuipathfn(repo)(f), hint=hint)
163 171
164 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 177 keepcommit = pats
166 178 if not keepcommit:
167 179 if opts.get('keep') is not None:
168 180 keepcommit = opts.get('keep')
169 181 else:
170 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 186 if newid is None:
173 187 ui.status(_("nothing to uncommit\n"))
174 188 return 1
@@ -38,6 +38,10 b' Help for uncommit'
38 38 --allow-dirty-working-copy allow uncommit with outstanding changes
39 39 -I --include PATTERN [+] include names matching the given patterns
40 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 46 (some details hidden, use --verbose to show complete help)
43 47
@@ -531,9 +535,18 b' can be uncommitted.'
531 535 $ mkdir dir
532 536 $ echo 1 > dir/file.txt
533 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 540 $ hg status
536 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 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