##// END OF EJS Templates
histedit: pick an appropriate base changeset by default (BC)...
Gregory Szorc -
r27262:3d0feb2f default
parent child Browse files
Show More
@@ -149,6 +149,13 b' configuration file::'
149
149
150 [histedit]
150 [histedit]
151 linelen = 120 # truncate rule lines at 120 characters
151 linelen = 120 # truncate rule lines at 120 characters
152
153 ``hg histedit`` attempts to automatically choose an appropriate base
154 revision to use. To change which base revision is used, define a
155 revset in your configuration file::
156
157 [histedit]
158 defaultrev = only(.) & draft()
152 """
159 """
153
160
154 try:
161 try:
@@ -166,6 +173,7 b' from mercurial import discovery'
166 from mercurial import error
173 from mercurial import error
167 from mercurial import copies
174 from mercurial import copies
168 from mercurial import context
175 from mercurial import context
176 from mercurial import destutil
169 from mercurial import exchange
177 from mercurial import exchange
170 from mercurial import extensions
178 from mercurial import extensions
171 from mercurial import hg
179 from mercurial import hg
@@ -786,13 +794,19 b' def findoutgoing(ui, repo, remote=None, '
786 ('f', 'force', False,
794 ('f', 'force', False,
787 _('force outgoing even for unrelated repositories')),
795 _('force outgoing even for unrelated repositories')),
788 ('r', 'rev', [], _('first revision to be edited'), _('REV'))],
796 ('r', 'rev', [], _('first revision to be edited'), _('REV'))],
789 _("ANCESTOR | --outgoing [URL]"))
797 _("[ANCESTOR] | --outgoing [URL]"))
790 def histedit(ui, repo, *freeargs, **opts):
798 def histedit(ui, repo, *freeargs, **opts):
791 """interactively edit changeset history
799 """interactively edit changeset history
792
800
793 This command edits changesets between ANCESTOR and the parent of
801 This command edits changesets between an ANCESTOR and the parent of
794 the working directory.
802 the working directory.
795
803
804 The value from the "histedit.defaultrev" config option is used as a
805 revset to select the base revision when ANCESTOR is not specified.
806 The first revision returned by the revset is used. By default, this
807 selects the editable history that is unique to the ancestry of the
808 working directory.
809
796 With --outgoing, this edits changesets not found in the
810 With --outgoing, this edits changesets not found in the
797 destination repository. If URL of the destination is omitted, the
811 destination repository. If URL of the destination is omitted, the
798 'default-push' (or 'default') path will be used.
812 'default-push' (or 'default') path will be used.
@@ -917,10 +931,10 b' def _histedit(ui, repo, state, *freeargs'
917 else:
931 else:
918 revs.extend(freeargs)
932 revs.extend(freeargs)
919 if len(revs) == 0:
933 if len(revs) == 0:
920 # experimental config: histedit.defaultrev
934 defaultrev = destutil.desthistedit(ui, repo)
921 histeditdefault = ui.config('histedit', 'defaultrev')
935 if defaultrev is not None:
922 if histeditdefault:
936 revs.append(defaultrev)
923 revs.append(histeditdefault)
937
924 if len(revs) != 1:
938 if len(revs) != 1:
925 raise error.Abort(
939 raise error.Abort(
926 _('histedit requires exactly one ancestor revision'))
940 _('histedit requires exactly one ancestor revision'))
@@ -198,3 +198,18 b' def destmerge(repo):'
198 else:
198 else:
199 node = _destmergebranch(repo)
199 node = _destmergebranch(repo)
200 return repo[node].rev()
200 return repo[node].rev()
201
202 histeditdefaultrevset = 'reverse(only(.) and not public() and not ::merge())'
203
204 def desthistedit(ui, repo):
205 """Default base revision to edit for `hg histedit`."""
206 default = ui.config('histedit', 'defaultrev', histeditdefaultrevset)
207 if default:
208 revs = repo.revs(default)
209 if revs:
210 # The revset supplied by the user may not be in ascending order nor
211 # take the first revision. So do this manually.
212 revs.sort()
213 return revs.first()
214
215 return None
@@ -347,3 +347,101 b' Histedit state has been exited'
347 commit: 1 added, 1 unknown (new branch head)
347 commit: 1 added, 1 unknown (new branch head)
348 update: 4 new changesets (update)
348 update: 4 new changesets (update)
349
349
350 $ cd ..
351
352 Set up default base revision tests
353
354 $ hg init defaultbase
355 $ cd defaultbase
356 $ touch foo
357 $ hg -q commit -A -m root
358 $ echo 1 > foo
359 $ hg commit -m 'public 1'
360 $ hg phase --force --public -r .
361 $ echo 2 > foo
362 $ hg commit -m 'draft after public'
363 $ hg -q up -r 1
364 $ echo 3 > foo
365 $ hg commit -m 'head 1 public'
366 created new head
367 $ hg phase --force --public -r .
368 $ echo 4 > foo
369 $ hg commit -m 'head 1 draft 1'
370 $ echo 5 > foo
371 $ hg commit -m 'head 1 draft 2'
372 $ hg -q up -r 2
373 $ echo 6 > foo
374 $ hg commit -m 'head 2 commit 1'
375 $ echo 7 > foo
376 $ hg commit -m 'head 2 commit 2'
377 $ hg -q up -r 2
378 $ echo 8 > foo
379 $ hg commit -m 'head 3'
380 created new head
381 $ hg -q up -r 2
382 $ echo 9 > foo
383 $ hg commit -m 'head 4'
384 created new head
385 $ hg merge --tool :local -r 8
386 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
387 (branch merge, don't forget to commit)
388 $ hg commit -m 'merge head 3 into head 4'
389 $ echo 11 > foo
390 $ hg commit -m 'commit 1 after merge'
391 $ echo 12 > foo
392 $ hg commit -m 'commit 2 after merge'
393
394 $ hg log -G -T '{rev}:{node|short} {phase} {desc}\n'
395 @ 12:8cde254db839 draft commit 2 after merge
396 |
397 o 11:6f2f0241f119 draft commit 1 after merge
398 |
399 o 10:90506cc76b00 draft merge head 3 into head 4
400 |\
401 | o 9:f8607a373a97 draft head 4
402 | |
403 o | 8:0da92be05148 draft head 3
404 |/
405 | o 7:4c35cdf97d5e draft head 2 commit 2
406 | |
407 | o 6:931820154288 draft head 2 commit 1
408 |/
409 | o 5:8cdc02b9bc63 draft head 1 draft 2
410 | |
411 | o 4:463b8c0d2973 draft head 1 draft 1
412 | |
413 | o 3:23a0c4eefcbf public head 1 public
414 | |
415 o | 2:4117331c3abb draft draft after public
416 |/
417 o 1:4426d359ea59 public public 1
418 |
419 o 0:54136a8ddf32 public root
420
421
422 Default base revision should stop at public changesets
423
424 $ hg -q up 8cdc02b9bc63
425 $ hg histedit --commands - <<EOF
426 > pick 463b8c0d2973
427 > pick 8cdc02b9bc63
428 > EOF
429 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
430
431 Default base revision should stop at branchpoint
432
433 $ hg -q up 4c35cdf97d5e
434 $ hg histedit --commands - <<EOF
435 > pick 931820154288
436 > pick 4c35cdf97d5e
437 > EOF
438 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
439
440 Default base revision should stop at merge commit
441
442 $ hg -q up 8cde254db839
443 $ hg histedit --commands - <<EOF
444 > pick 6f2f0241f119
445 > pick 8cde254db839
446 > EOF
447 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
General Comments 0
You need to be logged in to leave comments. Login now