mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
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:
parent
93b97b7fe1
commit
613b72b258
@ -704,7 +704,7 @@ class state_update(object):
|
|||||||
calculated based on the oldnode and newnode in the leave method.'''
|
calculated based on the oldnode and newnode in the leave method.'''
|
||||||
|
|
||||||
def __init__(self, repo, name, oldnode=None, newnode=None, distance=None,
|
def __init__(self, repo, name, oldnode=None, newnode=None, distance=None,
|
||||||
partial=False):
|
partial=False, metadata=None):
|
||||||
self.repo = repo.unfiltered()
|
self.repo = repo.unfiltered()
|
||||||
self.name = name
|
self.name = name
|
||||||
self.oldnode = oldnode
|
self.oldnode = oldnode
|
||||||
@ -713,6 +713,7 @@ class state_update(object):
|
|||||||
self.partial = partial
|
self.partial = partial
|
||||||
self._lock = None
|
self._lock = None
|
||||||
self.need_leave = False
|
self.need_leave = False
|
||||||
|
self.metadata = metadata or {}
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self.enter()
|
self.enter()
|
||||||
@ -761,18 +762,19 @@ class state_update(object):
|
|||||||
if not util.safehasattr(self.repo, '_watchmanclient'):
|
if not util.safehasattr(self.repo, '_watchmanclient'):
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
self.repo._watchmanclient.command(cmd, {
|
metadata = {
|
||||||
'name': self.name,
|
# the target revision
|
||||||
'metadata': {
|
'rev': commithash,
|
||||||
# the target revision
|
# approximate number of commits between current and target
|
||||||
'rev': commithash,
|
'distance': self.distance if self.distance else 0,
|
||||||
# approximate number of commits between current and target
|
# success/failure (only really meaningful for state-leave)
|
||||||
'distance': self.distance if self.distance else 0,
|
'status': status,
|
||||||
# success/failure (only really meaningful for state-leave)
|
# whether the working copy parent is changing
|
||||||
'status': status,
|
'partial': self.partial,
|
||||||
# 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
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Swallow any errors; fire and forget
|
# 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)
|
distance = calcdistance(repo.unfiltered(), oldnode, newnode)
|
||||||
|
|
||||||
with state_update(repo, name="hg.update", oldnode=oldnode, newnode=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(
|
return orig(
|
||||||
repo, node, branchmerge, force, ancestor, mergeancestor,
|
repo, node, branchmerge, force, ancestor, mergeancestor,
|
||||||
labels, matcher, **kwargs)
|
labels, matcher, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user