# HG changeset patch # User Martin von Zweigbergk # Date 2018-06-21 16:32:31 # Node ID 00368bc0a614889c30e996d1f2fae53a49bf9e43 # Parent 4f885770c4a2ee95d7627a8ab8933167e8ca3e23 # Parent 1322ae04d3d71c9bab8ca6e70c77dfa867421c9b merge with stable diff --git a/mercurial/cext/manifest.c b/mercurial/cext/manifest.c --- a/mercurial/cext/manifest.c +++ b/mercurial/cext/manifest.c @@ -135,12 +135,22 @@ static int find_lines(lazymanifest *self return 0; } +static void lazymanifest_init_early(lazymanifest *self) +{ + self->pydata = NULL; + self->lines = NULL; + self->numlines = 0; + self->maxlines = 0; +} + static int lazymanifest_init(lazymanifest *self, PyObject *args) { char *data; Py_ssize_t len; int err, ret; PyObject *pydata; + + lazymanifest_init_early(self); if (!PyArg_ParseTuple(args, "S", &pydata)) { return -1; } @@ -668,6 +678,7 @@ static lazymanifest *lazymanifest_copy(l if (!copy) { goto nomem; } + lazymanifest_init_early(copy); copy->numlines = self->numlines; copy->livelines = self->livelines; copy->dirty = false; @@ -705,6 +716,7 @@ static lazymanifest *lazymanifest_filter if (!copy) { goto nomem; } + lazymanifest_init_early(copy); copy->dirty = true; copy->lines = malloc(self->maxlines * sizeof(line)); if (!copy->lines) { diff --git a/mercurial/crecord.py b/mercurial/crecord.py --- a/mercurial/crecord.py +++ b/mercurial/crecord.py @@ -403,7 +403,7 @@ class uihunk(patchnode): if fromline != 0: if fromlen == 0: fromline -= 1 - if tolen == 0: + if tolen == 0 and toline > 0: toline -= 1 fromtoline = '@@ -%d,%d +%d,%d @@%s\n' % ( diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1150,8 +1150,10 @@ def manifestmerge(repo, wctx, p2, pa, br copied = set(copy.values()) copied.update(movewithdir.values()) - if '.hgsubstate' in m1: - # check whether sub state is modified + if '.hgsubstate' in m1 and wctx.rev() is None: + # Check whether sub state is modified, and overwrite the manifest + # to flag the change. If wctx is a committed revision, we shouldn't + # care for the dirty state of the working directory. if any(wctx.sub(s).dirty() for s in wctx.substate): m1['.hgsubstate'] = modifiednodeid diff --git a/tests/test-commit-interactive-curses.t b/tests/test-commit-interactive-curses.t --- a/tests/test-commit-interactive-curses.t +++ b/tests/test-commit-interactive-curses.t @@ -214,6 +214,14 @@ Amend option works @@ -0,0 +1,1 @@ +hello world +Make file empty + $ printf "" > x + $ cat <testModeCommands + > X + > EOF + $ hg ci -i -m emptify -d "0 0" + $ hg update -C '.^' -q + Editing a hunk puts you back on that hunk when done editing (issue5041) To do that, we change two lines in a file, pretend to edit the second line, exit, toggle the line selected at the end of the edit and commit. @@ -236,7 +244,7 @@ of the edit. > X > EOF $ printf "printf 'editor ran\n'; exit 0" > editor.sh - $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "edit hunk" -d "0 0" + $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "edit hunk" -d "0 0" -q editor ran $ hg cat -r . x foo diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t --- a/tests/test-subrepo.t +++ b/tests/test-subrepo.t @@ -1941,3 +1941,43 @@ and bad usernames: updating to branch default abort: potentially unsafe url: 'ssh://-oProxyCommand=touch owned@example.com/path' (in subrepository "s") [255] + +Test convert subrepositories including merge (issue5526): + + $ hg init tconv + $ hg convert --config extensions.convert= -q t/s tconv/s + $ hg convert --config extensions.convert= -q t/s/ss tconv/s/ss + $ hg convert --config extensions.convert= -q t/t tconv/t + + convert shouldn't fail because of pseudo filenode: + + $ hg convert --config extensions.convert= t tconv + scanning source... + sorting... + converting... + 17 0 + 16 1 + 15 2 + 14 3 + 13 4 + 12 5 + 11 6 + 10 7 + 9 8 + 8 9 + 7 10 + 6 11 + 5 12 + 4 13 + 3 rm2 + 2 phasecheck4 + 1 16 + 0 branch before subrepo add + + converted .hgsubstate should point to valid nodes: + + $ hg up -R tconv 9 + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ cat tconv/.hgsubstate + fc627a69481fcbe5f1135069e8a3881c023e4cf5 s + 60ca1237c19474e7a3978b0dc1ca4e6f36d51382 t