diff tests/test-import-git.t @ 24390:72d7d390ef5d

patch._applydiff: resolve prefix with respect to the cwd This has several advantages compared to resolving it relative to the root: - '--prefix .' works as expected. - consistent with upcoming 'hg diff' option to produce relative patches (I made sure to put in the (glob) annotations this time!)
author Siddharth Agarwal <sid0@fb.com>
date Thu, 19 Mar 2015 10:18:05 -0700
parents 885a573fa619
children 8286f551b7ee
line wrap: on
line diff
--- a/tests/test-import-git.t	Fri Mar 20 00:22:37 2015 +0900
+++ b/tests/test-import-git.t	Thu Mar 19 10:18:05 2015 -0700
@@ -626,6 +626,33 @@
   adding dir/d
   adding dir/dir2/b
   adding dir/dir2/c
+
+prefix '.' is the same as no prefix
+  $ hg import --no-commit --prefix . - <<EOF
+  > diff --git a/dir/a b/dir/a
+  > --- /dev/null
+  > +++ b/dir/a
+  > @@ -0,0 +1 @@
+  > +aaaa
+  > diff --git a/dir/d b/dir/d
+  > --- a/dir/d
+  > +++ b/dir/d
+  > @@ -1,1 +1,2 @@
+  >  d
+  > +dddd
+  > EOF
+  applying patch from stdin
+  $ cat dir/a
+  aaaa
+  $ cat dir/d
+  d
+  dddd
+  $ hg revert -aC
+  forgetting dir/a (glob)
+  reverting dir/d (glob)
+  $ rm dir/a
+
+prefix with default strip
   $ hg import --no-commit --prefix dir/ - <<EOF
   > diff --git a/a b/a
   > --- /dev/null
@@ -649,10 +676,10 @@
   forgetting dir/a (glob)
   reverting dir/d (glob)
   $ rm dir/a
-(test that prefixes are relative to the root)
+(test that prefixes are relative to the cwd)
   $ mkdir tmpdir
   $ cd tmpdir
-  $ hg import --no-commit -p2 --prefix dir/ - <<EOF
+  $ hg import --no-commit -p2 --prefix ../dir/ - <<EOF
   > diff --git a/foo/a b/foo/a
   > new file mode 100644
   > --- /dev/null