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.
This commit is contained in:
Siddharth Agarwal 2014-05-19 18:55:32 -07:00
parent 58c28a86e9
commit 0649f5c865
2 changed files with 14 additions and 4 deletions

View File

@ -33,6 +33,7 @@ from mercurial import ignore
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 @@ def gclear(ui, repo):
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 @@ cmdtable = {
(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]')),
}

View File

@ -16,7 +16,7 @@ from mercurial import scmutil
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 @@ def verify(ui, repo, **opts):
corresponding Git revision.
'''
hgctx = scmutil.revsingle(repo, opts.get('rev'), '.')
handler = repo.githandler
gitsha = handler.map_git_get(hgctx.hex())