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

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Fri Jan 31 23:23:25 UTC 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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:


More information about the Mercurial-devel mailing list