##// END OF EJS Templates
Allow callers to pass in the dirstate lock in most localrepo.py funcs....
mason@suse.com -
r1712:21dcf38e default
parent child Browse files
Show More
@@ -519,6 +519,9 b' def addremove(ui, repo, *pats, **opts):'
519 New files are ignored if they match any of the patterns in .hgignore. As
519 New files are ignored if they match any of the patterns in .hgignore. As
520 with add, these changes take effect at the next commit.
520 with add, these changes take effect at the next commit.
521 """
521 """
522 return addremove_lock(ui, repo, pats, opts)
523
524 def addremove_lock(ui, repo, pats, opts, wlock=None):
522 add, remove = [], []
525 add, remove = [], []
523 for src, abs, rel, exact in walk(repo, pats, opts):
526 for src, abs, rel, exact in walk(repo, pats, opts):
524 if src == 'f' and repo.dirstate.state(abs) == '?':
527 if src == 'f' and repo.dirstate.state(abs) == '?':
@@ -529,8 +532,8 b' def addremove(ui, repo, *pats, **opts):'
529 remove.append(abs)
532 remove.append(abs)
530 if ui.verbose or not exact:
533 if ui.verbose or not exact:
531 ui.status(_('removing %s\n') % ((pats and rel) or abs))
534 ui.status(_('removing %s\n') % ((pats and rel) or abs))
532 repo.add(add)
535 repo.add(add, wlock=wlock)
533 repo.remove(remove)
536 repo.remove(remove, wlock=wlock)
534
537
535 def annotate(ui, repo, *pats, **opts):
538 def annotate(ui, repo, *pats, **opts):
536 """show changeset information per file line
539 """show changeset information per file line
@@ -236,8 +236,9 b' class localrepository(object):'
236 self.ui.warn(_("no interrupted transaction available\n"))
236 self.ui.warn(_("no interrupted transaction available\n"))
237 return False
237 return False
238
238
239 def undo(self):
239 def undo(self, wlock=None):
240 wlock = self.wlock()
240 if not wlock:
241 wlock = self.wlock()
241 lock = self.lock()
242 lock = self.lock()
242 if os.path.exists(self.join("undo")):
243 if os.path.exists(self.join("undo")):
243 self.ui.status(_("rolling back last transaction\n"))
244 self.ui.status(_("rolling back last transaction\n"))
@@ -267,7 +268,7 b' class localrepository(object):'
267 self.dirstate.read()
268 self.dirstate.read()
268 return wlock
269 return wlock
269
270
270 def rawcommit(self, files, text, user, date, p1=None, p2=None):
271 def rawcommit(self, files, text, user, date, p1=None, p2=None, wlock=None):
271 orig_parent = self.dirstate.parents()[0] or nullid
272 orig_parent = self.dirstate.parents()[0] or nullid
272 p1 = p1 or self.dirstate.parents()[0] or nullid
273 p1 = p1 or self.dirstate.parents()[0] or nullid
273 p2 = p2 or self.dirstate.parents()[1] or nullid
274 p2 = p2 or self.dirstate.parents()[1] or nullid
@@ -283,7 +284,8 b' class localrepository(object):'
283 else:
284 else:
284 update_dirstate = 0
285 update_dirstate = 0
285
286
286 wlock = self.wlock()
287 if not wlock:
288 wlock = self.wlock()
287 lock = self.lock()
289 lock = self.lock()
288 tr = self.transaction()
290 tr = self.transaction()
289 mm = m1.copy()
291 mm = m1.copy()
@@ -340,7 +342,7 b' class localrepository(object):'
340 self.dirstate.setparents(n, nullid)
342 self.dirstate.setparents(n, nullid)
341
343
342 def commit(self, files=None, text="", user=None, date=None,
344 def commit(self, files=None, text="", user=None, date=None,
343 match=util.always, force=False):
345 match=util.always, force=False, wlock=None):
344 commit = []
346 commit = []
345 remove = []
347 remove = []
346 changed = []
348 changed = []
@@ -373,7 +375,8 b' class localrepository(object):'
373 if not self.hook("precommit"):
375 if not self.hook("precommit"):
374 return None
376 return None
375
377
376 wlock = self.wlock()
378 if not wlock:
379 wlock = self.wlock()
377 lock = self.lock()
380 lock = self.lock()
378 tr = self.transaction()
381 tr = self.transaction()
379
382
@@ -480,7 +483,8 b' class localrepository(object):'
480 for src, fn in self.dirstate.walk(files, match):
483 for src, fn in self.dirstate.walk(files, match):
481 yield src, fn
484 yield src, fn
482
485
483 def changes(self, node1=None, node2=None, files=[], match=util.always):
486 def changes(self, node1=None, node2=None, files=[], match=util.always,
487 wlock=None):
484 """return changes between two nodes or node and working directory
488 """return changes between two nodes or node and working directory
485
489
486 If node1 is None, use the first dirstate parent instead.
490 If node1 is None, use the first dirstate parent instead.
@@ -502,10 +506,11 b' class localrepository(object):'
502
506
503 # are we comparing the working directory?
507 # are we comparing the working directory?
504 if not node2:
508 if not node2:
505 try:
509 if not wlock:
506 wlock = self.wlock(wait=0)
510 try:
507 except lock.LockHeld:
511 wlock = self.wlock(wait=0)
508 wlock = None
512 except lock.LockHeld:
513 wlock = None
509 lookup, modified, added, removed, deleted, unknown = (
514 lookup, modified, added, removed, deleted, unknown = (
510 self.dirstate.changes(files, match))
515 self.dirstate.changes(files, match))
511
516
@@ -554,8 +559,9 b' class localrepository(object):'
554 l.sort()
559 l.sort()
555 return (modified, added, removed, deleted, unknown)
560 return (modified, added, removed, deleted, unknown)
556
561
557 def add(self, list):
562 def add(self, list, wlock=None):
558 wlock = self.wlock()
563 if not wlock:
564 wlock = self.wlock()
559 for f in list:
565 for f in list:
560 p = self.wjoin(f)
566 p = self.wjoin(f)
561 if not os.path.exists(p):
567 if not os.path.exists(p):
@@ -568,15 +574,16 b' class localrepository(object):'
568 else:
574 else:
569 self.dirstate.update([f], "a")
575 self.dirstate.update([f], "a")
570
576
571 def forget(self, list):
577 def forget(self, list, wlock=None):
572 wlock = self.wlock()
578 if not wlock:
579 wlock = self.wlock()
573 for f in list:
580 for f in list:
574 if self.dirstate.state(f) not in 'ai':
581 if self.dirstate.state(f) not in 'ai':
575 self.ui.warn(_("%s not added!\n") % f)
582 self.ui.warn(_("%s not added!\n") % f)
576 else:
583 else:
577 self.dirstate.forget([f])
584 self.dirstate.forget([f])
578
585
579 def remove(self, list, unlink=False):
586 def remove(self, list, unlink=False, wlock=None):
580 if unlink:
587 if unlink:
581 for f in list:
588 for f in list:
582 try:
589 try:
@@ -584,7 +591,8 b' class localrepository(object):'
584 except OSError, inst:
591 except OSError, inst:
585 if inst.errno != errno.ENOENT:
592 if inst.errno != errno.ENOENT:
586 raise
593 raise
587 wlock = self.wlock()
594 if not wlock:
595 wlock = self.wlock()
588 for f in list:
596 for f in list:
589 p = self.wjoin(f)
597 p = self.wjoin(f)
590 if os.path.exists(p):
598 if os.path.exists(p):
@@ -597,12 +605,13 b' class localrepository(object):'
597 else:
605 else:
598 self.dirstate.update([f], "r")
606 self.dirstate.update([f], "r")
599
607
600 def undelete(self, list):
608 def undelete(self, list, wlock=None):
601 p = self.dirstate.parents()[0]
609 p = self.dirstate.parents()[0]
602 mn = self.changelog.read(p)[0]
610 mn = self.changelog.read(p)[0]
603 mf = self.manifest.readflags(mn)
611 mf = self.manifest.readflags(mn)
604 m = self.manifest.read(mn)
612 m = self.manifest.read(mn)
605 wlock = self.wlock()
613 if not wlock:
614 wlock = self.wlock()
606 for f in list:
615 for f in list:
607 if self.dirstate.state(f) not in "r":
616 if self.dirstate.state(f) not in "r":
608 self.ui.warn("%s not removed!\n" % f)
617 self.ui.warn("%s not removed!\n" % f)
@@ -612,14 +621,15 b' class localrepository(object):'
612 util.set_exec(self.wjoin(f), mf[f])
621 util.set_exec(self.wjoin(f), mf[f])
613 self.dirstate.update([f], "n")
622 self.dirstate.update([f], "n")
614
623
615 def copy(self, source, dest):
624 def copy(self, source, dest, wlock=None):
616 p = self.wjoin(dest)
625 p = self.wjoin(dest)
617 if not os.path.exists(p):
626 if not os.path.exists(p):
618 self.ui.warn(_("%s does not exist!\n") % dest)
627 self.ui.warn(_("%s does not exist!\n") % dest)
619 elif not os.path.isfile(p):
628 elif not os.path.isfile(p):
620 self.ui.warn(_("copy failed: %s is not a file\n") % dest)
629 self.ui.warn(_("copy failed: %s is not a file\n") % dest)
621 else:
630 else:
622 wlock = self.wlock()
631 if not wlock:
632 wlock = self.wlock()
623 if self.dirstate.state(dest) == '?':
633 if self.dirstate.state(dest) == '?':
624 self.dirstate.update([dest], "a")
634 self.dirstate.update([dest], "a")
625 self.dirstate.copy(source, dest)
635 self.dirstate.copy(source, dest)
@@ -1381,7 +1391,7 b' class localrepository(object):'
1381 return
1391 return
1382
1392
1383 def update(self, node, allow=False, force=False, choose=None,
1393 def update(self, node, allow=False, force=False, choose=None,
1384 moddirstate=True, forcemerge=False):
1394 moddirstate=True, forcemerge=False, wlock=None):
1385 pl = self.dirstate.parents()
1395 pl = self.dirstate.parents()
1386 if not force and pl[1] != nullid:
1396 if not force and pl[1] != nullid:
1387 self.ui.warn(_("aborting: outstanding uncommitted merges\n"))
1397 self.ui.warn(_("aborting: outstanding uncommitted merges\n"))
@@ -1443,7 +1453,7 b' class localrepository(object):'
1443 mw[f] = ""
1453 mw[f] = ""
1444 mfw[f] = util.is_exec(self.wjoin(f), mfw.get(f, False))
1454 mfw[f] = util.is_exec(self.wjoin(f), mfw.get(f, False))
1445
1455
1446 if moddirstate:
1456 if moddirstate and not wlock:
1447 wlock = self.wlock()
1457 wlock = self.wlock()
1448
1458
1449 for f in deleted + removed:
1459 for f in deleted + removed:
General Comments 0
You need to be logged in to leave comments. Login now