A Scalable, User-Friendly Source Control System.
Go to file
timeless 04b3592b35 parents: correct help revset replacements
Implementing `hg parents -r REV FILE` correctly is hard.

The output can be 0, 1, or 2 revs.

First, you can't use parents(), because it sorts its output...

Consider:
echo $a
echo par@rev: `hg log -r "parents($a)" -q`
echo p12@rev: `hg log -r "p1($a)+p2($a)" -q`
echo parents: `hg parents -q -r $a`

(Merge 1 into 0)
3
par@rev: 0:d9612eafe8ec 1:070fe4290d06
p12@rev: 0:d9612eafe8ec 1:070fe4290d06
parents: 0:d9612eafe8ec 1:070fe4290d06

(Merge 4 into 5)
6
par@rev: 4:db73392995c3 5:c26e7dd67644
p12@rev: 5:c26e7dd67644 4:db73392995c3
parents: 5:c26e7dd67644 4:db73392995c3

(Merge 7 into 8)
9
par@rev: 7:d84f47462f70 8:9597bcab36e0
p12@rev: 8:9597bcab36e0 7:d84f47462f70
parents: 8:9597bcab36e0 7:d84f47462f70

You also can't use parents or/p1/p2 alone with a set, as in:
-r "parents(::REV and file(FILE))"
-r "parents(::REV - REV and file(FILE))"
... because each will return all parents for each candidate revision,
and the :: gives too many candidates.

Thus, we need a max and a p1/p2.

Also, anything of this form:
max(::REV - REV and file(FILE))
... is wrong, because max will return only one revision, and for
a proper parents, you need to return two occasionally.

Lastly, it doesn't help that `hg parents -r REV FILE` is buggy
due to a quirk in filelogs.

Here's a repository to consider when evaluating whether your
revset is correct:

$ hg log -G --template '{rev} {files}\n';
@  10 a
|
o    9 a b
|\
| o  8 a
| |
o |  7 a
| |
+---o  6 b
| |/
| o  5 b
| |
o |  4 b
| |
+---o  3
| |/
+---o  2
| |/
| o  1 b
|
o  0 a

revs 4 and 5 create a conflict.
The conflict is resolved in the same way by both 6 and 9.

You would hope that parents around 9/10 would point to 9,
but `hg parents` will point to 6 due to the aforementioned bug.

Here's the winning solution test script and its output.

echo $a;
echo rp12-max: `hg log -r "max(::p1($a) and file(b)) + max(::p2($a) and file(b))" -q` 2> /dev/null;
echo expected: `hg parents -q -r $a b` 2> /dev/null;

Note that for 10, the output differs, but again, this is because
of the aforementioned bug. The rp12-max output is "correct",
whereas "expected" is just an unfortunate bug. The abort output
is due to something else. I'm not sure why someone thought it
was important to abort to stdio instead of stderr, but that's
really not my problem here.

10
rp12-max: 9:184ebefc2fce
expected: 6:dd558142b03f
9
rp12-max: 5:c26e7dd67644 4:db73392995c3
expected: 5:c26e7dd67644 4:db73392995c3
8
rp12-max: 5:c26e7dd67644
expected: 5:c26e7dd67644
7
rp12-max: 4:db73392995c3
expected: 4:db73392995c3
6
rp12-max: 5:c26e7dd67644 4:db73392995c3
expected: 5:c26e7dd67644 4:db73392995c3
5
rp12-max: 1:070fe4290d06
expected: 1:070fe4290d06
4
rp12-max:
abort: 'b' not found in manifest!
expected:
3
rp12-max: 1:070fe4290d06
expected: 1:070fe4290d06
2
rp12-max: 1:070fe4290d06
expected: 1:070fe4290d06
1
rp12-max:
abort: 'b' not found in manifest!
expected:
0
rp12-max:
abort: 'b' not found in manifest!
expected:
2015-12-23 19:07:34 +00:00
contrib check-code: improve test-check-code error diffs 2015-12-24 19:32:14 +00:00
doc check-seclevel: pass a ui to the extension loader 2015-12-22 21:38:06 -08:00
hgext histedit: handle exceptions from node.bin in fromrule 2015-12-23 23:51:29 +00:00
i18n i18n: add execute bit to check-translation.py 2015-12-22 11:03:33 +00:00
mercurial parents: correct help revset replacements 2015-12-23 19:07:34 +00:00
tests run-tests: avoid double counting server fails 2015-12-28 16:01:31 +00:00
.hgignore hgignore: ignore the PyCharm workspace folder 2014-10-13 11:46:04 +02:00
.hgsigs Added signature for changeset 86c16f25367c 2015-12-01 20:18:28 -06:00
CONTRIBUTORS Add note to CONTRIBUTORS file 2007-11-07 21:10:30 -06:00
COPYING COPYING: refresh with current address from fsf.org 2011-06-02 11:17:02 -05:00
hg hg: add support for HGUNICODEPEDANTRY environment variable 2014-06-23 09:33:07 -04:00
hgeditor spelling: trivial spell checking 2015-10-17 00:58:46 +02:00
hgweb.cgi urls: bulk-change primary website URLs 2015-09-30 15:43:49 -05:00
Makefile builddeb: read default distribution and codename from lsb_release 2015-11-25 18:07:33 +08:00
README urls: bulk-change primary website URLs 2015-09-30 15:43:49 -05:00
setup.py setup.py: package internals help files 2015-12-13 11:34:04 -08:00

Mercurial
=========

Mercurial is a fast, easy to use, distributed revision control tool
for software developers.

Basic install:

 $ make            # see install targets
 $ make install    # do a system-wide install
 $ hg debuginstall # sanity-check setup
 $ hg              # see help

Running without installing:

 $ make local      # build for inplace usage
 $ ./hg --version  # should show the latest version

See https://mercurial-scm.org/ for detailed installation
instructions, platform-specific notes, and Mercurial user information.