hgext/rebase.py
changeset 27260 d755a9531fce
parent 27229 40a2f972f26d
child 27261 986d04b9fedd
equal deleted inserted replaced
27259:290b41913d9f 27260:d755a9531fce
    44 # leave the attribute unspecified.
    44 # leave the attribute unspecified.
    45 testedwith = 'internal'
    45 testedwith = 'internal'
    46 
    46 
    47 def _nothingtorebase():
    47 def _nothingtorebase():
    48     return 1
    48     return 1
    49 
       
    50 def _savegraft(ctx, extra):
       
    51     s = ctx.extra().get('source', None)
       
    52     if s is not None:
       
    53         extra['source'] = s
       
    54     s = ctx.extra().get('intermediate-source', None)
       
    55     if s is not None:
       
    56         extra['intermediate-source'] = s
       
    57 
       
    58 def _savebranch(ctx, extra):
       
    59     extra['branch'] = ctx.branch()
       
    60 
    49 
    61 def _makeextrafn(copiers):
    50 def _makeextrafn(copiers):
    62     """make an extrafn out of the given copy-functions.
    51     """make an extrafn out of the given copy-functions.
    63 
    52 
    64     A copy function takes a context and an extra dict, and mutates the
    53     A copy function takes a context and an extra dict, and mutates the
   226         abortf = opts.get('abort')
   215         abortf = opts.get('abort')
   227         collapsef = opts.get('collapse', False)
   216         collapsef = opts.get('collapse', False)
   228         collapsemsg = cmdutil.logmessage(ui, opts)
   217         collapsemsg = cmdutil.logmessage(ui, opts)
   229         date = opts.get('date', None)
   218         date = opts.get('date', None)
   230         e = opts.get('extrafn') # internal, used by e.g. hgsubversion
   219         e = opts.get('extrafn') # internal, used by e.g. hgsubversion
   231         extrafns = [_savegraft]
   220         extrafns = []
   232         if e:
   221         if e:
   233             extrafns = [e]
   222             extrafns = [e]
   234         keepf = opts.get('keep', False)
   223         keepf = opts.get('keep', False)
   235         keepbranchesf = opts.get('keepbranches', False)
   224         keepbranchesf = opts.get('keepbranches', False)
   236         # keepopen is not meant for use on the command line, but by
   225         # keepopen is not meant for use on the command line, but by
   396 
   385 
   397             if dest.closesbranch() and not keepbranchesf:
   386             if dest.closesbranch() and not keepbranchesf:
   398                 ui.status(_('reopening closed branch head %s\n') % dest)
   387                 ui.status(_('reopening closed branch head %s\n') % dest)
   399 
   388 
   400         if keepbranchesf:
   389         if keepbranchesf:
   401             # insert _savebranch at the start of extrafns so if
       
   402             # there's a user-provided extrafn it can clobber branch if
       
   403             # desired
       
   404             extrafns.insert(0, _savebranch)
       
   405             if collapsef:
   390             if collapsef:
   406                 branches = set()
   391                 branches = set()
   407                 for rev in state:
   392                 for rev in state:
   408                     branches.add(repo[rev].branch())
   393                     branches.add(repo[rev].branch())
   409                     if len(branches) > 1:
   394                     if len(branches) > 1: