Mercurial > hg-stable
changeset 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 | dc2b8c005697 |
children | 6e715040c172 |
files | mercurial/commands.py |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Fri Oct 09 03:53:46 2015 +0900 +++ b/mercurial/commands.py Fri Oct 09 03:53:47 2015 +0900 @@ -4407,10 +4407,11 @@ try: try: wlock = repo.wlock() - dsguard = cmdutil.dirstateguard(repo, 'import') if not opts.get('no_commit'): lock = repo.lock() tr = repo.transaction('import') + else: + dsguard = cmdutil.dirstateguard(repo, 'import') parents = repo.parents() for patchurl in patches: if patchurl == '-': @@ -4448,7 +4449,8 @@ tr.close() if msgs: repo.savecommitmessage('\n* * *\n'.join(msgs)) - dsguard.close() + if dsguard: + dsguard.close() return ret finally: # TODO: get rid of this meaningless try/finally enclosing.