1590 parentlock = None |
1590 parentlock = None |
1591 # the contents of parentenvvar are used by the underlying lock to |
1591 # the contents of parentenvvar are used by the underlying lock to |
1592 # determine whether it can be inherited |
1592 # determine whether it can be inherited |
1593 if parentenvvar is not None: |
1593 if parentenvvar is not None: |
1594 parentlock = encoding.environ.get(parentenvvar) |
1594 parentlock = encoding.environ.get(parentenvvar) |
1595 try: |
1595 |
1596 l = lockmod.lock(vfs, lockname, 0, releasefn=releasefn, |
1596 timeout = 0 |
1597 acquirefn=acquirefn, desc=desc, |
1597 if wait: |
1598 inheritchecker=inheritchecker, |
1598 timeout = self.ui.configint("ui", "timeout") |
1599 parentlock=parentlock) |
1599 |
1600 except error.LockHeld as inst: |
1600 l = lockmod.trylock(self.ui, vfs, lockname, timeout, |
1601 if not wait: |
1601 releasefn=releasefn, |
1602 raise |
1602 acquirefn=acquirefn, desc=desc, |
1603 # show more details for new-style locks |
1603 inheritchecker=inheritchecker, |
1604 if ':' in inst.locker: |
1604 parentlock=parentlock) |
1605 host, pid = inst.locker.split(":", 1) |
|
1606 self.ui.warn( |
|
1607 _("waiting for lock on %s held by process %r " |
|
1608 "on host %r\n") % (desc, pid, host)) |
|
1609 else: |
|
1610 self.ui.warn(_("waiting for lock on %s held by %r\n") % |
|
1611 (desc, inst.locker)) |
|
1612 # default to 600 seconds timeout |
|
1613 l = lockmod.lock(vfs, lockname, |
|
1614 self.ui.configint("ui", "timeout"), |
|
1615 releasefn=releasefn, acquirefn=acquirefn, |
|
1616 desc=desc) |
|
1617 self.ui.warn(_("got lock after %s seconds\n") % l.delay) |
|
1618 return l |
1605 return l |
1619 |
1606 |
1620 def _afterlock(self, callback): |
1607 def _afterlock(self, callback): |
1621 """add a callback to be run when the repository is fully unlocked |
1608 """add a callback to be run when the repository is fully unlocked |
1622 |
1609 |