Show More
@@ -19,7 +19,7 b" def fetch(ui, repo, source='default', **" | |||
|
19 | 19 | merged, and the result of the merge is committed. Otherwise, the |
|
20 | 20 | working directory is updated.''' |
|
21 | 21 | |
|
22 | def postincoming(other, modheads): | |
|
22 | def postincoming(other, modheads, lock, wlock): | |
|
23 | 23 | if modheads == 0: |
|
24 | 24 | return 0 |
|
25 | 25 | if modheads == 1: |
@@ -50,7 +50,7 b" def fetch(ui, repo, source='default', **" | |||
|
50 | 50 | ui.status(_('new changeset %d:%s merges remote changes ' |
|
51 | 51 | 'with local\n') % (repo.changelog.rev(n), |
|
52 | 52 | short(n))) |
|
53 | def pull(): | |
|
53 | def pull(lock, wlock): | |
|
54 | 54 | cmdutil.setremoteconfig(ui, opts) |
|
55 | 55 | |
|
56 | 56 | other = hg.repository(ui, ui.expandpath(source)) |
@@ -61,7 +61,7 b" def fetch(ui, repo, source='default', **" | |||
|
61 | 61 | elif opts['rev']: |
|
62 | 62 | revs = [other.lookup(rev) for rev in opts['rev']] |
|
63 | 63 | modheads = repo.pull(other, heads=revs, lock=lock) |
|
64 | return postincoming(other, modheads) | |
|
64 | return postincoming(other, modheads, lock, wlock) | |
|
65 | 65 | |
|
66 | 66 | parent, p2 = repo.dirstate.parents() |
|
67 | 67 | if parent != repo.changelog.tip(): |
@@ -69,19 +69,19 b" def fetch(ui, repo, source='default', **" | |||
|
69 | 69 | '(use "hg update" to check out tip)')) |
|
70 | 70 | if p2 != nullid: |
|
71 | 71 | raise util.Abort(_('outstanding uncommitted merge')) |
|
72 | wlock = lock = None | |
|
73 | try: | |
|
72 | 74 | wlock = repo.wlock() |
|
73 | 75 | lock = repo.lock() |
|
74 | try: | |
|
75 | 76 | mod, add, rem = repo.status(wlock=wlock)[:3] |
|
76 | 77 | if mod or add or rem: |
|
77 | 78 | raise util.Abort(_('outstanding uncommitted changes')) |
|
78 | 79 | if len(repo.heads()) > 1: |
|
79 | 80 | raise util.Abort(_('multiple heads in this repository ' |
|
80 | 81 | '(use "hg heads" and "hg merge" to merge)')) |
|
81 | return pull() | |
|
82 | return pull(lock, wlock) | |
|
82 | 83 | finally: |
|
83 | lock.release() | |
|
84 | wlock.release() | |
|
84 | del lock, wlock | |
|
85 | 85 | |
|
86 | 86 | cmdtable = { |
|
87 | 87 | 'fetch': |
@@ -439,6 +439,8 b' class queue:' | |||
|
439 | 439 | def apply(self, repo, series, list=False, update_status=True, |
|
440 | 440 | strict=False, patchdir=None, merge=None, wlock=None, |
|
441 | 441 | all_files={}): |
|
442 | lock = tr = None | |
|
443 | try: | |
|
442 | 444 | if not wlock: |
|
443 | 445 | wlock = repo.wlock() |
|
444 | 446 | lock = repo.lock() |
@@ -457,6 +459,8 b' class queue:' | |||
|
457 | 459 | repo.invalidate() |
|
458 | 460 | repo.dirstate.invalidate() |
|
459 | 461 | raise |
|
462 | finally: | |
|
463 | del lock, wlock, tr | |
|
460 | 464 | |
|
461 | 465 | def _apply(self, tr, repo, series, list=False, update_status=True, |
|
462 | 466 | strict=False, patchdir=None, merge=None, wlock=None, |
@@ -616,6 +620,7 b' class queue:' | |||
|
616 | 620 | commitfiles = m + a + r |
|
617 | 621 | self.check_toppatch(repo) |
|
618 | 622 | wlock = repo.wlock() |
|
623 | try: | |
|
619 | 624 | insert = self.full_series_end() |
|
620 | 625 | if msg: |
|
621 | 626 | n = repo.commit(commitfiles, msg, force=True, wlock=wlock) |
@@ -640,8 +645,12 b' class queue:' | |||
|
640 | 645 | if commitfiles: |
|
641 | 646 | self.refresh(repo, short=True) |
|
642 | 647 | self.removeundo(repo) |
|
648 | finally: | |
|
649 | del wlock | |
|
643 | 650 | |
|
644 | 651 | def strip(self, repo, rev, update=True, backup="all", wlock=None): |
|
652 | lock = None | |
|
653 | try: | |
|
645 | 654 | if not wlock: |
|
646 | 655 | wlock = repo.wlock() |
|
647 | 656 | lock = repo.lock() |
@@ -654,6 +663,8 b' class queue:' | |||
|
654 | 663 | |
|
655 | 664 | self.removeundo(repo) |
|
656 | 665 | repair.strip(self.ui, repo, rev, backup) |
|
666 | finally: | |
|
667 | del lock, wlock | |
|
657 | 668 | |
|
658 | 669 | def isapplied(self, patch): |
|
659 | 670 | """returns (index, rev, patch)""" |
@@ -740,27 +751,30 b' class queue:' | |||
|
740 | 751 | mergeq=None, wlock=None): |
|
741 | 752 | if not wlock: |
|
742 | 753 | wlock = repo.wlock() |
|
754 | try: | |
|
743 | 755 | patch = self.lookup(patch) |
|
744 |
# Suppose our series file is: A B C and the current 'top' |
|
|
745 | # qpush C should be performed (moving forward) | |
|
746 | # qpush B is a NOP (no change) | |
|
747 |
|
|
|
756 | # Suppose our series file is: A B C and the current 'top' | |
|
757 | # patch is B. qpush C should be performed (moving forward) | |
|
758 | # qpush B is a NOP (no change) qpush A is an error (can't | |
|
759 | # go backwards with qpush) | |
|
748 | 760 | if patch: |
|
749 | 761 | info = self.isapplied(patch) |
|
750 | 762 | if info: |
|
751 | 763 | if info[0] < len(self.applied) - 1: |
|
752 |
raise util.Abort( |
|
|
753 |
|
|
|
764 | raise util.Abort( | |
|
765 | _("cannot push to a previous patch: %s") % patch) | |
|
754 | 766 | if info[0] < len(self.series) - 1: |
|
755 | self.ui.warn(_('qpush: %s is already at the top\n') % patch) | |
|
767 | self.ui.warn( | |
|
768 | _('qpush: %s is already at the top\n') % patch) | |
|
756 | 769 | else: |
|
757 | 770 | self.ui.warn(_('all patches are currently applied\n')) |
|
758 | 771 | return |
|
759 | 772 | |
|
760 | 773 | # Following the above example, starting at 'top' of B: |
|
761 |
|
|
|
762 |
# an argument is an error (nothing to |
|
|
763 | # of "...while hg qpush..." to work as it detects an error when done | |
|
774 | # qpush should be performed (pushes C), but a subsequent | |
|
775 | # qpush without an argument is an error (nothing to | |
|
776 | # apply). This allows a loop of "...while hg qpush..." to | |
|
777 | # work as it detects an error when done | |
|
764 | 778 | if self.series_end() == len(self.series): |
|
765 | 779 | self.ui.warn(_('patch series already fully applied\n')) |
|
766 | 780 | return 1 |
@@ -798,11 +812,13 b' class queue:' | |||
|
798 | 812 | raise |
|
799 | 813 | top = self.applied[-1].name |
|
800 | 814 | if ret[0]: |
|
801 | self.ui.write("Errors during apply, please fix and refresh %s\n" % | |
|
802 | top) | |
|
815 | self.ui.write( | |
|
816 | "Errors during apply, please fix and refresh %s\n" % top) | |
|
803 | 817 | else: |
|
804 | 818 | self.ui.write("Now at: %s\n" % top) |
|
805 | 819 | return ret[0] |
|
820 | finally: | |
|
821 | del wlock | |
|
806 | 822 | |
|
807 | 823 | def pop(self, repo, patch=None, force=False, update=True, all=False, |
|
808 | 824 | wlock=None): |
@@ -812,6 +828,7 b' class queue:' | |||
|
812 | 828 | |
|
813 | 829 | if not wlock: |
|
814 | 830 | wlock = repo.wlock() |
|
831 | try: | |
|
815 | 832 | if patch: |
|
816 | 833 | # index, rev, patch |
|
817 | 834 | info = self.isapplied(patch) |
@@ -888,6 +905,8 b' class queue:' | |||
|
888 | 905 | self.ui.write("Now at: %s\n" % self.applied[-1].name) |
|
889 | 906 | else: |
|
890 | 907 | self.ui.write("Patch queue now empty\n") |
|
908 | finally: | |
|
909 | del wlock | |
|
891 | 910 | |
|
892 | 911 | def diff(self, repo, pats, opts): |
|
893 | 912 | top = self.check_toppatch(repo) |
@@ -904,6 +923,7 b' class queue:' | |||
|
904 | 923 | self.ui.write("No patches applied\n") |
|
905 | 924 | return 1 |
|
906 | 925 | wlock = repo.wlock() |
|
926 | try: | |
|
907 | 927 | self.check_toppatch(repo) |
|
908 | 928 | (top, patchfn) = (self.applied[-1].rev, self.applied[-1].name) |
|
909 | 929 | top = revlog.bin(top) |
@@ -969,9 +989,10 b' class queue:' | |||
|
969 | 989 | match = util.always |
|
970 | 990 | m, a, r, d, u = repo.status(files=filelist, match=match)[:5] |
|
971 | 991 | |
|
972 |
# we might end up with files that were added between |
|
|
973 |
# the dirstate parent, but then changed in the |
|
|
974 |
# in this case, we want them to only |
|
|
992 | # we might end up with files that were added between | |
|
993 | # tip and the dirstate parent, but then changed in the | |
|
994 | # local dirstate. in this case, we want them to only | |
|
995 | # show up in the added section | |
|
975 | 996 | for x in m: |
|
976 | 997 | if x not in aa: |
|
977 | 998 | mm.append(x) |
@@ -1031,8 +1052,8 b' class queue:' | |||
|
1031 | 1052 | repo.dirstate.copy(src, dst) |
|
1032 | 1053 | for f in r: |
|
1033 | 1054 | repo.dirstate.remove(f) |
|
1034 |
# if the patch excludes a modified file, mark that |
|
|
1035 | # so status can see it. | |
|
1055 | # if the patch excludes a modified file, mark that | |
|
1056 | # file with mtime=0 so status can see it. | |
|
1036 | 1057 | mm = [] |
|
1037 | 1058 | for i in xrange(len(m)-1, -1, -1): |
|
1038 | 1059 | if not matchfn(m[i]): |
@@ -1053,7 +1074,8 b' class queue:' | |||
|
1053 | 1074 | else: |
|
1054 | 1075 | message = msg |
|
1055 | 1076 | |
|
1056 |
self.strip(repo, top, update=False, |
|
|
1077 | self.strip(repo, top, update=False, | |
|
1078 | backup='strip', wlock=wlock) | |
|
1057 | 1079 | n = repo.commit(filelist, message, changes[1], match=matchfn, |
|
1058 | 1080 | force=1, wlock=wlock) |
|
1059 | 1081 | self.applied[-1] = statusentry(revlog.hex(n), patchfn) |
@@ -1077,6 +1099,8 b' class queue:' | |||
|
1077 | 1099 | repo.dirstate.forget(a) |
|
1078 | 1100 | self.pop(repo, force=True, wlock=wlock) |
|
1079 | 1101 | self.push(repo, force=True, wlock=wlock) |
|
1102 | finally: | |
|
1103 | del wlock | |
|
1080 | 1104 | |
|
1081 | 1105 | def init(self, repo, create=False): |
|
1082 | 1106 | if not create and os.path.isdir(self.path): |
@@ -1872,10 +1896,13 b' def rename(ui, repo, patch, name=None, *' | |||
|
1872 | 1896 | r = q.qrepo() |
|
1873 | 1897 | if r: |
|
1874 | 1898 | wlock = r.wlock() |
|
1899 | try: | |
|
1875 | 1900 | if r.dirstate[name] == 'r': |
|
1876 | 1901 | r.undelete([name], wlock) |
|
1877 | 1902 | r.copy(patch, name, wlock) |
|
1878 | 1903 | r.remove([patch], False, wlock) |
|
1904 | finally: | |
|
1905 | del wlock | |
|
1879 | 1906 | |
|
1880 | 1907 | q.save_dirty() |
|
1881 | 1908 |
@@ -96,9 +96,10 b' class transplanter:' | |||
|
96 | 96 | diffopts = patch.diffopts(self.ui, opts) |
|
97 | 97 | diffopts.git = True |
|
98 | 98 | |
|
99 | lock = wlock = None | |
|
100 | try: | |
|
99 | 101 | wlock = repo.wlock() |
|
100 | 102 | lock = repo.lock() |
|
101 | try: | |
|
102 | 103 | for rev in revs: |
|
103 | 104 | node = revmap[rev] |
|
104 | 105 | revstr = '%s:%s' % (rev, revlog.short(node)) |
@@ -166,6 +167,7 b' class transplanter:' | |||
|
166 | 167 | finally: |
|
167 | 168 | self.saveseries(revmap, merges) |
|
168 | 169 | self.transplants.write() |
|
170 | del lock, wlock | |
|
169 | 171 | |
|
170 | 172 | def filter(self, filter, changelog, patchfile): |
|
171 | 173 | '''arbitrarily rewrite changeset before applying it''' |
@@ -272,13 +274,16 b' class transplanter:' | |||
|
272 | 274 | |
|
273 | 275 | extra = {'transplant_source': node} |
|
274 | 276 | wlock = repo.wlock() |
|
277 | try: | |
|
275 | 278 | p1, p2 = repo.dirstate.parents() |
|
276 | 279 | if p1 != parents[0]: |
|
277 | raise util.Abort(_('working dir not at transplant parent %s') % | |
|
280 | raise util.Abort( | |
|
281 | _('working dir not at transplant parent %s') % | |
|
278 | 282 | revlog.hex(parents[0])) |
|
279 | 283 | if merge: |
|
280 | 284 | repo.dirstate.setparents(p1, parents[1]) |
|
281 |
n = repo.commit(None, message, user, date, wlock=wlock, |
|
|
285 | n = repo.commit(None, message, user, date, wlock=wlock, | |
|
286 | extra=extra) | |
|
282 | 287 | if not n: |
|
283 | 288 | raise util.Abort(_('commit failed')) |
|
284 | 289 | if not merge: |
@@ -286,6 +291,8 b' class transplanter:' | |||
|
286 | 291 | self.unlog() |
|
287 | 292 | |
|
288 | 293 | return n, node |
|
294 | finally: | |
|
295 | del wlock | |
|
289 | 296 | |
|
290 | 297 | def readseries(self): |
|
291 | 298 | nodes = [] |
@@ -676,7 +676,10 b' def copy(ui, repo, *pats, **opts):' | |||
|
676 | 676 | before that, see hg revert. |
|
677 | 677 | """ |
|
678 | 678 | wlock = repo.wlock(False) |
|
679 | try: | |
|
679 | 680 | errs, copied = docopy(ui, repo, pats, opts, wlock) |
|
681 | finally: | |
|
682 | del wlock | |
|
680 | 683 | return errs |
|
681 | 684 | |
|
682 | 685 | def debugancestor(ui, index, rev1, rev2): |
@@ -713,7 +716,10 b' def debugrebuildstate(ui, repo, rev=""):' | |||
|
713 | 716 | ctx = repo.changectx(rev) |
|
714 | 717 | files = ctx.manifest() |
|
715 | 718 | wlock = repo.wlock() |
|
719 | try: | |
|
716 | 720 | repo.dirstate.rebuild(rev, files) |
|
721 | finally: | |
|
722 | del wlock | |
|
717 | 723 | |
|
718 | 724 | def debugcheckstate(ui, repo): |
|
719 | 725 | """validate the correctness of the current dirstate""" |
@@ -782,7 +788,7 b' def debugsetparents(ui, repo, rev1, rev2' | |||
|
782 | 788 | try: |
|
783 | 789 | repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2)) |
|
784 | 790 | finally: |
|
785 |
wlock |
|
|
791 | del wlock | |
|
786 | 792 | |
|
787 | 793 | def debugstate(ui, repo): |
|
788 | 794 | """show the contents of the current dirstate""" |
@@ -1581,19 +1587,21 b' def import_(ui, repo, patch1, *patches, ' | |||
|
1581 | 1587 | |
|
1582 | 1588 | d = opts["base"] |
|
1583 | 1589 | strip = opts["strip"] |
|
1584 | ||
|
1590 | wlock = lock = None | |
|
1591 | try: | |
|
1585 | 1592 | wlock = repo.wlock() |
|
1586 | 1593 | lock = repo.lock() |
|
1587 | ||
|
1588 | 1594 | for p in patches: |
|
1589 | 1595 | pf = os.path.join(d, p) |
|
1590 | 1596 | |
|
1591 | 1597 | if pf == '-': |
|
1592 | 1598 | ui.status(_("applying patch from stdin\n")) |
|
1593 |
|
|
|
1599 | data = patch.extract(ui, sys.stdin) | |
|
1594 | 1600 | else: |
|
1595 | 1601 | ui.status(_("applying %s\n") % p) |
|
1596 |
|
|
|
1602 | data = patch.extract(ui, file(pf, 'rb')) | |
|
1603 | ||
|
1604 | tmpname, message, user, date, branch, nodeid, p1, p2 = data | |
|
1597 | 1605 | |
|
1598 | 1606 | if tmpname is None: |
|
1599 | 1607 | raise util.Abort(_('no diffs found')) |
@@ -1638,13 +1646,17 b' def import_(ui, repo, patch1, *patches, ' | |||
|
1638 | 1646 | files=files) |
|
1639 | 1647 | finally: |
|
1640 | 1648 | files = patch.updatedir(ui, repo, files, wlock=wlock) |
|
1641 |
n = repo.commit(files, message, user, date, wlock=wlock, |
|
|
1649 | n = repo.commit(files, message, user, date, wlock=wlock, | |
|
1650 | lock=lock) | |
|
1642 | 1651 | if opts.get('exact'): |
|
1643 | 1652 | if hex(n) != nodeid: |
|
1644 | 1653 | repo.rollback(wlock=wlock, lock=lock) |
|
1645 |
raise util.Abort(_('patch is damaged |
|
|
1654 | raise util.Abort(_('patch is damaged' + | |
|
1655 | ' or loses information')) | |
|
1646 | 1656 | finally: |
|
1647 | 1657 | os.unlink(tmpname) |
|
1658 | finally: | |
|
1659 | del wlock, lock | |
|
1648 | 1660 | |
|
1649 | 1661 | def incoming(ui, repo, source="default", **opts): |
|
1650 | 1662 | """show new changesets found in source |
@@ -2248,6 +2260,7 b' def rename(ui, repo, *pats, **opts):' | |||
|
2248 | 2260 | before that, see hg revert. |
|
2249 | 2261 | """ |
|
2250 | 2262 | wlock = repo.wlock(False) |
|
2263 | try: | |
|
2251 | 2264 | errs, copied = docopy(ui, repo, pats, opts, wlock) |
|
2252 | 2265 | names = [] |
|
2253 | 2266 | for abs, rel, exact in copied: |
@@ -2257,6 +2270,8 b' def rename(ui, repo, *pats, **opts):' | |||
|
2257 | 2270 | if not opts.get('dry_run'): |
|
2258 | 2271 | repo.remove(names, True, wlock=wlock) |
|
2259 | 2272 | return errs |
|
2273 | finally: | |
|
2274 | del wlock | |
|
2260 | 2275 | |
|
2261 | 2276 | def revert(ui, repo, *pats, **opts): |
|
2262 | 2277 | """revert files or dirs to their states as of some revision |
@@ -2310,8 +2325,6 b' def revert(ui, repo, *pats, **opts):' | |||
|
2310 | 2325 | else: |
|
2311 | 2326 | pmf = None |
|
2312 | 2327 | |
|
2313 | wlock = repo.wlock() | |
|
2314 | ||
|
2315 | 2328 | # need all matching names in dirstate and manifest of target rev, |
|
2316 | 2329 | # so have to walk both. do not print errors if files exist in one |
|
2317 | 2330 | # but not other. |
@@ -2319,8 +2332,9 b' def revert(ui, repo, *pats, **opts):' | |||
|
2319 | 2332 | names = {} |
|
2320 | 2333 | target_only = {} |
|
2321 | 2334 | |
|
2335 | wlock = repo.wlock() | |
|
2336 | try: | |
|
2322 | 2337 | # walk dirstate. |
|
2323 | ||
|
2324 | 2338 | for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, |
|
2325 | 2339 | badmatch=mf.has_key): |
|
2326 | 2340 | names[abs] = (rel, exact) |
@@ -2426,6 +2440,8 b' def revert(ui, repo, *pats, **opts):' | |||
|
2426 | 2440 | for f in remove[0]: |
|
2427 | 2441 | repo.dirstate.remove(f) |
|
2428 | 2442 | return r |
|
2443 | finally: | |
|
2444 | del wlock | |
|
2429 | 2445 | |
|
2430 | 2446 | def rollback(ui, repo): |
|
2431 | 2447 | """roll back the last transaction in this repository |
@@ -130,7 +130,8 b' def clone(ui, source, dest=None, pull=Fa' | |||
|
130 | 130 | if self.dir_: |
|
131 | 131 | self.rmtree(self.dir_, True) |
|
132 | 132 | |
|
133 | dir_cleanup = None | |
|
133 | src_lock = dest_lock = dir_cleanup = None | |
|
134 | try: | |
|
134 | 135 | if islocal(dest): |
|
135 | 136 | dir_cleanup = DirCleanup(dest) |
|
136 | 137 | |
@@ -140,7 +141,6 b' def clone(ui, source, dest=None, pull=Fa' | |||
|
140 | 141 | abspath = os.path.abspath(origsource) |
|
141 | 142 | copy = not pull and not rev |
|
142 | 143 | |
|
143 | src_lock, dest_lock = None, None | |
|
144 | 144 | if copy: |
|
145 | 145 | try: |
|
146 | 146 | # we use a lock here because if we race with commit, we |
@@ -205,18 +205,12 b' def clone(ui, source, dest=None, pull=Fa' | |||
|
205 | 205 | else: |
|
206 | 206 | raise util.Abort(_("clone from remote to remote not supported")) |
|
207 | 207 | |
|
208 | if src_lock: | |
|
209 | src_lock.release() | |
|
210 | ||
|
211 | 208 | if dest_repo.local(): |
|
212 | 209 | fp = dest_repo.opener("hgrc", "w", text=True) |
|
213 | 210 | fp.write("[paths]\n") |
|
214 | 211 | fp.write("default = %s\n" % abspath) |
|
215 | 212 | fp.close() |
|
216 | 213 | |
|
217 | if dest_lock: | |
|
218 | dest_lock.release() | |
|
219 | ||
|
220 | 214 | if update: |
|
221 | 215 | try: |
|
222 | 216 | checkout = dest_repo.lookup("default") |
@@ -227,6 +221,8 b' def clone(ui, source, dest=None, pull=Fa' | |||
|
227 | 221 | dir_cleanup.close() |
|
228 | 222 | |
|
229 | 223 | return src_repo, dest_repo |
|
224 | finally: | |
|
225 | del src_lock, dest_lock, dir_cleanup | |
|
230 | 226 | |
|
231 | 227 | def _showstats(repo, stats): |
|
232 | 228 | stats = ((stats[0], _("updated")), |
@@ -1168,7 +1168,7 b' class hgweb(object):' | |||
|
1168 | 1168 | req.write('%d\n' % ret) |
|
1169 | 1169 | req.write(val) |
|
1170 | 1170 | finally: |
|
1171 |
lock |
|
|
1171 | del lock | |
|
1172 | 1172 | except (OSError, IOError), inst: |
|
1173 | 1173 | req.write('0\n') |
|
1174 | 1174 | filename = getattr(inst, 'filename', '') |
@@ -516,6 +516,7 b' class localrepository(repo.repository):' | |||
|
516 | 516 | |
|
517 | 517 | def recover(self): |
|
518 | 518 | l = self.lock() |
|
519 | try: | |
|
519 | 520 | if os.path.exists(self.sjoin("journal")): |
|
520 | 521 | self.ui.status(_("rolling back interrupted transaction\n")) |
|
521 | 522 | transaction.rollback(self.sopener, self.sjoin("journal")) |
@@ -524,8 +525,11 b' class localrepository(repo.repository):' | |||
|
524 | 525 | else: |
|
525 | 526 | self.ui.warn(_("no interrupted transaction available\n")) |
|
526 | 527 | return False |
|
528 | finally: | |
|
529 | del l | |
|
527 | 530 | |
|
528 | 531 | def rollback(self, wlock=None, lock=None): |
|
532 | try: | |
|
529 | 533 | if not wlock: |
|
530 | 534 | wlock = self.wlock() |
|
531 | 535 | if not lock: |
@@ -538,6 +542,8 b' class localrepository(repo.repository):' | |||
|
538 | 542 | self.dirstate.invalidate() |
|
539 | 543 | else: |
|
540 | 544 | self.ui.warn(_("no rollback information available\n")) |
|
545 | finally: | |
|
546 | del wlock, lock | |
|
541 | 547 | |
|
542 | 548 | def invalidate(self): |
|
543 | 549 | for a in "changelog manifest".split(): |
@@ -639,7 +645,8 b' class localrepository(repo.repository):' | |||
|
639 | 645 | def commit(self, files=None, text="", user=None, date=None, |
|
640 | 646 | match=util.always, force=False, lock=None, wlock=None, |
|
641 | 647 | force_editor=False, p1=None, p2=None, extra={}): |
|
642 | ||
|
648 | tr = None | |
|
649 | try: | |
|
643 | 650 | commit = [] |
|
644 | 651 | remove = [] |
|
645 | 652 | changed = [] |
@@ -717,8 +724,9 b' class localrepository(repo.repository):' | |||
|
717 | 724 | new_exec = is_exec(f) |
|
718 | 725 | new_link = is_link(f) |
|
719 | 726 | if not changed or changed[-1] != f: |
|
720 |
# mention the file in the changelog if some |
|
|
721 |
# even if there was no content |
|
|
727 | # mention the file in the changelog if some | |
|
728 | # flag changed, even if there was no content | |
|
729 | # change. | |
|
722 | 730 | old_exec = m1.execf(f) |
|
723 | 731 | old_link = m1.linkf(f) |
|
724 | 732 | if old_exec != new_exec or old_link != new_link: |
@@ -742,7 +750,8 b' class localrepository(repo.repository):' | |||
|
742 | 750 | removed.append(f) |
|
743 | 751 | elif f in m2: |
|
744 | 752 | removed.append(f) |
|
745 |
mn = self.manifest.add(m1, tr, linkrev, c1[0], c2[0], |
|
|
753 | mn = self.manifest.add(m1, tr, linkrev, c1[0], c2[0], | |
|
754 | (new, removed)) | |
|
746 | 755 | |
|
747 | 756 | # add changeset |
|
748 | 757 | new = new.keys() |
@@ -797,6 +806,8 b' class localrepository(repo.repository):' | |||
|
797 | 806 | |
|
798 | 807 | self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2) |
|
799 | 808 | return n |
|
809 | finally: | |
|
810 | del lock, wlock, tr | |
|
800 | 811 | |
|
801 | 812 | def walk(self, node=None, files=[], match=util.always, badmatch=None): |
|
802 | 813 | ''' |
@@ -895,18 +906,18 b' class localrepository(repo.repository):' | |||
|
895 | 906 | |
|
896 | 907 | # update dirstate for files that are actually clean |
|
897 | 908 | if fixup: |
|
898 |
|
|
|
899 | if not wlock: | |
|
909 | fixlock = wlock | |
|
900 | 910 |
|
|
901 |
|
|
|
902 |
|
|
|
911 | if not fixlock: | |
|
912 | try: | |
|
913 | fixlock = self.wlock(False) | |
|
903 | 914 | except lock.LockException: |
|
904 | 915 | pass |
|
905 |
if |
|
|
916 | if fixlock: | |
|
906 | 917 | for f in fixup: |
|
907 | 918 | self.dirstate.normal(f) |
|
908 |
|
|
|
909 |
|
|
|
919 | finally: | |
|
920 | del fixlock | |
|
910 | 921 | else: |
|
911 | 922 | # we are comparing working dir against non-parent |
|
912 | 923 | # generate a pseudo-manifest for the working dir |
@@ -954,6 +965,7 b' class localrepository(repo.repository):' | |||
|
954 | 965 | return (modified, added, removed, deleted, unknown, ignored, clean) |
|
955 | 966 | |
|
956 | 967 | def add(self, list, wlock=None): |
|
968 | try: | |
|
957 | 969 | if not wlock: |
|
958 | 970 | wlock = self.wlock() |
|
959 | 971 | for f in list: |
@@ -975,8 +987,11 b' class localrepository(repo.repository):' | |||
|
975 | 987 | self.ui.warn(_("%s already tracked!\n") % f) |
|
976 | 988 | else: |
|
977 | 989 | self.dirstate.add(f) |
|
990 | finally: | |
|
991 | del wlock | |
|
978 | 992 | |
|
979 | 993 | def forget(self, list, wlock=None): |
|
994 | try: | |
|
980 | 995 | if not wlock: |
|
981 | 996 | wlock = self.wlock() |
|
982 | 997 | for f in list: |
@@ -984,8 +999,11 b' class localrepository(repo.repository):' | |||
|
984 | 999 | self.ui.warn(_("%s not added!\n") % f) |
|
985 | 1000 | else: |
|
986 | 1001 | self.dirstate.forget(f) |
|
1002 | finally: | |
|
1003 | del wlock | |
|
987 | 1004 | |
|
988 | 1005 | def remove(self, list, unlink=False, wlock=None): |
|
1006 | try: | |
|
989 | 1007 | if unlink: |
|
990 | 1008 | for f in list: |
|
991 | 1009 | try: |
@@ -1004,8 +1022,11 b' class localrepository(repo.repository):' | |||
|
1004 | 1022 | self.ui.warn(_("%s not tracked!\n") % f) |
|
1005 | 1023 | else: |
|
1006 | 1024 | self.dirstate.remove(f) |
|
1025 | finally: | |
|
1026 | del wlock | |
|
1007 | 1027 | |
|
1008 | 1028 | def undelete(self, list, wlock=None): |
|
1029 | try: | |
|
1009 | 1030 | p = self.dirstate.parents()[0] |
|
1010 | 1031 | mn = self.changelog.read(p)[0] |
|
1011 | 1032 | m = self.manifest.read(mn) |
@@ -1018,8 +1039,11 b' class localrepository(repo.repository):' | |||
|
1018 | 1039 | t = self.file(f).read(m[f]) |
|
1019 | 1040 | self.wwrite(f, t, m.flags(f)) |
|
1020 | 1041 | self.dirstate.normal(f) |
|
1042 | finally: | |
|
1043 | del wlock | |
|
1021 | 1044 | |
|
1022 | 1045 | def copy(self, source, dest, wlock=None): |
|
1046 | try: | |
|
1023 | 1047 | p = self.wjoin(dest) |
|
1024 | 1048 | if not (os.path.exists(p) or os.path.islink(p)): |
|
1025 | 1049 | self.ui.warn(_("%s does not exist!\n") % dest) |
@@ -1032,6 +1056,8 b' class localrepository(repo.repository):' | |||
|
1032 | 1056 | if dest not in self.dirstate: |
|
1033 | 1057 | self.dirstate.add(dest) |
|
1034 | 1058 | self.dirstate.copy(source, dest) |
|
1059 | finally: | |
|
1060 | del wlock | |
|
1035 | 1061 | |
|
1036 | 1062 | def heads(self, start=None): |
|
1037 | 1063 | heads = self.changelog.heads(start) |
@@ -1309,12 +1335,9 b' class localrepository(repo.repository):' | |||
|
1309 | 1335 | return subset |
|
1310 | 1336 | |
|
1311 | 1337 | def pull(self, remote, heads=None, force=False, lock=None): |
|
1312 | mylock = False | |
|
1338 | try: | |
|
1313 | 1339 | if not lock: |
|
1314 | 1340 | lock = self.lock() |
|
1315 | mylock = True | |
|
1316 | ||
|
1317 | try: | |
|
1318 | 1341 | fetch = self.findincoming(remote, force=force) |
|
1319 | 1342 | if fetch == [nullid]: |
|
1320 | 1343 | self.ui.status(_("requesting all changes\n")) |
@@ -1331,8 +1354,7 b' class localrepository(repo.repository):' | |||
|
1331 | 1354 | cg = remote.changegroupsubset(fetch, heads, 'pull') |
|
1332 | 1355 | return self.addchangegroup(cg, 'pull', remote.url()) |
|
1333 | 1356 | finally: |
|
1334 |
|
|
|
1335 | lock.release() | |
|
1357 | del lock | |
|
1336 | 1358 | |
|
1337 | 1359 | def push(self, remote, force=False, revs=None): |
|
1338 | 1360 | # there are two ways to push to remote repo: |
@@ -1405,12 +1427,14 b' class localrepository(repo.repository):' | |||
|
1405 | 1427 | |
|
1406 | 1428 | def push_addchangegroup(self, remote, force, revs): |
|
1407 | 1429 | lock = remote.lock() |
|
1408 | ||
|
1430 | try: | |
|
1409 | 1431 | ret = self.prepush(remote, force, revs) |
|
1410 | 1432 | if ret[0] is not None: |
|
1411 | 1433 | cg, remote_heads = ret |
|
1412 | 1434 | return remote.addchangegroup(cg, 'push', self.url()) |
|
1413 | 1435 | return ret[1] |
|
1436 | finally: | |
|
1437 | del lock | |
|
1414 | 1438 | |
|
1415 | 1439 | def push_unbundle(self, remote, force, revs): |
|
1416 | 1440 | # local repo finds heads on server, finds out what revs it |
@@ -1794,14 +1818,14 b' class localrepository(repo.repository):' | |||
|
1794 | 1818 | |
|
1795 | 1819 | changesets = files = revisions = 0 |
|
1796 | 1820 | |
|
1797 | tr = self.transaction() | |
|
1798 | ||
|
1799 | 1821 | # write changelog data to temp files so concurrent readers will not see |
|
1800 | 1822 | # inconsistent view |
|
1801 | 1823 | cl = self.changelog |
|
1802 | 1824 | cl.delayupdate() |
|
1803 | 1825 | oldheads = len(cl.heads()) |
|
1804 | 1826 | |
|
1827 | tr = self.transaction() | |
|
1828 | try: | |
|
1805 | 1829 | # pull off the changeset group |
|
1806 | 1830 | self.ui.status(_("adding changesets\n")) |
|
1807 | 1831 | cor = cl.count() - 1 |
@@ -1853,6 +1877,8 b' class localrepository(repo.repository):' | |||
|
1853 | 1877 | url=url) |
|
1854 | 1878 | |
|
1855 | 1879 | tr.close() |
|
1880 | finally: | |
|
1881 | del tr | |
|
1856 | 1882 | |
|
1857 | 1883 | if changesets > 0: |
|
1858 | 1884 | self.hook("changegroup", node=hex(self.changelog.node(cor+1)), |
@@ -506,6 +506,7 b' def update(repo, node, branchmerge, forc' | |||
|
506 | 506 | wlock = working dir lock, if already held |
|
507 | 507 | """ |
|
508 | 508 | |
|
509 | try: | |
|
509 | 510 | if not wlock: |
|
510 | 511 | wlock = repo.wlock() |
|
511 | 512 | |
@@ -567,4 +568,5 b' def update(repo, node, branchmerge, forc' | |||
|
567 | 568 | repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3]) |
|
568 | 569 | |
|
569 | 570 | return stats |
|
570 | ||
|
571 | finally: | |
|
572 | del wlock |
@@ -66,6 +66,8 b' def stream_out(repo, fileobj, untrusted=' | |||
|
66 | 66 | |
|
67 | 67 | # get consistent snapshot of repo. lock during scan so lock not |
|
68 | 68 | # needed while we stream, and commits can happen. |
|
69 | lock = None | |
|
70 | try: | |
|
69 | 71 | try: |
|
70 | 72 | repolock = repo.lock() |
|
71 | 73 | except (lock.LockHeld, lock.LockUnavailable), inst: |
@@ -81,7 +83,8 b' def stream_out(repo, fileobj, untrusted=' | |||
|
81 | 83 | name = repo.decodefn(util.pconvert(name)) |
|
82 | 84 | entries.append((name, size)) |
|
83 | 85 | total_bytes += size |
|
84 | repolock.release() | |
|
86 | finally: | |
|
87 | del repolock | |
|
85 | 88 | |
|
86 | 89 | repo.ui.debug('%d files, %d bytes to transfer\n' % |
|
87 | 90 | (len(entries), total_bytes)) |
@@ -10,6 +10,13 b' from i18n import _' | |||
|
10 | 10 | import revlog, mdiff |
|
11 | 11 | |
|
12 | 12 | def verify(repo): |
|
13 | lock = repo.lock() | |
|
14 | try: | |
|
15 | return _verify(repo) | |
|
16 | finally: | |
|
17 | del lock | |
|
18 | ||
|
19 | def _verify(repo): | |
|
13 | 20 | filelinkrevs = {} |
|
14 | 21 | filenodes = {} |
|
15 | 22 | changesets = revisions = files = 0 |
@@ -17,8 +24,6 b' def verify(repo):' | |||
|
17 | 24 | warnings = [0] |
|
18 | 25 | neededmanifests = {} |
|
19 | 26 | |
|
20 | lock = repo.lock() | |
|
21 | ||
|
22 | 27 | def err(msg): |
|
23 | 28 | repo.ui.warn(msg + "\n") |
|
24 | 29 | errors[0] += 1 |
General Comments 0
You need to be logged in to leave comments.
Login now