def testBustedHgrc(self):
        # Test that we can recover from hgrc being lost
        mercurial(self.repodir, self.wc)

        # Delete .hg/hgrc
        os.unlink(os.path.join(self.wc, '.hg', 'hgrc'))

        # path is busted now
        p = path(self.wc)
        self.assertEquals(p, None)

        # cloning again should fix this up
        mercurial(self.repodir, self.wc)

        p = path(self.wc)
        self.assertEquals(p, self.repodir)
예제 #2
0
    def testBustedHgrc(self):
        # Test that we can recover from hgrc being lost
        mercurial(self.repodir, self.wc)

        # Delete .hg/hgrc
        os.unlink(os.path.join(self.wc, '.hg', 'hgrc'))

        # path is busted now
        p = path(self.wc)
        self.assertEquals(p, None)

        # cloning again should fix this up
        mercurial(self.repodir, self.wc)

        p = path(self.wc)
        self.assertEquals(p, self.repodir)
예제 #3
0
    def testCloneWithBadMirror(self):
        mirror = os.path.join(self.tmpdir, 'repo2')

        # Now clone from the mirror
        clone(self.repodir, self.wc, mirrors=[mirror])

        # We still end up with a valid repo
        self.assertEquals(self.revisions, getRevisions(self.wc))
        self.assertEquals(self.repodir, path(self.wc))
예제 #4
0
    def testCloneWithBadMirror(self):
        mirror = os.path.join(self.tmpdir, 'repo2')

        # Now clone from the mirror
        clone(self.repodir, self.wc, mirrors=[mirror])

        # We still end up with a valid repo
        self.assertEquals(self.revisions, getRevisions(self.wc))
        self.assertEquals(self.repodir, path(self.wc))
    def testAdjustPaths(self):
        mercurial(self.repodir, self.wc)

        # Make sure our default path is correct
        self.assertEquals(path(self.wc), self.repodir)

        # Add a comment, make sure it's still there if we don't change
        # anything
        hgrc = os.path.join(self.wc, '.hg', 'hgrc')
        open(hgrc, 'a').write("# Hello world")
        adjust_paths(self.wc, default=self.repodir)
        self.assert_("Hello world" in open(hgrc).read())

        # Add a path, and the comment goes away
        adjust_paths(self.wc, test=self.repodir)
        self.assert_("Hello world" not in open(hgrc).read())

        # Make sure our paths are correct
        self.assertEquals(path(self.wc), self.repodir)
        self.assertEquals(path(self.wc, 'test'), self.repodir)
예제 #6
0
    def testAdjustPaths(self):
        mercurial(self.repodir, self.wc)

        # Make sure our default path is correct
        self.assertEquals(path(self.wc), self.repodir)

        # Add a comment, make sure it's still there if we don't change
        # anything
        hgrc = os.path.join(self.wc, '.hg', 'hgrc')
        open(hgrc, 'a').write("# Hello world")
        adjust_paths(self.wc, default=self.repodir)
        self.assert_("Hello world" in open(hgrc).read())

        # Add a path, and the comment goes away
        adjust_paths(self.wc, test=self.repodir)
        self.assert_("Hello world" not in open(hgrc).read())

        # Make sure our paths are correct
        self.assertEquals(path(self.wc), self.repodir)
        self.assertEquals(path(self.wc, 'test'), self.repodir)
예제 #7
0
    def testBustedHgrcWithShare(self):
        # Test that we can recover from hgrc being lost
        shareBase = os.path.join(self.tmpdir, 'share')
        sharerepo = os.path.join(shareBase, self.repodir.lstrip("/"))
        os.mkdir(shareBase)
        mercurial(self.repodir, self.wc, shareBase=shareBase)

        # Delete .hg/hgrc
        for d in sharerepo, self.wc:
            f = os.path.join(d, '.hg', 'hgrc')
            os.unlink(f)

        # path is busted now
        p = path(self.wc)
        self.assertEquals(p, None)

        # cloning again should fix this up
        mercurial(self.repodir, self.wc, shareBase=shareBase)

        p = path(self.wc)
        self.assertEquals(p, self.repodir)
    def testBustedHgrcWithShare(self):
        # Test that we can recover from hgrc being lost
        shareBase = os.path.join(self.tmpdir, 'share')
        sharerepo = os.path.join(shareBase, self.repodir.lstrip("/"))
        os.mkdir(shareBase)
        mercurial(self.repodir, self.wc, shareBase=shareBase)

        # Delete .hg/hgrc
        for d in sharerepo, self.wc:
            f = os.path.join(d, '.hg', 'hgrc')
            os.unlink(f)

        # path is busted now
        p = path(self.wc)
        self.assertEquals(p, None)

        # cloning again should fix this up
        mercurial(self.repodir, self.wc, shareBase=shareBase)

        p = path(self.wc)
        self.assertEquals(p, self.repodir)
예제 #9
0
    def testPullWithBadMirror(self):
        mirror = os.path.join(self.tmpdir, "repo2")

        # Now clone from the original
        clone(self.repodir, self.wc)

        # Create a new commit in the original repo
        open(os.path.join(self.repodir, "test.txt"), "w").write("hello!")
        run_cmd(["hg", "add", "test.txt"], cwd=self.repodir)
        run_cmd(["hg", "commit", "-m", "adding changeset"], cwd=self.repodir)

        # Pull using the mirror
        pull(self.repodir, self.wc, mirrors=[mirror])

        self.assertEquals(getRevisions(self.wc), getRevisions(self.repodir))

        # Our default path should point to the original repo
        self.assertEquals(self.repodir, path(self.wc))
예제 #10
0
    def testPullWithBadMirror(self):
        mirror = os.path.join(self.tmpdir, 'repo2')

        # Now clone from the original
        clone(self.repodir, self.wc)

        # Create a new commit in the original repo
        open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
        run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
        run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)

        # Pull using the mirror
        pull(self.repodir, self.wc, mirrors=[mirror])

        self.assertEquals(getRevisions(self.wc), getRevisions(self.repodir))

        # Our default path should point to the original repo
        self.assertEquals(self.repodir, path(self.wc))
예제 #11
0
    def testCloneWithMirror(self):
        mirror = os.path.join(self.tmpdir, 'repo2')
        clone(self.repodir, mirror)

        # Create a commit in the original repo
        open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
        run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
        run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)

        # Now clone from the mirror
        clone(self.repodir, self.wc, mirrors=[mirror])

        # We'll be missing the new revision from repodir
        self.assertNotEquals(getRevisions(self.repodir), getRevisions(self.wc))
        # But we should have everything from the mirror
        self.assertEquals(getRevisions(mirror), getRevisions(self.wc))
        # Our default path should point to the original repo though.
        self.assertEquals(self.repodir, path(self.wc))
예제 #12
0
    def testCloneWithMirror(self):
        mirror = os.path.join(self.tmpdir, 'repo2')
        clone(self.repodir, mirror)

        # Create a commit in the original repo
        open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
        run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
        run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)

        # Now clone from the mirror
        clone(self.repodir, self.wc, mirrors=[mirror])

        # We'll be missing the new revision from repodir
        self.assertNotEquals(getRevisions(self.repodir), getRevisions(self.wc))
        # But we should have everything from the mirror
        self.assertEquals(getRevisions(mirror), getRevisions(self.wc))
        # Our default path should point to the original repo though.
        self.assertEquals(self.repodir, path(self.wc))
예제 #13
0
    def testPullWithBadMirror(self):
        mirror = os.path.join(self.tmpdir, 'repo2')

        # Now clone from the original
        clone(self.repodir, self.wc)

        # Create a new commit in the original repo
        open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
        run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
        run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)

        # Pull using the mirror
        pull(self.repodir, self.wc, mirrors=[mirror])

        self.assertEquals(getRevisions(self.wc), getRevisions(self.repodir))

        # Our default path should point to the original repo
        self.assertEquals(self.repodir, path(self.wc))
예제 #14
0
    def testCloneWithMirror(self):
        mirror = os.path.join(self.tmpdir, "repo2")
        clone(self.repodir, mirror)

        # Create a commit in the original repo
        open(os.path.join(self.repodir, "test.txt"), "w").write("hello!")
        run_cmd(["hg", "add", "test.txt"], cwd=self.repodir)
        run_cmd(["hg", "commit", "-m", "adding changeset"], cwd=self.repodir)

        # Now clone from the mirror
        clone(self.repodir, self.wc, mirrors=[mirror])

        # We'll be missing the new revision from repodir
        self.assertNotEquals(getRevisions(self.repodir), getRevisions(self.wc))
        # But we should have everything from the mirror
        self.assertEquals(getRevisions(mirror), getRevisions(self.wc))
        # Our default path should point to the original repo though.
        self.assertEquals(self.repodir, path(self.wc))
예제 #15
0
    def testCloneWithRevAndMirror(self):
        mirror = os.path.join(self.tmpdir, "repo2")
        clone(self.repodir, mirror)

        # Create a commit in the original repo
        open(os.path.join(self.repodir, "test.txt"), "w").write("hello!")
        run_cmd(["hg", "add", "test.txt"], cwd=self.repodir)
        run_cmd(["hg", "commit", "-m", "adding changeset"], cwd=self.repodir)

        # Now clone from the mirror
        revisions = getRevisions(self.repodir)
        clone(self.repodir, self.wc, revision=revisions[0], mirrors=[mirror], clone_by_rev=True)

        # We'll be missing the middle revision (on another branch)
        self.assertEquals(revisions[:2] + revisions[3:], getRevisions(self.wc))
        # But not from the mirror
        self.assertNotEquals(getRevisions(mirror), getRevisions(self.wc))
        # Our default path should point to the original repo though.
        self.assertEquals(self.repodir, path(self.wc))
예제 #16
0
    def testCloneWithRevAndMirror(self):
        mirror = os.path.join(self.tmpdir, 'repo2')
        clone(self.repodir, mirror)

        # Create a commit in the original repo
        open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
        run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
        run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)

        # Now clone from the mirror
        revisions = getRevisions(self.repodir)
        clone(self.repodir, self.wc, revision=revisions[0],
              mirrors=[mirror], clone_by_rev=True)

        # We'll be missing the middle revision (on another branch)
        self.assertEquals(revisions[:2] + revisions[3:], getRevisions(self.wc))
        # But not from the mirror
        self.assertNotEquals(getRevisions(mirror), getRevisions(self.wc))
        # Our default path should point to the original repo though.
        self.assertEquals(self.repodir, path(self.wc))
예제 #17
0
    def testCloneWithBundle(self):
        # First create the bundle
        bundle = os.path.join(self.tmpdir, 'bundle')
        run_cmd(['hg', 'bundle', '-a', bundle], cwd=self.repodir)

        # Wrap unbundle so we can tell if it got called
        orig_unbundle = unbundle
        try:
            called = []
            def new_unbundle(*args, **kwargs):
                called.append(True)
                return orig_unbundle(*args, **kwargs)
            hg.unbundle = new_unbundle

            # Now clone it using the bundle
            clone(self.repodir, self.wc, bundles=[bundle])
            self.assertEquals(self.revisions, getRevisions(self.wc))
            self.assertEquals(called, [True])
            self.assertEquals(path(self.wc), self.repodir)
        finally:
            hg.unbundle = orig_unbundle
예제 #18
0
    def testPullWithUnrelatedMirror(self):
        mirror = os.path.join(self.tmpdir, "repo2")
        run_cmd(["%s/init_hgrepo.sh" % os.path.dirname(__file__), mirror])

        # Now clone from the original
        clone(self.repodir, self.wc)

        # Create a new commit in the original repo
        open(os.path.join(self.repodir, "test.txt"), "w").write("hello!")
        run_cmd(["hg", "add", "test.txt"], cwd=self.repodir)
        run_cmd(["hg", "commit", "-m", "adding changeset"], cwd=self.repodir)

        # Pull using the mirror
        pull(self.repodir, self.wc, mirrors=[mirror])

        self.assertEquals(getRevisions(self.wc), getRevisions(self.repodir))
        # We shouldn't have anything from the unrelated mirror
        self.assertEquals(set(), set(getRevisions(mirror)).intersection(set(getRevisions(self.wc))))

        # Our default path should point to the original repo
        self.assertEquals(self.repodir, path(self.wc))
예제 #19
0
    def testPullWithUnrelatedMirror(self):
        mirror = os.path.join(self.tmpdir, 'repo2')
        run_cmd(['%s/init_hgrepo.sh' % os.path.dirname(__file__), mirror])

        # Now clone from the original
        clone(self.repodir, self.wc)

        # Create a new commit in the original repo
        open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
        run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
        run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)

        # Pull using the mirror
        pull(self.repodir, self.wc, mirrors=[mirror])

        self.assertEquals(getRevisions(self.wc), getRevisions(self.repodir))
        # We shouldn't have anything from the unrelated mirror
        self.assertEquals(set(),
                          set(getRevisions(mirror)).intersection(set(getRevisions(self.wc))))

        # Our default path should point to the original repo
        self.assertEquals(self.repodir, path(self.wc))
예제 #20
0
    def testCloneWithBundle(self):
        # First create the bundle
        bundle = os.path.join(self.tmpdir, 'bundle')
        run_cmd(['hg', 'bundle', '-a', bundle], cwd=self.repodir)

        # Wrap unbundle so we can tell if it got called
        orig_unbundle = unbundle
        try:
            called = []

            def new_unbundle(*args, **kwargs):
                called.append(True)
                return orig_unbundle(*args, **kwargs)

            hg.unbundle = new_unbundle

            # Now clone it using the bundle
            clone(self.repodir, self.wc, bundles=[bundle])
            self.assertEquals(self.revisions, getRevisions(self.wc))
            self.assertEquals(called, [True])
            self.assertEquals(path(self.wc), self.repodir)
        finally:
            hg.unbundle = orig_unbundle
예제 #21
0
    def testCloneWithRevAndMirror(self):
        mirror = os.path.join(self.tmpdir, 'repo2')
        clone(self.repodir, mirror)

        # Create a commit in the original repo
        open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
        run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
        run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)

        # Now clone from the mirror
        revisions = getRevisions(self.repodir)
        clone(self.repodir,
              self.wc,
              revision=revisions[0],
              mirrors=[mirror],
              clone_by_rev=True)

        # We'll be missing the middle revision (on another branch)
        self.assertEquals(revisions[:2] + revisions[3:], getRevisions(self.wc))
        # But not from the mirror
        self.assertNotEquals(getRevisions(mirror), getRevisions(self.wc))
        # Our default path should point to the original repo though.
        self.assertEquals(self.repodir, path(self.wc))
예제 #22
0
    def testPullWithUnrelatedMirror(self):
        mirror = os.path.join(self.tmpdir, 'repo2')
        run_cmd(['%s/init_hgrepo.sh' % os.path.dirname(__file__), mirror])

        # Now clone from the original
        clone(self.repodir, self.wc)

        # Create a new commit in the original repo
        open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
        run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
        run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)

        # Pull using the mirror
        pull(self.repodir, self.wc, mirrors=[mirror])

        self.assertEquals(getRevisions(self.wc), getRevisions(self.repodir))
        # We shouldn't have anything from the unrelated mirror
        self.assertEquals(
            set(),
            set(getRevisions(mirror)).intersection(set(getRevisions(self.wc))))

        # Our default path should point to the original repo
        self.assertEquals(self.repodir, path(self.wc))
 def testPath(self):
     clone(self.repodir, self.wc)
     p = path(self.wc)
     self.assertEquals(p, self.repodir)
예제 #24
0
 def testPath(self):
     clone(self.repodir, self.wc)
     p = path(self.wc)
     self.assertEquals(p, self.repodir)