# HG changeset patch # User Thomas Arendsen Hein # Date 2006-03-21 11:45:27 # Node ID ae12a81549a77c1cb1af783648c107d0121efcff # Parent 70ba0c86da8b6348ba3ca69431aa303b421bb2f4 Pass correct username as $HGUSER to hgeditor if "commit -u" is used. And only use the new util.system parameter to set the environment. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -442,6 +442,7 @@ class localrepository(object): new = new.keys() new.sort() + user = user or self.ui.username() if not text: edittext = [""] if p2 != nullid: @@ -454,13 +455,12 @@ class localrepository(object): # 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) diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -194,7 +194,7 @@ class ui(object): 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 @@ class ui(object): 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()