record: fix adding new file with record from within a subdir (issue4626) stable
authorLaurent Charignon <lcharignon@fb.com>
Mon, 27 Apr 2015 14:02:49 -0700
branchstable
changeset 24866 e1ec3d075c67
parent 24865 d90e50c6e406
child 24867 6d97ca3f05ba
record: fix adding new file with record from within a subdir (issue4626) In my latest change on record (edit newly added file), I forgot the repo.wjoin() so that record was not computing the paths properly to delete the backups and was crashing.
mercurial/cmdutil.py
tests/test-commit-interactive.t
--- a/mercurial/cmdutil.py	Mon Apr 27 16:24:43 2015 -0500
+++ b/mercurial/cmdutil.py	Mon Apr 27 14:02:49 2015 -0700
@@ -161,7 +161,7 @@
             dopatch = fp.tell()
             fp.seek(0)
 
-            [os.unlink(c) for c in newlyaddedandmodifiedfiles]
+            [os.unlink(repo.wjoin(c)) for c in newlyaddedandmodifiedfiles]
             # 3a. apply filtered patch to clean repo  (clean)
             if backups:
                 # Equivalent to hg.revert
--- a/tests/test-commit-interactive.t	Mon Apr 27 16:24:43 2015 -0500
+++ b/tests/test-commit-interactive.t	Mon Apr 27 14:02:49 2015 -0700
@@ -1463,4 +1463,37 @@
   This is the first line
   This is the second line
   This is the third line
+
+Add new file from within a subdirectory
+  $ hg update -C .
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ mkdir folder
+  $ cd folder
+  $ echo "foo" > bar
+  $ hg add bar
+  $ hg commit -i -d '23 0' -mnewfilesubdir  <<EOF
+  > y
+  > y
+  > EOF
+  diff --git a/folder/bar b/folder/bar
+  new file mode 100644
+  examine changes to 'folder/bar'? [Ynesfdaq?] y
+  
+  @@ -0,0 +1,1 @@
+  +foo
+  record this change to 'folder/bar'? [Ynesfdaq?] y
+  
+  $ hg tip -p
+  changeset:   32:fb46c2a66466
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:23 1970 +0000
+  summary:     newfilesubdir
+  
+  diff -r 34c65441ddfb -r fb46c2a66466 folder/bar
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/folder/bar	Thu Jan 01 00:00:23 1970 +0000
+  @@ -0,0 +1,1 @@
+  +foo
+  
   $ cd ..