3109 raise error.Abort(_('cannot use --exact with --edit')) |
3106 raise error.Abort(_('cannot use --exact with --edit')) |
3110 if opts.get('prefix'): |
3107 if opts.get('prefix'): |
3111 raise error.Abort(_('cannot use --exact with --prefix')) |
3108 raise error.Abort(_('cannot use --exact with --prefix')) |
3112 |
3109 |
3113 base = opts["base"] |
3110 base = opts["base"] |
3114 dsguard = lock = tr = None |
|
3115 msgs = [] |
3111 msgs = [] |
3116 ret = 0 |
3112 ret = 0 |
3117 |
3113 |
3118 with repo.wlock(): |
3114 with repo.wlock(): |
3119 try: |
3115 if update: |
3120 if update: |
3116 cmdutil.checkunfinished(repo) |
3121 cmdutil.checkunfinished(repo) |
3117 if (exact or not opts.get('force')): |
3122 if (exact or not opts.get('force')): |
3118 cmdutil.bailifchanged(repo) |
3123 cmdutil.bailifchanged(repo) |
3119 |
3124 |
3120 if not opts.get('no_commit'): |
3125 if not opts.get('no_commit'): |
3121 lock = repo.lock |
3126 lock = repo.lock() |
3122 tr = lambda: repo.transaction('import') |
3127 tr = repo.transaction('import') |
3123 dsguard = util.nullcontextmanager |
3128 else: |
3124 else: |
3129 dsguard = dirstateguard.dirstateguard(repo, 'import') |
3125 lock = util.nullcontextmanager |
|
3126 tr = util.nullcontextmanager |
|
3127 dsguard = lambda: dirstateguard.dirstateguard(repo, 'import') |
|
3128 with lock(), tr(), dsguard(): |
3130 parents = repo[None].parents() |
3129 parents = repo[None].parents() |
3131 for patchurl in patches: |
3130 for patchurl in patches: |
3132 if patchurl == '-': |
3131 if patchurl == '-': |
3133 ui.status(_('applying patch from stdin\n')) |
3132 ui.status(_('applying patch from stdin\n')) |
3134 patchfile = ui.fin |
3133 patchfile = ui.fin |
3160 break |
3159 break |
3161 |
3160 |
3162 if not haspatch: |
3161 if not haspatch: |
3163 raise error.Abort(_('%s: no diffs found') % patchurl) |
3162 raise error.Abort(_('%s: no diffs found') % patchurl) |
3164 |
3163 |
3165 if tr: |
|
3166 tr.close() |
|
3167 if msgs: |
3164 if msgs: |
3168 repo.savecommitmessage('\n* * *\n'.join(msgs)) |
3165 repo.savecommitmessage('\n* * *\n'.join(msgs)) |
3169 if dsguard: |
3166 return ret |
3170 dsguard.close() |
|
3171 return ret |
|
3172 finally: |
|
3173 if tr: |
|
3174 tr.release() |
|
3175 release(lock, dsguard) |
|
3176 |
3167 |
3177 @command('incoming|in', |
3168 @command('incoming|in', |
3178 [('f', 'force', None, |
3169 [('f', 'force', None, |
3179 _('run even if remote repository is unrelated')), |
3170 _('run even if remote repository is unrelated')), |
3180 ('n', 'newest-first', None, _('show newest record first')), |
3171 ('n', 'newest-first', None, _('show newest record first')), |