comparison mercurial/localrepo.py @ 3297:fa59d6763441

merge with upstream
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Mon, 09 Oct 2006 21:22:55 +0200
parents 4546a5e31cb8
children a1aad25ccc3e a2d93b186a0e
comparison
equal deleted inserted replaced
3294:80654c248793 3297:fa59d6763441
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 checkfilemerge(self, filename, text, filelog, manifest1, manifest2):
465 "determine whether a new filenode is needed" 465 """
466 Determine whether a new filenode is needed and what parent
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 """
466 fp1 = manifest1.get(filename, nullid) 473 fp1 = manifest1.get(filename, nullid)
467 fp2 = manifest2.get(filename, nullid) 474 fp2 = manifest2.get(filename, nullid)
468 475
469 if fp2 != nullid: 476 meta = {}
477 cp = self.dirstate.copied(filename)
478 if cp:
479 meta["copy"] = cp
480 if not manifest2: # not a branch merge
481 meta["copyrev"] = hex(manifest1.get(cp, nullid))
482 fp2 = nullid
483 elif fp2 != nullid: # copied on remote side
484 meta["copyrev"] = hex(manifest1.get(cp, nullid))
485 else: # copied on local side, reversed
486 meta["copyrev"] = hex(manifest2.get(cp))
487 fp2 = nullid
488 self.ui.debug(_(" %s: copy %s:%s\n") %
489 (filename, cp, meta["copyrev"]))
490 fp1 = nullid
491 elif fp2 != nullid:
470 # is one parent an ancestor of the other? 492 # is one parent an ancestor of the other?
471 fpa = filelog.ancestor(fp1, fp2) 493 fpa = filelog.ancestor(fp1, fp2)
472 if fpa == fp1: 494 if fpa == fp1:
473 fp1, fp2 = fp2, nullid 495 fp1, fp2 = fp2, nullid
474 elif fpa == fp2: 496 elif fpa == fp2:
475 fp2 = nullid 497 fp2 = nullid
476 498
477 # is the file unmodified from the parent? report existing entry 499 # is the file unmodified from the parent? report existing entry
478 if fp2 == nullid and text == filelog.read(fp1): 500 if fp2 == nullid and not filelog.cmp(fp1, text):
479 return (fp1, None, None) 501 return (fp1, None, None, {})
480 502
481 return (None, fp1, fp2) 503 return (None, fp1, fp2, meta)
482 504
483 def rawcommit(self, files, text, user, date, p1=None, p2=None, wlock=None): 505 def rawcommit(self, files, text, user, date, p1=None, p2=None, wlock=None):
484 orig_parent = self.dirstate.parents()[0] or nullid 506 orig_parent = self.dirstate.parents()[0] or nullid
485 p1 = p1 or self.dirstate.parents()[0] or nullid 507 p1 = p1 or self.dirstate.parents()[0] or nullid
486 p2 = p2 or self.dirstate.parents()[1] or nullid 508 p2 = p2 or self.dirstate.parents()[1] or nullid
504 try: 526 try:
505 t = self.wread(f) 527 t = self.wread(f)
506 m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f))) 528 m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f)))
507 r = self.file(f) 529 r = self.file(f)
508 530
509 (entry, fp1, fp2) = self.checkfilemerge(f, t, r, m1, m2) 531 entry, fp1, fp2, meta = self.checkfilemerge(f, t, r, m1, m2)
510 if entry: 532 if entry:
511 m1[f] = entry 533 m1[f] = entry
512 continue 534 continue
513 535
514 m1[f] = r.add(t, {}, tr, linkrev, fp1, fp2) 536 m1[f] = r.add(t, meta, tr, linkrev, fp1, fp2)
515 changed.append(f) 537 changed.append(f)
516 if update_dirstate: 538 if update_dirstate:
517 self.dirstate.update([f], "n") 539 self.dirstate.update([f], "n")
518 except IOError: 540 except IOError:
519 try: 541 try:
587 self.ui.warn(_("trouble committing %s!\n") % f) 609 self.ui.warn(_("trouble committing %s!\n") % f)
588 raise 610 raise
589 611
590 r = self.file(f) 612 r = self.file(f)
591 613
592 meta = {} 614 entry, fp1, fp2, meta = self.checkfilemerge(f, t, r, m1, m2)
593 cp = self.dirstate.copied(f) 615 if entry:
594 if cp: 616 new[f] = entry
595 meta["copy"] = cp 617 continue
596 meta["copyrev"] = hex(m1.get(cp, m2.get(cp, nullid)))
597 self.ui.debug(_(" %s: copy %s:%s\n") % (f, cp, meta["copyrev"]))
598 fp1, fp2 = nullid, nullid
599 else:
600 entry, fp1, fp2 = self.checkfilemerge(f, t, r, m1, m2)
601 if entry:
602 new[f] = entry
603 continue
604 618
605 new[f] = r.add(t, meta, tr, linkrev, fp1, fp2) 619 new[f] = r.add(t, meta, tr, linkrev, fp1, fp2)
606 # remember what we've added so that we can later calculate 620 # remember what we've added so that we can later calculate
607 # the files to pull from a set of changesets 621 # the files to pull from a set of changesets
608 changed.append(f) 622 changed.append(f)