[PATCH RFC] extdiff: add support for subrepo diff

Yuya Nishihara yuya at tcha.org
Sat Feb 7 10:03:09 UTC 2015


On Sat, 07 Feb 2015 09:56:09 +0100, Mathias De Maré wrote:
> # HG changeset patch
> # User Mathias De Maré <mathias.demare at gmail.com>
> # Date 1423299130 -3600
> #      Sam Feb 07 09:52:10 2015 +0100
> # Node ID dd4c16684d072b2eb35d0ef5f6e567eb9ea5b430
> # Parent  ff5caa8dfd993680d9602ca6ebb14da9de10d5f4
> extdiff: add support for subrepo diff
> 
> Sending as RFC, I'd like to get some general feedback on
> how to progress with this patch.
> 
> Up to this point, extdiff did not have a '--subrepos' flag.
> This patch makes it possible to view changes in subrepos
> as well, though not in sub-subrepos.
> 
> No special treatment of executable files
> or links is done at this point.
> 
> diff --git a/hgext/extdiff.py b/hgext/extdiff.py
> --- a/hgext/extdiff.py
> +++ b/hgext/extdiff.py
> @@ -69,7 +69,7 @@ cmdtable = {}
>  command = cmdutil.command(cmdtable)
>  testedwith = 'internal'
>  
> -def snapshot(ui, repo, files, node, tmproot):
> +def snapshot(ui, repo, files, subs, node, tmproot):
>      '''snapshot files as of some revision
>      if not using snapshot, -I/-X does not work and recursive diff
>      in tools like kdiff3 and meld displays too many files.'''
> @@ -107,8 +107,40 @@ def snapshot(ui, repo, files, node, tmpr
>          if node is None:
>              fns_and_mtime.append((dest, repo.wjoin(fn),
>                                    os.lstat(dest).st_mtime))
> +
> +    for s in subs:
> +        for fn in sorted(subs[s]):
> +            wfn = util.pconvert(fn)
> +            ws = util.pconvert(s)
> +            wfnroot = os.path.join(ws, wfn)
> +            matcher = scmutil.match(repo[node], ['path:' + wfnroot],
> +                                    {"exact": True})
> +            dest = os.path.join(base, wfnroot)
> +            destdir = os.path.dirname(dest)
> +            if not os.path.exists(destdir):
> +                os.makedirs(destdir)
> +            if node is None:
> +                util.copyfile(wfnroot, dest)
> +                fns_and_mtime.append((dest, repo.wjoin(ws),
> +                                      os.lstat(dest).st_mtime))
> +            else:
> +                cmdutil.cat(ui, repo, repo[node], matcher, '', output=dest)
>      return dirname, fns_and_mtime

Maybe extdiff.snapshot() can share code with "hg archive" that supports
--subrepos.



More information about the Mercurial-devel mailing list