--- a/hgext/record.py
+++ b/hgext/record.py
@@ -363,7 +363,7 @@ def record(ui, repo, *pats, **opts):
try:
for realname, tmpname in backups.iteritems():
ui.debug('restoring %r to %r\n' % (tmpname, realname))
- util.copyfile(tmpname, realname)
+ util.copyfile(tmpname, repo.wjoin(realname))
os.unlink(tmpname)
os.rmdir(backupdir)
except OSError:
--- a/tests/test-record
+++ b/tests/test-record
@@ -202,3 +202,15 @@ y
y
EOF
echo; hg tip -p
+
+mkdir subdir
+cd subdir
+echo a > a
+hg ci -d '16 0' -Amsubdir
+
+echo a >> a
+hg record -d '16 0' -m subdir-change a <<EOF
+y
+y
+EOF
+echo; hg tip -p
--- a/tests/test-record.out
+++ b/tests/test-record.out
@@ -381,3 +381,23 @@ diff -r c1c639d8b268 -r 80b74bbc7808 pla
+10
+11
+adding subdir/a
+diff --git a/subdir/a b/subdir/a
+1 hunks, 1 lines changed
+record changes to 'subdir/a'? [y]es [n]o @@ -1,1 +1,2 @@ a
+ a
++a
+record this change to 'subdir/a'? [y]es [n]o
+changeset: 18:33ff5c4fb017
+tag: tip
+user: test
+date: Thu Jan 01 00:00:16 1970 +0000
+summary: subdir-change
+
+diff -r aecf2b2ea83c -r 33ff5c4fb017 subdir/a
+--- a/subdir/a Thu Jan 01 00:00:16 1970 +0000
++++ b/subdir/a Thu Jan 01 00:00:16 1970 +0000
+@@ -1,1 +1,2 @@ a
+ a
++a
+