Mercurial > hg > hg-git
changeset 732:705f0a2a7c18
verify: add a wrapper function in __init__.py
Upcoming patches will switch to the new-style command decorator instead of the
explicit command table. That doesn't mesh well with top-level command functions
defined in other modules.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 19 May 2014 18:55:32 -0700 |
parents | 381a135a9548 |
children | a67fecf02adb |
files | hggit/__init__.py hggit/verify.py |
diffstat | 2 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -33,6 +33,7 @@ from mercurial import localrepo from mercurial.node import hex from mercurial import revset +from mercurial import scmutil from mercurial import templatekw from mercurial import util as hgutil from mercurial import url @@ -126,6 +127,17 @@ repo.ui.status(_("clearing out the git cache data\n")) repo.githandler.clear() +def gverify(ui, repo, **opts): + '''verify that a Mercurial rev matches the corresponding Git rev + + Given a Mercurial revision that has a corresponding Git revision in the map, + this attempts to answer whether that revision has the same contents as the + corresponding Git revision. + + ''' + ctx = scmutil.revsingle(repo, opts.get('rev'), '.') + return verify.verify(ui, repo, ctx) + if (getattr(dirstate, 'rootcache', False) and getattr(ignore, 'readpats', False)): # only install our dirstate wrapper if it has a hope of working @@ -226,6 +238,6 @@ (gclear, [], _('Clears out the Git cached data')), "git-cleanup": (git_cleanup, [], _( "Cleans up git repository after history editing")), - "gverify": (verify.verify, + "gverify": (gverify, [('r', 'rev', '', _('revision to verify'), _('REV'))], _('[-r REV]')), }
--- a/hggit/verify.py +++ b/hggit/verify.py @@ -16,7 +16,7 @@ from dulwich import diff_tree from dulwich.objects import Commit, S_IFGITLINK -def verify(ui, repo, **opts): +def verify(ui, repo, hgctx): '''verify that a Mercurial rev matches the corresponding Git rev Given a Mercurial revision that has a corresponding Git revision in the map, @@ -24,8 +24,6 @@ corresponding Git revision. ''' - hgctx = scmutil.revsingle(repo, opts.get('rev'), '.') - handler = repo.githandler gitsha = handler.map_git_get(hgctx.hex())