568
def common_ancestor(self, other, self_revno=None, other_revno=None):
571
>>> sb = ScratchBranch(files=['foo', 'foo~'])
572
>>> sb.common_ancestor(sb) == (None, None)
574
>>> commit.commit(sb, "Committing first revision", verbose=False)
575
>>> sb.common_ancestor(sb)[0]
577
>>> clone = sb.clone()
578
>>> commit.commit(sb, "Committing second revision", verbose=False)
579
>>> sb.common_ancestor(sb)[0]
581
>>> sb.common_ancestor(clone)[0]
583
>>> commit.commit(clone, "Committing divergent second revision",
585
>>> sb.common_ancestor(clone)[0]
587
>>> sb.common_ancestor(clone) == clone.common_ancestor(sb)
589
>>> sb.common_ancestor(sb) != clone.common_ancestor(clone)
591
>>> clone2 = sb.clone()
592
>>> sb.common_ancestor(clone2)[0]
594
>>> sb.common_ancestor(clone2, self_revno=1)[0]
596
>>> sb.common_ancestor(clone2, other_revno=1)[0]
599
my_history = self.revision_history()
600
other_history = other.revision_history()
601
if self_revno is None:
602
self_revno = len(my_history)
603
if other_revno is None:
604
other_revno = len(other_history)
605
indices = range(min((self_revno, other_revno)))
608
if my_history[r] == other_history[r]:
609
return r+1, my_history[r]
568
612
def enum_history(self, direction):
569
613
"""Return (revno, revision_id) for history of branch.
787
def __init__(self, files=[], dirs=[]):
831
def __init__(self, files=[], dirs=[], base=None):
788
832
"""Make a test branch.
790
834
This creates a temporary directory and runs init-tree in it.
792
836
If any files are listed, they are created in the working copy.
794
Branch.__init__(self, tempfile.mkdtemp(), init=True)
840
base = tempfile.mkdtemp()
842
Branch.__init__(self, base, init=init)
796
844
os.mkdir(self.abspath(d))
799
847
file(os.path.join(self.base, f), 'w').write('content of %s' % f)
852
>>> orig = ScratchBranch(files=["file1", "file2"])
853
>>> clone = orig.clone()
854
>>> os.path.samefile(orig.base, clone.base)
856
>>> os.path.isfile(os.path.join(clone.base, "file1"))
859
base = tempfile.mkdtemp()
861
shutil.copytree(self.base, base, symlinks=True)
862
return ScratchBranch(base=base)
802
864
def __del__(self):