Submitter | Durham Goode |
---|---|
Date | March 8, 2017, 3:22 a.m. |
Message ID | <ccec5eeceb85929c5df0.1488943355@dev111.prn1.facebook.com> |
Download | mbox | patch |
Permalink | /patch/18981/ |
State | Accepted |
Delegated to: | Martin von Zweigbergk |
Headers | show |
Comments
On Tue, Mar 7, 2017 at 7:22 PM, Durham Goode <durham@fb.com> wrote: > # HG changeset patch > # User Durham Goode <durham@fb.com> > # Date 1488940700 28800 > # Tue Mar 07 18:38:20 2017 -0800 > # Node ID ccec5eeceb85929c5df041b768d01694176b3a9d > # Parent f70310209acbbcb4cf7cae7c38d94e15c09c1ace > merge: remove uses of manifest.matches > > This gets rid of the manifest.matches calls in merge.py in favor of the new api. > This is part of getting rid of manifest.matches since it is O(manifest). > > diff --git a/mercurial/merge.py b/mercurial/merge.py > --- a/mercurial/merge.py > +++ b/mercurial/merge.py > @@ -27,6 +27,7 @@ from . import ( > copies, > error, > filemerge, > + match as matchmod, > obsolete, > pycompat, > scmutil, > @@ -818,11 +819,10 @@ def manifestmerge(repo, wctx, p2, pa, br > if any(wctx.sub(s).dirty() for s in wctx.substate): > m1['.hgsubstate'] = modifiednodeid > > - # Compare manifests > - if matcher is not None: > - m1 = m1.matches(matcher) > - m2 = m2.matches(matcher) > - diff = m1.diff(m2) > + diff = m1.diff(m2, match=matcher) > + > + if matcher is None: > + matcher = matchmod.always('', '') There's a condition further up that does almost the opposite, but I can clean that up in a followup.
On 3/8/17 9:47 AM, Martin von Zweigbergk wrote: > On Tue, Mar 7, 2017 at 7:22 PM, Durham Goode <durham@fb.com> wrote: >> # HG changeset patch >> # User Durham Goode <durham@fb.com> >> # Date 1488940700 28800 >> # Tue Mar 07 18:38:20 2017 -0800 >> # Node ID ccec5eeceb85929c5df041b768d01694176b3a9d >> # Parent f70310209acbbcb4cf7cae7c38d94e15c09c1ace >> merge: remove uses of manifest.matches >> >> This gets rid of the manifest.matches calls in merge.py in favor of the new api. >> This is part of getting rid of manifest.matches since it is O(manifest). >> >> diff --git a/mercurial/merge.py b/mercurial/merge.py >> --- a/mercurial/merge.py >> +++ b/mercurial/merge.py >> @@ -27,6 +27,7 @@ from . import ( >> copies, >> error, >> filemerge, >> + match as matchmod, >> obsolete, >> pycompat, >> scmutil, >> @@ -818,11 +819,10 @@ def manifestmerge(repo, wctx, p2, pa, br >> if any(wctx.sub(s).dirty() for s in wctx.substate): >> m1['.hgsubstate'] = modifiednodeid >> >> - # Compare manifests >> - if matcher is not None: >> - m1 = m1.matches(matcher) >> - m2 = m2.matches(matcher) >> - diff = m1.diff(m2) >> + diff = m1.diff(m2, match=matcher) >> + >> + if matcher is None: >> + matcher = matchmod.always('', '') > > There's a condition further up that does almost the opposite, but I > can clean that up in a followup. Hmm, yea. I err'd on passing None to the diff function since a None check would be faster than a function call, but that's probably over optimizing.
Patch
diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -27,6 +27,7 @@ from . import ( copies, error, filemerge, + match as matchmod, obsolete, pycompat, scmutil, @@ -818,11 +819,10 @@ def manifestmerge(repo, wctx, p2, pa, br if any(wctx.sub(s).dirty() for s in wctx.substate): m1['.hgsubstate'] = modifiednodeid - # Compare manifests - if matcher is not None: - m1 = m1.matches(matcher) - m2 = m2.matches(matcher) - diff = m1.diff(m2) + diff = m1.diff(m2, match=matcher) + + if matcher is None: + matcher = matchmod.always('', '') actions = {} for f, ((n1, fl1), (n2, fl2)) in diff.iteritems(): @@ -858,7 +858,7 @@ def manifestmerge(repo, wctx, p2, pa, br pass # we'll deal with it on m2 side elif f in movewithdir: # directory rename, move local f2 = movewithdir[f] - if f2 in m2: + if matcher(f2) and f2 in m2: actions[f2] = ('m', (f, f2, None, True, pa.node()), "remote directory rename, both created") else: @@ -887,7 +887,7 @@ def manifestmerge(repo, wctx, p2, pa, br pass # we'll deal with it on m1 side elif f in movewithdir: f2 = movewithdir[f] - if f2 in m1: + if matcher(f2) and f2 in m1: actions[f2] = ('m', (f2, f, None, False, pa.node()), "local directory rename, both created") else: @@ -895,7 +895,7 @@ def manifestmerge(repo, wctx, p2, pa, br "local directory rename - get from " + f) elif f in copy: f2 = copy[f] - if f2 in m2: + if matcher(f2) and f2 in m2: actions[f] = ('m', (f2, f, f2, False, pa.node()), "remote copied from " + f2) else: @@ -927,7 +927,7 @@ def manifestmerge(repo, wctx, p2, pa, br # new file added in a directory that was moved df = dirmove[d] + f[len(d):] break - if df in m1: + if matcher(df) and df in m1: actions[df] = ('m', (df, f, f, False, pa.node()), "local directory rename - respect move from " + f) elif acceptremote: