hgext/histedit.py
changeset 18437 358c23e8f1c6
parent 18436 b38c10502af9
child 18440 35513c59f376
equal deleted inserted replaced
18436:b38c10502af9 18437:358c23e8f1c6
   179 def commitfuncfor(repo, src):
   179 def commitfuncfor(repo, src):
   180     """Build a commit function for the replacement of <src>
   180     """Build a commit function for the replacement of <src>
   181 
   181 
   182     This function ensure we apply the same treatement to all changesets.
   182     This function ensure we apply the same treatement to all changesets.
   183 
   183 
   184     No such treatment is done yet.
   184     - Add a 'histedit_source' entry in extra.
   185 
   185 
   186     Note that fold have its own separated logic because its handling is a bit
   186     Note that fold have its own separated logic because its handling is a bit
   187     different and not easily factored out of the fold method.
   187     different and not easily factored out of the fold method.
   188     """
   188     """
   189     def commitfunc(**kwargs):
   189     def commitfunc(**kwargs):
       
   190         extra = kwargs.get('extra', {}).copy()
       
   191         extra['histedit_source'] = src.hex()
       
   192         kwargs['extra'] = extra
   190         return repo.commit(**kwargs)
   193         return repo.commit(**kwargs)
   191     return commitfunc
   194     return commitfunc
   192 
   195 
   193 
   196 
   194 
   197 
   268         message = commitopts['message']
   271         message = commitopts['message']
   269     else:
   272     else:
   270         message = first.description()
   273         message = first.description()
   271     user = commitopts.get('user')
   274     user = commitopts.get('user')
   272     date = commitopts.get('date')
   275     date = commitopts.get('date')
   273     extra = first.extra()
   276     extra = commitopts.get('extra')
   274 
   277 
   275     parents = (first.p1().node(), first.p2().node())
   278     parents = (first.p1().node(), first.p2().node())
   276     new = context.memctx(repo,
   279     new = context.memctx(repo,
   277                          parents=parents,
   280                          parents=parents,
   278                          text=message,
   281                          text=message,
   346         [repo[r].description() for r in internalchanges] +
   349         [repo[r].description() for r in internalchanges] +
   347         [oldctx.description()]) + '\n'
   350         [oldctx.description()]) + '\n'
   348     commitopts['message'] = newmessage
   351     commitopts['message'] = newmessage
   349     # date
   352     # date
   350     commitopts['date'] = max(ctx.date(), oldctx.date())
   353     commitopts['date'] = max(ctx.date(), oldctx.date())
       
   354     extra = ctx.extra().copy()
       
   355     # histedit_source
       
   356     # note: ctx is likely a temporary commit but that the best we can do here
       
   357     #       This is sufficient to solve issue3681 anyway
       
   358     extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex())
       
   359     commitopts['extra'] = extra
   351     n = collapse(repo, ctx, repo[newnode], commitopts)
   360     n = collapse(repo, ctx, repo[newnode], commitopts)
   352     if n is None:
   361     if n is None:
   353         return ctx, []
   362         return ctx, []
   354     hg.update(repo, n)
   363     hg.update(repo, n)
   355     replacements = [(oldctx.node(), (newnode,)),
   364     replacements = [(oldctx.node(), (newnode,)),