##// END OF EJS Templates
rewrite: simplify the `retained_extras` extra logic...
marmoute -
r51536:cbcbf63b default
parent child Browse files
Show More
@@ -24,7 +24,6 b' from mercurial.node import ('
24 wdirrev,
24 wdirrev,
25 )
25 )
26 from mercurial.pycompat import open
26 from mercurial.pycompat import open
27 from mercurial.thirdparty.jaraco.collections import Projection
28 from mercurial import (
27 from mercurial import (
29 bookmarks,
28 bookmarks,
30 cmdutil,
29 cmdutil,
@@ -86,19 +85,6 b' def _nothingtorebase():'
86 return 1
85 return 1
87
86
88
87
89 def retained_extras():
90 """
91 Yield the names of the extras to be retained.
92 """
93 # graft
94 yield b'source'
95 yield b'intermediate-source'
96
97
98 def _save_extras(ctx, extra):
99 extra.update(Projection(retained_extras(), ctx.extra()))
100
101
102 def _savebranch(ctx, extra):
88 def _savebranch(ctx, extra):
103 extra[b'branch'] = ctx.branch()
89 extra[b'branch'] = ctx.branch()
104
90
@@ -199,7 +185,7 b' class rebaseruntime:'
199 self.date = opts.get('date', None)
185 self.date = opts.get('date', None)
200
186
201 e = opts.get('extrafn') # internal, used by e.g. hgsubversion
187 e = opts.get('extrafn') # internal, used by e.g. hgsubversion
202 self.extrafns = [_save_extras]
188 self.extrafns = [rewriteutil.preserve_extras_on_rebase]
203 if e:
189 if e:
204 self.extrafns = [e]
190 self.extrafns = [e]
205
191
@@ -27,6 +27,21 b' from . import ('
27
27
28 NODE_RE = re.compile(br'\b[0-9a-f]{6,64}\b')
28 NODE_RE = re.compile(br'\b[0-9a-f]{6,64}\b')
29
29
30 # set of extra entry that should survive a rebase-like operation, extensible by extensions
31 retained_extras_on_rebase = {
32 b'source',
33 b'intermediate-source',
34 }
35
36
37 def preserve_extras_on_rebase(old_ctx, new_extra):
38 """preserve the relevant `extra` entry from old_ctx on rebase-like operation"""
39 new_extra.update(
40 (key, value)
41 for key, value in old_ctx.extra().items()
42 if key in retained_extras_on_rebase
43 )
44
30
45
31 def _formatrevs(repo, revs, maxrevs=4):
46 def _formatrevs(repo, revs, maxrevs=4):
32 """returns a string summarizing revisions in a decent size
47 """returns a string summarizing revisions in a decent size
@@ -1303,7 +1303,6 b' packages = ['
1303 'mercurial.templates',
1303 'mercurial.templates',
1304 'mercurial.thirdparty',
1304 'mercurial.thirdparty',
1305 'mercurial.thirdparty.attr',
1305 'mercurial.thirdparty.attr',
1306 'mercurial.thirdparty.jaraco',
1307 'mercurial.thirdparty.zope',
1306 'mercurial.thirdparty.zope',
1308 'mercurial.thirdparty.zope.interface',
1307 'mercurial.thirdparty.zope.interface',
1309 'mercurial.upgrade_utils',
1308 'mercurial.upgrade_utils',
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now