hgext/rebase.py
changeset 37041 0b1230a5a958
parent 37040 b8d305bd12ca
child 37042 8ff5772711fa
equal deleted inserted replaced
37040:b8d305bd12ca 37041:0b1230a5a958
   444         Return node of committed revision.'''
   444         Return node of committed revision.'''
   445         repo = self.repo
   445         repo = self.repo
   446         ctx = repo[rev]
   446         ctx = repo[rev]
   447         if commitmsg is None:
   447         if commitmsg is None:
   448             commitmsg = ctx.description()
   448             commitmsg = ctx.description()
       
   449         date = self.date
       
   450         if date is None:
       
   451             date = ctx.date()
   449         extra = {'rebase_source': ctx.hex()}
   452         extra = {'rebase_source': ctx.hex()}
   450         for c in self.extrafns:
   453         for c in self.extrafns:
   451             c(ctx, extra)
   454             c(ctx, extra)
   452         keepbranch = self.keepbranchesf and repo[p1].branch() != ctx.branch()
   455         keepbranch = self.keepbranchesf and repo[p1].branch() != ctx.branch()
   453         destphase = max(ctx.phase(), phases.draft)
   456         destphase = max(ctx.phase(), phases.draft)
   459                 newnode = concludememorynode(repo, ctx, p1, p2,
   462                 newnode = concludememorynode(repo, ctx, p1, p2,
   460                     wctx=self.wctx,
   463                     wctx=self.wctx,
   461                     extra=extra,
   464                     extra=extra,
   462                     commitmsg=commitmsg,
   465                     commitmsg=commitmsg,
   463                     editor=editor,
   466                     editor=editor,
   464                     date=self.date)
   467                     date=date)
   465                 mergemod.mergestate.clean(repo)
   468                 mergemod.mergestate.clean(repo)
   466             else:
   469             else:
   467                 newnode = concludenode(repo, ctx, p1, p2,
   470                 newnode = concludenode(repo, ctx, p1, p2,
   468                     extra=extra,
   471                     extra=extra,
   469                     commitmsg=commitmsg,
   472                     commitmsg=commitmsg,
   470                     editor=editor,
   473                     editor=editor,
   471                     date=self.date)
   474                     date=date)
   472 
   475 
   473             if newnode is None:
   476             if newnode is None:
   474                 # If it ended up being a no-op commit, then the normal
   477                 # If it ended up being a no-op commit, then the normal
   475                 # merge state clean-up path doesn't happen, so do it
   478                 # merge state clean-up path doesn't happen, so do it
   476                 # here. Fix issue5494
   479                 # here. Fix issue5494
  1033     Return node of committed revision.'''
  1036     Return node of committed revision.'''
  1034     # Replicates the empty check in ``repo.commit``.
  1037     # Replicates the empty check in ``repo.commit``.
  1035     if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'):
  1038     if wctx.isempty() and not repo.ui.configbool('ui', 'allowemptycommit'):
  1036         return None
  1039         return None
  1037 
  1040 
  1038     if date is None:
       
  1039         date = ctx.date()
       
  1040 
       
  1041     # By convention, ``extra['branch']`` (set by extrafn) clobbers
  1041     # By convention, ``extra['branch']`` (set by extrafn) clobbers
  1042     # ``branch`` (used when passing ``--keepbranches``).
  1042     # ``branch`` (used when passing ``--keepbranches``).
  1043     branch = repo[p1].branch()
  1043     branch = repo[p1].branch()
  1044     if 'branch' in extra:
  1044     if 'branch' in extra:
  1045         branch = extra['branch']
  1045         branch = extra['branch']
  1058         dsguard = dirstateguard.dirstateguard(repo, 'rebase')
  1058         dsguard = dirstateguard.dirstateguard(repo, 'rebase')
  1059     with dsguard:
  1059     with dsguard:
  1060         repo.setparents(repo[p1].node(), repo[p2].node())
  1060         repo.setparents(repo[p1].node(), repo[p2].node())
  1061 
  1061 
  1062         # Commit might fail if unresolved files exist
  1062         # Commit might fail if unresolved files exist
  1063         if date is None:
       
  1064             date = ctx.date()
       
  1065         newnode = repo.commit(text=commitmsg, user=ctx.user(),
  1063         newnode = repo.commit(text=commitmsg, user=ctx.user(),
  1066                               date=date, extra=extra, editor=editor)
  1064                               date=date, extra=extra, editor=editor)
  1067 
  1065 
  1068         repo.dirstate.setbranch(repo[newnode].branch())
  1066         repo.dirstate.setbranch(repo[newnode].branch())
  1069         return newnode
  1067         return newnode