def testClone(self): cfg1 = createConfig() cfg1.set("a", "x", "1", "set1") cfg2 = cfg1.clone() cfg2.set("b", "y", "2", "set2") eq(cfg1.sections(), ["a"]) eq(cfg2.sections(), ["a", "b"])
def testsynopsischangefailure(self): "Assert that we cannot change the synopsis" with self.assertRaises(error.ProgrammingError) as err: @command("commandstring", synopsis="this is the new synopsis") def helpredefiner2(): pass eq(str(err.exception), 'duplicate help message for name: "commandstring"')
def testhelptextchangefailure(self): "Assert that we cannot change the help text" with self.assertRaises(error.ProgrammingError) as err: @command("notacommand") def helpredefiner(): "this is the help text for not a command" pass eq(str(err.exception), 'duplicate help message for name: "notacommand"')
eq( generateworkingcopystates.main("filelist", 2), r""" content1_content1_content1-tracked content1_content1_content1-untracked content1_content1_content3-tracked content1_content1_content3-untracked content1_content1_missing-tracked content1_content1_missing-untracked content1_content2_content1-tracked content1_content2_content1-untracked content1_content2_content2-tracked content1_content2_content2-untracked content1_content2_content3-tracked content1_content2_content3-untracked content1_content2_missing-tracked content1_content2_missing-untracked content1_missing_content1-tracked content1_missing_content1-untracked content1_missing_content3-tracked content1_missing_content3-untracked content1_missing_missing-tracked content1_missing_missing-untracked missing_content2_content2-tracked missing_content2_content2-untracked missing_content2_content3-tracked missing_content2_content3-untracked missing_content2_missing-tracked missing_content2_missing-untracked missing_missing_content3-tracked missing_missing_content3-untracked missing_missing_missing-tracked missing_missing_missing-untracked""", )
tuple(line.split()) for line in sh.hgexcept(*args).splitlines()) sh % '. "$TESTDIR/library.sh"' sh % "configure dummyssh" sh % "enable treemanifest remotenames remotefilelog pushrebase" # Check manifest behavior with empty commit sh % "hginit emptycommit" sh % "cd emptycommit" sh % "drawdag" << r""" # drawdag.defaultfiles=false A """ eq( listcommitandmanifesthashes("$A::"), [("A", "7b3f3d5e5faf", "0000000000000000000000000000000000000000")], ) # Check hash and manifest values in a local repository sh % "hginit $TESTTMP/localcommitsandmerge" sh % "cd $TESTTMP/localcommitsandmerge" # A - add # B - modify # C, D - add + modify # E - merge with conflict and divergence # F - just checking that merge doesn't mess repo by performing a modify sh % "drawdag" << r""" # drawdag.defaultfiles=false F # F/y/c=f # crash with rustmanifest if y/c=c | E # E/y/d=(removed)
sh % "cd binaryremoval" sh % "echo a" > "a" open("b", "wb").write("a\0b") sh % "hg ci -Am addall" == r""" adding a adding b""" sh % "hg rm a" sh % "hg rm b" sh % "hg st" == r""" R a R b""" sh % "hg ci -m remove" sh % "hg export --git ." > "remove.diff" eq( [l for l in open("remove.diff") if "git" in l], ["diff --git a/a b/a\n", "diff --git a/b b/b\n"], ) sh % "hg up -C 0" == "2 files updated, 0 files merged, 0 files removed, 0 files unresolved" sh % "hg import remove.diff" == "applying remove.diff" sh % "hg manifest" sh % "cd .." # Issue927: test update+rename with common name sh % "hg init t" sh % "cd t" sh % "touch a" sh % "hg ci -Am t" == "adding a" sh % "echo a" > "a" # Here, bfile.startswith(afile)
def translateeq(code, expected): eq(translatebody(code + "\n").strip(), expected, nested=1)
| A """ ) # Prepare bookmarks and remotenames. Set them to A in backup, and B on disk. setbookmarks("A") backup() setbookmarks("B") # Test migrating from disk to metalog. # They should migrate "B" from disk to metalog and use it. sh.setconfig("experimental.metalog=1") eq(listbookmarks(), ["B", "B"]) # Metalog is the source of truth. Changes to .hg/store are ignored. restore() eq(listbookmarks(), ["B", "B"]) # Test migrating from metalog to disk. # Metalog is not the source of truth. Changes to .hg/store are effective. sh.setconfig("experimental.metalog=0") setbookmarks("C") eq(listbookmarks(), ["C", "C"]) restore() eq(listbookmarks(), ["A", "A"])
def testIncludelist(self): cfg = createConfig() cfg.readpath("a.rc", "readpath", None, None, [("a", "y")]) eq(cfg.get("a", "x"), "1") eq(cfg.get("a", "y"), None)
def testSectionRemap(self): cfg = createConfig() cfg.readpath("a.rc", "readpath", None, [("a", "x")], None) eq(cfg.sections(), ["x", "b"])
def testSectionIncludelist(self): cfg = createConfig() cfg.readpath("a.rc", "readpath", ["a"], None, None) eq(cfg.sections(), ["a"])
def testReadConfig(self): cfg = createConfig() cfg.readpath("a.rc", "readpath", None, None, None) cfg.parse("[c]\nx=1", "parse") cfg.set("d", "y", "2", "set1") cfg.set("d", "x", None, "set2") eq(cfg.sections(), ["a", "b", "c", "d"]) eq(cfg.get("a", "x"), "1") eq(cfg.get("a", "y"), None) eq(cfg.get("b", "z"), "3") eq(cfg.get("c", "x"), "1") eq(cfg.get("d", "x"), None) eq(cfg.get("d", "y"), "2") eq(cfg.get("e", "x"), None) eq(normalizeSources(cfg, "a", "x"), [("1", ("a.rc", 6, 7, 2), "readpath")]) eq( normalizeSources(cfg, "a", "y"), [ ("2", ("a.rc", 10, 11, 3), "readpath"), (None, ("b.rc", 29, 36, 5), "readpath"), ], ) eq(cfg.sources("c", "x"), [("1", ("<builtin>", 6, 7, 2), "parse")])
predicate = edenscm.mercurial.revset.predicate excluded = edenscm.mercurial.help._exclkeywords @predicate("notarealpredicate()") def notarealpredicate(): pass # Assert that all predicates have docstrings unless they are explicitly # marked as hidden or have name starting with an underscore eq( [ name for name, func in predicate._table.items() if not name.startswith("_") and func.__doc__ is None ], ["notarealpredicate"], ) # Assert that revsets from the "hg help revsets" command are the expected ones helpoutput = (sh % "hg help revsets").output expectedpredicates = set( str(func.__doc__.strip().split("(")[0][2:]) for name, func in predicate._table.items() if name[0] != "_" and func.__doc__ and not any(w in func.__doc__ for w in excluded) ) eq( set(pred for pred in expectedpredicates if pred + "(" not in helpoutput),
def thisisnotacommand(_ui, **opts): "yadayadayada" return "foo" command._table[ "commandstring"] = "Rust commands are actually registered as strings" # Redifining commands should not be an issue as long as they do not have any documentation @command("notacommand") def thisalreadyexisted(_ui, **opts): return "foobar" eq(thisalreadyexisted(None), "foobar") class TestRegistrar(unittest.TestCase): def testhelptextchangefailure(self): "Assert that we cannot change the help text" with self.assertRaises(error.ProgrammingError) as err: @command("notacommand") def helpredefiner(): "this is the help text for not a command" pass eq(str(err.exception), 'duplicate help message for name: "notacommand"')
sh % "setconfig experimental.allowfilepeer=True" sh % '. "$TESTDIR/library.sh"' sh % "configure dummyssh" sh % "enable treemanifest remotenames remotefilelog pushrebase" # Check manifest behavior with empty commit sh % "hginit emptycommit" sh % "cd emptycommit" (sh % "drawdag" << r""" # drawdag.defaultfiles=false A """) eq( listcommitandmanifesthashes("$A::"), [("A", "7b3f3d5e5faf", "0000000000000000000000000000000000000000")], ) # Check hash and manifest values in a local repository sh % "hginit $TESTTMP/localcommitsandmerge" sh % "cd $TESTTMP/localcommitsandmerge" # A - add # B - modify # C, D - add + modify # E - merge with conflict and divergence # F - just checking that merge doesn't mess repo by performing a modify (sh % "drawdag" << r""" # drawdag.defaultfiles=false F # F/y/c=f # crash with rustmanifest if y/c=c | E # E/y/d=(removed)
| # B/y/x/y/z=B2 | | | D # D/d/d/d/d=D1 | | | C # C/c/c/c/c=C1 |/ A # A/x/x/y/z=A1 # A/y/x/y/z=A2 # A/z/x/y/z=A3 """ sh % "hg sparse include x" # Good: Updating to A should avoid downloading y/ or z/ eq(collectprefetch("hg update -q $A"), ["x", "x/x", "x/x/y"]) # Good: Updating to B should avoid downloading y/ eq(collectprefetch("hg update -q $B"), ["x", "x/x", "x/x/y"]) sh % "hg update -q $D" # Good: Rebasing B to D should avoid downloading d/ or c/, or z/. # (This is optimized by "rebase: use matcher to optimize manifestmerge", # https://www.mercurial-scm.org/repo/hg/rev/4d504e541d3d, # fbsource-hg: 94ad1b49ede1f8e5897c7c9381304785746fa460) eq( collectprefetch("hg rebase -r $B -d $D -q"), ["x", "x/x", "x/x/y", "y", "y/x", "y/x/y"], )