[PATCH 4 of 6] cmdutil: stop tryimportone from using dirstateguard (BC)

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Oct 8 13:59:03 CDT 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1444330426 -32400
#      Fri Oct 09 03:53:46 2015 +0900
# Node ID fd24d7ebe63f0c9d99dc467f1a17885b884ad2cd
# Parent  c86761d89c8b7a032af93b5058163a9f231f0131
cmdutil: stop tryimportone from using dirstateguard (BC)

There is no user of 'cmdutil.tryimportone()' other than
'commands.import_()', which can restore dirstate at failure of
applying patches by transaction or dirstateguard.

Therefore, it is reasonable to stop 'tryimportone()' from using
redundant 'dirstateguard', even though it changes behavior of
'tryimportone()'.

After this patch, 3rd party extensions should use 'dirstateguard' or
so explicitly, if they want to restore dirstate at failure of
importing a patch.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -862,7 +862,6 @@
     msg = _('applied to working directory')
 
     rejects = False
-    dsguard = None
 
     try:
         cmdline_message = logmessage(ui, opts)
@@ -904,7 +903,6 @@
 
         n = None
         if update:
-            dsguard = dirstateguard(repo, 'tryimportone')
             if p1 != parents[0]:
                 updatefunc(repo, p1.node())
             if p2 != parents[1]:
@@ -950,7 +948,6 @@
                                     editor=editor)
                 finally:
                     repo.ui.restoreconfig(allowemptyback)
-            dsguard.close()
         else:
             if opts.get('exact') or opts.get('import_branch'):
                 branch = branch or 'default'
@@ -988,7 +985,6 @@
             msg = _('created %s') % short(n)
         return (msg, n, rejects)
     finally:
-        lockmod.release(dsguard)
         os.unlink(tmpname)
 
 def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False,


More information about the Mercurial-devel mailing list