コード例 #1
0
def patchrepo(ui, meta, parentctx, patchfp):
    store = patch.filestore(util.getfilestoresize(ui))
    try:
        touched = set()
        backend = svnbackend(ui, meta.repo, parentctx, store)

        try:
            try:
                ret = patch.patchbackend(ui, backend, patchfp, 0, files=touched)
            except TypeError:
                # Mercurial >= 3.4 have an extra prefix parameter
                ret = patch.patchbackend(ui, backend, patchfp, 0, '',
                                         files=touched)
            if ret < 0:
                raise BadPatchApply('patching failed')
            if ret > 0:
                raise BadPatchApply('patching succeeded with fuzz')
        except patch.PatchError, e:
            raise BadPatchApply(str(e))

        files = {}
        for f in touched:
            try:
                data, mode, copied = store.getfile(f)
                files[f] = data
            except IOError:
                files[f] = None
        return files
コード例 #2
0
ファイル: stupid.py プロジェクト: fuzzball81/dotfiles
def patchrepo(ui, meta, parentctx, patchfp):
    store = patch.filestore(util.getfilestoresize(ui))
    try:
        touched = set()
        backend = svnbackend(ui, meta.repo, parentctx, store)

        try:
            try:
                ret = patch.patchbackend(ui, backend, patchfp, 0, files=touched)
            except TypeError:
                # Mercurial >= 3.4 have an extra prefix parameter
                ret = patch.patchbackend(ui, backend, patchfp, 0, '',
                                         files=touched)
            if ret < 0:
                raise BadPatchApply('patching failed')
            if ret > 0:
                raise BadPatchApply('patching succeeded with fuzz')
        except patch.PatchError, e:
            raise BadPatchApply(str(e))

        files = {}
        for f in touched:
            try:
                data, mode, copied = store.getfile(f)
                files[f] = data
            except IOError:
                files[f] = None
        return files
コード例 #3
0
def partialcommit(orig, ui, repo, *pats, **opts):
    patchfilename = opts.get('partials', None)
    if patchfilename:
        # attach a patch.filestore to this repo prior to calling commit()
        # the wrapped workingfilectx methods will see this filestore and use
        # the patched file data rather than the working copy data (for only the
        # files modified by the patch)
        fp = open(patchfilename, 'rb')
        store = patch.filestore()
        try:
            # patch files in tmp directory
            patch.patchrepo(ui, repo, repo['.'], store, fp, 1, prefix='')
            store.keys = set(store.files.keys() + store.data.keys())
            repo._filestore = store
        except patch.PatchError, e:
            raise util.Abort(str(e))
        finally:
コード例 #4
0
ファイル: stupid.py プロジェクト: avuori/dotfiles
def patchrepo(ui, meta, parentctx, patchfp):
    if not svnbackend:
        return patchrepoold(ui, meta, parentctx, patchfp)
    store = patch.filestore()
    try:
        touched = set()
        backend = svnbackend(ui, meta.repo, parentctx, store)
        ret = patch.patchbackend(ui, backend, patchfp, 0, touched)
        if ret < 0:
            raise BadPatchApply("patching failed")
        if ret > 0:
            raise BadPatchApply("patching succeeded with fuzz")
        files = {}
        for f in touched:
            try:
                data, mode, copied = store.getfile(f)
                files[f] = data
            except IOError:
                files[f] = None
        return files
    finally:
        store.close()
コード例 #5
0
def partialcommit(orig, ui, repo, *pats, **opts):
    patchfilename = opts.get('partials', None)
    if patchfilename:
        # attach a patch.filestore to this repo prior to calling commit()
        # the wrapped workingfilectx methods will see this filestore and use
        # the patched file data rather than the working copy data (for only the
        # files modified by the patch)
        fp = open(patchfilename, 'rb')
        store = patch.filestore()
        try:
            try:
                # patch files in tmp directory
                patch.patchrepo(ui, repo, repo['.'], store, fp, 1, None)
                store.keys = set(store.files.keys() + store.data.keys())
                repo._filestore = store
            except patch.PatchError, e:
                raise util.Abort(str(e))
        finally:
            fp.close()

    try:
        ret = orig(ui, repo, *pats, **opts)
        if hasattr(repo, '_filestore'):
            store.close()
            wlock = repo.wlock()
            try:
                # mark partially committed files for 'needing lookup' in
                # the dirstate.  The next status call will find them as M
                for f in store.keys:
                    repo.dirstate.normallookup(f)
            finally:
                wlock.release()
        return ret
    finally:
        if patchfilename:
            os.unlink(patchfilename)
コード例 #6
0
ファイル: partialcommit.py プロジェクト: velorientc/git_test7
def partialcommit(orig, ui, repo, *pats, **opts):
    patchfilename = opts.get('partials', None)
    if patchfilename:
        # attach a patch.filestore to this repo prior to calling commit()
        # the wrapped workingfilectx methods will see this filestore and use
        # the patched file data rather than the working copy data (for only the
        # files modified by the patch)
        fp = open(patchfilename, 'rb')
        store = patch.filestore()
        try:
            try:
                # patch files in tmp directory
                patch.patchrepo(ui, repo, repo['.'], store, fp, 1, None)
                store.keys = set(store.files.keys() + store.data.keys())
                repo._filestore = store
            except patch.PatchError, e:
                raise util.Abort(str(e))
        finally:
            fp.close()

    try:
        ret = orig(ui, repo, *pats, **opts)
        if hasattr(repo, '_filestore'):
            store.close()
            wlock = repo.wlock()
            try:
                # mark partially committed files for 'needing lookup' in
                # the dirstate.  The next status call will find them as M
                for f in store.keys:
                    repo.dirstate.normallookup(f)
            finally:
                wlock.release()
        return ret
    finally:
        if patchfilename:
            os.unlink(patchfilename)