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