[PATCH 1 of 1] patch: update working directory in _applydiff, not in updatedir

Augie Fackler lists at durin42.com
Mon Apr 26 11:05:15 CDT 2010


On Mon, Apr 26, 2010 at 10:28 AM, Mads Kiilerich <mads at kiilerich.com> wrote:
> # HG changeset patch
> # User Mads Kiilerich <mads at kiilerich.com>
> # Date 1272295709 -7200
> # Node ID 07019a4ff5dc30df5cadcd6c350a1fdd9a920a0e
> # Parent  5c474bb5ebb060a3d941a339bba35700f7fa8014
> patch: update working directory in _applydiff, not in updatedir
>
> Previously updatedir (which apparently except for that was intended to be
> updatedirstate) modified the working directory, fixing stuff that applydiff
> hadn't finished.  Now we do everything in applydiff.
>
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -1178,6 +1178,16 @@
>
>     rejects += closefile()
>
> +    for gp in changed.values():
> +        if gp:
> +            dst = util.canonpath(cwd, cwd, gp.path)
> +            # git patches can add empty files which we didn't create above
> +            if gp.op == 'ADD' and not os.path.exists(dst):
> +                file(dst, 'w').close()

not dependency injected, requires a real directory - file creation
should be passed in as some kind of function.

> +            if gp.mode:
> +                islink, isexec = gp.mode
> +                util.set_flags(dst, islink, isexec)

Ditto for setting flags.

> +
>     if rejects:
>         return -1
>     return err
> @@ -1207,16 +1217,6 @@
>         repo.copy(src, dst)
>     if (not similarity) and removes:
>         repo.remove(sorted(removes), True)
> -    for f in patches:
> -        gp = patches[f]
> -        if gp and gp.mode:
> -            islink, isexec = gp.mode
> -            dst = repo.wjoin(gp.path)
> -            # patch won't create empty files
> -            if gp.op == 'ADD' and not os.path.exists(dst):
> -                flags = (isexec and 'x' or '') + (islink and 'l' or '')
> -                repo.wwrite(gp.path, '', flags)
> -            util.set_flags(dst, islink, isexec)
>     cmdutil.addremove(repo, cfiles, similarity=similarity)
>     files = patches.keys()
>     files.extend([r for r in removes if r not in files])
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>


More information about the Mercurial-devel mailing list