Show More
@@ -3263,7 +3263,7 b' def import_(ui, repo, patch1, *patches, ' | |||||
3263 |
|
3263 | |||
3264 | base = opts["base"] |
|
3264 | base = opts["base"] | |
3265 | strip = opts["strip"] |
|
3265 | strip = opts["strip"] | |
3266 | wlock = lock = None |
|
3266 | wlock = lock = tr = None | |
3267 | msgs = [] |
|
3267 | msgs = [] | |
3268 |
|
3268 | |||
3269 | def checkexact(repo, n, nodeid): |
|
3269 | def checkexact(repo, n, nodeid): | |
@@ -3334,9 +3334,6 b' def import_(ui, repo, patch1, *patches, ' | |||||
3334 | opts.get('date') or date, match=m, |
|
3334 | opts.get('date') or date, match=m, | |
3335 | editor=cmdutil.commiteditor) |
|
3335 | editor=cmdutil.commiteditor) | |
3336 | checkexact(repo, n, nodeid) |
|
3336 | checkexact(repo, n, nodeid) | |
3337 | # Force a dirstate write so that the next transaction |
|
|||
3338 | # backups an up-to-date file. |
|
|||
3339 | repo.dirstate.write() |
|
|||
3340 | else: |
|
3337 | else: | |
3341 | if opts.get('exact') or opts.get('import_branch'): |
|
3338 | if opts.get('exact') or opts.get('import_branch'): | |
3342 | branch = branch or 'default' |
|
3339 | branch = branch or 'default' | |
@@ -3370,6 +3367,7 b' def import_(ui, repo, patch1, *patches, ' | |||||
3370 | try: |
|
3367 | try: | |
3371 | wlock = repo.wlock() |
|
3368 | wlock = repo.wlock() | |
3372 | lock = repo.lock() |
|
3369 | lock = repo.lock() | |
|
3370 | tr = repo.transaction('import') | |||
3373 | parents = repo.parents() |
|
3371 | parents = repo.parents() | |
3374 | for patchurl in patches: |
|
3372 | for patchurl in patches: | |
3375 | if patchurl == '-': |
|
3373 | if patchurl == '-': | |
@@ -3395,9 +3393,18 b' def import_(ui, repo, patch1, *patches, ' | |||||
3395 | if not haspatch: |
|
3393 | if not haspatch: | |
3396 | raise util.Abort(_('%s: no diffs found') % patchurl) |
|
3394 | raise util.Abort(_('%s: no diffs found') % patchurl) | |
3397 |
|
3395 | |||
|
3396 | tr.close() | |||
3398 | if msgs: |
|
3397 | if msgs: | |
3399 | repo.savecommitmessage('\n* * *\n'.join(msgs)) |
|
3398 | repo.savecommitmessage('\n* * *\n'.join(msgs)) | |
|
3399 | except: | |||
|
3400 | # wlock.release() indirectly calls dirstate.write(): since | |||
|
3401 | # we're crashing, we do not want to change the working dir | |||
|
3402 | # parent after all, so make sure it writes nothing | |||
|
3403 | repo.dirstate.invalidate() | |||
|
3404 | raise | |||
3400 | finally: |
|
3405 | finally: | |
|
3406 | if tr: | |||
|
3407 | tr.release() | |||
3401 | release(lock, wlock) |
|
3408 | release(lock, wlock) | |
3402 |
|
3409 | |||
3403 | @command('incoming|in', |
|
3410 | @command('incoming|in', |
@@ -60,8 +60,8 b' Test --user, --date and --message' | |||||
60 | |/ |
|
60 | |/ | |
61 | @ 0:07f494440405 test 0 0 - default - adda |
|
61 | @ 0:07f494440405 test 0 0 - default - adda | |
62 |
|
62 | |||
63 |
$ hg rollback |
|
63 | $ hg rollback | |
64 |
repository tip rolled back to revision 1 (undo |
|
64 | repository tip rolled back to revision 1 (undo import) | |
65 |
|
65 | |||
66 | Test --import-branch |
|
66 | Test --import-branch | |
67 |
|
67 | |||
@@ -72,8 +72,8 b' Test --import-branch' | |||||
72 | | |
|
72 | | | |
73 | @ 0:07f494440405 test 0 0 - default - adda |
|
73 | @ 0:07f494440405 test 0 0 - default - adda | |
74 |
|
74 | |||
75 |
$ hg rollback |
|
75 | $ hg rollback | |
76 |
repository tip rolled back to revision 1 (undo |
|
76 | repository tip rolled back to revision 1 (undo import) | |
77 |
|
77 | |||
78 | Test --strip |
|
78 | Test --strip | |
79 |
|
79 | |||
@@ -94,8 +94,8 b' Test --strip' | |||||
94 | > +a |
|
94 | > +a | |
95 | > EOF |
|
95 | > EOF | |
96 | applying patch from stdin |
|
96 | applying patch from stdin | |
97 |
$ hg rollback |
|
97 | $ hg rollback | |
98 |
repository tip rolled back to revision 1 (undo |
|
98 | repository tip rolled back to revision 1 (undo import) | |
99 |
|
99 | |||
100 | Test unsupported combinations |
|
100 | Test unsupported combinations | |
101 |
|
101 |
@@ -365,10 +365,10 b' patches: import patch1 patch2; rollback' | |||||
365 | a |
|
365 | a | |
366 | created 6d019af21222 |
|
366 | created 6d019af21222 | |
367 | $ hg --cwd b rollback |
|
367 | $ hg --cwd b rollback | |
368 |
repository tip rolled back to revision |
|
368 | repository tip rolled back to revision 0 (undo import) | |
369 |
working directory now based on revision |
|
369 | working directory now based on revision 0 | |
370 | $ hg --cwd b parents --template 'parent: {rev}\n' |
|
370 | $ hg --cwd b parents --template 'parent: {rev}\n' | |
371 |
parent: |
|
371 | parent: 0 | |
372 | $ rm -r b |
|
372 | $ rm -r b | |
373 |
|
373 | |||
374 |
|
374 | |||
@@ -688,6 +688,7 b' Issue1495: add empty file from the end o' | |||||
688 | adding a |
|
688 | adding a | |
689 | $ hg ci -m "commit" |
|
689 | $ hg ci -m "commit" | |
690 | $ cat > a.patch <<EOF |
|
690 | $ cat > a.patch <<EOF | |
|
691 | > add a, b | |||
691 | > diff --git a/a b/a |
|
692 | > diff --git a/a b/a | |
692 | > --- a/a |
|
693 | > --- a/a | |
693 | > +++ b/a |
|
694 | > +++ b/a | |
@@ -698,9 +699,25 b' Issue1495: add empty file from the end o' | |||||
698 | > EOF |
|
699 | > EOF | |
699 | $ hg import --no-commit a.patch |
|
700 | $ hg import --no-commit a.patch | |
700 | applying a.patch |
|
701 | applying a.patch | |
|
702 | ||||
|
703 | apply a good patch followed by an empty patch (mainly to ensure | |||
|
704 | that dirstate is *not* updated when import crashes) | |||
|
705 | $ hg update -q -C . | |||
|
706 | $ rm b | |||
|
707 | $ touch empty.patch | |||
|
708 | $ hg import a.patch empty.patch | |||
|
709 | applying a.patch | |||
|
710 | applying empty.patch | |||
|
711 | transaction abort! | |||
|
712 | rollback completed | |||
|
713 | abort: empty.patch: no diffs found | |||
|
714 | [255] | |||
|
715 | $ hg tip --template '{rev} {desc|firstline}\n' | |||
|
716 | 0 commit | |||
|
717 | $ hg -q status | |||
|
718 | M a | |||
701 | $ cd .. |
|
719 | $ cd .. | |
702 |
|
720 | |||
703 |
|
||||
704 | create file when source is not /dev/null |
|
721 | create file when source is not /dev/null | |
705 |
|
722 | |||
706 | $ cat > create.patch <<EOF |
|
723 | $ cat > create.patch <<EOF |
@@ -825,7 +825,7 b' Imported patch should not be rejected' | |||||
825 | ignore $Id$ |
|
825 | ignore $Id$ | |
826 |
|
826 | |||
827 | $ hg rollback |
|
827 | $ hg rollback | |
828 |
repository tip rolled back to revision 2 (undo |
|
828 | repository tip rolled back to revision 2 (undo import) | |
829 | working directory now based on revision 2 |
|
829 | working directory now based on revision 2 | |
830 | $ hg update --clean |
|
830 | $ hg update --clean | |
831 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
831 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
General Comments 0
You need to be logged in to leave comments.
Login now