Patchwork [3,of,3] ignore: process hgignore files in deterministic order

login
register
mail settings
Submitter Bryan O'Sullivan
Date Dec. 18, 2012, 12:30 a.m.
Message ID <d1022684cdeaa3764f8f.1355790603@fedora>
Download mbox | patch
Permalink /patch/179/
State Accepted
Commit 0127366df8fef5f1b1889f4387de341b94128b92
Headers show

Comments

Bryan O'Sullivan - Dec. 18, 2012, 12:30 a.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1355788622 28800
# Node ID d1022684cdeaa3764f8f95658372b4155e7a96bd
# Parent  588d2a23ca25b43dd4afd1a194343635a1255992
ignore: process hgignore files in deterministic order

Previously, we processed them in whatever order the dict iterator gave us.
Matt Mackall - Dec. 19, 2012, 9:57 p.m.
On Mon, 2012-12-17 at 16:30 -0800, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano at fb.com>
> # Date 1355788622 28800
> # Node ID d1022684cdeaa3764f8f95658372b4155e7a96bd
> # Parent  588d2a23ca25b43dd4afd1a194343635a1255992
> ignore: process hgignore files in deterministic order
> 
> Previously, we processed them in whatever order the dict iterator gave us.

Why does this matter?
Bryan O'Sullivan - Dec. 20, 2012, 8:29 p.m.
On Wed, Dec 19, 2012 at 1:57 PM, Matt Mackall <mpm at selenic.com> wrote:

> Why does this matter?
>

It doesn't yet. But in the happier shinier future of inotify, we will want
to know if a client and server's hgignore data are in sync, which will
involve the client sending a hash of its hgignore data to the server to
validate. We need a well-defined order to make that future hash stable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121220/6ee2be03/attachment.html>
Idan Kamara - Dec. 20, 2012, 8:45 p.m.
On Thu, Dec 20, 2012 at 10:29 PM, Bryan O'Sullivan <bos at serpentine.com> wrote:
> On Wed, Dec 19, 2012 at 1:57 PM, Matt Mackall <mpm at selenic.com> wrote:
>>
>> Why does this matter?
>
>
> It doesn't yet. But in the happier shinier future of inotify, we will want
> to know if a client and server's hgignore data are in sync, which will
> involve the client sending a hash of its hgignore data to the server to
> validate. We need a well-defined order to make that future hash stable.

This sounds strikingly similar to something the command server (or
more precisely the filecache) can deal with. It currently stats file on
demand to look for changes, but replacing that with events sounds
doable.

Patch

diff --git a/mercurial/ignore.py b/mercurial/ignore.py
--- a/mercurial/ignore.py
+++ b/mercurial/ignore.py
@@ -70,7 +70,7 @@ 
             if f != files[0]:
                 warn(_("skipping unreadable ignore file '%s': %s\n") %
                      (f, inst.strerror))
-    return pats
+    return [(f, pats[f]) for f in files if f in pats]
 
 def ignore(root, files, warn):
     '''return matcher covering patterns in 'files'.
@@ -95,7 +95,7 @@ 
     pats = readpats(root, files, warn)
 
     allpats = []
-    for patlist in pats.values():
+    for f, patlist in pats:
         allpats.extend(patlist)
     if not allpats:
         return util.never
@@ -104,7 +104,7 @@ 
         ignorefunc = match.match(root, '', [], allpats)
     except util.Abort:
         # Re-raise an exception where the src is the right file
-        for f, patlist in pats.iteritems():
+        for f, patlist in pats:
             try:
                 match.match(root, '', [], patlist)
             except util.Abort, inst: