mercurial/localrepo.py
changeset 2020 00925397236c
parent 2019 ced2d3620f95
parent 2016 ff5c9a92f556
child 2021 fc22ed56afe3
equal deleted inserted replaced
2019:ced2d3620f95 2020:00925397236c
    29 
    29 
    30         if not create and not os.path.isdir(self.path):
    30         if not create and not os.path.isdir(self.path):
    31             raise repo.RepoError(_("repository %s not found") % path)
    31             raise repo.RepoError(_("repository %s not found") % path)
    32 
    32 
    33         self.root = os.path.abspath(path)
    33         self.root = os.path.abspath(path)
       
    34         self.origroot = path
    34         self.ui = ui.ui(parentui=parentui)
    35         self.ui = ui.ui(parentui=parentui)
    35         self.opener = util.opener(self.path)
    36         self.opener = util.opener(self.path)
    36         self.wopener = util.opener(self.root)
    37         self.wopener = util.opener(self.root)
    37         self.manifest = manifest.manifest(self.opener)
    38         self.manifest = manifest.manifest(self.opener)
    38         self.changelog = changelog.changelog(self.opener)
    39         self.changelog = changelog.changelog(self.opener)
   259         self.changelog.load()
   260         self.changelog.load()
   260         self.manifest.load()
   261         self.manifest.load()
   261         self.tagscache = None
   262         self.tagscache = None
   262         self.nodetagscache = None
   263         self.nodetagscache = None
   263 
   264 
   264     def do_lock(self, lockname, wait, releasefn=None, acquirefn=None):
   265     def do_lock(self, lockname, wait, releasefn=None, acquirefn=None,
       
   266                 desc=None):
   265         try:
   267         try:
   266             l = lock.lock(self.join(lockname), 0, releasefn)
   268             l = lock.lock(self.join(lockname), 0, releasefn, desc=desc)
   267         except lock.LockHeld, inst:
   269         except lock.LockHeld, inst:
   268             if not wait:
   270             if not wait:
   269                 raise inst
   271                 raise
   270             self.ui.warn(_("waiting for lock held by %s\n") % inst.args[0])
   272             self.ui.warn(_("waiting for lock on %s held by %s\n") %
   271             try:
   273                          (desc, inst.args[0]))
   272                 # default to 600 seconds timeout
   274             # default to 600 seconds timeout
   273                 l = lock.lock(self.join(lockname),
   275             l = lock.lock(self.join(lockname),
   274                               int(self.ui.config("ui", "timeout") or 600),
   276                           int(self.ui.config("ui", "timeout") or 600),
   275                               releasefn)
   277                           releasefn, desc=desc)
   276             except lock.LockHeld, inst:
       
   277                 raise util.Abort(_("timeout while waiting for "
       
   278                                    "lock held by %s") % inst.args[0])
       
   279         if acquirefn:
   278         if acquirefn:
   280             acquirefn()
   279             acquirefn()
   281         return l
   280         return l
   282 
   281 
   283     def lock(self, wait=1):
   282     def lock(self, wait=1):
   284         return self.do_lock("lock", wait, acquirefn=self.reload)
   283         return self.do_lock("lock", wait, acquirefn=self.reload,
       
   284                             desc=_('repository %s') % self.origroot)
   285 
   285 
   286     def wlock(self, wait=1):
   286     def wlock(self, wait=1):
   287         return self.do_lock("wlock", wait,
   287         return self.do_lock("wlock", wait, self.dirstate.write,
   288                             self.dirstate.write,
   288                             self.wreload,
   289                             self.wreload)
   289                             desc=_('working directory of %s') % self.origroot)
   290 
   290 
   291     def checkfilemerge(self, filename, text, filelog, manifest1, manifest2):
   291     def checkfilemerge(self, filename, text, filelog, manifest1, manifest2):
   292         "determine whether a new filenode is needed"
   292         "determine whether a new filenode is needed"
   293         fp1 = manifest1.get(filename, nullid)
   293         fp1 = manifest1.get(filename, nullid)
   294         fp2 = manifest2.get(filename, nullid)
   294         fp2 = manifest2.get(filename, nullid)