Patchwork [2,of,3] import: inline checkexact function

login
register
mail settings
Submitter Pierre-Yves David
Date April 17, 2013, 8:57 a.m.
Message ID <66fdcdc7cb399d62bb7b.1366189067@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/1379/
State Accepted
Commit 1dc393614e61beba91bd1e42f7174b317c059f21
Headers show

Comments

Pierre-Yves David - April 17, 2013, 8:57 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1366187114 -7200
#      Wed Apr 17 10:25:14 2013 +0200
# Node ID 66fdcdc7cb399d62bb7bcc4115df3a79c89196e8
# Parent  9d42bbd12d4340f81f080913d44f9fd212c6f30f
import: inline checkexact function

We have  sngle clal now. no need to make it a function.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3601,14 +3601,10 @@  def import_(ui, repo, patch1=None, *patc
     base = opts["base"]
     strip = opts["strip"]
     wlock = lock = tr = None
     msgs = []
 
-    def checkexact(repo, n, nodeid):
-        if opts.get('exact') and hex(n) != nodeid:
-            raise util.Abort(_('patch is damaged or loses information'))
-
     def tryone(ui, hunk, parents):
         tmpname, message, user, date, branch, nodeid, p1, p2 = \
             patch.extract(ui, hunk)
 
         if not tmpname:
@@ -3699,11 +3695,12 @@  def import_(ui, repo, patch1=None, *patc
                                               editor=cmdutil.commiteditor)
                     repo.savecommitmessage(memctx.description())
                     n = memctx.commit()
                 finally:
                     store.close()
-            checkexact(repo, n, nodeid)
+            if opts.get('exact') and hex(n) != nodeid:
+                raise util.Abort(_('patch is damaged or loses information'))
             if n:
                 # i18n: refers to a short changeset id
                 msg = _('created %s') % short(n)
             return (msg, n)
         finally: