Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 6370:6440e25a1ba3
localrepo.commit: grab locks before getting the list of files to commit
Somebody may change the dirstate after we've determined the parents of
the working dir and run repo.status, but before we called wlock().
This should also fix issue997, where backout would change a file without
changing its size and then call repo.commit without passing the list of
files. If this happened in less than one second, we wouldn't detect any
file changes - the in-memory dirstate still has the cached stat data for
that file. Grabbing the wlock early causes the dirstate to be
invalidated and we end up reading the dirstate file again, which has
that file marked for lookup (size == -1).
A better fix would be for backout to give repo.commit the exact list of
files, but that'll require some changes to the revert operation.
A significant user-visible change is that the precommit hook is always
run with both locks grabbed - previously, hg commit would run it before
grabbing any locks, but hg import would run it after grabbing locks.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sun, 23 Mar 2008 21:03:24 -0300 |
parents | 7016f7fb8fe3 |
children | b2f1d97d10eb |
comparison
equal
deleted
inserted
replaced
6369:53912d30ac40 | 6370:6440e25a1ba3 |
---|---|
750 wlock = lock = tr = None | 750 wlock = lock = tr = None |
751 valid = 0 # don't save the dirstate if this isn't set | 751 valid = 0 # don't save the dirstate if this isn't set |
752 if files: | 752 if files: |
753 files = util.unique(files) | 753 files = util.unique(files) |
754 try: | 754 try: |
755 wlock = self.wlock() | |
756 lock = self.lock() | |
755 commit = [] | 757 commit = [] |
756 remove = [] | 758 remove = [] |
757 changed = [] | 759 changed = [] |
758 use_dirstate = (p1 is None) # not rawcommit | 760 use_dirstate = (p1 is None) # not rawcommit |
759 extra = extra.copy() | 761 extra = extra.copy() |
808 if p2 == nullid: xp2 = '' | 810 if p2 == nullid: xp2 = '' |
809 else: xp2 = hex(p2) | 811 else: xp2 = hex(p2) |
810 | 812 |
811 self.hook("precommit", throw=True, parent1=xp1, parent2=xp2) | 813 self.hook("precommit", throw=True, parent1=xp1, parent2=xp2) |
812 | 814 |
813 wlock = self.wlock() | |
814 lock = self.lock() | |
815 tr = self.transaction() | 815 tr = self.transaction() |
816 trp = weakref.proxy(tr) | 816 trp = weakref.proxy(tr) |
817 | 817 |
818 # check in files | 818 # check in files |
819 new = {} | 819 new = {} |