A Scalable, User-Friendly Source Control System.
Go to file
Jun Wu b48ea46da6 linelog: be conservative when deleting a chunk from an old revision
Summary:
This is a subtle change. Consider the following case, where revision 1 has 3
lines and revision 2 has 1 line inserted between the second and the third
lines of revision 1:

  0: +---- INSERTED BY REV 1
     |                          --+             --+
  1: |     LINE REV=1 LINENUM=0   | DEL BLOCK A   | DEL BLOCK B
  2: |     LINE REV=1 LINENUM=1   |               |
     |                          --+               |
  3: | +-- INSERTED BY REV 2                      |
  4: | |   LINE REV=2 LINENUM=2                   |
     | +--                                      --+
  5: |     LINE REV=1 LINENUM=2
     +----

Now what if the user has run `annotate(rev=1)` and wants to delete the first 2
lines, by calling `replacelines(a1=0, a2=2, ...)`?

The current code would use "DEL BLOCK B", which is more efficient because
the block contains more instructions, and more simple because it is just a
JGE to the a2 address.

While that works fine for the "appending" case (always edit new revisions),
it deletes future lines between the second and third line (in this case,
"LINE REV=2 LINENUM=2"). This is undesired by some users, namely smartfixup.

Surely we can add a boolean flag to the `replacelines` API to decide whether
A or B will be used. But that is too low-level and `replacelines` already
has too many parameters. Today we don't see other requirements to choose
between them precisely. Therefore, just change the default behavior, when
deleting chunks from old revisions to "DEL BLOCK A".

Test Plan: This change is needed to help pass the future smartfixup tests

Reviewers: #mercurial, ttung, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3716435

Signature: t1:3716435:1471262664:0ae40d95d6389db733a88d9fafe19962d9166e35
2016-08-15 12:08:06 +01:00
cfastmanifest [fastmanifest] fix unhexlify 2016-08-02 15:35:49 -07:00
fastmanifest [fastmanifest] prune the cache only when the revset is empty 2016-07-26 23:35:24 -07:00
hgext3rd Parallel callout to scmquery through conduit 2016-08-12 15:52:50 -07:00
linelog linelog: be conservative when deleting a chunk from an old revision 2016-08-15 12:08:06 +01:00
phabricator conduit: stop using httplib 2016-07-04 03:00:37 -07:00
scripts scm-prompt: use double square brackets everywhere 2016-07-22 16:31:51 -07:00
sqldirstate sqldirstate: call the registered callbacks on wd parent change 2016-08-15 03:46:52 -07:00
tests sqldirstate: call the registered callbacks on wd parent change 2016-08-15 03:46:52 -07:00
.editorconfig Add editorconfig 2016-04-20 03:05:42 -07:00
.hgignore hgignore: ignore linelog non-source files 2016-08-10 22:32:21 +01:00
cfastmanifest.c [cfastmanifest] add PyObject_Del to dealloc method 2016-08-09 13:47:49 -07:00
COPYING Initial commit with extensions and readme 2014-06-02 12:54:54 -07:00
Makefile Initial commit: fbamend, smartlog 2013-06-20 12:16:36 -07:00
README.md Merge fbonly into default 2015-03-08 12:22:25 -07:00
setup.py setup: build linelog 2016-08-10 22:26:05 +01:00
statprof.py statprof: prevent divide by zero error if there are no samples 2016-08-05 10:05:13 -07:00

hg-experimental

This is a collection of proof-of-concept Mercurial extensions written at Facebook. While they are all in basic use, they are considered experimental, are unsupported, and may or may not receive updates in the future. We're making them open source as examples of some better workflows we've been experimenting with.

Note that there will be extensions included here that only work with Facebook's infrastructure; they are included to give you an idea of how we integrate mercurial with our workflows.

smartlog

An extension that adds the 'hg smartlog' command. It prints graph log output containing only the commits relevant to yourself. Shows your bookmarks, the @ or master bookmark, and any draft commits without bookmarks that you've made within the past 2 weeks. Any commits in the graph that are skipped are represented by '...'.

We recommend also having an 'hg sl' alias that gives more concise output:

alias.sl=smartlog --template "{shortest(node)}  {author|user}  {bookmarks % '{ifeq(bookmark, current, label(\"yellow\", \" {bookmark}*\"), label(\"green\", \" {bookmark}\"))}'} {ifeq(branch, 'default', '', label(\"bold\", branch))}\n{desc|firstline}\n\n"

githelp

An extension that adds the 'hg githelp' command. It translates Git commands into Mercurial commands. Example:

$ hg githelp -- git rebase origin/master
  hg rebase -d master

$ hg githelp -- reset --hard HEAD^
  hg strip -r .

So it acts as a useful cheat sheet tool for people moving from Git to Mercurial.

backups

An extension that adds the 'hg backups' command. 'hg backups' prints a list of recently deleted commits (by reading your .hg/strip-backups directory) and allows you to recover a commit by doing 'hg backups --recover '. It prints the missing commits in reverse chronological order, and acts as a pseudo-replacement for Git's reflog.

fbamend

An extension that adds the 'hg amend --rebase' command. When working with a stack of commits, it's currently impossible to amend a commit in the middle of the stack. This extension enables that ability, adds a 'hg amend' command that invokes 'hg commit --amend', and adds a --rebase flag to 'hg amend --rebase' that rebase all the children of the commit onto the newly amended version.

If 'hg amend' is run on a commit in the middle of a stack without using --rebase, the amend succeeds and the old version of the commit is left behind with a marker bookmark on it 'bookmarkname(preamend)'. The user can then run 'hg amend --fixup' to post-humously rebase the children onto the new version of the commit.

chistedit

An interactive ncurses interface to histedit.

NOTE: This requires python-curses installed and Mercurial's histedit extension enabled.

This extensions allows you to interactively move around changesets or change the action to perform while keeping track of possible conflicts.

upgradegeneraldelta

Upgrades manifests to generaldelta in-place, without needing to reclone.

Contributing

Patches are welcome as pull requests, though they will be collapsed and rebased to maintain a linear history.

We (Facebook) have to ask for a "Contributor License Agreement" from someone who sends in a patch or code that we want to include in the codebase. This is a legal requirement; a similar situation applies to Apache and other ASF projects.

If we ask you to fill out a CLA we'll direct you to our online CLA page where you can complete it easily. We use the same form as the Apache CLA so that friction is minimal.

License

These extensions are made available under the terms of the GNU General Public License version 2, or any later version. See the COPYING file that accompanies this distribution for the full text of the license.