D5183: narrow: rework logic to check whether we need to widen and narrow

2018-10-23 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG30a7d3b6b281: narrow: rework logic to check whether we need 
to widen and narrow (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5183?vs=12325=12327

REVISION DETAIL
  https://phab.mercurial-scm.org/D5183

AFFECTED FILES
  hgext/narrow/narrowcommands.py
  tests/test-narrow-clone-non-narrow-server.t
  tests/test-narrow-widen-no-ellipsis.t

CHANGE DETAILS

diff --git a/tests/test-narrow-widen-no-ellipsis.t 
b/tests/test-narrow-widen-no-ellipsis.t
--- a/tests/test-narrow-widen-no-ellipsis.t
+++ b/tests/test-narrow-widen-no-ellipsis.t
@@ -144,12 +144,7 @@
 wireprotocol command
 
   $ hg tracked --addinclude widest/f
-  comparing with ssh://user@dummy/master
-  searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 0 changesets with 0 changes to 0 files
+  nothing to widen or narrow
 
 Pull down the newly added upstream revision.
 
diff --git a/tests/test-narrow-clone-non-narrow-server.t 
b/tests/test-narrow-clone-non-narrow-server.t
--- a/tests/test-narrow-clone-non-narrow-server.t
+++ b/tests/test-narrow-clone-non-narrow-server.t
@@ -58,7 +58,11 @@
   comparing with http://localhost:$HGPORT1/
   searching for changes
   looking for local changes to affected paths
+
   $ hg tracked --addinclude f1 http://localhost:$HGPORT1/
+  nothing to widen or narrow
+
+  $ hg tracked --addinclude f9 http://localhost:$HGPORT1/
   comparing with http://localhost:$HGPORT1/
   abort: server does not support narrow clones
   [255]
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -392,9 +392,21 @@
 removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
 addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
 removedexcludes = narrowspec.parsepatterns(opts['removeexclude'])
+
+only_show = not (addedincludes or removedincludes or addedexcludes or
+ removedexcludes or newrules)
+
+oldincludes, oldexcludes = repo.narrowpats
+
+# filter the user passed additions and deletions into actual additions and
+# deletions of excludes and includes
+addedincludes = set([i for i in addedincludes if i not in oldincludes])
+removedincludes = set([i for i in removedincludes if i in oldincludes])
+addedexcludes = set([i for i in addedexcludes if i not in oldexcludes])
+removedexcludes = set([i for i in removedexcludes if i in oldexcludes])
+
 widening = addedincludes or removedexcludes
 narrowing = removedincludes or addedexcludes
-only_show = not widening and not narrowing
 
 # Only print the current narrowspec.
 if only_show:
@@ -413,6 +425,10 @@
 fm.end()
 return 0
 
+if not widening and not narrowing:
+ui.status(_("nothing to widen or narrow\n"))
+return 0
+
 with repo.wlock(), repo.lock():
 cmdutil.bailifchanged(repo)
 
@@ -432,7 +448,6 @@
 
 commoninc = discovery.findcommonincoming(repo, remote)
 
-oldincludes, oldexcludes = repo.narrowpats
 if narrowing:
 newincludes = oldincludes - removedincludes
 newexcludes = oldexcludes | addedexcludes



To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5183: narrow: rework logic to check whether we need to widen and narrow

2018-10-23 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 12325.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5183?vs=12321=12325

REVISION DETAIL
  https://phab.mercurial-scm.org/D5183

AFFECTED FILES
  hgext/narrow/narrowcommands.py
  tests/test-narrow-clone-non-narrow-server.t
  tests/test-narrow-widen-no-ellipsis.t

CHANGE DETAILS

diff --git a/tests/test-narrow-widen-no-ellipsis.t 
b/tests/test-narrow-widen-no-ellipsis.t
--- a/tests/test-narrow-widen-no-ellipsis.t
+++ b/tests/test-narrow-widen-no-ellipsis.t
@@ -144,12 +144,7 @@
 wireprotocol command
 
   $ hg tracked --addinclude widest/f
-  comparing with ssh://user@dummy/master
-  searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 0 changesets with 0 changes to 0 files
+  nothing to widen or narrow
 
 Pull down the newly added upstream revision.
 
diff --git a/tests/test-narrow-clone-non-narrow-server.t 
b/tests/test-narrow-clone-non-narrow-server.t
--- a/tests/test-narrow-clone-non-narrow-server.t
+++ b/tests/test-narrow-clone-non-narrow-server.t
@@ -58,7 +58,11 @@
   comparing with http://localhost:$HGPORT1/
   searching for changes
   looking for local changes to affected paths
+
   $ hg tracked --addinclude f1 http://localhost:$HGPORT1/
+  nothing to widen or narrow
+
+  $ hg tracked --addinclude f9 http://localhost:$HGPORT1/
   comparing with http://localhost:$HGPORT1/
   abort: server does not support narrow clones
   [255]
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -392,9 +392,21 @@
 removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
 addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
 removedexcludes = narrowspec.parsepatterns(opts['removeexclude'])
+
+only_show = not (addedincludes or removedincludes or addedexcludes or
+ removedexcludes or newrules)
+
+oldincludes, oldexcludes = repo.narrowpats
+
+# filter the user passed additions and deletions into actual additions and
+# deletions of excludes and includes
+addedincludes = set([i for i in addedincludes if i not in oldincludes])
+removedincludes = set([i for i in removedincludes if i in oldincludes])
+addedexcludes = set([i for i in addedexcludes if i not in oldexcludes])
+removedexcludes = set([i for i in removedexcludes if i in oldexcludes])
+
 widening = addedincludes or removedexcludes
 narrowing = removedincludes or addedexcludes
-only_show = not widening and not narrowing
 
 # Only print the current narrowspec.
 if only_show:
@@ -413,6 +425,10 @@
 fm.end()
 return 0
 
+if not widening and not narrowing:
+ui.status(_("nothing to widen or narrow\n"))
+return 0
+
 with repo.wlock(), repo.lock():
 cmdutil.bailifchanged(repo)
 
@@ -432,7 +448,6 @@
 
 commoninc = discovery.findcommonincoming(repo, remote)
 
-oldincludes, oldexcludes = repo.narrowpats
 if narrowing:
 newincludes = oldincludes - removedincludes
 newexcludes = oldexcludes | addedexcludes



To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5183: narrow: rework logic to check whether we need to widen and narrow

2018-10-23 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> martinvonz wrote in narrowcommands.py:429
> nit: s/extend/widen/? that seems like the natural opposite to (the verb) 
> "narrow"

I am fine with anyone, you can fix this in flight or I can send an updated 
version too.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5183

To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5183: narrow: rework logic to check whether we need to widen and narrow

2018-10-23 Thread martinvonz (Martin von Zweigbergk)
martinvonz accepted this revision.
martinvonz added inline comments.
This revision is now accepted and ready to land.

INLINE COMMENTS

> narrowcommands.py:429
> +if not widening and not narrowing:
> +ui.status(_("nothing to extend or narrow\n"))
> +return 0

nit: s/extend/widen/? that seems like the natural opposite to (the verb) 
"narrow"

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5183

To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5183: narrow: rework logic to check whether we need to widen and narrow

2018-10-23 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch reworks logic which calculates whether we need to extend or narrow
  our working copy or not.
  
  We filter the addincludes, removeincludes, addexcludes and removeexcludes 
passed
  from user to the actual added and removed includes and excludes. What that 
means
  is a user can pass an already included path as addincludes, a path which is 
not
  included as removeincludes etc. In such situations the old logic use to think 
we
  need to do some work, whereas we don't need to do that work.
  
  In old logic, even if we don't have anything new to include but it believes we
  need to call widen, this adds some good amount of work on large repository. A
  widen calls involves computing incomming csets, calling the narrow_widen() 
which
  in non-ellipses cases goes through all the set of csets which are available
  which can take ~2-3 mins on large repos. Those 2-3 minutes are spend on doing
  nothing which a client can prevent by checking is there really anything which
  needs to be included.
  
  The tests changes shows that we don't go to the server anymore in such cases
  which is nice.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5183

AFFECTED FILES
  hgext/narrow/narrowcommands.py
  tests/test-narrow-clone-non-narrow-server.t
  tests/test-narrow-widen-no-ellipsis.t

CHANGE DETAILS

diff --git a/tests/test-narrow-widen-no-ellipsis.t 
b/tests/test-narrow-widen-no-ellipsis.t
--- a/tests/test-narrow-widen-no-ellipsis.t
+++ b/tests/test-narrow-widen-no-ellipsis.t
@@ -144,12 +144,7 @@
 wireprotocol command
 
   $ hg tracked --addinclude widest/f
-  comparing with ssh://user@dummy/master
-  searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 0 changesets with 0 changes to 0 files
+  nothing to extend or narrow
 
 Pull down the newly added upstream revision.
 
diff --git a/tests/test-narrow-clone-non-narrow-server.t 
b/tests/test-narrow-clone-non-narrow-server.t
--- a/tests/test-narrow-clone-non-narrow-server.t
+++ b/tests/test-narrow-clone-non-narrow-server.t
@@ -58,7 +58,11 @@
   comparing with http://localhost:$HGPORT1/
   searching for changes
   looking for local changes to affected paths
+
   $ hg tracked --addinclude f1 http://localhost:$HGPORT1/
+  nothing to extend or narrow
+
+  $ hg tracked --addinclude f9 http://localhost:$HGPORT1/
   comparing with http://localhost:$HGPORT1/
   abort: server does not support narrow clones
   [255]
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -392,9 +392,21 @@
 removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
 addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
 removedexcludes = narrowspec.parsepatterns(opts['removeexclude'])
+
+only_show = not (addedincludes or removedincludes or addedexcludes or
+ removedexcludes or newrules)
+
+oldincludes, oldexcludes = repo.narrowpats
+
+# filter the user passed additions and deletions into actual additions and
+# deletions of excludes and includes
+addedincludes = set([i for i in addedincludes if i not in oldincludes])
+removedincludes = set([i for i in removedincludes if i in oldincludes])
+addedexcludes = set([i for i in addedexcludes if i not in oldexcludes])
+removedexcludes = set([i for i in removedexcludes if i in oldexcludes])
+
 widening = addedincludes or removedexcludes
 narrowing = removedincludes or addedexcludes
-only_show = not widening and not narrowing
 
 # Only print the current narrowspec.
 if only_show:
@@ -413,6 +425,10 @@
 fm.end()
 return 0
 
+if not widening and not narrowing:
+ui.status(_("nothing to extend or narrow\n"))
+return 0
+
 with repo.wlock(), repo.lock():
 cmdutil.bailifchanged(repo)
 
@@ -432,7 +448,6 @@
 
 commoninc = discovery.findcommonincoming(repo, remote)
 
-oldincludes, oldexcludes = repo.narrowpats
 if narrowing:
 newincludes = oldincludes - removedincludes
 newexcludes = oldexcludes | addedexcludes



To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel