[PATCH] Introduce ui functions that return the edit/merge tool
to use
Matt Mackall
mpm at selenic.com
Mon May 8 09:13:51 CDT 2006
On Sun, May 07, 2006 at 01:34:57PM +0100, Stephen Darnell wrote:
> 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
> # 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")
I think it'd be better to do this with setconfig in ui.__init__.
Similarly for several other legacy functions, like username.
Otherwise, looks good.
> +
> + 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"))
>
> _______________________________________________
> Mercurial mailing list
> Mercurial at selenic.com
> http://selenic.com/mailman/listinfo/mercurial
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial
mailing list