From 6a19e26cae50b5c129dfcc135e6cc2c0824d2712 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Sun, 8 May 2016 12:04:41 -0700 Subject: [PATCH] Write a script to help validate a migration Start with checking commit counts. --- hg-git-migrator.py => hg_git_migrator.py | 0 hg_git_validator.py | 27 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) rename hg-git-migrator.py => hg_git_migrator.py (100%) create mode 100644 hg_git_validator.py diff --git a/hg-git-migrator.py b/hg_git_migrator.py similarity index 100% rename from hg-git-migrator.py rename to hg_git_migrator.py diff --git a/hg_git_validator.py b/hg_git_validator.py new file mode 100644 index 0000000..2fc4e46 --- /dev/null +++ b/hg_git_validator.py @@ -0,0 +1,27 @@ +import hg_git_migrator + + +def check_commit_count(hg_path, git_path): + with hg_git_migrator.pushd(hg_path): + hg_results = hg_git_migrator.strict_execute('hg id --num --rev tip') + hg_count = int(hg_results.stdout) + 1 + with hg_git_migrator.pushd(git_path): + git_results = hg_git_migrator.strict_execute('git log --pretty=oneline') + git_count = len(git_results.stdout.splitlines()) + if hg_count != git_count: + raise ValueError('hg commit count != git commit count ' + '({} != {})'.format(hg_count, git_count)) + + + +if __name__ == '__main__': + import argparse + + parser = argparse.ArgumentParser() + parser.add_argument("hg_repo", help="location of mercurial repository in the filesystem.") + parser.add_argument("git_repo", help="location of git repository in the filesystem.") + args = parser.parse_args() + + hg_git_migrator.check_prerequisites(hg_git_ext=False) + + check_commit_count(args.hg_repo, args.git_repo)