Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 3323:b7a46cbf3f59
merge with upstream
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 10 Oct 2006 09:30:05 +0200 |
parents | a1aad25ccc3e a2d93b186a0e |
children | 929d04962115 |
comparison
equal
deleted
inserted
replaced
3322:a1aad25ccc3e | 3323:b7a46cbf3f59 |
---|---|
459 def wlock(self, wait=1): | 459 def wlock(self, wait=1): |
460 return self.do_lock("wlock", wait, self.dirstate.write, | 460 return self.do_lock("wlock", wait, self.dirstate.write, |
461 self.wreload, | 461 self.wreload, |
462 desc=_('working directory of %s') % self.origroot) | 462 desc=_('working directory of %s') % self.origroot) |
463 | 463 |
464 def checkfilemerge(self, filename, text, filelog, manifest1, manifest2): | 464 def filecommit(self, fn, manifest1, manifest2, linkrev, transaction, changelist): |
465 """ | 465 """ |
466 Determine whether a new filenode is needed and what parent | 466 commit an individual file as part of a larger transaction |
467 and rename information is needed for a file commit. | |
468 | |
469 Returns (old entry, file parent 1, file parent 2, metadata) | |
470 | |
471 If old entry is not None, a commit is not needed. | |
472 """ | 467 """ |
473 fp1 = manifest1.get(filename, nullid) | 468 |
474 fp2 = manifest2.get(filename, nullid) | 469 t = self.wread(fn) |
470 fl = self.file(fn) | |
471 fp1 = manifest1.get(fn, nullid) | |
472 fp2 = manifest2.get(fn, nullid) | |
475 | 473 |
476 meta = {} | 474 meta = {} |
477 cp = self.dirstate.copied(filename) | 475 cp = self.dirstate.copied(fn) |
478 if cp: | 476 if cp: |
479 meta["copy"] = cp | 477 meta["copy"] = cp |
480 if not manifest2: # not a branch merge | 478 if not manifest2: # not a branch merge |
481 meta["copyrev"] = hex(manifest1.get(cp, nullid)) | 479 meta["copyrev"] = hex(manifest1.get(cp, nullid)) |
482 fp2 = nullid | 480 fp2 = nullid |
484 meta["copyrev"] = hex(manifest1.get(cp, nullid)) | 482 meta["copyrev"] = hex(manifest1.get(cp, nullid)) |
485 else: # copied on local side, reversed | 483 else: # copied on local side, reversed |
486 meta["copyrev"] = hex(manifest2.get(cp)) | 484 meta["copyrev"] = hex(manifest2.get(cp)) |
487 fp2 = nullid | 485 fp2 = nullid |
488 self.ui.debug(_(" %s: copy %s:%s\n") % | 486 self.ui.debug(_(" %s: copy %s:%s\n") % |
489 (filename, cp, meta["copyrev"])) | 487 (fn, cp, meta["copyrev"])) |
490 fp1 = nullid | 488 fp1 = nullid |
491 elif fp2 != nullid: | 489 elif fp2 != nullid: |
492 # is one parent an ancestor of the other? | 490 # is one parent an ancestor of the other? |
493 fpa = filelog.ancestor(fp1, fp2) | 491 fpa = fl.ancestor(fp1, fp2) |
494 if fpa == fp1: | 492 if fpa == fp1: |
495 fp1, fp2 = fp2, nullid | 493 fp1, fp2 = fp2, nullid |
496 elif fpa == fp2: | 494 elif fpa == fp2: |
497 fp2 = nullid | 495 fp2 = nullid |
498 | 496 |
499 # is the file unmodified from the parent? report existing entry | 497 # is the file unmodified from the parent? report existing entry |
500 if fp2 == nullid and not filelog.cmp(fp1, text): | 498 if fp2 == nullid and not fl.cmp(fp1, t): |
501 return (fp1, None, None, {}) | 499 return fp1 |
502 | 500 |
503 return (None, fp1, fp2, meta) | 501 changelist.append(fn) |
502 return fl.add(t, meta, transaction, linkrev, fp1, fp2) | |
504 | 503 |
505 def rawcommit(self, files, text, user, date, p1=None, p2=None, wlock=None): | 504 def rawcommit(self, files, text, user, date, p1=None, p2=None, wlock=None): |
506 orig_parent = self.dirstate.parents()[0] or nullid | 505 orig_parent = self.dirstate.parents()[0] or nullid |
507 p1 = p1 or self.dirstate.parents()[0] or nullid | 506 p1 = p1 or self.dirstate.parents()[0] or nullid |
508 p2 = p2 or self.dirstate.parents()[1] or nullid | 507 p2 = p2 or self.dirstate.parents()[1] or nullid |
522 l = self.lock() | 521 l = self.lock() |
523 tr = self.transaction() | 522 tr = self.transaction() |
524 linkrev = self.changelog.count() | 523 linkrev = self.changelog.count() |
525 for f in files: | 524 for f in files: |
526 try: | 525 try: |
527 t = self.wread(f) | 526 m1[f] = self.filecommit(f, m1, m2, linkrev, tr, changed) |
528 m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f))) | 527 m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f))) |
529 r = self.file(f) | |
530 | |
531 entry, fp1, fp2, meta = self.checkfilemerge(f, t, r, m1, m2) | |
532 if entry: | |
533 m1[f] = entry | |
534 continue | |
535 | |
536 m1[f] = r.add(t, meta, tr, linkrev, fp1, fp2) | |
537 changed.append(f) | |
538 if update_dirstate: | |
539 self.dirstate.update([f], "n") | |
540 except IOError: | 528 except IOError: |
541 try: | 529 try: |
542 del m1[f] | 530 del m1[f] |
543 if update_dirstate: | 531 if update_dirstate: |
544 self.dirstate.forget([f]) | 532 self.dirstate.forget([f]) |
601 linkrev = self.changelog.count() | 589 linkrev = self.changelog.count() |
602 commit.sort() | 590 commit.sort() |
603 for f in commit: | 591 for f in commit: |
604 self.ui.note(f + "\n") | 592 self.ui.note(f + "\n") |
605 try: | 593 try: |
594 new[f] = self.filecommit(f, m1, m2, linkrev, tr, changed) | |
606 m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f))) | 595 m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f))) |
607 t = self.wread(f) | |
608 except IOError: | 596 except IOError: |
609 self.ui.warn(_("trouble committing %s!\n") % f) | 597 self.ui.warn(_("trouble committing %s!\n") % f) |
610 raise | 598 raise |
611 | |
612 r = self.file(f) | |
613 | |
614 entry, fp1, fp2, meta = self.checkfilemerge(f, t, r, m1, m2) | |
615 if entry: | |
616 new[f] = entry | |
617 continue | |
618 | |
619 new[f] = r.add(t, meta, tr, linkrev, fp1, fp2) | |
620 # remember what we've added so that we can later calculate | |
621 # the files to pull from a set of changesets | |
622 changed.append(f) | |
623 | 599 |
624 # update manifest | 600 # update manifest |
625 m1.update(new) | 601 m1.update(new) |
626 for f in remove: | 602 for f in remove: |
627 if f in m1: | 603 if f in m1: |
628 del m1[f] | 604 del m1[f] |
629 mn = self.manifest.add(m1, tr, linkrev, c1[0], c2[0], | 605 mn = self.manifest.add(m1, tr, linkrev, c1[0], c2[0], (new, remove)) |
630 (new, remove)) | |
631 | 606 |
632 # add changeset | 607 # add changeset |
633 new = new.keys() | 608 new = new.keys() |
634 new.sort() | 609 new.sort() |
635 | 610 |