##// END OF EJS Templates
narrow: filter merge actions in core...
Martin von Zweigbergk -
r38055:8f37b5fc default
parent child Browse files
Show More
@@ -7,48 +7,13 b''
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 from mercurial.i18n import _
11 from mercurial import (
10 from mercurial import (
12 copies,
11 copies,
13 error,
14 extensions,
12 extensions,
15 merge,
13 merge,
16 )
14 )
17
15
18 def setup():
16 def setup():
19 def _manifestmerge(orig, repo, wctx, p2, pa, branchmerge, *args, **kwargs):
20 """Filter updates to only lay out files that match the narrow spec."""
21 actions, diverge, renamedelete = orig(
22 repo, wctx, p2, pa, branchmerge, *args, **kwargs)
23
24 narrowmatch = repo.narrowmatch()
25 if narrowmatch.always():
26 return actions, diverge, renamedelete
27
28 nooptypes = set(['k']) # TODO: handle with nonconflicttypes
29 nonconflicttypes = set('a am c cm f g r e'.split())
30 # We mutate the items in the dict during iteration, so iterate
31 # over a copy.
32 for f, action in list(actions.items()):
33 if narrowmatch(f):
34 pass
35 elif not branchmerge:
36 del actions[f] # just updating, ignore changes outside clone
37 elif action[0] in nooptypes:
38 del actions[f] # merge does not affect file
39 elif action[0] in nonconflicttypes:
40 raise error.Abort(_('merge affects file \'%s\' outside narrow, '
41 'which is not yet supported') % f,
42 hint=_('merging in the other direction '
43 'may work'))
44 else:
45 raise error.Abort(_('conflict in file \'%s\' is outside '
46 'narrow clone') % f)
47
48 return actions, diverge, renamedelete
49
50 extensions.wrapfunction(merge, 'manifestmerge', _manifestmerge)
51
52 def _checkcollision(orig, repo, wmf, actions):
17 def _checkcollision(orig, repo, wmf, actions):
53 narrowmatch = repo.narrowmatch()
18 narrowmatch = repo.narrowmatch()
54 if not narrowmatch.always():
19 if not narrowmatch.always():
@@ -1072,6 +1072,33 b' def checkpathconflicts(repo, wctx, mctx,'
1072 repo.ui.warn(_("%s: is both a file and a directory\n") % p)
1072 repo.ui.warn(_("%s: is both a file and a directory\n") % p)
1073 raise error.Abort(_("destination manifest contains path conflicts"))
1073 raise error.Abort(_("destination manifest contains path conflicts"))
1074
1074
1075 def _filternarrowactions(narrowmatch, branchmerge, actions):
1076 """
1077 Filters out actions that can ignored because the repo is narrowed.
1078
1079 Raise an exception if the merge cannot be completed because the repo is
1080 narrowed.
1081 """
1082 nooptypes = set(['k']) # TODO: handle with nonconflicttypes
1083 nonconflicttypes = set('a am c cm f g r e'.split())
1084 # We mutate the items in the dict during iteration, so iterate
1085 # over a copy.
1086 for f, action in list(actions.items()):
1087 if narrowmatch(f):
1088 pass
1089 elif not branchmerge:
1090 del actions[f] # just updating, ignore changes outside clone
1091 elif action[0] in nooptypes:
1092 del actions[f] # merge does not affect file
1093 elif action[0] in nonconflicttypes:
1094 raise error.Abort(_('merge affects file \'%s\' outside narrow, '
1095 'which is not yet supported') % f,
1096 hint=_('merging in the other direction '
1097 'may work'))
1098 else:
1099 raise error.Abort(_('conflict in file \'%s\' is outside '
1100 'narrow clone') % f)
1101
1075 def manifestmerge(repo, wctx, p2, pa, branchmerge, force, matcher,
1102 def manifestmerge(repo, wctx, p2, pa, branchmerge, force, matcher,
1076 acceptremote, followcopies, forcefulldiff=False):
1103 acceptremote, followcopies, forcefulldiff=False):
1077 """
1104 """
@@ -1256,6 +1283,11 b' def manifestmerge(repo, wctx, p2, pa, br'
1256 # If we are merging, look for path conflicts.
1283 # If we are merging, look for path conflicts.
1257 checkpathconflicts(repo, wctx, p2, actions)
1284 checkpathconflicts(repo, wctx, p2, actions)
1258
1285
1286 narrowmatch = repo.narrowmatch()
1287 if not narrowmatch.always():
1288 # Updates "actions" in place
1289 _filternarrowactions(narrowmatch, branchmerge, actions)
1290
1259 return actions, diverge, renamedelete
1291 return actions, diverge, renamedelete
1260
1292
1261 def _resolvetrivial(repo, wctx, mctx, ancestor, actions):
1293 def _resolvetrivial(repo, wctx, mctx, ancestor, actions):
General Comments 0
You need to be logged in to leave comments. Login now