Patchwork D2922: rebase: look up default date outside of conclude[memory]node()

login
register
mail settings
Submitter phabricator
Date March 21, 2018, 6:11 p.m.
Message ID <differential-rev-PHID-DREV-tvegl4bf645ahataia2g-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29710/
State Superseded
Headers show

Comments

phabricator - March 21, 2018, 6:11 p.m.
martinvonz created this revision.
martinvonz added a reviewer: phillco.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2922

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS




To: martinvonz, phillco, #hg-reviewers
Cc: mercurial-devel
phabricator - March 21, 2018, 11:46 p.m.
indygreg accepted this revision.
indygreg added inline comments.
This revision is now accepted and ready to land.

INLINE COMMENTS

> rebase.py:449-451
> +        date = self.date
> +        if date is None:
> +            date = ctx.date()

We could probably write this as `date = self.date or ctx.date()`, since date values can never be an empty string. But this is strictly equivalent to what came before. So meh.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2922

To: martinvonz, phillco, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -446,6 +446,9 @@ 
         ctx = repo[rev]
         if commitmsg is None:
             commitmsg = ctx.description()
+        date = self.date
+        if date is None:
+            date = ctx.date()
         extra = {'rebase_source': ctx.hex()}
         for c in self.extrafns:
             c(ctx, extra)
@@ -461,14 +464,14 @@ 
                     extra=extra,
                     commitmsg=commitmsg,
                     editor=editor,
-                    date=self.date)
+                    date=date)
                 mergemod.mergestate.clean(repo)
             else:
                 newnode = concludenode(repo, ctx, p1, p2,
                     extra=extra,
                     commitmsg=commitmsg,
                     editor=editor,
-                    date=self.date)
+                    date=date)
 
             if newnode is None:
                 # If it ended up being a no-op commit, then the normal
@@ -1035,9 +1038,6 @@ 
     if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'):
         return None
 
-    if date is None:
-        date = ctx.date()
-
     # By convention, ``extra['branch']`` (set by extrafn) clobbers
     # ``branch`` (used when passing ``--keepbranches``).
     branch = repo[p1].branch()
@@ -1060,8 +1060,6 @@ 
         repo.setparents(repo[p1].node(), repo[p2].node())
 
         # Commit might fail if unresolved files exist
-        if date is None:
-            date = ctx.date()
         newnode = repo.commit(text=commitmsg, user=ctx.user(),
                               date=date, extra=extra, editor=editor)