Show More
@@ -187,7 +187,7 b' class bisect(object):' | |||
|
187 | 187 | check_clean(self.ui, self.repo) |
|
188 | 188 | rev = self.next() |
|
189 | 189 | self.ui.write("Now testing %s\n" % hg.hex(rev)) |
|
190 |
return self.repo.update(rev, |
|
|
190 | return self.repo.update(rev, force=True) | |
|
191 | 191 | |
|
192 | 192 | def good(self, rev): |
|
193 | 193 | self.goodrevs.append(rev) |
@@ -232,7 +232,7 b' def test(ui, repo, rev):' | |||
|
232 | 232 | b.good(new_rev) |
|
233 | 233 | ui.write("it is good\n") |
|
234 | 234 | anc = b.ancestors() |
|
235 |
repo.update(new_rev, |
|
|
235 | repo.update(new_rev, force=True) | |
|
236 | 236 | for v in anc: |
|
237 | 237 | if v != rev: |
|
238 | 238 | ui.warn("fail to found cset! :(\n") |
@@ -115,8 +115,8 b' def walkchangerevs(ui, repo, pats, opts)' | |||
|
115 | 115 | yield rev |
|
116 | 116 | |
|
117 | 117 | minrev, maxrev = min(revs), max(revs) |
|
118 | for file in files: | |
|
119 | filelog = repo.file(file) | |
|
118 | for file_ in files: | |
|
119 | filelog = repo.file(file_) | |
|
120 | 120 | # A zero count may be a directory or deleted file, so |
|
121 | 121 | # try to find matching entries on the slow path. |
|
122 | 122 | if filelog.count() == 0: |
@@ -127,7 +127,7 b' def walkchangerevs(ui, repo, pats, opts)' | |||
|
127 | 127 | if rev < minrev: |
|
128 | 128 | break |
|
129 | 129 | fncache.setdefault(rev, []) |
|
130 | fncache[rev].append(file) | |
|
130 | fncache[rev].append(file_) | |
|
131 | 131 | wanted[rev] = 1 |
|
132 | 132 | if slowpath: |
|
133 | 133 | # The slow path checks files modified in every changeset. |
@@ -447,7 +447,6 b' def help_(ui, cmd=None, with_version=Fal' | |||
|
447 | 447 | f = f.lstrip("^") |
|
448 | 448 | if not ui.debugflag and f.startswith("debug"): |
|
449 | 449 | continue |
|
450 | d = "" | |
|
451 | 450 | doc = e[0].__doc__ |
|
452 | 451 | if not doc: |
|
453 | 452 | doc = _("(No help text available)") |
@@ -725,8 +724,8 b' def clone(ui, source, dest=None, **opts)' | |||
|
725 | 724 | # can end up with extra data in the cloned revlogs that's |
|
726 | 725 | # not pointed to by changesets, thus causing verify to |
|
727 | 726 | # fail |
|
728 | l1 = lock.lock(os.path.join(source, ".hg", "lock")) | |
|
729 |
except |
|
|
727 | l1 = other.lock() | |
|
728 | except lock.LockException: | |
|
730 | 729 | copy = False |
|
731 | 730 | |
|
732 | 731 | if copy: |
@@ -986,6 +985,18 b' def debugancestor(ui, index, rev1, rev2)' | |||
|
986 | 985 | a = r.ancestor(r.lookup(rev1), r.lookup(rev2)) |
|
987 | 986 | ui.write("%d:%s\n" % (r.rev(a), hex(a))) |
|
988 | 987 | |
|
988 | def debugrebuildstate(ui, repo, rev=None): | |
|
989 | """rebuild the dirstate as it would look like for the given revision""" | |
|
990 | if not rev: | |
|
991 | rev = repo.changelog.tip() | |
|
992 | else: | |
|
993 | rev = repo.lookup(rev) | |
|
994 | change = repo.changelog.read(rev) | |
|
995 | n = change[0] | |
|
996 | files = repo.manifest.readflags(n) | |
|
997 | wlock = self.repo.wlock() | |
|
998 | repo.dirstate.rebuild(rev, files.iteritems()) | |
|
999 | ||
|
989 | 1000 | def debugcheckstate(ui, repo): |
|
990 | 1001 | """validate the correctness of the current dirstate""" |
|
991 | 1002 | parent1, parent2 = repo.dirstate.parents() |
@@ -1290,6 +1301,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
1290 | 1301 | s = linestate(line, lnum, cstart, cend) |
|
1291 | 1302 | m[s] = s |
|
1292 | 1303 | |
|
1304 | # FIXME: prev isn't used, why ? | |
|
1293 | 1305 | prev = {} |
|
1294 | 1306 | ucache = {} |
|
1295 | 1307 | def display(fn, rev, states, prevstates): |
@@ -2373,6 +2385,10 b' table = {' | |||
|
2373 | 2385 | _('forcibly copy over an existing managed file'))], |
|
2374 | 2386 | _('hg copy [OPTION]... [SOURCE]... DEST')), |
|
2375 | 2387 | "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')), |
|
2388 | "debugrebuildstate": | |
|
2389 | (debugrebuildstate, | |
|
2390 | [('r', 'rev', "", _("revision to rebuild to"))], | |
|
2391 | _('debugrebuildstate [-r REV] [REV]')), | |
|
2376 | 2392 | "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')), |
|
2377 | 2393 | "debugconfig": (debugconfig, [], _('debugconfig')), |
|
2378 | 2394 | "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')), |
@@ -197,6 +197,19 b' class dirstate(object):' | |||
|
197 | 197 | |
|
198 | 198 | def clear(self): |
|
199 | 199 | self.map = {} |
|
200 | self.copies = {} | |
|
201 | self.markdirty() | |
|
202 | ||
|
203 | def rebuild(self, parent, files): | |
|
204 | self.clear() | |
|
205 | umask = os.umask(0) | |
|
206 | os.umask(umask) | |
|
207 | for f, mode in files: | |
|
208 | if mode: | |
|
209 | self.map[f] = ('n', ~umask, -1, 0) | |
|
210 | else: | |
|
211 | self.map[f] = ('n', ~umask & 0666, -1, 0) | |
|
212 | self.pl = (parent, nullid) | |
|
200 | 213 | self.markdirty() |
|
201 | 214 | |
|
202 | 215 | def write(self): |
@@ -270,11 +283,11 b' class dirstate(object):' | |||
|
270 | 283 | elif not dc: |
|
271 | 284 | dc = self.filterfiles(files) |
|
272 | 285 | |
|
273 | def statmatch(file, stat): | |
|
274 | file = util.pconvert(file) | |
|
275 | if file not in dc and self.ignore(file): | |
|
286 | def statmatch(file_, stat): | |
|
287 | file_ = util.pconvert(file_) | |
|
288 | if file_ not in dc and self.ignore(file_): | |
|
276 | 289 | return False |
|
277 | return match(file) | |
|
290 | return match(file_) | |
|
278 | 291 | |
|
279 | 292 | return self.walkhelper(files=files, statmatch=statmatch, dc=dc) |
|
280 | 293 | |
@@ -350,9 +363,9 b' class dirstate(object):' | |||
|
350 | 363 | continue |
|
351 | 364 | if stat.S_ISDIR(st.st_mode): |
|
352 | 365 | cmp1 = (lambda x, y: cmp(x[1], y[1])) |
|
353 | sorted = [ x for x in findfiles(f) ] | |
|
354 | sorted.sort(cmp1) | |
|
355 | for e in sorted: | |
|
366 | sorted_ = [ x for x in findfiles(f) ] | |
|
367 | sorted_.sort(cmp1) | |
|
368 | for e in sorted_: | |
|
356 | 369 | yield e |
|
357 | 370 | else: |
|
358 | 371 | ff = util.normpath(ff) |
@@ -380,7 +393,7 b' class dirstate(object):' | |||
|
380 | 393 | |
|
381 | 394 | for src, fn, st in self.statwalk(files, match): |
|
382 | 395 | try: |
|
383 | type, mode, size, time = self[fn] | |
|
396 | type_, mode, size, time = self[fn] | |
|
384 | 397 | except KeyError: |
|
385 | 398 | unknown.append(fn) |
|
386 | 399 | continue |
@@ -399,22 +412,23 b' class dirstate(object):' | |||
|
399 | 412 | nonexistent = False |
|
400 | 413 | # XXX: what to do with file no longer present in the fs |
|
401 | 414 | # who are not removed in the dirstate ? |
|
402 | if nonexistent and type in "nm": | |
|
415 | if nonexistent and type_ in "nm": | |
|
403 | 416 | deleted.append(fn) |
|
404 | 417 | continue |
|
405 | 418 | # check the common case first |
|
406 | if type == 'n': | |
|
419 | if type_ == 'n': | |
|
407 | 420 | if not st: |
|
408 | 421 | st = os.stat(fn) |
|
409 |
if size != st.st_size |
|
|
422 | if size >= 0 and (size != st.st_size | |
|
423 | or (mode ^ st.st_mode) & 0100): | |
|
410 | 424 | modified.append(fn) |
|
411 | 425 | elif time != st.st_mtime: |
|
412 | 426 | lookup.append(fn) |
|
413 | elif type == 'm': | |
|
427 | elif type_ == 'm': | |
|
414 | 428 | modified.append(fn) |
|
415 | elif type == 'a': | |
|
429 | elif type_ == 'a': | |
|
416 | 430 | added.append(fn) |
|
417 | elif type == 'r': | |
|
431 | elif type_ == 'r': | |
|
418 | 432 | removed.append(fn) |
|
419 | 433 | |
|
420 | 434 | return (lookup, modified, added, removed, deleted, unknown) |
@@ -231,7 +231,7 b' class localrepository(object):' | |||
|
231 | 231 | self.join("journal"), after) |
|
232 | 232 | |
|
233 | 233 | def recover(self): |
|
234 |
l |
|
|
234 | l = self.lock() | |
|
235 | 235 | if os.path.exists(self.join("journal")): |
|
236 | 236 | self.ui.status(_("rolling back interrupted transaction\n")) |
|
237 | 237 | transaction.rollback(self.opener, self.join("journal")) |
@@ -245,7 +245,7 b' class localrepository(object):' | |||
|
245 | 245 | def undo(self, wlock=None): |
|
246 | 246 | if not wlock: |
|
247 | 247 | wlock = self.wlock() |
|
248 |
l |
|
|
248 | l = self.lock() | |
|
249 | 249 | if os.path.exists(self.join("undo")): |
|
250 | 250 | self.ui.status(_("rolling back last transaction\n")) |
|
251 | 251 | transaction.rollback(self.opener, self.join("undo")) |
@@ -254,25 +254,25 b' class localrepository(object):' | |||
|
254 | 254 | else: |
|
255 | 255 | self.ui.warn(_("no undo information available\n")) |
|
256 | 256 | |
|
257 | def lock(self, wait=1): | |
|
257 | def do_lock(self, lockname, wait, releasefn=None, acquirefn=None): | |
|
258 | 258 | try: |
|
259 |
|
|
|
260 | except lock.LockHeld, inst: | |
|
261 | if wait: | |
|
262 | self.ui.warn(_("waiting for lock held by %s\n") % inst.args[0]) | |
|
263 | return lock.lock(self.join("lock"), wait) | |
|
264 | raise inst | |
|
265 | ||
|
266 | def wlock(self, wait=1): | |
|
267 | try: | |
|
268 | wlock = lock.lock(self.join("wlock"), 0, self.dirstate.write) | |
|
259 | l = lock.lock(self.join(lockname), 0, releasefn) | |
|
269 | 260 | except lock.LockHeld, inst: |
|
270 | 261 | if not wait: |
|
271 | 262 | raise inst |
|
272 | 263 | self.ui.warn(_("waiting for lock held by %s\n") % inst.args[0]) |
|
273 |
|
|
|
274 | self.dirstate.read() | |
|
275 | return wlock | |
|
264 | l = lock.lock(self.join(lockname), wait, releasefn) | |
|
265 | if acquirefn: | |
|
266 | acquirefn() | |
|
267 | return l | |
|
268 | ||
|
269 | def lock(self, wait=1): | |
|
270 | return self.do_lock("lock", wait) | |
|
271 | ||
|
272 | def wlock(self, wait=1): | |
|
273 | return self.do_lock("wlock", wait, | |
|
274 | self.dirstate.write, | |
|
275 | self.dirstate.read) | |
|
276 | 276 | |
|
277 | 277 | def checkfilemerge(self, filename, text, filelog, manifest1, manifest2): |
|
278 | 278 | "determine whether a new filenode is needed" |
@@ -311,7 +311,7 b' class localrepository(object):' | |||
|
311 | 311 | |
|
312 | 312 | if not wlock: |
|
313 | 313 | wlock = self.wlock() |
|
314 |
l |
|
|
314 | l = self.lock() | |
|
315 | 315 | tr = self.transaction() |
|
316 | 316 | mm = m1.copy() |
|
317 | 317 | mfm = mf1.copy() |
@@ -388,7 +388,7 b' class localrepository(object):' | |||
|
388 | 388 | |
|
389 | 389 | if not wlock: |
|
390 | 390 | wlock = self.wlock() |
|
391 |
l |
|
|
391 | l = self.lock() | |
|
392 | 392 | tr = self.transaction() |
|
393 | 393 | |
|
394 | 394 | # check in files |
@@ -508,7 +508,7 b' class localrepository(object):' | |||
|
508 | 508 | if not wlock: |
|
509 | 509 | try: |
|
510 | 510 | wlock = self.wlock(wait=0) |
|
511 |
except lock.Lock |
|
|
511 | except lock.LockException: | |
|
512 | 512 | wlock = None |
|
513 | 513 | lookup, modified, added, removed, deleted, unknown = ( |
|
514 | 514 | self.dirstate.changes(files, match)) |
@@ -931,7 +931,7 b' class localrepository(object):' | |||
|
931 | 931 | return subset |
|
932 | 932 | |
|
933 | 933 | def pull(self, remote, heads=None): |
|
934 |
l |
|
|
934 | l = self.lock() | |
|
935 | 935 | |
|
936 | 936 | # if we have an empty repo, fetch everything |
|
937 | 937 | if self.changelog.tip() == nullid: |
@@ -951,7 +951,7 b' class localrepository(object):' | |||
|
951 | 951 | return self.addchangegroup(cg) |
|
952 | 952 | |
|
953 | 953 | def push(self, remote, force=False): |
|
954 |
l |
|
|
954 | l = remote.lock() | |
|
955 | 955 | |
|
956 | 956 | base = {} |
|
957 | 957 | heads = remote.heads() |
@@ -5,10 +5,14 b'' | |||
|
5 | 5 | # This software may be used and distributed according to the terms |
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | |
|
8 | import os, time | |
|
8 | import errno, os, time | |
|
9 | 9 | import util |
|
10 | 10 | |
|
11 |
class Lock |
|
|
11 | class LockException(Exception): | |
|
12 | pass | |
|
13 | class LockHeld(LockException): | |
|
14 | pass | |
|
15 | class LockUnavailable(LockException): | |
|
12 | 16 | pass |
|
13 | 17 | |
|
14 | 18 | class lock(object): |
@@ -38,8 +42,11 b' class lock(object):' | |||
|
38 | 42 | try: |
|
39 | 43 | util.makelock(str(pid), self.f) |
|
40 | 44 | self.held = 1 |
|
41 | except (OSError, IOError): | |
|
42 | raise LockHeld(util.readlock(self.f)) | |
|
45 | except (OSError, IOError), why: | |
|
46 | if why.errno == errno.EEXIST: | |
|
47 | raise LockHeld(util.readlock(self.f)) | |
|
48 | else: | |
|
49 | raise LockUnavailable(why) | |
|
43 | 50 | |
|
44 | 51 | def release(self): |
|
45 | 52 | if self.held: |
@@ -624,12 +624,10 b' class revlog(object):' | |||
|
624 | 624 | # we store negative distances because heap returns smallest member |
|
625 | 625 | h = [(-dist[node], node)] |
|
626 | 626 | seen = {} |
|
627 | earliest = self.count() | |
|
628 | 627 | while h: |
|
629 | 628 | d, n = heapq.heappop(h) |
|
630 | 629 | if n not in seen: |
|
631 | 630 | seen[n] = 1 |
|
632 | r = self.rev(n) | |
|
633 | 631 | yield (-d, n) |
|
634 | 632 | for p in self.parents(n): |
|
635 | 633 | heapq.heappush(h, (-dist[p], p)) |
@@ -690,11 +688,6 b' class revlog(object):' | |||
|
690 | 688 | p = self.parents(self.node(revs[0]))[0] |
|
691 | 689 | revs.insert(0, self.rev(p)) |
|
692 | 690 | |
|
693 | # helper to reconstruct intermediate versions | |
|
694 | def construct(text, base, rev): | |
|
695 | bins = [self.chunk(r) for r in xrange(base + 1, rev + 1)] | |
|
696 | return mdiff.patches(text, bins) | |
|
697 | ||
|
698 | 691 | # build deltas |
|
699 | 692 | for d in xrange(0, len(revs) - 1): |
|
700 | 693 | a, b = revs[d], revs[d + 1] |
@@ -738,10 +731,10 b' class revlog(object):' | |||
|
738 | 731 | base = prev = -1 |
|
739 | 732 | start = end = measure = 0 |
|
740 | 733 | if r: |
|
741 |
|
|
|
734 | base = self.base(t) | |
|
735 | start = self.start(base) | |
|
742 | 736 | end = self.end(t) |
|
743 |
measure = self.length( |
|
|
744 | base = self.base(t) | |
|
737 | measure = self.length(base) | |
|
745 | 738 | prev = self.tip() |
|
746 | 739 | |
|
747 | 740 | transaction.add(self.datafile, end) |
@@ -793,14 +786,15 b' class revlog(object):' | |||
|
793 | 786 | raise RevlogError(_("consistency error adding group")) |
|
794 | 787 | measure = len(text) |
|
795 | 788 | else: |
|
796 |
e = (end, len(cdelta), |
|
|
789 | e = (end, len(cdelta), base, link, p1, p2, node) | |
|
797 | 790 | self.index.append(e) |
|
798 | 791 | self.nodemap[node] = r |
|
799 | 792 | dfh.write(cdelta) |
|
800 | 793 | ifh.write(struct.pack(indexformat, *e)) |
|
801 | 794 | |
|
802 | 795 | t, r, chain, prev = r, r + 1, node, node |
|
803 |
|
|
|
796 | base = self.base(t) | |
|
797 | start = self.start(base) | |
|
804 | 798 | end = self.end(t) |
|
805 | 799 | |
|
806 | 800 | dfh.close() |
General Comments 0
You need to be logged in to leave comments.
Login now