Show More
@@ -90,6 +90,7 b' class mergestate(object):' | |||||
90 | self._local = node |
|
90 | self._local = node | |
91 | self._other = other |
|
91 | self._other = other | |
92 | self._mdstate = 'u' |
|
92 | self._mdstate = 'u' | |
|
93 | self._readmergedriver = None | |||
93 | shutil.rmtree(self._repo.join('merge'), True) |
|
94 | shutil.rmtree(self._repo.join('merge'), True) | |
94 | self._dirty = False |
|
95 | self._dirty = False | |
95 |
|
96 | |||
@@ -105,6 +106,7 b' class mergestate(object):' | |||||
105 | self._mdstate = 'u' |
|
106 | self._mdstate = 'u' | |
106 | if 'otherctx' in vars(self): |
|
107 | if 'otherctx' in vars(self): | |
107 | del self.otherctx |
|
108 | del self.otherctx | |
|
109 | self._readmergedriver = None | |||
108 | records = self._readrecords() |
|
110 | records = self._readrecords() | |
109 | for rtype, record in records: |
|
111 | for rtype, record in records: | |
110 | if rtype == 'L': |
|
112 | if rtype == 'L': | |
@@ -118,18 +120,7 b' class mergestate(object):' | |||||
118 | # the merge driver should be idempotent, so just rerun it |
|
120 | # the merge driver should be idempotent, so just rerun it | |
119 | mdstate = 'u' |
|
121 | mdstate = 'u' | |
120 |
|
122 | |||
121 | # protect against the following: |
|
123 | self._readmergedriver = bits[0] | |
122 | # - A configures a malicious merge driver in their hgrc, then |
|
|||
123 | # pauses the merge |
|
|||
124 | # - A edits their hgrc to remove references to the merge driver |
|
|||
125 | # - A gives a copy of their entire repo, including .hg, to B |
|
|||
126 | # - B inspects .hgrc and finds it to be clean |
|
|||
127 | # - B then continues the merge and the malicious merge driver |
|
|||
128 | # gets invoked |
|
|||
129 | if self.mergedriver != bits[0]: |
|
|||
130 | raise error.ConfigError( |
|
|||
131 | _("merge driver changed since merge started"), |
|
|||
132 | hint=_("revert merge driver change or abort merge")) |
|
|||
133 | self._mdstate = mdstate |
|
124 | self._mdstate = mdstate | |
134 | elif rtype in 'FD': |
|
125 | elif rtype in 'FD': | |
135 | bits = record.split('\0') |
|
126 | bits = record.split('\0') | |
@@ -236,7 +227,23 b' class mergestate(object):' | |||||
236 |
|
227 | |||
237 | @util.propertycache |
|
228 | @util.propertycache | |
238 | def mergedriver(self): |
|
229 | def mergedriver(self): | |
239 | return self._repo.ui.config('experimental', 'mergedriver') |
|
230 | # protect against the following: | |
|
231 | # - A configures a malicious merge driver in their hgrc, then | |||
|
232 | # pauses the merge | |||
|
233 | # - A edits their hgrc to remove references to the merge driver | |||
|
234 | # - A gives a copy of their entire repo, including .hg, to B | |||
|
235 | # - B inspects .hgrc and finds it to be clean | |||
|
236 | # - B then continues the merge and the malicious merge driver | |||
|
237 | # gets invoked | |||
|
238 | configmergedriver = self._repo.ui.config('experimental', 'mergedriver') | |||
|
239 | if (self._readmergedriver is not None | |||
|
240 | and self._readmergedriver != configmergedriver): | |||
|
241 | raise error.ConfigError( | |||
|
242 | _("merge driver changed since merge started"), | |||
|
243 | hint=_("revert merge driver change or abort merge")) | |||
|
244 | ||||
|
245 | return configmergedriver | |||
|
246 | ||||
240 | @util.propertycache |
|
247 | @util.propertycache | |
241 | def otherctx(self): |
|
248 | def otherctx(self): | |
242 | return self._repo[self._other] |
|
249 | return self._repo[self._other] |
General Comments 0
You need to be logged in to leave comments.
Login now