Submitter | Matt Harbison |
---|---|
Date | Feb. 11, 2015, 3:23 a.m. |
Message ID | <op.xtviddos9lwrgf@envy> |
Download | mbox | patch |
Permalink | /patch/7782/ |
State | Not Applicable |
Headers | show |
Comments
On Wed, Feb 11, 2015 at 4:23 AM, Matt Harbison <mharbison72@gmail.com> wrote: On Tue, 10 Feb 2015 14:36:42 -0500, Mathias De Maré < > mathias.demare@gmail.com> wrote: > > Adding a single file in the working directory worked fine (since it only >> does the snapshot for the old (non-working dir) context). >> When I add a file and remove another, I get 'abort: no files match the >> archive pattern' when the snapshot of the working directory is done. I had >> a further look, and it seems (archive.py:307-310) like for the >> subrepositories, the revision is always extracted by checking the >> substate. >> As a result, the last revision is used (instead of the working directory). >> Specifically for Git, I have the impression there's additionally the >> problem that 'git archive' does not support archiving the working >> directory. >> > > After some digging, I think that makes sense. hg doesn't support > archiving the working copy from the command line either. Maybe what you > can try is in subrepo:1550, put a print statement before returning from the > 'if not revision' check. The working copy is represented by None, so 0 > files is returned, and if the parent didn't have anything to archive, > archive() complains. (I also bet that if the delta is only file removes, > it will also archive 0 files and abort. Maybe we need to pass some sort of > flag from extdiff to archive to control whether it aborts.) > No, I think the issue is simply that when you select the subrepo version through substate (like is done in archive.py:307-310), you will get the latest version of the substate file, and as a result you will get the latest committed revision, instead of None. I just tried this (with 1 added file and 1 removed file), and the output when adding on subrepo:1550 is (this is with your 2 RFC patches and the one you presented in this mail): > revision: aa307b592e8a579e599c79665d9f1c4ec19af59f > revision: aa307b592e8a579e599c79665d9f1c4ec19af59f > Since the only file that is passed to the subrepo archive is exactly the file that was added (and so is not in the revision specified), the archive will indeed say that no files can be archived. So archive should actually return 'None' to the subrepo, so we can handle it correctly in the subrepo. > > I think you may need to manually copy from the filesystem to the archive > for this conditional. Since the status call was previously done, every > file you need to archive is listed in the matcher. > That is indeed correct, I'll have a look if I can create a patch to handle that case for git and for svn. However, we don't even get into that case yet, because of the issue above. > > Whatever you implement should work for svn too, since it is just > filesystem access. (But svn seems to use the base class implementation, > which doesn't check the revision. Not sure what is going on there.) > > >> If I then commit the added and removed file and run extdiff on those, it >> works fine. >> >> So to get the working directory working, we'll also need to modify the >> support for archiving subrepos in general and git subrepos in particular. >> > > Here's a demo that working directory archiving for hgsubrepos works. The > thing that surprised me is it seems to ignore uncommitted adds. But so > does 'hg diff' apparently. This should apply on top of this series. > Ignore the tests at the very bottom around line 518- it uses largefiles, > and is probably wonky. > > # HG changeset patch > # User Matt Harbison <matt_harbison@yahoo.com> > # Date 1423621101 18000 > # Tue Feb 10 21:18:21 2015 -0500 > # Node ID 57c3177c05122a6655ac27ed71f07276ef5c8375 > # Parent 9c4f27e5c804662d2d25581ad3856ef6da3729ec > extdiff: quick and dirty working copy snapshot via archive > > The subrepos have uncommitted changes; diff -S and extdiff -S agree on the > files > of interest, and the content. Strangely, they both ignore 'A' files. I > thought > I've seen added files before, but maybe it was in thg? git and svn may > not be > archiving uncommitted files. > > diff --git a/hgext/extdiff.py b/hgext/extdiff.py > --- a/hgext/extdiff.py > +++ b/hgext/extdiff.py > @@ -102,26 +102,15 @@ > # TODO: Use filesystem routines to duplicate the relevant parts > of the > # working directory instead of this (archive doesn't work > for > # wctx). This will allow any subrepo type and largefiles > to work > - wopener = scmutil.opener(base) > - ctx = repo[node] > - for fn in sorted(files): > - wfn = util.pconvert(fn) > - if wfn not in ctx: > - # File doesn't exist; could be a bogus modify > - continue > - ui.note(' %s\n' % wfn) > - dest = os.path.join(base, wfn) > - fctx = ctx[wfn] > - data = repo.wwritedata(wfn, fctx.data()) > - if 'l' in fctx.flags(): > - wopener.symlink(data, wfn) > - else: > - wopener.write(wfn, data) > - if 'x' in fctx.flags(): > - util.setflags(dest, False, True) > + if files: > + repo.ui.setconfig("ui", "archivemeta", False) > > - fns_and_mtime.append((dest, repo.wjoin(fn), > - os.lstat(dest).st_mtime)) > + archival.archive(repo, base, node, 'files', > + matchfn=scmutil.matchfiles(repo, files), > + subrepos=listsubrepos) > + > +## fns_and_mtime.append((dest, repo.wjoin(fn), > +## os.lstat(dest).st_mtime)) > return dirname, fns_and_mtime > > def dodiff(ui, repo, cmdline, pats, opts): > diff --git a/tests/test-subrepo-deep-nested-change.t > b/tests/test-subrepo-deep-nested-change.t > --- a/tests/test-subrepo-deep-nested-change.t > +++ b/tests/test-subrepo-deep-nested-change.t > @@ -163,6 +163,34 @@ > A foo/bar/abc > A sub1/foo > R sub1/sub2/test.txt > + > +Each subrepo is dirty on its own, as well as relative to its parent > + $ hg -R sub1 status sub1 > + A sub1/foo > + $ hg -R sub1/sub2 status sub1/sub2 > + R sub1/sub2/test.txt > + > +Vanilla diff doesn't seem to notice 'A' files (foo/bar/abc). > + $ hg diff > + > +Diff and extdiff seem capable of seeing 'R' files in a subrepo (see > +sub1/sub2/test.txt), but NOT 'A' (sub1/foo). But it also doesn't > +see 'A' in a parent repo either (i.e. foo/bar/abc). > + $ hg diff -S > + diff -r 78026e779ea6 sub1/sub2/test.txt > + --- a/sub1/sub2/test.txt Thu Jan 01 00:00:00 1970 +0000 > + +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 > + @@ -1,1 +0,0 @@ > + -test > + > + $ hg extdiff -S --config extensions.extdiff= > + diff -Npru cloned.9bb10eebee29/sub1/sub2/test.txt > cloned/sub1/sub2/test.txt > + --- cloned.9bb10eebee29/sub1/sub2/test.txt * (glob) > + +++ cloned/sub1/sub2/test.txt 1970-01-01 00:00:00 +0000 > + @@ -1 +0,0 @@ > + -test > + [1] > + > $ hg update -Cq > $ touch sub1/sub2/folder/bar > $ hg addremove sub1/sub2 > @@ -171,6 +199,68 @@ > A sub1/sub2/folder/bar > ? foo/bar/abc > ? sub1/foo > + > + $ hg diff -S -r 0 > + diff -r 7f491f53a367 .hgsubstate > + --- a/.hgsubstate Thu Jan 01 00:00:00 1970 +0000 > + +++ b/.hgsubstate * (glob) > + @@ -1,1 +1,1 @@ > + -fc3b4ce2696f7741438c79207583768f2ce6b0dd sub1 > + +c528958d0b1e01e0ddb7561375e002fae55d5c09 sub1 > + diff -r fc3b4ce2696f sub1/.hgsubstate > + --- a/sub1/.hgsubstate Thu Jan 01 00:00:00 1970 +0000 > + +++ b/sub1/.hgsubstate * (glob) > + @@ -1,1 +1,1 @@ > + -c57a0840e3badd667ef3c3ef65471609acb2ba3c sub2 > + +78026e779ea642d307116a6bece56af08b49a52f sub2 > + diff -r c57a0840e3ba sub1/sub2/folder/test.txt > + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > + +++ b/sub1/sub2/folder/test.txt * (glob) > + @@ -0,0 +1,1 @@ > + +subfolder > + diff -r c57a0840e3ba sub1/sub2/sub2 > + --- a/sub1/sub2/sub2 Thu Jan 01 00:00:00 1970 +0000 > + +++ b/sub1/sub2/sub2 * (glob) > + @@ -1,1 +1,1 @@ > + -sub2 > + +modified > + diff -r c57a0840e3ba sub1/sub2/test.txt > + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > + +++ b/sub1/sub2/test.txt * (glob) > + @@ -0,0 +1,1 @@ > + +test > + > + $ hg extdiff -S --config extensions.extdiff= -r 0 > + diff -Npru cloned.7f491f53a367/.hgsubstate cloned/.hgsubstate > + --- cloned.7f491f53a367/.hgsubstate * (glob) > + +++ cloned/.hgsubstate * (glob) > + @@ -1 +1 @@ > + -fc3b4ce2696f7741438c79207583768f2ce6b0dd sub1 > + +c528958d0b1e01e0ddb7561375e002fae55d5c09 sub1 > + diff -Npru cloned.7f491f53a367/sub1/.hgsubstate cloned/sub1/.hgsubstate > + --- cloned.7f491f53a367/sub1/.hgsubstate * (glob) > + +++ cloned/sub1/.hgsubstate * (glob) > + @@ -1 +1 @@ > + -c57a0840e3badd667ef3c3ef65471609acb2ba3c sub2 > + +78026e779ea642d307116a6bece56af08b49a52f sub2 > + diff -Npru cloned.7f491f53a367/sub1/sub2/folder/test.txt > cloned/sub1/sub2/folder/test.txt > + --- cloned.7f491f53a367/sub1/sub2/folder/test.txt 1970-01-01 > 00:00:00 +0000 > + +++ cloned/sub1/sub2/folder/test.txt * (glob) > + @@ -0,0 +1 @@ > + +subfolder > + diff -Npru cloned.7f491f53a367/sub1/sub2/sub2 cloned/sub1/sub2/sub2 > + --- cloned.7f491f53a367/sub1/sub2/sub2 * (glob) > + +++ cloned/sub1/sub2/sub2 * (glob) > + @@ -1 +1 @@ > + -sub2 > + +modified > + diff -Npru cloned.7f491f53a367/sub1/sub2/test.txt > cloned/sub1/sub2/test.txt > + --- cloned.7f491f53a367/sub1/sub2/test.txt 1970-01-01 00:00:00 +0000 > + +++ cloned/sub1/sub2/test.txt * (glob) > + @@ -0,0 +1 @@ > + +test > + [1] > + > $ hg update -Cq > $ hg addremove sub1 > adding sub1/sub2/folder/bar (glob) > @@ -428,24 +518,9 @@ > Interaction with extdiff, largefiles and subrepos > > $ hg --config extensions.extdiff= extdiff -S > - diff -Npru cloned.6e907bf12afc/.hglf/a.dat cloned/.hglf/a.dat > - --- cloned.6e907bf12afc/.hglf/a.dat 1970-01-01 00:00:00 +0000 > - +++ cloned/.hglf/a.dat * (glob) > - @@ -0,0 +1 @@ > - + > [1] > > $ hg --config extensions.extdiff= extdiff -r .^ -S > - diff -Npru cloned.1f79fbad5d0f/.hglf/a.dat cloned/.hglf/a.dat > - --- cloned.1f79fbad5d0f/.hglf/a.dat 1970-01-01 00:00:00 +0000 > - +++ cloned/.hglf/a.dat * (glob) > - @@ -0,0 +1 @@ > - + > - diff -Npru cloned.1f79fbad5d0f/.hglf/foo/bar/large.dat > cloned/.hglf/foo/bar/large.dat > - --- cloned.1f79fbad5d0f/.hglf/foo/bar/large.dat 1970-01-01 > 00:00:00 +0000 > - +++ cloned/.hglf/foo/bar/large.dat * (glob) > - @@ -0,0 +1 @@ > - +2f6933b5ee0f5fdd823d9717d8729f3c2523811b > diff -Npru cloned.1f79fbad5d0f/foo/bar/abc cloned/foo/bar/abc > --- cloned.1f79fbad5d0f/foo/bar/abc * (glob) > +++ cloned/foo/bar/abc * (glob) >
Patch
diff --git a/hgext/extdiff.py b/hgext/extdiff.py --- a/hgext/extdiff.py +++ b/hgext/extdiff.py @@ -102,26 +102,15 @@ # TODO: Use filesystem routines to duplicate the relevant parts of the # working directory instead of this (archive doesn't work for # wctx). This will allow any subrepo type and largefiles to work - wopener = scmutil.opener(base) - ctx = repo[node] - for fn in sorted(files): - wfn = util.pconvert(fn) - if wfn not in ctx: - # File doesn't exist; could be a bogus modify - continue - ui.note(' %s\n' % wfn) - dest = os.path.join(base, wfn) - fctx = ctx[wfn] - data = repo.wwritedata(wfn, fctx.data()) - if 'l' in fctx.flags(): - wopener.symlink(data, wfn) - else: - wopener.write(wfn, data) - if 'x' in fctx.flags(): - util.setflags(dest, False, True) + if files: + repo.ui.setconfig("ui", "archivemeta", False) - fns_and_mtime.append((dest, repo.wjoin(fn), - os.lstat(dest).st_mtime)) + archival.archive(repo, base, node, 'files', + matchfn=scmutil.matchfiles(repo, files), + subrepos=listsubrepos) + +## fns_and_mtime.append((dest, repo.wjoin(fn), +## os.lstat(dest).st_mtime)) return dirname, fns_and_mtime def dodiff(ui, repo, cmdline, pats, opts): diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t --- a/tests/test-subrepo-deep-nested-change.t +++ b/tests/test-subrepo-deep-nested-change.t @@ -163,6 +163,34 @@ A foo/bar/abc A sub1/foo R sub1/sub2/test.txt + +Each subrepo is dirty on its own, as well as relative to its parent + $ hg -R sub1 status sub1 + A sub1/foo + $ hg -R sub1/sub2 status sub1/sub2 + R sub1/sub2/test.txt + +Vanilla diff doesn't seem to notice 'A' files (foo/bar/abc). + $ hg diff + +Diff and extdiff seem capable of seeing 'R' files in a subrepo (see +sub1/sub2/test.txt), but NOT 'A' (sub1/foo). But it also doesn't +see 'A' in a parent repo either (i.e. foo/bar/abc). + $ hg diff -S + diff -r 78026e779ea6 sub1/sub2/test.txt + --- a/sub1/sub2/test.txt Thu Jan 01 00:00:00 1970 +0000 + +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 + @@ -1,1 +0,0 @@ + -test + + $ hg extdiff -S --config extensions.extdiff= + diff -Npru cloned.9bb10eebee29/sub1/sub2/test.txt cloned/sub1/sub2/test.txt + --- cloned.9bb10eebee29/sub1/sub2/test.txt * (glob) + +++ cloned/sub1/sub2/test.txt 1970-01-01 00:00:00 +0000 + @@ -1 +0,0 @@ + -test + [1] + $ hg update -Cq $ touch sub1/sub2/folder/bar