Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 15194:0705f2ac79d6
import: simplify status reporting logic (and make it more I18N-friendly)
The old code printed (with ui.status()) the changeset ID created by
patch N after committing patch N+1, e.g.
applying patch1
applying patch2
applied 1d4bd90af0e4
where 1d4bd90af0e4 is the changeset ID resulting from patch1. That's
just weird. It's also inconsistent: we only reported the changeset ID
when applying >1 patches. And it's inconsistent with 'commit', which
only tells you the new changeset ID in verbose mode. Finally, the
existing code was I18N-hostile, since it concatenated translated
strings.
The new way is to print the just-created changeset ID with ui.note()
immediately after committing it. It also clarifies what the user
message is for easier I18N.
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Sat, 01 Oct 2011 21:30:49 -0400 |
parents | 3834ca04664a |
children | 5b2a3bb06cef |
comparison
equal
deleted
inserted
replaced
15193:a84e3ed661cb | 15194:0705f2ac79d6 |
---|---|
3274 def tryone(ui, hunk, parents): | 3274 def tryone(ui, hunk, parents): |
3275 tmpname, message, user, date, branch, nodeid, p1, p2 = \ | 3275 tmpname, message, user, date, branch, nodeid, p1, p2 = \ |
3276 patch.extract(ui, hunk) | 3276 patch.extract(ui, hunk) |
3277 | 3277 |
3278 if not tmpname: | 3278 if not tmpname: |
3279 return None | 3279 return (None, None) |
3280 commitid = _('to working directory') | 3280 msg = _('applied to working directory') |
3281 | 3281 |
3282 try: | 3282 try: |
3283 cmdline_message = cmdutil.logmessage(ui, opts) | 3283 cmdline_message = cmdutil.logmessage(ui, opts) |
3284 if cmdline_message: | 3284 if cmdline_message: |
3285 # pickup the cmdline msg | 3285 # pickup the cmdline msg |
3360 n = memctx.commit() | 3360 n = memctx.commit() |
3361 checkexact(repo, n, nodeid) | 3361 checkexact(repo, n, nodeid) |
3362 finally: | 3362 finally: |
3363 store.close() | 3363 store.close() |
3364 if n: | 3364 if n: |
3365 commitid = short(n) | 3365 msg = _('created %s') % short(n) |
3366 return commitid | 3366 return (msg, n) |
3367 finally: | 3367 finally: |
3368 os.unlink(tmpname) | 3368 os.unlink(tmpname) |
3369 | 3369 |
3370 try: | 3370 try: |
3371 wlock = repo.wlock() | 3371 wlock = repo.wlock() |
3372 lock = repo.lock() | 3372 lock = repo.lock() |
3373 parents = repo.parents() | 3373 parents = repo.parents() |
3374 lastcommit = None | |
3375 for p in patches: | 3374 for p in patches: |
3376 pf = os.path.join(d, p) | 3375 pf = os.path.join(d, p) |
3377 | 3376 |
3378 if pf == '-': | 3377 if pf == '-': |
3379 ui.status(_("applying patch from stdin\n")) | 3378 ui.status(_("applying patch from stdin\n")) |
3382 ui.status(_("applying %s\n") % p) | 3381 ui.status(_("applying %s\n") % p) |
3383 pf = url.open(ui, pf) | 3382 pf = url.open(ui, pf) |
3384 | 3383 |
3385 haspatch = False | 3384 haspatch = False |
3386 for hunk in patch.split(pf): | 3385 for hunk in patch.split(pf): |
3387 commitid = tryone(ui, hunk, parents) | 3386 (msg, node) = tryone(ui, hunk, parents) |
3388 if commitid: | 3387 if msg: |
3389 haspatch = True | 3388 haspatch = True |
3390 if lastcommit: | 3389 ui.note(msg + '\n') |
3391 ui.status(_('applied %s\n') % lastcommit) | |
3392 lastcommit = commitid | |
3393 if update or opts.get('exact'): | 3390 if update or opts.get('exact'): |
3394 parents = repo.parents() | 3391 parents = repo.parents() |
3395 else: | 3392 else: |
3396 parents = [repo[commitid]] | 3393 parents = [repo[node]] |
3397 | 3394 |
3398 if not haspatch: | 3395 if not haspatch: |
3399 raise util.Abort(_('no diffs found')) | 3396 raise util.Abort(_('no diffs found')) |
3400 | 3397 |
3401 if msgs: | 3398 if msgs: |