Patchwork [5,of,6] cmdutil: call memctx directly instead of makememctx

login
register
mail settings
Submitter Sean Farley
Date Aug. 6, 2014, 8:42 p.m.
Message ID <cefda708ede4ff90ff5d.1407357731@178.1.168.192.in-addr.arpa>
Download mbox | patch
Permalink /patch/5298/
State Accepted
Headers show

Comments

Sean Farley - Aug. 6, 2014, 8:42 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1402871026 25200
#      Sun Jun 15 15:23:46 2014 -0700
# Node ID cefda708ede4ff90ff5db86885c3118509461ec0
# Parent  afeff43a1849fae470730880a7c949d28fc25750
cmdutil: call memctx directly instead of makememctx

Now that a memctx can take a store-type object directly, let's use that instead
of makememctx.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -598,10 +598,11 @@  def tryimportone(ui, repo, hunk, parents
     strip = opts["strip"]
     sim = float(opts.get('similarity') or 0)
     if not tmpname:
         return (None, None, False)
     msg = _('applied to working directory')
+    extra = {}
 
     rejects = False
 
     try:
         cmdline_message = logmessage(ui, opts)
@@ -674,28 +675,30 @@  def tryimportone(ui, repo, hunk, parents
                 n = repo.commit(message, opts.get('user') or user,
                                 opts.get('date') or date, match=m,
                                 editor=editor, force=partial)
         else:
             if opts.get('exact') or opts.get('import_branch'):
-                branch = branch or 'default'
+                extra['branch'] = branch or 'default'
             else:
-                branch = p1.branch()
+                extra['branch'] = p1.branch()
             store = patch.filestore()
             try:
                 files = set()
                 try:
                     patch.patchrepo(ui, repo, p1, store, tmpname, strip,
                                     files, eolmode=None)
                 except patch.PatchError, e:
                     raise util.Abort(str(e))
                 editor = getcommiteditor(editform='import.bypass')
-                memctx = context.makememctx(repo, (p1.node(), p2.node()),
-                                            message,
-                                            opts.get('user') or user,
-                                            opts.get('date') or date,
-                                            branch, files, store,
-                                            editor=editor)
+                memctx = context.memctx(repo, (p1.node(), p2.node()),
+                                        message,
+                                        files,
+                                        store,
+                                        opts.get('user') or user,
+                                        opts.get('date') or date,
+                                        extra,
+                                        editor=getcommiteditor())
                 n = memctx.commit()
             finally:
                 store.close()
         if opts.get('exact') and hex(n) != nodeid:
             raise util.Abort(_('patch is damaged or loses information'))