# HG changeset patch # User Siddharth Agarwal # Date 1426017998 25200 # Node ID 76225ab5a5da6e33471d7f81df1c483dde0b2ae3 # Parent 5ac8ce04baa24a1cbbda879ceef2f9bda8554e7e cmdutil.tryimportone: allow importing relative patches with --bypass diff -r 5ac8ce04baa2 -r 76225ab5a5da mercurial/cmdutil.py --- a/mercurial/cmdutil.py Mon Mar 09 18:22:24 2015 -0700 +++ b/mercurial/cmdutil.py Tue Mar 10 13:06:38 2015 -0700 @@ -713,7 +713,7 @@ try: files = set() try: - patch.patchrepo(ui, repo, p1, store, tmpname, strip, + patch.patchrepo(ui, repo, p1, store, tmpname, strip, prefix, files, eolmode=None) except patch.PatchError, e: raise util.Abort(str(e)) diff -r 5ac8ce04baa2 -r 76225ab5a5da mercurial/patch.py --- a/mercurial/patch.py Mon Mar 09 18:22:24 2015 -0700 +++ b/mercurial/patch.py Tue Mar 10 13:06:38 2015 -0700 @@ -1528,10 +1528,10 @@ backend = workingbackend(ui, repo, similarity) return patchbackend(ui, backend, patchobj, strip, prefix, files, eolmode) -def patchrepo(ui, repo, ctx, store, patchobj, strip, files=None, +def patchrepo(ui, repo, ctx, store, patchobj, strip, prefix, files=None, eolmode='strict'): backend = repobackend(ui, repo, ctx, store) - return patchbackend(ui, backend, patchobj, strip, '', files, eolmode) + return patchbackend(ui, backend, patchobj, strip, prefix, files, eolmode) def patch(ui, repo, patchname, strip=1, prefix='', files=None, eolmode='strict', similarity=0): diff -r 5ac8ce04baa2 -r 76225ab5a5da tests/test-import-bypass.t --- a/tests/test-import-bypass.t Mon Mar 09 18:22:24 2015 -0700 +++ b/tests/test-import-bypass.t Tue Mar 10 13:06:38 2015 -0700 @@ -104,6 +104,86 @@ $ hg rollback repository tip rolled back to revision 1 (undo import) +Test --strip with --bypass + + $ mkdir -p dir/dir2 + $ echo bb > dir/dir2/b + $ echo cc > dir/dir2/c + $ echo d > dir/d + $ hg ci -Am 'addabcd' + adding dir/d + adding dir/dir2/b + adding dir/dir2/c + $ shortlog + @ 2:d805bc8236b6 test 0 0 - default - addabcd + | + | o 1:4e322f7ce8e3 test 0 0 - foo - changea + |/ + o 0:07f494440405 test 0 0 - default - adda + + $ hg import --bypass --strip 2 --prefix dir/ - < # HG changeset patch + > # User test + > # Date 0 0 + > # Branch foo + > changeabcd + > + > diff --git a/foo/a b/foo/a + > new file mode 100644 + > --- /dev/null + > +++ b/foo/a + > @@ -0,0 +1 @@ + > +a + > diff --git a/foo/dir2/b b/foo/dir2/b2 + > rename from foo/dir2/b + > rename to foo/dir2/b2 + > diff --git a/foo/dir2/c b/foo/dir2/c + > --- a/foo/dir2/c + > +++ b/foo/dir2/c + > @@ -0,0 +1 @@ + > +cc + > diff --git a/foo/d b/foo/d + > deleted file mode 100644 + > --- a/foo/d + > +++ /dev/null + > @@ -1,1 +0,0 @@ + > -d + > EOF + applying patch from stdin + + $ shortlog + o 3:5bd46886ca3e test 0 0 - default - changeabcd + | + @ 2:d805bc8236b6 test 0 0 - default - addabcd + | + | o 1:4e322f7ce8e3 test 0 0 - foo - changea + |/ + o 0:07f494440405 test 0 0 - default - adda + + $ hg diff --change 3 --git + diff --git a/dir/a b/dir/a + new file mode 100644 + --- /dev/null + +++ b/dir/a + @@ -0,0 +1,1 @@ + +a + diff --git a/dir/d b/dir/d + deleted file mode 100644 + --- a/dir/d + +++ /dev/null + @@ -1,1 +0,0 @@ + -d + diff --git a/dir/dir2/b b/dir/dir2/b2 + rename from dir/dir2/b + rename to dir/dir2/b2 + diff --git a/dir/dir2/c b/dir/dir2/c + --- a/dir/dir2/c + +++ b/dir/dir2/c + @@ -1,1 +1,2 @@ + cc + +cc + $ hg -q --config extensions.strip= strip . + Test unsupported combinations $ hg import --bypass --no-commit ../test.diff