Skip to content
Snippets Groups Projects
Commit 11ca2182 authored by Siddharth Agarwal's avatar Siddharth Agarwal
Browse files

overlay: adapt diff to work with lazymanifests

parent 5cc2ad8a
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@
from mercurial import hg
from mercurial import ignore
from mercurial import localrepo
from mercurial import manifest
from mercurial.node import hex
from mercurial import revset
from mercurial import scmutil
......@@ -45,6 +46,7 @@
import gitrepo
import hgrepo
import overlay
import util
from git_handler import GitHandler
import verify
......@@ -126,6 +128,11 @@
klass = hgrepo.generate_repo_subclass(repo.__class__)
repo.__class__ = klass
if hgutil.safehasattr(manifest, '_lazymanifest'):
# Mercurial >= 3.4
extensions.wrapfunction(manifest.manifestdict, 'diff',
overlay.wrapmanifestdictdiff)
@command('gimport')
def gimport(ui, repo, remote_name=None):
'''import commits from Git to Mercurial'''
......
......@@ -103,6 +103,12 @@
# below code copied from manifest.py:manifestdict.diff
diff = {}
try:
m2flagget = m2.flags
except AttributeError:
# Mercurial <= 3.3
m2flagget = m2._flags.get
for fn, n1 in self.iteritems():
fl1 = self._flags.get(fn, '')
n2 = m2.get(fn, None)
......@@ -106,7 +112,7 @@
for fn, n1 in self.iteritems():
fl1 = self._flags.get(fn, '')
n2 = m2.get(fn, None)
fl2 = m2._flags.get(fn, '')
fl2 = m2flagget(fn, '')
if n2 is None:
fl2 = ''
if n1 != n2 or fl1 != fl2:
......@@ -116,7 +122,7 @@
for fn, n2 in m2.iteritems():
if fn not in self:
fl2 = m2._flags.get(fn, '')
fl2 = m2flagget(fn, '')
diff[fn] = ((None, ''), (n2, fl2))
return diff
......@@ -124,6 +130,18 @@
def __delitem__(self, path):
del self._map[path]
def wrapmanifestdictdiff(orig, self, m2, clean=False):
'''avoid calling into lazymanifest code if m2 is an overlaymanifest'''
if isinstance(m2, overlaymanifest):
diff = m2.diff(self, clean=clean)
# since we calculated the diff with m2 vs m1, flip it around
for fn in diff:
c1, c2 = diff[fn]
diff[fn] = c2, c1
return diff
else:
return orig(self, m2, clean=clean)
class overlayfilectx(object):
def __init__(self, repo, path, fileid=None):
self.repo = repo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment