mercurial/destutil.py
changeset 27262 3d0feb2f978b
parent 26728 e8f1b7285917
child 27333 2c60b4b2a0de
--- a/mercurial/destutil.py	Sat Dec 05 23:50:13 2015 +0900
+++ b/mercurial/destutil.py	Sat Oct 24 19:56:39 2015 +0100
@@ -198,3 +198,18 @@
     else:
         node = _destmergebranch(repo)
     return repo[node].rev()
+
+histeditdefaultrevset = 'reverse(only(.) and not public() and not ::merge())'
+
+def desthistedit(ui, repo):
+    """Default base revision to edit for `hg histedit`."""
+    default = ui.config('histedit', 'defaultrev', histeditdefaultrevset)
+    if default:
+        revs = repo.revs(default)
+        if revs:
+            # The revset supplied by the user may not be in ascending order nor
+            # take the first revision. So do this manually.
+            revs.sort()
+            return revs.first()
+
+    return None