[PATCH] Introduce ui functions that return the edit/merge tool to
use
Stephen Darnell
stephen at darnell.plus.com
Sun May 7 07:34:57 CDT 2006
Bryan O'Sullivan wrote:
>> - cmd = (os.environ.get("HGMERGE") or self.ui.config("ui",
>> "merge")
>> - or "hgmerge")
>> + cmd = self.ui.merge()
>
> Can you separate the new ui.ui methods from the rest of the patch and
> post those as a separate patch that comes first?
Attached is the patch with just the new ui.merge() and ui.editor()
methods.
Regards,
Stephen
-------------- next part --------------
# HG changeset patch
# User Stephen Darnell <stephen at darnell.plus.com>
# Node ID 9f507c409b4eff6ded57215ae00b6d66f6037c1c
# Parent f72c438ce08cb1f8ca3bae754d5ebd92c81ab783
Introduce ui functions that return the edit/merge tool to use
In the future there will be multiple callers
diff -r f72c438ce08c -r 9f507c409b4e mercurial/localrepo.py
--- a/mercurial/localrepo.py Sat May 06 16:43:16 2006 +0200
+++ b/mercurial/localrepo.py Sun May 07 13:29:40 2006 +0100
@@ -1853,8 +1853,7 @@ class localrepository(object):
self.ui.debug(_("file %s: my %s other %s ancestor %s\n") %
(fn, short(my), short(other), short(base)))
- cmd = (os.environ.get("HGMERGE") or self.ui.config("ui", "merge")
- or "hgmerge")
+ cmd = self.ui.merge()
r = util.system('%s "%s" "%s" "%s"' % (cmd, a, b, c), cwd=self.root,
environ={'HG_FILE': fn,
'HG_MY_NODE': p1,
diff -r f72c438ce08c -r 9f507c409b4e mercurial/ui.py
--- a/mercurial/ui.py Sat May 06 16:43:16 2006 +0200
+++ b/mercurial/ui.py Sun May 07 13:29:40 2006 +0100
@@ -241,6 +241,17 @@ class ui(object):
if self.verbose: self.write(*msg)
def debug(self, *msg):
if self.debugflag: self.write(*msg)
+
+ def merge(self):
+ return (os.environ.get("HGMERGE") or
+ self.config("ui", "merge") or
+ "hgmerge")
+
+ def editor(self):
+ return (os.environ.get("HGEDITOR") or
+ self.config("ui", "editor") or
+ os.environ.get("EDITOR", "vi"))
+
def edit(self, text, user):
(fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
text=True)
@@ -249,11 +260,7 @@ class ui(object):
f.write(text)
f.close()
- editor = (os.environ.get("HGEDITOR") or
- self.config("ui", "editor") or
- os.environ.get("EDITOR", "vi"))
-
- util.system("%s \"%s\"" % (editor, name),
+ util.system("%s \"%s\"" % (self.editor(), name),
environ={'HGUSER': user},
onerr=util.Abort, errprefix=_("edit failed"))
More information about the Mercurial
mailing list