...
 
Commits (8)
......@@ -798,7 +798,7 @@ class rebaseruntime(object):
shouldupdate = repo[b'.'].rev() in updateifonnodes
# Update away from the rebase if necessary
if shouldupdate or needupdate(repo, self.state):
if shouldupdate:
mergemod.update(
repo, self.originalwd, branchmerge=False, force=True
)
......@@ -1056,10 +1056,9 @@ def rebase(ui, repo, **opts):
b'changesets'
),
)
if needupdate(repo, rbsrt.state):
# update to the current working revision
# to clear interrupted merge
hg.updaterepo(repo, rbsrt.originalwd, overwrite=True)
# update to the current working revision
# to clear interrupted merge
hg.updaterepo(repo, rbsrt.originalwd, overwrite=True)
rbsrt._finishrebase()
return 0
elif inmemory:
......@@ -1430,13 +1429,13 @@ def commitmemorynode(repo, p1, p2, wctx, editor, extra, user, date, commitmsg):
# By convention, ``extra['branch']`` (set by extrafn) clobbers
# ``branch`` (used when passing ``--keepbranches``).
branch = repo[p1].branch()
branch = None
if b'branch' in extra:
branch = extra[b'branch']
wctx.setparents(repo[p1].node(), repo[p2].node())
memctx = wctx.tomemctx(
commitmsg,
parents=(p1, p2),
date=date,
extra=extra,
user=user,
......@@ -1924,25 +1923,6 @@ def clearstatus(repo):
repo.vfs.unlinkpath(b"rebasestate", ignoremissing=True)
def needupdate(repo, state):
'''check whether we should `update --clean` away from a merge, or if
somehow the working dir got forcibly updated, e.g. by older hg'''
parents = [p.rev() for p in repo[None].parents()]
# Are we in a merge state at all?
if len(parents) < 2:
return False
# We should be standing on the first as-of-yet unrebased commit.
firstunrebased = min(
[old for old, new in pycompat.iteritems(state) if new == nullrev]
)
if firstunrebased in parents:
return True
return False
def sortsource(destmap):
"""yield source revisions in an order that we only rebase things once
......
......@@ -167,10 +167,10 @@ class appender(object):
def _divertopener(opener, target):
"""build an opener that writes in 'target.a' instead of 'target'"""
def _divert(name, mode=b'r', checkambig=False):
def _divert(name, mode=b'r', checkambig=False, **kwargs):
if name != target:
return opener(name, mode)
return opener(name + b".a", mode)
return opener(name, mode, **kwargs)
return opener(name + b".a", mode, **kwargs)
return _divert
......@@ -178,9 +178,10 @@ def _divertopener(opener, target):
def _delayopener(opener, target, buf):
"""build an opener that stores chunks in 'buf' instead of 'target'"""
def _delay(name, mode=b'r', checkambig=False):
def _delay(name, mode=b'r', checkambig=False, **kwargs):
if name != target:
return opener(name, mode)
return opener(name, mode, **kwargs)
assert not kwargs
return appender(opener, name, mode, buf)
return _delay
......
......@@ -2429,12 +2429,16 @@ def walkchangerevs(repo, match, opts, prepare):
def fns_generator():
if allfiles:
fiter = iter(ctx)
else:
fiter = ctx.files()
for f in fiter:
if match(f):
def bad(f, msg):
pass
for f in ctx.matches(matchmod.badmatch(match, bad)):
yield f
else:
for f in ctx.files():
if match(f):
yield f
fns = fns_generator()
prepare(ctx, fns)
......
......@@ -1528,6 +1528,23 @@ class workingctx(committablectx):
for n in p
]
def setparents(self, p1node, p2node=nullid):
dirstate = self._repo.dirstate
with dirstate.parentchange():
copies = dirstate.setparents(p1node, p2node)
pctx = self._repo[p1node]
if copies:
# Adjust copy records, the dirstate cannot do it, it
# requires access to parents manifests. Preserve them
# only for entries added to first parent.
for f in copies:
if f not in pctx and copies[f] in pctx:
dirstate.copy(copies[f], f)
if p2node == nullid:
for f, s in sorted(dirstate.copies().items()):
if f not in pctx and s not in pctx:
dirstate.copy(None, f)
def _fileinfo(self, path):
# populate __dict__['_manifest'] as workingctx has no _manifestdelta
self._manifest
......@@ -2161,6 +2178,10 @@ class overlayworkingctx(committablectx):
# ``overlayworkingctx`` (e.g. with --collapse).
util.clearcachedproperty(self, b'_manifest')
def setparents(self, p1node, p2node=nullid):
assert p1node == self._wrappedctx.node()
self._parents = [self._wrappedctx, self._repo.unfiltered()[p2node]]
def data(self, path):
if self.isdirty(path):
if self._cache[path][b'exists']:
......@@ -2415,9 +2436,9 @@ class overlayworkingctx(committablectx):
``text`` is the commit message.
``parents`` (optional) are rev numbers.
"""
# Default parents to the wrapped contexts' if not passed.
# Default parents to the wrapped context if not passed.
if parents is None:
parents = self._wrappedctx.parents()
parents = self.parents()
if len(parents) == 1:
parents = (parents[0], None)
......@@ -2445,6 +2466,9 @@ class overlayworkingctx(committablectx):
# necessary for memctx to register a deletion.
return None
if branch is None:
branch = self._wrappedctx.branch()
return memctx(
self._repo,
parents,
......
......@@ -1886,20 +1886,7 @@ class localrepository(object):
return self.vfs.reljoin(self.root, f, *insidef)
def setparents(self, p1, p2=nullid):
with self.dirstate.parentchange():
copies = self.dirstate.setparents(p1, p2)
pctx = self[p1]
if copies:
# Adjust copy records, the dirstate cannot do it, it
# requires access to parents manifests. Preserve them
# only for entries added to first parent.
for f in copies:
if f not in pctx and copies[f] in pctx:
self.dirstate.copy(copies[f], f)
if p2 == nullid:
for f, s in sorted(self.dirstate.copies().items()):
if f not in pctx and s not in pctx:
self.dirstate.copy(None, f)
self[None].setparents(p1, p2)
def filectx(self, path, changeid=None, fileid=None, changectx=None):
"""changeid must be a changeset revision, if specified.
......
......@@ -592,10 +592,10 @@ class revlog(object):
self._storedeltachains = True
self._io = revlogio()
if rustrevlog is not None and self.opener.options.get(b'rust.index'):
self._io = rustrevlogio()
if self.version == REVLOGV0:
self._io = revlogoldio()
elif rustrevlog is not None and self.opener.options.get(b'rust.index'):
self._io = rustrevlogio()
try:
d = self._io.parseindex(indexdata, self._inline)
except (ValueError, IndexError):
......
......@@ -456,6 +456,12 @@ class transaction(util.transactional):
return self._anypending
@active
def hasfinalize(self, category):
"""check is a callback already exist for a category
"""
return category in self._finalizecallback
@active
def addfinalize(self, category, callback):
"""add a callback to be called when the transaction is closed
......