Commit Graph

198 Commits

Author SHA1 Message Date
Johan Herland
ccfee0eae6 Add --html=<file> for producing HTML diagram of merge frontier
When given --html=foo.html, a HTML file containing a table of the
current merge frontier is written to foo.html. The table contains
the classes needed to allow the accompanying imerge.css to render
it in colorful glory.
2013-05-22 11:53:42 +02:00
Michael Haggerty
13a88ab584 Merge branch 'diagram-colors'
Add (optional) colors to the "git-imerge diagram" output.
2013-05-21 00:01:32 +02:00
Johan Herland
0c5abb731e Fix PPM output 2013-05-20 23:45:32 +02:00
Johan Herland
f0a9ae9b48 Add ANSI coloring of diagram when outputting to terminal
Controlled with new diagram options --color and --no-color:

--no-color forces coloring off, else --color forces coloring on, else
we turn on coloring only if stdout is a tty.
2013-05-20 23:34:33 +02:00
Johan Herland
e834e116ff MergeFrontier: Split creation and formatting of diagram
Instead of working directly with the formatting characters returned
from Block.format_diagram(), build on the semantic diagram returned
from Block.create_diagram(), and bitwise-or in additional constants
to represent the merge frontier semantically.

Then add MergeFrontier.format_diagram() to perform a similar mapping
of the semantic information into a "graphical" format. The end result
printed to the screen is identical across this refactoring.
2013-05-20 23:33:43 +02:00
Johan Herland
bf2dc362aa Block: Split creation and formatting of diagram
Instead of passing formatting characters directly into
Block.create_diagram(), create the diagram using integer constants
to represent the semantic state of each node in the diagram.

Provide Block.format_diagram() for mapping the integer constants
onto a provided "legend", which provides the "graphical" (insofar
as ASCII-art can be considered such) representation of the various
states for each node in the diagram.

Also collapse Block._write() into Block.write(), since the latter
is equivalent to the former with default arguments passed.
2013-05-20 23:32:07 +02:00
Johan Herland
26b377ed33 Refactor to improve readability 2013-05-20 23:32:07 +02:00
Johan Herland
b44199f787 Remove unused diagram argument, and s/fill_diagram/create_diagram/
The diagram argument to the fill_diagram() methods of MergeFrontier and
Block was never used, so remove it. Once removed, the fill_diagram()
name no longer makes much sense, since the diagram is created within
the method, and no longer passed in as an argument. Therefore, rename
the methods to create_diagram().

The docstrings of the two methods are adjusted accordingly.
2013-05-20 13:42:14 +02:00
Michael Haggerty
1d17c7764c Merge branch 'knirch/preserve-author-info'
When simplifying an incremental merge into a "rebase", preserve the
author info from the original commits (but update the committer info
to the person running "git-imerge simplify").

I've taken some liberties when merging this commit, integrating it
into the commit_tree() command that I recently added for backwards
compatibility reasons, and renaming the function get_commit_info() to
get_author_info().

Conflicts:
	git-imerge
2013-05-17 11:32:22 +02:00
Michael Haggerty
a5f76815c4 Fix call sequence for old "git commit-tree".
Apparently old "git commit-tree" requires "TREE" *before* "-p PARENT".
2013-05-17 11:11:39 +02:00
Michael Haggerty
881063d4bc Merge branch 'commit-tree-no-m'
Do not use "git commit-tree -m", because the "-m" option has only
recently been added to Git.
2013-05-17 10:36:17 +02:00
Michael Haggerty
1e07a395d4 Pipe commit message into "git commit-tree" rather than using "-m" option.
The "-m" option was added to Git recently, so use the old-fashioned
method to be portable to older Git versions.
2013-05-17 10:35:31 +02:00
Michael Haggerty
1388618a60 Extract a method commit_tree().
Its implementation needs to be changed, so centralized how it is called.
2013-05-17 10:29:32 +02:00
Michael Haggerty
2d420ce8f0 Fix Python 2.6.x compatibility.
The subprocess module in Python 2.6 has a CalledProcessError class,
but its constructor doesn't take a third (output) argument.  So don't
only pass the constructor two arguments.
2013-05-17 09:30:14 +02:00
Michael Haggerty
2c9656309f Complete web links.
(If a web log is called a "blog", is a web link called a "blink"?)
2013-05-16 16:39:47 +02:00
Thomas Nilsson
bbddb93e0c Retain author information with --goal=rebase
Keeps GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE.
2013-05-16 16:32:32 +02:00
Michael Haggerty
7854ecd038 Merge branch 'vertex-consistency'
Handle the automatic merges at the vertex of a block more carefully,
by merging them two ways and verifying that the two resulting trees
are identical.
2013-05-14 10:18:29 +02:00
Michael Haggerty
8d283e9658 Handle vertex merges more carefully.
When autofilling the vertex of a block, it is possible to do the merge
three ways:

1. Using the commits directly above and to the left as parents

2. Using the commits at [i1,0] and [i1-1,i2] as parents (i.e., as a
   continuation of the bottom edge)

3. Using the commits at [i1,i2-1] and [0,i2] as parents (i.e., as a
   continuation of the right edge)

We want the final history to be *as if* the parents were as in (1).

Formerly we were doing (1) and simply using the result.  This is
incorrect because the neighboring commits do not have correct
histories.  Therefore, the merge base for this merge is [0,0], and the
merge can have unnecessary conflicts.

Change to trying both (2) and (3).  If both of those commits succeed
*and* if they give identical trees, then create a synthetic commit
with the parents as in (1) and use that; otherwise, fail.
2013-05-14 10:07:01 +02:00
Michael Haggerty
c41fa18056 Make message for UnexpectedMergeFailure sound less scary.
And give the user hope that progress is still possible.

Suggested by: Thomas Nilsson <knirch@unixangst.com>
2013-05-14 09:30:26 +02:00
Michael Haggerty
43c96036be Add a function get_tree(). 2013-05-14 09:30:26 +02:00
Michael Haggerty
52067e92fb Merge branch 'test-dirs'
Manage the directories used by the tests better.
2013-05-14 07:47:12 +02:00
Michael Haggerty
3258cfdfb4 Rename "test-conflictless" to "test-unconflicted".
I have typed it wrong several times now so it seems to want its
new name.
2013-05-14 07:46:53 +02:00
Michael Haggerty
914aa3c32f Fix MergeFrontier.remove_failure().
MergeFrontier.remove_failure() was not doing the right thing.  If
there is a conflict like this:

    *******
    *......
    *.....X
    *......

then it should attempt to split the conflicting block into two blocks
(one of which might be empty) like this:

    *****||
    -----++
    *....|X
    -----+.

but instead it is doing this:

    *****|*
    *----+.
    *.....X
    *......

which is nonsense.  This could lead to an infinite loop (GitHub issue
2013-05-14 07:40:14 +02:00
Michael Haggerty
e1f377ea4a Remove unused local variables.
Usually pyflakes detects problems like this, but it missed this one...

Problem was pointed out by Thomas Nilsson <knirch@unixangst.com>
2013-05-14 07:08:03 +02:00
Peter Jönsson
593dea1422 Use python2 from environment
Some environments might have a old and/or broken version of python2
installed in /usr/bin but still wish to use git-imerge. The non-broken
version of python might be loaded separately from the base operating
system image via for example environment modules [1].

So use the currently active python2 from the environment instead of
hard coding the path to /usr/bin/python2.

[1] http://modules.sourceforge.net/
2013-05-13 10:55:39 +02:00
Michael Haggerty
dfbe2d446d Merge branch 'git-merge-talk'.
Add a talk that I presented at GitMerge 2013.
2013-05-11 18:01:59 +02:00
Michael Haggerty
e7e4b9acee Add the talk that I presented at GitMerge 2013. 2013-05-11 18:01:12 +02:00
Michael Haggerty
34ad88aebf Add the files used automatically by "rst2s5 --theme=small-white".
These files are in the public domain, except for iepngfix.htc, which
is under LGPL 2.1+ (see notice in file).

This command adds the pristine versions of the files, so that the
small changes that I made in the files in the next commit will be
documented.
2013-05-11 17:57:08 +02:00
Michael Haggerty
2bceac55ef Ignore all *.html files, but only in top directory. 2013-05-11 17:29:55 +02:00
Michael Haggerty
1f023c49cc Add a Makefile.
Type "make html" to convert the reStructuredText files to HTML.
2013-05-11 16:34:55 +02:00
Michael Haggerty
c706be10de Add a script to remove test detritus from the temporary test repository. 2013-05-11 16:29:18 +02:00
Michael Haggerty
ba8bd57bae Fix test scripts' use of directories.
The test scripts used to assume that they were being run from a
strange place.  Instead, teach them to derive the main project
directory "BASE" from $0 and

* always place the temporary directory at $BASE/t/tmp

* always run git-imerge from $BASE/git-imerge

* be more careful before deleting an old test directory.
2013-05-11 16:24:09 +02:00
Jeff King
f9c06e2876 t: don't use well-known git aliases
Not everybody has them, which can cause the test script to
abort.
2013-05-10 11:17:03 +02:00
Michael Haggerty
fa647c2b3a Add a TODO file. 2013-05-08 14:09:02 +02:00
Michael Haggerty
87e63c556f Improve the README file. 2013-05-08 14:08:30 +02:00
Michael Haggerty
3ef66b97e1 Improve the prompt for merge conflicts. 2013-05-08 14:06:52 +02:00
Michael Haggerty
4ae814411a Add method MergeRecord.is_manual(). 2013-05-07 17:03:24 +02:00
Michael Haggerty
176627375b Merge branch 'remember-blockers'
Keep track of which commits block frontier blocker blocks.  (Hmmm,
maybe the word "block" is being overused...)

This makes it possible to preserve a persistent record of which of the
blocks on the current frontier have no hope of progressing without
user interaction, and allow us to avoid some checks at every program
start.

I also think that with some extra code we could use an *unblocked*
blocker when bisecting and outlining and thereby avoid the need to
outline unblocked blocks as two blocks in many cases; i.e., instead of
filling such a block like this:

    *******
    *@.....
    *?????.
    *?????.
    *......

we could fill it like this:

    *******
    *@????.
    *?????.
    *?????.
    *......

and thereby avoid a lot of bookkeeping commits.
2013-05-07 16:15:14 +02:00
Michael Haggerty
b388b1a05c Update the blockers when a [1,1] merge fails or when the user records a manual merge.
This means that we have to call save() even if
MergeFrontier.auto_expand() raises a FrontierBlockedError.
2013-05-07 16:12:35 +02:00
Michael Haggerty
ce0ef7a97f In MergeFrontier.compute_by_bisection(), exit early if commit [1,1] is blocked. 2013-05-07 16:10:54 +02:00
Michael Haggerty
7fc14255fa Do not allow the MergeFrontier to pass through a blocked merge. 2013-05-07 16:10:42 +02:00
Michael Haggerty
57763acf26 Make incorporate_user_merge() return the blocked block that would be affected.
Raise NoManualMergeError if there was no manual merge ready to go.

Raise NotABlockingCommitError if the manual merge was not blocking the
frontier.
2013-05-07 16:09:58 +02:00
Michael Haggerty
99f732a4ac Teach "diagram" to show blockers. 2013-05-07 16:09:58 +02:00
Michael Haggerty
8c7b9dd2a6 Change how user merges are incorporated.
Rename MergeFrontier.add_success() to get_affected_blocker_block() and
change it to return the block that was freed up by the new merge.  If
there is no such merge, raise an exception.
2013-05-07 16:09:58 +02:00
Michael Haggerty
6ac36f1ccf Allow "blocker" commits to be recorded as part of MergeState. 2013-05-07 16:09:58 +02:00
Michael Haggerty
9fd67a3670 Tighten up logic in MergeFrontier.compute_by_bisection().
This removes some redundant automerge attempts.

Also add lots of comments and expand the method docstring.
2013-05-07 16:09:58 +02:00
Michael Haggerty
3922ea6563 Output json without indentation but with a trailing newline. 2013-05-07 15:52:01 +02:00
Michael Haggerty
b1eee46e2d Change tests to output both kinds of diagram. 2013-05-07 15:52:01 +02:00
Michael Haggerty
06f10442e4 Make Block.set_value() private and remove Block.__setitem__().
Callers shouldn't be setting records like this.  They should get the
MergeRecord using __getitem__() and then modify the MergeRecord in
place.
2013-05-06 14:21:25 +02:00
Michael Haggerty
5effd876e7 Merge branch 'fill-diagram'
Generate diagram output in two stages:

* Write one string for each commit to a 2D array
* Write the array to output

Then give access to the former functionality via new fill_diagram()
methods.
2013-05-06 10:35:44 +02:00