changeset 1983:ae12a81549a7

Pass correct username as $HGUSER to hgeditor if "commit -u" is used. And only use the new util.system parameter to set the environment.
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 21 Mar 2006 12:45:27 +0100
parents 70ba0c86da8b
children df7436f439a0
files mercurial/localrepo.py mercurial/ui.py
diffstat 2 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Tue Mar 21 12:15:25 2006 +0100
+++ b/mercurial/localrepo.py	Tue Mar 21 12:45:27 2006 +0100
@@ -442,6 +442,7 @@
         new = new.keys()
         new.sort()
 
+        user = user or self.ui.username()
         if not text:
             edittext = [""]
             if p2 != nullid:
@@ -454,13 +455,12 @@
             # run editor in the repository root
             olddir = os.getcwd()
             os.chdir(self.root)
-            edittext = self.ui.edit("\n".join(edittext))
+            edittext = self.ui.edit("\n".join(edittext), user)
             os.chdir(olddir)
             if not edittext.rstrip():
                 return None
             text = edittext
 
-        user = user or self.ui.username()
         n = self.changelog.add(mn, changed + remove, text, tr, p1, p2, user, date)
         self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
                   parent2=xp2)
--- a/mercurial/ui.py	Tue Mar 21 12:15:25 2006 +0100
+++ b/mercurial/ui.py	Tue Mar 21 12:45:27 2006 +0100
@@ -194,7 +194,7 @@
         if self.verbose: self.write(*msg)
     def debug(self, *msg):
         if self.debugflag: self.write(*msg)
-    def edit(self, text):
+    def edit(self, text, user):
         import tempfile
         (fd, name) = tempfile.mkstemp("hg")
         f = os.fdopen(fd, "w")
@@ -205,9 +205,8 @@
                   self.config("ui", "editor") or
                   os.environ.get("EDITOR", "vi"))
 
-        os.environ["HGUSER"] = self.username()
         util.system("%s \"%s\"" % (editor, name),
-                    environ={'HGUSER': self.username()},
+                    environ={'HGUSER': user},
                     onerr=util.Abort, errprefix=_("edit failed"))
 
         t = open(name).read()