##// END OF EJS Templates
cmdutil.tryimportone: allow importing relative patches into the working dir...
Siddharth Agarwal -
r24259:5ac8ce04 default
parent child Browse files
Show More
@@ -615,6 +615,7 b' def tryimportone(ui, repo, hunk, parents'
615 615
616 616 update = not opts.get('bypass')
617 617 strip = opts["strip"]
618 prefix = opts["prefix"]
618 619 sim = float(opts.get('similarity') or 0)
619 620 if not tmpname:
620 621 return (None, None, False)
@@ -674,8 +675,8 b' def tryimportone(ui, repo, hunk, parents'
674 675 partial = opts.get('partial', False)
675 676 files = set()
676 677 try:
677 patch.patch(ui, repo, tmpname, strip=strip, files=files,
678 eolmode=None, similarity=sim / 100.0)
678 patch.patch(ui, repo, tmpname, strip=strip, prefix=prefix,
679 files=files, eolmode=None, similarity=sim / 100.0)
679 680 except patch.PatchError, e:
680 681 if not partial:
681 682 raise util.Abort(str(e))
@@ -1533,7 +1533,7 b' def patchrepo(ui, repo, ctx, store, patc'
1533 1533 backend = repobackend(ui, repo, ctx, store)
1534 1534 return patchbackend(ui, backend, patchobj, strip, '', files, eolmode)
1535 1535
1536 def patch(ui, repo, patchname, strip=1, files=None, eolmode='strict',
1536 def patch(ui, repo, patchname, strip=1, prefix='', files=None, eolmode='strict',
1537 1537 similarity=0):
1538 1538 """Apply <patchname> to the working directory.
1539 1539
@@ -1552,7 +1552,7 b' def patch(ui, repo, patchname, strip=1, '
1552 1552 if patcher:
1553 1553 return _externalpatch(ui, repo, patcher, patchname, strip,
1554 1554 files, similarity)
1555 return internalpatch(ui, repo, patchname, strip, '', files, eolmode,
1555 return internalpatch(ui, repo, patchname, strip, prefix, files, eolmode,
1556 1556 similarity)
1557 1557
1558 1558 def changedfiles(ui, repo, patchpath, strip=1):
@@ -612,12 +612,64 b' Renames and strip'
612 612 a
613 613 R a
614 614
615 Renames, similarity and git diff
615 Prefix with strip, renames, creates etc
616 616
617 617 $ hg revert -aC
618 618 undeleting a
619 619 forgetting b
620 620 $ rm b
621 $ mkdir -p dir/dir2
622 $ echo b > dir/dir2/b
623 $ echo c > dir/dir2/c
624 $ echo d > dir/d
625 $ hg ci -Am addbcd
626 adding dir/d
627 adding dir/dir2/b
628 adding dir/dir2/c
629 (test that prefixes are relative to the root)
630 $ mkdir tmpdir
631 $ cd tmpdir
632 $ hg import --no-commit -p2 --prefix dir/ - <<EOF
633 > diff --git a/foo/a b/foo/a
634 > new file mode 100644
635 > --- /dev/null
636 > +++ b/foo/a
637 > @@ -0,0 +1 @@
638 > +a
639 > diff --git a/foo/dir2/b b/foo/dir2/b2
640 > rename from foo/dir2/b
641 > rename to foo/dir2/b2
642 > diff --git a/foo/dir2/c b/foo/dir2/c
643 > --- a/foo/dir2/c
644 > +++ b/foo/dir2/c
645 > @@ -0,0 +1 @@
646 > +cc
647 > diff --git a/foo/d b/foo/d
648 > deleted file mode 100644
649 > --- a/foo/d
650 > +++ /dev/null
651 > @@ -1,1 +0,0 @@
652 > -d
653 > EOF
654 applying patch from stdin
655 $ hg st --copies
656 M dir/dir2/c
657 A dir/a
658 A dir/dir2/b2
659 dir/dir2/b
660 R dir/d
661 R dir/dir2/b
662 $ cd ..
663
664 Renames, similarity and git diff
665
666 $ hg revert -aC
667 forgetting dir/a (glob)
668 undeleting dir/d (glob)
669 undeleting dir/dir2/b (glob)
670 forgetting dir/dir2/b2 (glob)
671 reverting dir/dir2/c (glob)
672 $ rm dir/a dir/dir2/b2
621 673 $ hg import --similarity 90 --no-commit - <<EOF
622 674 > diff --git a/a b/b
623 675 > rename from a
@@ -670,6 +670,25 b' test -p0'
670 670 $ hg status
671 671 $ cat a
672 672 bb
673
674 test --prefix
675
676 $ mkdir -p dir/dir2
677 $ echo b > dir/dir2/b
678 $ hg ci -Am b
679 adding dir/dir2/b
680 $ hg import -p2 --prefix dir - << EOF
681 > foobar
682 > --- drop1/drop2/dir2/b
683 > +++ drop1/drop2/dir2/b
684 > @@ -1,1 +1,1 @@
685 > -b
686 > +cc
687 > EOF
688 applying patch from stdin
689 $ hg status
690 $ cat dir/dir2/b
691 cc
673 692 $ cd ..
674 693
675 694
General Comments 0
You need to be logged in to leave comments. Login now