Patchwork [3,of,5,v3] graft: move commit info building

login
register
mail settings
Submitter David Schleimer
Date Dec. 4, 2012, 8:58 p.m.
Message ID <5b80a205b9a25ef1f6b2.1354654718@dev010.prn1.facebook.com>
Download mbox | patch
Permalink /patch/15/
State Accepted
Commit f8aee8033ab2fe7c8a7ae6d8a692d2aa2569e07a
Headers show

Comments

David Schleimer - Dec. 4, 2012, 8:58 p.m.
# HG changeset patch
# User David Schleimer <dschleimer at fb.com>
# Date 1354654458 28800
# Node ID 5b80a205b9a25ef1f6b292c5ded87a8fc73007ec
# Parent  3a6b107fd5d39114ead60e07c998da6fabb4a1dc
graft: move commit info building

This moves the logic for generating the commit metadata ahead of the
merge operation.  The only purposae of this patch is to make
subsequent patches easier to read, and there should be no behavior
changes.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2837,6 +2837,20 @@ 
             if opts.get('dry_run'):
                 continue
 
+            source = ctx.extra().get('source')
+            if not source:
+                source = ctx.hex()
+            extra = {'source': source}
+            user = ctx.user()
+            if opts.get('user'):
+                user = opts['user']
+            date = ctx.date()
+            if opts.get('date'):
+                date = opts['date']
+            message = ctx.description()
+            if opts.get('log'):
+                message += '\n(grafted from %s)' % ctx.hex()
+
             # we don't merge the first commit when continuing
             if not cont:
                 # perform the graft merge with p1(rev) as 'ancestor'
@@ -2865,19 +2879,6 @@ 
             cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
 
             # commit
-            source = ctx.extra().get('source')
-            if not source:
-                source = ctx.hex()
-            extra = {'source': source}
-            user = ctx.user()
-            if opts.get('user'):
-                user = opts['user']
-            date = ctx.date()
-            if opts.get('date'):
-                date = opts['date']
-            message = ctx.description()
-            if opts.get('log'):
-                message += '\n(grafted from %s)' % ctx.hex()
             node = repo.commit(text=message, user=user,
                         date=date, extra=extra, editor=editor)
             if node is None: