Re: [PATCH 1 of 2] merge: use labels in prompts to the user

2016-08-15 Thread FUJIWARA Katsunori
At Sun, 14 Aug 2016 10:08:20 +0900,
Yuya Nishihara wrote:
> 
> On Sat, 13 Aug 2016 21:54:11 +0900, FUJIWARA Katsunori wrote:
> > Making labels more descriptive would resolve this problem (e.g.
> > "destination revision" instead of "destination"). But it makes
> > prompting message in English very redundant, doesn't it ?
> > 
> > Or introducing "gettext with context" ? :-)
> > 
> >   # i18n: "destination" at merging. omit after "@" at translation
> >   l10ntext = _c('destination@merging')
> >   # _c() returns "destination", if there is no translation
> >   # corresponded to "destination@merging" msgid
> 
> You can specify msgctxt by 2nd argument of _() for example, and pass
> "--keyword=_:1,2c" or "--keyword=_:1,2c,2t" to xgettext to collect them.
> 
> https://developer.mozilla.org/en-US/docs/gettext#Using_context_with_msgctxt
> https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/xgettext-Invocation.html
> 
> msgctxt is concatenated with '\004'.
> 
> https://github.com/django/django/blob/master/django/utils/translation/trans_real.py#L346
> 

Oh, thank you for information !

I'll work for "gettext with context".

--
[FUJIWARA Katsunori] fo...@lares.dti.ne.jp
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 2] merge: use labels in prompts to the user

2016-08-13 Thread Yuya Nishihara
On Sat, 13 Aug 2016 21:54:11 +0900, FUJIWARA Katsunori wrote:
> Making labels more descriptive would resolve this problem (e.g.
> "destination revision" instead of "destination"). But it makes
> prompting message in English very redundant, doesn't it ?
> 
> Or introducing "gettext with context" ? :-)
> 
>   # i18n: "destination" at merging. omit after "@" at translation
>   l10ntext = _c('destination@merging')
>   # _c() returns "destination", if there is no translation
>   # corresponded to "destination@merging" msgid

You can specify msgctxt by 2nd argument of _() for example, and pass
"--keyword=_:1,2c" or "--keyword=_:1,2c,2t" to xgettext to collect them.

https://developer.mozilla.org/en-US/docs/gettext#Using_context_with_msgctxt
https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/xgettext-Invocation.html

msgctxt is concatenated with '\004'.

https://github.com/django/django/blob/master/django/utils/translation/trans_real.py#L346
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2] merge: use labels in prompts to the user

2016-08-12 Thread Simon Farnsworth
# HG changeset patch
# User Simon Farnsworth 
# Date 1471006902 25200
#  Fri Aug 12 06:01:42 2016 -0700
# Node ID 6d3af00243808b1be9f27a5545be0fce0e43d1f2
# Parent  37b6f0ec6241a62de90737409458cd622e2fac0d
merge: use labels in prompts to the user

Now that we persist the labels, we can consistently use the labels in
prompts for the user without risk of confusion. This changes a huge amount
of command output:

This means that merge prompts like:
  no tool found to merge a
  keep (l)ocal, take (o)ther, or leave (u)nresolved? u
and
  remote changed a which local deleted
  use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
become:
  no tool found to merge a
  keep (l)ocal [working copy], take (o)ther [destination], or leave 
(u)nresolved? u
and
  remote [source] changed a which local [dest] deleted
  use (c)hanged version, leave (d)eleted, or leave (u)nresolved? c
where "working copy" and "destination" were supplied by the command that
requested the merge as labels for conflict markers, and thus should be
human-friendly.

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -230,50 +230,56 @@
 util.writefile(file, newdata)
 
 @internaltool('prompt', nomerge)
-def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf):
+def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Asks the user which of the local `p1()` or the other `p2()` version to
 keep as the merged version."""
 ui = repo.ui
 fd = fcd.path()
 
+prompts = partextras(labels)
+prompts['fd'] = fd
 try:
 if fco.isabsent():
 index = ui.promptchoice(
-_("local changed %s which remote deleted\n"
+_("local%(l)s changed %(fd)s which remote%(o)s deleted\n"
   "use (c)hanged version, (d)elete, or leave (u)nresolved?"
-  "$$  $$  $$ ") % fd, 2)
+  "$$  $$  $$ ") % prompts, 2)
 choice = ['local', 'other', 'unresolved'][index]
 elif fcd.isabsent():
 index = ui.promptchoice(
-_("remote changed %s which local deleted\n"
+_("remote%(o)s changed %(fd)s which local%(l)s deleted\n"
   "use (c)hanged version, leave (d)eleted, or "
   "leave (u)nresolved?"
-  "$$  $$  $$ ") % fd, 2)
+  "$$  $$  $$ ") % prompts, 2)
 choice = ['other', 'local', 'unresolved'][index]
 else:
 index = ui.promptchoice(
-_("no tool found to merge %s\n"
-  "keep (l)ocal, take (o)ther, or leave (u)nresolved?"
-  "$$  $$  $$ ") % fd, 2)
+_("no tool found to merge %(fd)s\n"
+  "keep (l)ocal%(l)s, take (o)ther%(o)s, or leave 
(u)nresolved?"
+  "$$  $$  $$ ") % prompts, 2)
 choice = ['local', 'other', 'unresolved'][index]
 
 if choice == 'other':
-return _iother(repo, mynode, orig, fcd, fco, fca, toolconf)
+return _iother(repo, mynode, orig, fcd, fco, fca, toolconf,
+   labels)
 elif choice == 'local':
-return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf)
+return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf,
+   labels)
 elif choice == 'unresolved':
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf)
+return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+  labels)
 except error.ResponseExpected:
 ui.write("\n")
-return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf)
+return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+  labels)
 
 @internaltool('local', nomerge)
-def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf):
+def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the local `p1()` version of files as the merged version."""
 return 0, fcd.isabsent()
 
 @internaltool('other', nomerge)
-def _iother(repo, mynode, orig, fcd, fco, fca, toolconf):
+def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """Uses the other `p2()` version of files as the merged version."""
 if fco.isabsent():
 # local changed, remote deleted -- 'deleted' picked
@@ -285,7 +291,7 @@
 return 0, deleted
 
 @internaltool('fail', nomerge)
-def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf):
+def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
 """
 Rather than attempting to merge files that were modified on both
 branches, it marks them as unresolved. The resolve command must be
@@ -537,6 +543,22 @@
 newlabels.append(_formatconflictmarker(repo, ca, tmpl, labels[2], pad))
 return newlabels
 
+def partextras(labels):
+"""Return