[PATCH 1 of 1 V2] histedit: abort if there are multiple roots in "--outgoing" revisions

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Mon Sep 9 08:51:30 CDT 2013


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1378733863 -32400
#      Mon Sep 09 22:37:43 2013 +0900
# Node ID f0edc4e70f976b20d0c886a287b472a629789329
# Parent  1d07bf106c2ad1c7ef5e257e754ca8d858bd04b0
histedit: abort if there are multiple roots in "--outgoing" revisions

Before this patch, if there are multiple roots in "--outgoing"
revisions, result of "histedit --outgoing" depends on the parent of
the working directory. It succeeds only when the parent of the working
directory is a descendant of the oldest root in "--outgoing"
revisions, and fails otherwise.

It seems to be ambiguous and difficult for users.

This patch makes "histedit --outgoing" abort if there are multiple
roots in "--outgoing" revisions always.

This patch also recommends to use "min(outgoing() and ::.)" or similar
revset specification in such ambiguous situation by online help.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -422,7 +422,12 @@
     outgoing = discovery.findcommonoutgoing(repo, other, revs, force=force)
     if not outgoing.missing:
         raise util.Abort(_('no outgoing ancestors'))
-    return outgoing.missing[0]
+    roots = list(repo.set("roots(%ln)", outgoing.missing))
+    if 1 < len(roots):
+        msg = _('there are multiple roots in outgoing revisions')
+        hint = _('see "hg help histedit" for detail about --outgoing')
+        raise util.Abort(msg, hint=hint)
+    return repo.lookup(roots[0])
 
 actiontable = {'p': pick,
                'pick': pick,
@@ -457,6 +462,13 @@
     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 is aborted, if there are multiple roots in revisions
+    specified by --outgoing, to avoid editing unexpected
+    revisions. Use "min(outgoing() and ::.)" or similar revset
+    specification instead of --outgoing to specify the root of
+    outgoing ancestors of the working directory in such ambiguous
+    situation.
     """
     # 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,38 @@
   #  m, mess = edit message without changing commit content
   #
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+test to check number of roots in outgoing revisions
+
+  $ hg -q outgoing -G --template '{node|short}({branch})' '../r'
+  @  f26599ee3441(foo)
+  
+  o  652413bf663e(default)
+  |
+  o  e860deea161a(default)
+  |
+  o  055a42cdd887(default)
+  
+  $ HGEDITOR=cat hg -q histedit --outgoing '../r'
+  abort: there are multiple roots in outgoing revisions
+  (see "hg help histedit" for detail about --outgoing)
+  [255]
+
+  $ hg -q update -C 2
+  $ echo aa >> a
+  $ hg -q commit -m 'another head on default'
+  $ hg -q outgoing -G --template '{node|short}({branch})' '../r#default'
+  @  3879dc049647(default)
+  
+  o  652413bf663e(default)
+  |
+  o  e860deea161a(default)
+  |
+  o  055a42cdd887(default)
+  
+  $ HGEDITOR=cat hg -q histedit --outgoing '../r#default'
+  abort: there are multiple roots in outgoing revisions
+  (see "hg help histedit" for detail about --outgoing)
+  [255]
+
   $ cd ..


More information about the Mercurial-devel mailing list