Patchwork [5,of,5] histedit: choose only outgoing ancestors of the working directory always

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Aug. 26, 2013, 7:41 a.m.
Message ID <194e5b271e3f46f1fd6d.1377502912@feefifofum>
Download mbox | patch
Permalink /patch/2261/
State Changes Requested
Headers show

Comments

Katsunori FUJIWARA - Aug. 26, 2013, 7:41 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1377501081 -32400
#      Mon Aug 26 16:11:21 2013 +0900
# Node ID 194e5b271e3f46f1fd6d6b31494c450aef873f2b
# Parent  530564f737e2bf5111f769f944f6d0f7b6942def
histedit: choose only outgoing ancestors of the working directory always

Before this patch, when there are two or more "root" revisions in
outgoing ones, "histedit --outgoing" only succeeds when working
directory is a descendant of the oldest root. It seems to be ambiguous
and difficult for users.

This patch makes "histedit --outgoing" choose only outgoing ancestors
of the working directory always.

This patch also compares between branch names of working directory and
the destination URL, for sensitivity to branch in the destination URL.
This comparison also omits useless looking up.
Augie Fackler - Aug. 26, 2013, 1:50 p.m.
On Mon, Aug 26, 2013 at 04:41:52PM +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1377501081 -32400
> #      Mon Aug 26 16:11:21 2013 +0900
> # Node ID 194e5b271e3f46f1fd6d6b31494c450aef873f2b
> # Parent  530564f737e2bf5111f769f944f6d0f7b6942def
> histedit: choose only outgoing ancestors of the working directory always

I think I'd reword this entire commit message in terms of revsets:

"""

Prior to this patch, --outgoing was equivalent to `outgoing()`, which
might have revisions that are not an ancestor of the working copy. Now
--outgoing is equivalent to `outgoing() and ::.`, which ensures that
all selected revisions will be an ancestor of the working copy.

"""

>
> Before this patch, when there are two or more "root" revisions in
> outgoing ones, "histedit --outgoing" only succeeds when working
> directory is a descendant of the oldest root. It seems to be ambiguous
> and difficult for users.
>
> This patch makes "histedit --outgoing" choose only outgoing ancestors
> of the working directory always.
>
> This patch also compares between branch names of working directory and
> the destination URL, for sensitivity to branch in the destination URL.
> This comparison also omits useless looking up.

Huh? I have literally no idea what named branches have to do with anything here.

>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -411,14 +411,15 @@
>      Used by initialisation code"""
>      dest = ui.expandpath(remote or 'default-push', remote or 'default')
>      dest, revs = hg.parseurl(dest, None)[:2]
> +    if revs[0] and repo.dirstate.branch() != revs[0]:
> +        msg = _('no outgoing ancestors')
> +        hint = _('branch "%s" is specified in the destination URL') % revs[0]
> +        raise util.Abort(msg, hint=hint)
>      ui.status(_('comparing with %s\n') % util.hidepassword(dest))
>
> -    revs, checkout = hg.addbranchrevs(repo, repo, revs, None)
> +    revs = repo.dirstate.parents()[:1]
>      other = hg.peer(repo, opts, dest)
>
> -    if revs:
> -        revs = [repo.lookup(rev) for rev in revs]
> -
>      outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force)
>      if not outgoing.missing:
>          raise util.Abort(_('no outgoing ancestors'))
> @@ -457,6 +458,9 @@
>      With --outgoing, this edits changesets not found in the
>      destination repository. If URL of the destination is omitted, the
>      'default-push' (or 'default') path will be used.
> +
> +    This command edits only outgoing ancestors of the working
> +    directory.
>      """
>      # TODO only abort if we try and histedit mq patches, not just
>      # blanket if mq patches are applied somewhere
> diff --git a/tests/test-histedit-outgoing.t b/tests/test-histedit-outgoing.t
> --- a/tests/test-histedit-outgoing.t
> +++ b/tests/test-histedit-outgoing.t
> @@ -102,4 +102,34 @@
>    #  m, mess = edit message without changing commit content
>    #
>    0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +
> +  $ HGEDITOR=cat hg histedit --outgoing '../r#default' | grep -v comparing | grep -v searching | grep -v '^#'
> +  abort: no outgoing ancestors
> +  (branch "default" is specified in the destination URL)
> +  [1]
> +
> +test to edit only outgoing ancestors of the working directory
> +
> +  $ HGEDITOR=cat hg histedit --outgoing '../r' | grep -v comparing | grep -v searching | grep -v '^#'
> +  pick f26599ee3441 6 create foo branch
> +
> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +
> +  $ hg -q update -C 2
> +  $ echo aa >> a
> +  $ hg -q commit -m 'another head on default'
> +
> +  $ HGEDITOR=cat hg histedit --outgoing '../r' | grep -v comparing | grep -v searching | grep -v '^#'
> +  pick 3879dc049647 7 another head on default
> +
> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +
> +  $ hg -q update -C 5
> +  $ HGEDITOR=cat hg histedit --outgoing '../r' | grep -v comparing | grep -v searching | grep -v '^#'
> +  pick 055a42cdd887 3 d
> +  pick e860deea161a 4 e
> +  pick 652413bf663e 5 f
> +
> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +
>    $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Katsunori FUJIWARA - Aug. 27, 2013, 7:01 a.m.
At Mon, 26 Aug 2013 09:50:19 -0400,
Augie Fackler wrote:
> 
> On Mon, Aug 26, 2013 at 04:41:52PM +0900, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> > # Date 1377501081 -32400
> > #      Mon Aug 26 16:11:21 2013 +0900
> > # Node ID 194e5b271e3f46f1fd6d6b31494c450aef873f2b
> > # Parent  530564f737e2bf5111f769f944f6d0f7b6942def
> > histedit: choose only outgoing ancestors of the working directory always
> 
> I think I'd reword this entire commit message in terms of revsets:
> 
> """
> 
> Prior to this patch, --outgoing was equivalent to `outgoing()`, which
> might have revisions that are not an ancestor of the working copy. Now
> --outgoing is equivalent to `outgoing() and ::.`, which ensures that
> all selected revisions will be an ancestor of the working copy.
> 
> """

Thank you for your suggestion. I'll resend rewritten one.

> >
> > Before this patch, when there are two or more "root" revisions in
> > outgoing ones, "histedit --outgoing" only succeeds when working
> > directory is a descendant of the oldest root. It seems to be ambiguous
> > and difficult for users.
> >
> > This patch makes "histedit --outgoing" choose only outgoing ancestors
> > of the working directory always.
> >
> > This patch also compares between branch names of working directory and
> > the destination URL, for sensitivity to branch in the destination URL.
> > This comparison also omits useless looking up.
> 
> Huh? I have literally no idea what named branches have to do with anything here.

If the branch is specified in URL, outgoings should belong to it: for
example, dest URL "http://foo/baz#stable" ignores outgoing revisions
on branches other than "stable".

Additional steps like below around "discovery.findcommonoutgoing()"
can keep sensitivity to the branch in URL for editing `outgoing()
and::.`:

  - looking up by branch tip as "onlyheads" (or all outgoings), and
    then picking up ones which are ancestors of working copy, or

  - looking up by working copy as "onlyheads", and then picking up
    ones which belong to the branch specified in URL

But these are not efficient, because:

  - looking up outgoings on topological branches other than one of
    working copy is meaningless

  - looking up itself is meaningless, if branch is specified in URL
    and working copy doesn't belong to it

So, I wrote a little care about named branch in this patch for
efficiency.


> >
> > diff --git a/hgext/histedit.py b/hgext/histedit.py
> > --- a/hgext/histedit.py
> > +++ b/hgext/histedit.py
> > @@ -411,14 +411,15 @@
> >      Used by initialisation code"""
> >      dest = ui.expandpath(remote or 'default-push', remote or 'default')
> >      dest, revs = hg.parseurl(dest, None)[:2]
> > +    if revs[0] and repo.dirstate.branch() != revs[0]:
> > +        msg = _('no outgoing ancestors')
> > +        hint = _('branch "%s" is specified in the destination URL') % revs[0]
> > +        raise util.Abort(msg, hint=hint)
> >      ui.status(_('comparing with %s\n') % util.hidepassword(dest))
> >
> > -    revs, checkout = hg.addbranchrevs(repo, repo, revs, None)
> > +    revs = repo.dirstate.parents()[:1]
> >      other = hg.peer(repo, opts, dest)
> >
> > -    if revs:
> > -        revs = [repo.lookup(rev) for rev in revs]
> > -
> >      outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force)
> >      if not outgoing.missing:
> >          raise util.Abort(_('no outgoing ancestors'))
> > @@ -457,6 +458,9 @@
> >      With --outgoing, this edits changesets not found in the
> >      destination repository. If URL of the destination is omitted, the
> >      'default-push' (or 'default') path will be used.
> > +
> > +    This command edits only outgoing ancestors of the working
> > +    directory.
> >      """
> >      # TODO only abort if we try and histedit mq patches, not just
> >      # blanket if mq patches are applied somewhere
> > diff --git a/tests/test-histedit-outgoing.t b/tests/test-histedit-outgoing.t
> > --- a/tests/test-histedit-outgoing.t
> > +++ b/tests/test-histedit-outgoing.t
> > @@ -102,4 +102,34 @@
> >    #  m, mess = edit message without changing commit content
> >    #
> >    0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> > +
> > +  $ HGEDITOR=cat hg histedit --outgoing '../r#default' | grep -v comparing | grep -v searching | grep -v '^#'
> > +  abort: no outgoing ancestors
> > +  (branch "default" is specified in the destination URL)
> > +  [1]
> > +
> > +test to edit only outgoing ancestors of the working directory
> > +
> > +  $ HGEDITOR=cat hg histedit --outgoing '../r' | grep -v comparing | grep -v searching | grep -v '^#'
> > +  pick f26599ee3441 6 create foo branch
> > +
> > +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> > +
> > +  $ hg -q update -C 2
> > +  $ echo aa >> a
> > +  $ hg -q commit -m 'another head on default'
> > +
> > +  $ HGEDITOR=cat hg histedit --outgoing '../r' | grep -v comparing | grep -v searching | grep -v '^#'
> > +  pick 3879dc049647 7 another head on default
> > +
> > +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> > +
> > +  $ hg -q update -C 5
> > +  $ HGEDITOR=cat hg histedit --outgoing '../r' | grep -v comparing | grep -v searching | grep -v '^#'
> > +  pick 055a42cdd887 3 d
> > +  pick e860deea161a 4 e
> > +  pick 652413bf663e 5 f
> > +
> > +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> > +
> >    $ cd ..
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel@selenic.com
> > http://selenic.com/mailman/listinfo/mercurial-devel
> 

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -411,14 +411,15 @@ 
     Used by initialisation code"""
     dest = ui.expandpath(remote or 'default-push', remote or 'default')
     dest, revs = hg.parseurl(dest, None)[:2]
+    if revs[0] and repo.dirstate.branch() != revs[0]:
+        msg = _('no outgoing ancestors')
+        hint = _('branch "%s" is specified in the destination URL') % revs[0]
+        raise util.Abort(msg, hint=hint)
     ui.status(_('comparing with %s\n') % util.hidepassword(dest))
 
-    revs, checkout = hg.addbranchrevs(repo, repo, revs, None)
+    revs = repo.dirstate.parents()[:1]
     other = hg.peer(repo, opts, dest)
 
-    if revs:
-        revs = [repo.lookup(rev) for rev in revs]
-
     outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force)
     if not outgoing.missing:
         raise util.Abort(_('no outgoing ancestors'))
@@ -457,6 +458,9 @@ 
     With --outgoing, this edits changesets not found in the
     destination repository. If URL of the destination is omitted, the
     'default-push' (or 'default') path will be used.
+
+    This command edits only outgoing ancestors of the working
+    directory.
     """
     # TODO only abort if we try and histedit mq patches, not just
     # blanket if mq patches are applied somewhere
diff --git a/tests/test-histedit-outgoing.t b/tests/test-histedit-outgoing.t
--- a/tests/test-histedit-outgoing.t
+++ b/tests/test-histedit-outgoing.t
@@ -102,4 +102,34 @@ 
   #  m, mess = edit message without changing commit content
   #
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ HGEDITOR=cat hg histedit --outgoing '../r#default' | grep -v comparing | grep -v searching | grep -v '^#'
+  abort: no outgoing ancestors
+  (branch "default" is specified in the destination URL)
+  [1]
+
+test to edit only outgoing ancestors of the working directory
+
+  $ HGEDITOR=cat hg histedit --outgoing '../r' | grep -v comparing | grep -v searching | grep -v '^#'
+  pick f26599ee3441 6 create foo branch
+  
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ hg -q update -C 2
+  $ echo aa >> a
+  $ hg -q commit -m 'another head on default'
+
+  $ HGEDITOR=cat hg histedit --outgoing '../r' | grep -v comparing | grep -v searching | grep -v '^#'
+  pick 3879dc049647 7 another head on default
+  
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ hg -q update -C 5
+  $ HGEDITOR=cat hg histedit --outgoing '../r' | grep -v comparing | grep -v searching | grep -v '^#'
+  pick 055a42cdd887 3 d
+  pick e860deea161a 4 e
+  pick 652413bf663e 5 f
+  
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
   $ cd ..