fsmonitor: add "merge" metadata to "hg.update" state

Summary:
The "merge" metadata is a boolean value that indicates whether a merge of
two branches are ongoing and could have potential conflicts.

Note: state-leave does not mean the merge conflict is resolved. There might
still be unresolved conflicts in the working copy.

Differential Revision: D7286169

fbshipit-source-id: 0948174eb9a9d7c28af64b8ade58dc509d49f747
This commit is contained in:
Jun Wu 2018-03-15 11:06:20 -07:00 committed by Saurabh Singh
parent 93b97b7fe1
commit 613b72b258

View File

@ -704,7 +704,7 @@ class state_update(object):
calculated based on the oldnode and newnode in the leave method.'''
def __init__(self, repo, name, oldnode=None, newnode=None, distance=None,
partial=False):
partial=False, metadata=None):
self.repo = repo.unfiltered()
self.name = name
self.oldnode = oldnode
@ -713,6 +713,7 @@ class state_update(object):
self.partial = partial
self._lock = None
self.need_leave = False
self.metadata = metadata or {}
def __enter__(self):
self.enter()
@ -761,18 +762,19 @@ class state_update(object):
if not util.safehasattr(self.repo, '_watchmanclient'):
return False
try:
self.repo._watchmanclient.command(cmd, {
'name': self.name,
'metadata': {
# the target revision
'rev': commithash,
# approximate number of commits between current and target
'distance': self.distance if self.distance else 0,
# success/failure (only really meaningful for state-leave)
'status': status,
# whether the working copy parent is changing
'partial': self.partial,
}})
metadata = {
# the target revision
'rev': commithash,
# approximate number of commits between current and target
'distance': self.distance if self.distance else 0,
# success/failure (only really meaningful for state-leave)
'status': status,
# whether the working copy parent is changing
'partial': self.partial,
}
metadata.update(self.metadata)
self.repo._watchmanclient.command(cmd, {'name': self.name,
'metadata': metadata})
return True
except Exception as e:
# Swallow any errors; fire and forget
@ -804,7 +806,8 @@ def wrapupdate(orig, repo, node, branchmerge, force, ancestor=None,
distance = calcdistance(repo.unfiltered(), oldnode, newnode)
with state_update(repo, name="hg.update", oldnode=oldnode, newnode=newnode,
distance=distance, partial=partial):
distance=distance, partial=partial,
metadata={'merge': branchmerge}):
return orig(
repo, node, branchmerge, force, ancestor, mergeancestor,
labels, matcher, **kwargs)