Patchwork [1,of,2] record: use absolute path instead of os.chdir

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 31, 2014, 11:23 p.m.
Message ID <33b269ec18fc46efd561.1391210605@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3425/
State Accepted
Commit 205599e318706070c75f6fb82460f97dd359520b
Headers show

Comments

Pierre-Yves David - Jan. 31, 2014, 11:23 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1391208773 28800
#      Fri Jan 31 14:52:53 2014 -0800
# Branch stable
# Node ID 33b269ec18fc46efd5616ce6ba98e189d7cd8923
# Parent  a959f71670771a9dae97e73ec86da222950233a4
record: use absolute path instead of os.chdir

Record was changing the current directory to `repo.root` in order to be able to
feed `command.commit` file name relative to this `repo.root`. This is a bit
overkill and prevent an incoming fix to rebase. This would also break
multi-threaded usage.

Instead we just feed `command.commit` with absolute path name. works as well as
before but without chdir.

Patch

diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -599,16 +599,12 @@  def dorecord(ui, repo, commitfunc, cmdsu
             #    commit/qrefresh or the like!
 
             # it is important to first chdir to repo root -- we'll call
             # a highlevel command with list of pathnames relative to
             # repo root
-            cwd = os.getcwd()
-            os.chdir(repo.root)
-            try:
-                commitfunc(ui, repo, *newfiles, **opts)
-            finally:
-                os.chdir(cwd)
+            newfiles = [repo.wjoin(nf) for nf in newfiles]
+            commitfunc(ui, repo, *newfiles, **opts)
 
             return 0
         finally:
             # 5. finally restore backed-up files
             try: