Submitter | Yuya Nishihara |
---|---|
Date | March 24, 2015, 4:36 p.m. |
Message ID | <17865e7c47fda8176379.1427215007@mimosa> |
Download | mbox | patch |
Permalink | /patch/8236/ |
State | Deferred |
Headers | show |
Comments
On Wed, 2015-03-25 at 01:36 +0900, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara <yuya@tcha.org> > # Date 1422098310 -32400 > # Sat Jan 24 20:18:30 2015 +0900 > # Node ID 17865e7c47fda81763799c9a143b4452b874225f > # Parent 9b86951b17b05684797489000c1e2df904f2edcc > fileset: add wdir(set) to evaluate set in working directory (issue4497) > > "wdir()" can be used to avoid the ambiguity caused by evaluating a fileset > in both workingctx and target changectx. > > $ hg revert 'set:wdir(added())' This looks powerful, but for this particular case, I think it's disappointing that it's needed... because revert is one of the basic uses I had in mind for filesets. Also, I think we should have a story for how to evaluate a set against other revs than the working dir.
On Tue, Mar 24, 2015 at 10:36 AM Matt Mackall <mpm@selenic.com> wrote: > On Wed, 2015-03-25 at 01:36 +0900, Yuya Nishihara wrote: > > # HG changeset patch > > # User Yuya Nishihara <yuya@tcha.org> > > # Date 1422098310 -32400 > > # Sat Jan 24 20:18:30 2015 +0900 > > # Node ID 17865e7c47fda81763799c9a143b4452b874225f > > # Parent 9b86951b17b05684797489000c1e2df904f2edcc > > fileset: add wdir(set) to evaluate set in working directory (issue4497) > > > > "wdir()" can be used to avoid the ambiguity caused by evaluating a > fileset > > in both workingctx and target changectx. > > > > $ hg revert 'set:wdir(added())' > > This looks powerful, but for this particular case, I think it's > disappointing that it's needed... because revert is one of the basic > uses I had in mind for filesets. > And what a coincidence (I really didn't see this series until now) that I sent a fix for the same issue less than 2 hours later! Yuya, please see http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/77615 in case you haven't already. > > Also, I think we should have a story for how to evaluate a set against > other revs than the working dir. > > -- > Mathematics is the supreme nostalgia of our time. > > > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel >
On Wed, 25 Mar 2015 04:31:46 +0000, Martin von Zweigbergk wrote: > On Tue, Mar 24, 2015 at 10:36 AM Matt Mackall <mpm@selenic.com> wrote: > > On Wed, 2015-03-25 at 01:36 +0900, Yuya Nishihara wrote: > > > # HG changeset patch > > > # User Yuya Nishihara <yuya@tcha.org> > > > # Date 1422098310 -32400 > > > # Sat Jan 24 20:18:30 2015 +0900 > > > # Node ID 17865e7c47fda81763799c9a143b4452b874225f > > > # Parent 9b86951b17b05684797489000c1e2df904f2edcc > > > fileset: add wdir(set) to evaluate set in working directory (issue4497) > > > > > > "wdir()" can be used to avoid the ambiguity caused by evaluating a > > fileset > > > in both workingctx and target changectx. > > > > > > $ hg revert 'set:wdir(added())' > > > > This looks powerful, but for this particular case, I think it's > > disappointing that it's needed... because revert is one of the basic > > uses I had in mind for filesets. > > > > And what a coincidence (I really didn't see this series until now) that I > sent a fix for the same issue less than 2 hours later! Yuya, please see > http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/77615 in > case you haven't already. Yes, it looks nice. > > Also, I think we should have a story for how to evaluate a set against > > other revs than the working dir. I'll revisit this later. I have draft patch for rev(set, revspec), but it stopped because I couldn't figure out how it should handle multiple revisions. Regards,
Patch
diff --git a/mercurial/fileset.py b/mercurial/fileset.py --- a/mercurial/fileset.py +++ b/mercurial/fileset.py @@ -390,6 +390,14 @@ def copied(mctx, x): s.append(f) return s +def wdir(mctx, x): + """``wdir(set)`` + Evaluate set in the working directory. + """ + repo = mctx.ctx.repo() + wctx = repo[None] + return getset(mctx.switch(wctx, _buildstatus(wctx, x)), x) + def subrepo(mctx, x): """``subrepo([pattern])`` Subrepositories whose paths match the given pattern. @@ -434,6 +442,7 @@ symbols = { 'unknown': unknown, 'unresolved': unresolved, 'subrepo': subrepo, + 'wdir': wdir, } methods = { @@ -476,6 +485,7 @@ class matchctx(object): # filesets using matchctx.switch() _switchcallers = [ + 'wdir', ] def _intree(funcs, tree): diff --git a/mercurial/help/filesets.txt b/mercurial/help/filesets.txt --- a/mercurial/help/filesets.txt +++ b/mercurial/help/filesets.txt @@ -58,6 +58,10 @@ Some sample queries: hg revert "set:copied() and binary() and size('>1M')" +- Revert files that were added to the working directory:: + + hg revert "set:wdir(added())" + - Remove files listed in foo.lst that contain the letter a or b:: hg remove "set: 'listfile:foo.lst' and (**a* or **b*)" diff --git a/tests/test-fileset.t b/tests/test-fileset.t --- a/tests/test-fileset.t +++ b/tests/test-fileset.t @@ -77,6 +77,20 @@ Test files status $ fileset 'copied()' c1 +Test files status in different revisions +(currently files absent at -r0 are not listed) + + $ fileset -r0 'wdir(modified())' + b2 + $ fileset -r0 'wdir(added())' + $ fileset -r0 'added() and wdir(modified() or removed() or unknown())' + b2 + a2 + $ fileset -r0 'added() and a* or wdir(modified())' + a1 + a2 + b2 + Test files properties >>> file('bin', 'wb').write('\0a') @@ -278,3 +292,10 @@ Test with a revision mixed $ fileset 'eol(mac)' mac + +Test files at -r0 should be filtered by files at wdir + + $ fileset -r0 '* and wdir(*)' + a1 + b1 + b2