narrow: reuse narrowspec.updateworkingcopy() when widening
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 21 Dec 2018 10:05:37 -0800
changeset 41237 ad9ab2523149
parent 41236 44a51c1c8e17
child 41238 8c366af085f4
narrow: reuse narrowspec.updateworkingcopy() when widening The widening of the working copy we do after widening a repo is practically the same as we do in a repo share after the store narrowspec has been changed in a different share. Let's reuse the code for that that we now have in the narrowspec module. Differential Revision: https://phab.mercurial-scm.org/D5510
hgext/narrow/narrowcommands.py
tests/test-narrow-widen-no-ellipsis.t
--- a/hgext/narrow/narrowcommands.py	Sat Dec 29 23:40:18 2018 -0800
+++ b/hgext/narrow/narrowcommands.py	Fri Dec 21 10:05:37 2018 -0800
@@ -20,7 +20,6 @@
     exchange,
     extensions,
     hg,
-    merge,
     narrowspec,
     node,
     pycompat,
@@ -259,8 +258,6 @@
 
 def _widen(ui, repo, remote, commoninc, oldincludes, oldexcludes,
            newincludes, newexcludes):
-    newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
-
     # for now we assume that if a server has ellipses enabled, we will be
     # exchanging ellipses nodes. In future we should add ellipses as a client
     # side requirement (maybe) to distinguish a client is shallow or not and
@@ -316,20 +313,10 @@
                 bundle2.processbundle(repo, bundle,
                         transactiongetter=tgetter)
 
-        repo.setnewnarrowpats()
-        narrowspec.copytoworkingcopy(repo)
-        actions = merge.emptyactions()
-        addgaction = actions['g'].append
-
-        mf = repo['.'].manifest().matches(newmatch)
-        for f, fn in mf.iteritems():
-            if f not in repo.dirstate:
-                addgaction((f, (mf.flags(f), False),
-                            "add from widened narrow clone"))
-
-        merge.applyupdates(repo, actions, wctx=repo[None],
-                           mctx=repo['.'], overwrite=False)
-        merge.recordupdates(repo, actions, branchmerge=False)
+        with repo.transaction('widening'):
+            repo.setnewnarrowpats()
+            narrowspec.updateworkingcopy(repo)
+            narrowspec.copytoworkingcopy(repo)
 
 # TODO(rdamazio): Make new matcher format and update description
 @command('tracked',
--- a/tests/test-narrow-widen-no-ellipsis.t	Sat Dec 29 23:40:18 2018 -0800
+++ b/tests/test-narrow-widen-no-ellipsis.t	Fri Dec 21 10:05:37 2018 -0800
@@ -128,7 +128,7 @@
   added 0 changesets with 1 changes to 1 files
   bundle2-input-part: total payload size * (glob)
   bundle2-input-bundle: 0 parts total
-   widest/f: add from widened narrow clone -> g
+   widest/f: narrowspec updated -> g
   getting widest/f
   $ hg tracked
   I path:inside