1735 ) |
1735 ) |
1736 |
1736 |
1737 return data |
1737 return data |
1738 |
1738 |
1739 |
1739 |
1740 def _locksub(repo, lock, envvar, cmd, environ=None, *args, **kwargs): |
|
1741 if lock is None: |
|
1742 raise error.LockInheritanceContractViolation( |
|
1743 b'lock can only be inherited while held' |
|
1744 ) |
|
1745 if environ is None: |
|
1746 environ = {} |
|
1747 with lock.inherit() as locker: |
|
1748 environ[envvar] = locker |
|
1749 return repo.ui.system(cmd, environ=environ, *args, **kwargs) |
|
1750 |
|
1751 |
|
1752 def wlocksub(repo, cmd, *args, **kwargs): |
|
1753 """run cmd as a subprocess that allows inheriting repo's wlock |
|
1754 |
|
1755 This can only be called while the wlock is held. This takes all the |
|
1756 arguments that ui.system does, and returns the exit code of the |
|
1757 subprocess.""" |
|
1758 return _locksub( |
|
1759 repo, repo.currentwlock(), b'HG_WLOCK_LOCKER', cmd, *args, **kwargs |
|
1760 ) |
|
1761 |
|
1762 |
|
1763 class progress(object): |
1740 class progress(object): |
1764 def __init__(self, ui, updatebar, topic, unit=b"", total=None): |
1741 def __init__(self, ui, updatebar, topic, unit=b"", total=None): |
1765 self.ui = ui |
1742 self.ui = ui |
1766 self.pos = 0 |
1743 self.pos = 0 |
1767 self.topic = topic |
1744 self.topic = topic |