Patchwork [2,of,2] cmdutil: factor out pushsubrepos

login
register
mail settings
Submitter Ryan McElroy
Date Feb. 12, 2015, 8:41 a.m.
Message ID <ffd1a811f1c7c1998460.1423730465@devbig105.prn2.facebook.com>
Download mbox | patch
Permalink /patch/7797/
State Changes Requested
Headers show

Comments

Ryan McElroy - Feb. 12, 2015, 8:41 a.m.
# HG changeset patch
# User Ryan McElroy <rmcelroy@fb.com>
# Date 1423729275 28800
#      Thu Feb 12 00:21:15 2015 -0800
# Node ID ffd1a811f1c7c1998460e7bb64169183ad2c1657
# Parent  05e7d10145be0af89e1eb6cf70c56e97f81101ab
cmdutil: factor out pushsubrepos

In the remotenames extension, we replace large parts of the functionality of
the push command. By factoring out this code, we can call it from the extension
and avoid rewriting it in the extension.
Augie Fackler - Feb. 17, 2015, 4:27 p.m.
On Thu, Feb 12, 2015 at 12:41:05AM -0800, Ryan McElroy wrote:
> # HG changeset patch
> # User Ryan McElroy <rmcelroy@fb.com>
> # Date 1423729275 28800
> #      Thu Feb 12 00:21:15 2015 -0800
> # Node ID ffd1a811f1c7c1998460e7bb64169183ad2c1657
> # Parent  05e7d10145be0af89e1eb6cf70c56e97f81101ab
> cmdutil: factor out pushsubrepos

I tried to come up with a reason to not do this, but I couldn't. Queued.

>
> In the remotenames extension, we replace large parts of the functionality of
> the push command. By factoring out this code, we can call it from the extension
> and avoid rewriting it in the extension.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2977,3 +2977,16 @@ def pushdest(ui, repo, dest, opts):
>              raise
>
>      return (dest, branches, revs, other)
> +
> +def pushsubrepos(repo, dest, opts):
> +    repo._subtoppath = dest
> +    try:
> +        # push subrepos depth-first for coherent ordering
> +        c = repo['']
> +        subs = c.substate # only repos that are committed
> +        for s in sorted(subs):
> +            result = c.sub(s).push(opts)
> +            if result == 0:
> +                return not result
> +    finally:
> +        del repo._subtoppath
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5088,17 +5088,8 @@ def push(ui, repo, dest=None, **opts):
>      if revs:
>          revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
>
> -    repo._subtoppath = dest
> -    try:
> -        # push subrepos depth-first for coherent ordering
> -        c = repo['']
> -        subs = c.substate # only repos that are committed
> -        for s in sorted(subs):
> -            result = c.sub(s).push(opts)
> -            if result == 0:
> -                return not result
> -    finally:
> -        del repo._subtoppath
> +    cmdutil.pushsubrepos(repo, dest, opts)
> +
>      pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
>                             newbranch=opts.get('new_branch'),
>                             bookmarks=opts.get('bookmark', ()))
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler - Feb. 19, 2015, 8:42 p.m.
On Tue, Feb 17, 2015 at 11:27:44AM -0500, Augie Fackler wrote:
> On Thu, Feb 12, 2015 at 12:41:05AM -0800, Ryan McElroy wrote:
> > # HG changeset patch
> > # User Ryan McElroy <rmcelroy@fb.com>
> > # Date 1423729275 28800
> > #      Thu Feb 12 00:21:15 2015 -0800
> > # Node ID ffd1a811f1c7c1998460e7bb64169183ad2c1657
> > # Parent  05e7d10145be0af89e1eb6cf70c56e97f81101ab
> > cmdutil: factor out pushsubrepos
>
> I tried to come up with a reason to not do this, but I couldn't. Queued.

I'm dropping these for the moment because they break these:

Failed test-propertycache.py: output changed and returned error code 1
Failed test-status-inprocess.py: output changed and returned error code 1
Failed test-module-imports.t: output changed

Please investigate and do a v2.

>
> >
> > In the remotenames extension, we replace large parts of the functionality of
> > the push command. By factoring out this code, we can call it from the extension
> > and avoid rewriting it in the extension.
> >
> > diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py
> > +++ b/mercurial/cmdutil.py
> > @@ -2977,3 +2977,16 @@ def pushdest(ui, repo, dest, opts):
> >              raise
> >
> >      return (dest, branches, revs, other)
> > +
> > +def pushsubrepos(repo, dest, opts):
> > +    repo._subtoppath = dest
> > +    try:
> > +        # push subrepos depth-first for coherent ordering
> > +        c = repo['']
> > +        subs = c.substate # only repos that are committed
> > +        for s in sorted(subs):
> > +            result = c.sub(s).push(opts)
> > +            if result == 0:
> > +                return not result
> > +    finally:
> > +        del repo._subtoppath
> > diff --git a/mercurial/commands.py b/mercurial/commands.py
> > --- a/mercurial/commands.py
> > +++ b/mercurial/commands.py
> > @@ -5088,17 +5088,8 @@ def push(ui, repo, dest=None, **opts):
> >      if revs:
> >          revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
> >
> > -    repo._subtoppath = dest
> > -    try:
> > -        # push subrepos depth-first for coherent ordering
> > -        c = repo['']
> > -        subs = c.substate # only repos that are committed
> > -        for s in sorted(subs):
> > -            result = c.sub(s).push(opts)
> > -            if result == 0:
> > -                return not result
> > -    finally:
> > -        del repo._subtoppath
> > +    cmdutil.pushsubrepos(repo, dest, opts)
> > +
> >      pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
> >                             newbranch=opts.get('new_branch'),
> >                             bookmarks=opts.get('bookmark', ()))
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel@selenic.com
> > http://selenic.com/mailman/listinfo/mercurial-devel
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Ryan McElroy - Feb. 20, 2015, 7:46 a.m.
On 2/19/2015 12:42 PM, Augie Fackler wrote:
> On Tue, Feb 17, 2015 at 11:27:44AM -0500, Augie Fackler wrote:
>> On Thu, Feb 12, 2015 at 12:41:05AM -0800, Ryan McElroy wrote:
>>> # HG changeset patch
>>> # User Ryan McElroy <rmcelroy@fb.com>
>>> # Date 1423729275 28800
>>> #      Thu Feb 12 00:21:15 2015 -0800
>>> # Node ID ffd1a811f1c7c1998460e7bb64169183ad2c1657
>>> # Parent  05e7d10145be0af89e1eb6cf70c56e97f81101ab
>>> cmdutil: factor out pushsubrepos
>> I tried to come up with a reason to not do this, but I couldn't. Queued.
> I'm dropping these for the moment because they break these:
>
> Failed test-propertycache.py: output changed and returned error code 1
> Failed test-status-inprocess.py: output changed and returned error code 1
> Failed test-module-imports.t: output changed
>
> Please investigate and do a v2.
Thanks for the heads-up, I'll look into this.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2977,3 +2977,16 @@  def pushdest(ui, repo, dest, opts):
             raise
 
     return (dest, branches, revs, other)
+
+def pushsubrepos(repo, dest, opts):
+    repo._subtoppath = dest
+    try:
+        # push subrepos depth-first for coherent ordering
+        c = repo['']
+        subs = c.substate # only repos that are committed
+        for s in sorted(subs):
+            result = c.sub(s).push(opts)
+            if result == 0:
+                return not result
+    finally:
+        del repo._subtoppath
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5088,17 +5088,8 @@  def push(ui, repo, dest=None, **opts):
     if revs:
         revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
 
-    repo._subtoppath = dest
-    try:
-        # push subrepos depth-first for coherent ordering
-        c = repo['']
-        subs = c.substate # only repos that are committed
-        for s in sorted(subs):
-            result = c.sub(s).push(opts)
-            if result == 0:
-                return not result
-    finally:
-        del repo._subtoppath
+    cmdutil.pushsubrepos(repo, dest, opts)
+
     pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
                            newbranch=opts.get('new_branch'),
                            bookmarks=opts.get('bookmark', ()))