mercurial/commands.py
changeset 26580 4688945f316c
parent 26539 1956026e4db2
child 26581 6e715040c172
--- 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.