Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.py @ 41954:e1ceefab9bca
rebase: fix crash with in-memory rebase and copies
When using regular on-disk rebase, filectx.markcopies() calls to
dirstate.copy(), which happily records the copy. Then it's simply
ignored if it doesn't matter for the commit (as in the test case I
added in the previous patch). Let's do the same for overlayworkingctx.
Differential Revision: https://phab.mercurial-scm.org/D6133
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 14 Mar 2019 14:46:29 -0700 |
parents | 2ba96fca8528 |
children | 21cc92fea2aa |
comparison
equal
deleted
inserted
replaced
41953:dd1ab72be983 | 41954:e1ceefab9bca |
---|---|
1889 return self._cache[path]['date'] | 1889 return self._cache[path]['date'] |
1890 else: | 1890 else: |
1891 return self._wrappedctx[path].date() | 1891 return self._wrappedctx[path].date() |
1892 | 1892 |
1893 def markcopied(self, path, origin): | 1893 def markcopied(self, path, origin): |
1894 if self.isdirty(path): | 1894 self._markdirty(path, exists=True, date=self.filedate(path), |
1895 self._cache[path]['copied'] = origin | 1895 flags=self.flags(path), copied=origin) |
1896 else: | |
1897 raise error.ProgrammingError('markcopied() called on clean context') | |
1898 | 1896 |
1899 def copydata(self, path): | 1897 def copydata(self, path): |
1900 if self.isdirty(path): | 1898 if self.isdirty(path): |
1901 return self._cache[path]['copied'] | 1899 return self._cache[path]['copied'] |
1902 else: | 1900 else: |
2096 | 2094 |
2097 for path in keys: | 2095 for path in keys: |
2098 del self._cache[path] | 2096 del self._cache[path] |
2099 return keys | 2097 return keys |
2100 | 2098 |
2101 def _markdirty(self, path, exists, data=None, date=None, flags=''): | 2099 def _markdirty(self, path, exists, data=None, date=None, flags='', |
2100 copied=None): | |
2102 # data not provided, let's see if we already have some; if not, let's | 2101 # data not provided, let's see if we already have some; if not, let's |
2103 # grab it from our underlying context, so that we always have data if | 2102 # grab it from our underlying context, so that we always have data if |
2104 # the file is marked as existing. | 2103 # the file is marked as existing. |
2105 if exists and data is None: | 2104 if exists and data is None: |
2106 oldentry = self._cache.get(path) or {} | 2105 oldentry = self._cache.get(path) or {} |
2109 self._cache[path] = { | 2108 self._cache[path] = { |
2110 'exists': exists, | 2109 'exists': exists, |
2111 'data': data, | 2110 'data': data, |
2112 'date': date, | 2111 'date': date, |
2113 'flags': flags, | 2112 'flags': flags, |
2114 'copied': None, | 2113 'copied': copied, |
2115 } | 2114 } |
2116 | 2115 |
2117 def filectx(self, path, filelog=None): | 2116 def filectx(self, path, filelog=None): |
2118 return overlayworkingfilectx(self._repo, path, parent=self, | 2117 return overlayworkingfilectx(self._repo, path, parent=self, |
2119 filelog=filelog) | 2118 filelog=filelog) |