Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 10282:08a0f04b56bd
many, many trivial check-code fixups
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 25 Jan 2010 00:05:27 -0600 |
parents | d6512b3e9ac0 |
children | 808c187fc556 |
comparison
equal
deleted
inserted
replaced
10281:e7d3b509af8b | 10282:08a0f04b56bd |
---|---|
317 | 317 |
318 def _branchtags(self, partial, lrev): | 318 def _branchtags(self, partial, lrev): |
319 # TODO: rename this function? | 319 # TODO: rename this function? |
320 tiprev = len(self) - 1 | 320 tiprev = len(self) - 1 |
321 if lrev != tiprev: | 321 if lrev != tiprev: |
322 self._updatebranchcache(partial, lrev+1, tiprev+1) | 322 self._updatebranchcache(partial, lrev + 1, tiprev + 1) |
323 self._writebranchcache(partial, self.changelog.tip(), tiprev) | 323 self._writebranchcache(partial, self.changelog.tip(), tiprev) |
324 | 324 |
325 return partial | 325 return partial |
326 | 326 |
327 def branchmap(self): | 327 def branchmap(self): |
375 last, lrev = bin(last), int(lrev) | 375 last, lrev = bin(last), int(lrev) |
376 if lrev >= len(self) or self[lrev].node() != last: | 376 if lrev >= len(self) or self[lrev].node() != last: |
377 # invalidate the cache | 377 # invalidate the cache |
378 raise ValueError('invalidating branch cache (tip differs)') | 378 raise ValueError('invalidating branch cache (tip differs)') |
379 for l in lines: | 379 for l in lines: |
380 if not l: continue | 380 if not l: |
381 continue | |
381 node, label = l.split(" ", 1) | 382 node, label = l.split(" ", 1) |
382 partial.setdefault(label.strip(), []).append(bin(node)) | 383 partial.setdefault(label.strip(), []).append(bin(node)) |
383 except KeyboardInterrupt: | 384 except KeyboardInterrupt: |
384 raise | 385 raise |
385 except Exception, inst: | 386 except Exception, inst: |
560 if tr and tr.running(): | 561 if tr and tr.running(): |
561 return tr.nest() | 562 return tr.nest() |
562 | 563 |
563 # abort here if the journal already exists | 564 # abort here if the journal already exists |
564 if os.path.exists(self.sjoin("journal")): | 565 if os.path.exists(self.sjoin("journal")): |
565 raise error.RepoError(_("abandoned transaction found - run hg recover")) | 566 raise error.RepoError( |
567 _("abandoned transaction found - run hg recover")) | |
566 | 568 |
567 # save dirstate for rollback | 569 # save dirstate for rollback |
568 try: | 570 try: |
569 ds = self.opener("dirstate").read() | 571 ds = self.opener("dirstate").read() |
570 except IOError: | 572 except IOError: |
585 def recover(self): | 587 def recover(self): |
586 lock = self.lock() | 588 lock = self.lock() |
587 try: | 589 try: |
588 if os.path.exists(self.sjoin("journal")): | 590 if os.path.exists(self.sjoin("journal")): |
589 self.ui.status(_("rolling back interrupted transaction\n")) | 591 self.ui.status(_("rolling back interrupted transaction\n")) |
590 transaction.rollback(self.sopener, self.sjoin("journal"), self.ui.warn) | 592 transaction.rollback(self.sopener, self.sjoin("journal"), |
593 self.ui.warn) | |
591 self.invalidate() | 594 self.invalidate() |
592 return True | 595 return True |
593 else: | 596 else: |
594 self.ui.warn(_("no interrupted transaction available\n")) | 597 self.ui.warn(_("no interrupted transaction available\n")) |
595 return False | 598 return False |
601 try: | 604 try: |
602 wlock = self.wlock() | 605 wlock = self.wlock() |
603 lock = self.lock() | 606 lock = self.lock() |
604 if os.path.exists(self.sjoin("undo")): | 607 if os.path.exists(self.sjoin("undo")): |
605 self.ui.status(_("rolling back last transaction\n")) | 608 self.ui.status(_("rolling back last transaction\n")) |
606 transaction.rollback(self.sopener, self.sjoin("undo"), self.ui.warn) | 609 transaction.rollback(self.sopener, self.sjoin("undo"), |
610 self.ui.warn) | |
607 util.rename(self.join("undo.dirstate"), self.join("dirstate")) | 611 util.rename(self.join("undo.dirstate"), self.join("dirstate")) |
608 try: | 612 try: |
609 branch = self.opener("undo.branch").read() | 613 branch = self.opener("undo.branch").read() |
610 self.dirstate.setbranch(branch) | 614 self.dirstate.setbranch(branch) |
611 except IOError: | 615 except IOError: |
1337 if r: | 1341 if r: |
1338 reqcnt += 1 | 1342 reqcnt += 1 |
1339 self.ui.debug("request %d: %s\n" % | 1343 self.ui.debug("request %d: %s\n" % |
1340 (reqcnt, " ".join(map(short, r)))) | 1344 (reqcnt, " ".join(map(short, r)))) |
1341 for p in xrange(0, len(r), 10): | 1345 for p in xrange(0, len(r), 10): |
1342 for b in remote.branches(r[p:p+10]): | 1346 for b in remote.branches(r[p:p + 10]): |
1343 self.ui.debug("received %s:%s\n" % | 1347 self.ui.debug("received %s:%s\n" % |
1344 (short(b[0]), short(b[1]))) | 1348 (short(b[0]), short(b[1]))) |
1345 unknown.append(b) | 1349 unknown.append(b) |
1346 | 1350 |
1347 # do binary search on the branches we found | 1351 # do binary search on the branches we found |
1607 # aborts. | 1611 # aborts. |
1608 | 1612 |
1609 ret = self.prepush(remote, force, revs) | 1613 ret = self.prepush(remote, force, revs) |
1610 if ret[0] is not None: | 1614 if ret[0] is not None: |
1611 cg, remote_heads = ret | 1615 cg, remote_heads = ret |
1612 if force: remote_heads = ['force'] | 1616 if force: |
1617 remote_heads = ['force'] | |
1613 return remote.unbundle(cg, remote_heads, 'push') | 1618 return remote.unbundle(cg, remote_heads, 'push') |
1614 return ret[1] | 1619 return ret[1] |
1615 | 1620 |
1616 def changegroupinfo(self, nodes, source): | 1621 def changegroupinfo(self, nodes, source): |
1617 if self.ui.verbose or source == 'bundle': | 1622 if self.ui.verbose or source == 'bundle': |