Patchwork [STABLE] record: Fix Adding new file with record from within a subdir (issue4626)

login
register
mail settings
Submitter Laurent Charignon
Date April 27, 2015, 9:04 p.m.
Message ID <6ecda757a46c9b2e7a8a.1430168668@lcharignon-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/8799/
State Accepted
Headers show

Comments

Laurent Charignon - April 27, 2015, 9:04 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1430168569 25200
#      Mon Apr 27 14:02:49 2015 -0700
# Branch stable
# Node ID 6ecda757a46c9b2e7a8afd5136d574f52538eb48
# Parent  bff42a92012e49aabd925caa3cb243116285e243
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.
Matt Mackall - April 27, 2015, 9:27 p.m.
On Mon, 2015-04-27 at 14:04 -0700, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1430168569 25200
> #      Mon Apr 27 14:02:49 2015 -0700
> # Branch stable
> # Node ID 6ecda757a46c9b2e7a8afd5136d574f52538eb48
> # Parent  bff42a92012e49aabd925caa3cb243116285e243
> record: Fix Adding new file with record from within a subdir (issue4626)

Queued for stable with capitalization fixed, thanks.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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
diff --git a/tests/test-commit-interactive.t b/tests/test-commit-interactive.t
--- a/tests/test-commit-interactive.t
+++ b/tests/test-commit-interactive.t
@@ -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 ..