##// END OF EJS Templates
rebase: rework extrafn handling to support multiple extrafns...
Augie Fackler -
r19860:6cd9b842 default
parent child Browse files
Show More
@@ -29,6 +29,20 b' cmdtable = {}'
29 command = cmdutil.command(cmdtable)
29 command = cmdutil.command(cmdtable)
30 testedwith = 'internal'
30 testedwith = 'internal'
31
31
32 def _savebranch(ctx, extra):
33 extra['branch'] = ctx.branch()
34
35 def _makeextrafn(copiers):
36 """make an extrafn out of the given copy-functions.
37
38 A copy function takes a context and an extra dict, and mutates the
39 extra dict as needed based on the given context.
40 """
41 def extrafn(ctx, extra):
42 for c in copiers:
43 c(ctx, extra)
44 return extrafn
45
32 @command('rebase',
46 @command('rebase',
33 [('s', 'source', '',
47 [('s', 'source', '',
34 _('rebase from the specified changeset'), _('REV')),
48 _('rebase from the specified changeset'), _('REV')),
@@ -136,7 +150,10 b' def rebase(ui, repo, **opts):'
136 abortf = opts.get('abort')
150 abortf = opts.get('abort')
137 collapsef = opts.get('collapse', False)
151 collapsef = opts.get('collapse', False)
138 collapsemsg = cmdutil.logmessage(ui, opts)
152 collapsemsg = cmdutil.logmessage(ui, opts)
139 extrafn = opts.get('extrafn') # internal, used by e.g. hgsubversion
153 e = opts.get('extrafn') # internal, used by e.g. hgsubversion
154 extrafns = []
155 if e:
156 extrafns = [e]
140 keepf = opts.get('keep', False)
157 keepf = opts.get('keep', False)
141 keepbranchesf = opts.get('keepbranches', False)
158 keepbranchesf = opts.get('keepbranches', False)
142 # keepopen is not meant for use on the command line, but by
159 # keepopen is not meant for use on the command line, but by
@@ -240,9 +257,10 b' def rebase(ui, repo, **opts):'
240 external = checkexternal(repo, state, targetancestors)
257 external = checkexternal(repo, state, targetancestors)
241
258
242 if keepbranchesf:
259 if keepbranchesf:
243 assert not extrafn, 'cannot use both keepbranches and extrafn'
260 # insert _savebranch at the start of extrafns so if
244 def extrafn(ctx, extra):
261 # there's a user-provided extrafn it can clobber branch if
245 extra['branch'] = ctx.branch()
262 # desired
263 extrafns.insert(0, _savebranch)
246 if collapsef:
264 if collapsef:
247 branches = set()
265 branches = set()
248 for rev in state:
266 for rev in state:
@@ -262,6 +280,8 b' def rebase(ui, repo, **opts):'
262 if activebookmark:
280 if activebookmark:
263 bookmarks.unsetcurrent(repo)
281 bookmarks.unsetcurrent(repo)
264
282
283 extrafn = _makeextrafn(extrafns)
284
265 sortedstate = sorted(state)
285 sortedstate = sorted(state)
266 total = len(sortedstate)
286 total = len(sortedstate)
267 pos = 0
287 pos = 0
General Comments 0
You need to be logged in to leave comments. Login now