Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 26580:4688945f316c
commands: make "hg import" use dirstateguard only for --no-commit
Previous patch made dirstate changes in a transaction scope "all or
nothing". Therefore, 'dirstateguard' is meaningless, if its scope is
as same as one of the related transaction.
Before this patch, "hg import" uses 'dirstateguard' always, but
transaction is also started if '--no-commit' isn't specified.
To avoid redundancy, this patch makes "hg import" use dirstateguard
only if transaction isn't started (= '--no-commit' is specified).
In this patch, 'if dsguard' can be examined safely, because 'dsguard'
is initialized (with None) before outermost 'try'.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 09 Oct 2015 03:53:47 +0900 |
parents | 1956026e4db2 |
children | 6e715040c172 |
comparison
equal
deleted
inserted
replaced
26579:dc2b8c005697 | 26580:4688945f316c |
---|---|
4405 | 4405 |
4406 | 4406 |
4407 try: | 4407 try: |
4408 try: | 4408 try: |
4409 wlock = repo.wlock() | 4409 wlock = repo.wlock() |
4410 dsguard = cmdutil.dirstateguard(repo, 'import') | |
4411 if not opts.get('no_commit'): | 4410 if not opts.get('no_commit'): |
4412 lock = repo.lock() | 4411 lock = repo.lock() |
4413 tr = repo.transaction('import') | 4412 tr = repo.transaction('import') |
4413 else: | |
4414 dsguard = cmdutil.dirstateguard(repo, 'import') | |
4414 parents = repo.parents() | 4415 parents = repo.parents() |
4415 for patchurl in patches: | 4416 for patchurl in patches: |
4416 if patchurl == '-': | 4417 if patchurl == '-': |
4417 ui.status(_('applying patch from stdin\n')) | 4418 ui.status(_('applying patch from stdin\n')) |
4418 patchfile = ui.fin | 4419 patchfile = ui.fin |
4446 | 4447 |
4447 if tr: | 4448 if tr: |
4448 tr.close() | 4449 tr.close() |
4449 if msgs: | 4450 if msgs: |
4450 repo.savecommitmessage('\n* * *\n'.join(msgs)) | 4451 repo.savecommitmessage('\n* * *\n'.join(msgs)) |
4451 dsguard.close() | 4452 if dsguard: |
4453 dsguard.close() | |
4452 return ret | 4454 return ret |
4453 finally: | 4455 finally: |
4454 # TODO: get rid of this meaningless try/finally enclosing. | 4456 # TODO: get rid of this meaningless try/finally enclosing. |
4455 # this is kept only to reduce changes in a patch. | 4457 # this is kept only to reduce changes in a patch. |
4456 pass | 4458 pass |