D2597: graft: add test for reading old graftstate files with new mechanism

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Thu May 24 21:01:43 UTC 2018


pulkit updated this revision to Diff 8886.
pulkit edited the summary of this revision.
pulkit retitled this revision from "graft: add test for reading old format state files with new mechanism" to "graft: add test for reading old graftstate files with new mechanism".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2597?vs=7303&id=8886

REVISION DETAIL
  https://phab.mercurial-scm.org/D2597

AFFECTED FILES
  tests/test-graft.t

CHANGE DETAILS

diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1373,3 +1373,57 @@
   note: graft of 7:d3c3f2b38ecc created no changes to commit
 
   $ cd ..
+
+Testing the reading of old format graftstate file with newer mercurial
+
+  $ cat >> $TESTTMP/oldgraft.py <<EOF
+  > from __future__ import absolute_import
+  > from mercurial import merge, registrar, error
+  > cmdtable = {}
+  > command = registrar.command(cmdtable)
+  > @command(b'oldgraft', [(b'r', b'rev', [], b'revisions to graft')], ())
+  > def oldgraft(ui, repo, *args, **opts):
+  >     revs = opts[r'rev']
+  >     revs = [int(r) for r in revs]
+  >     for pos, ctx in enumerate(repo.set(b"%ld", revs)):
+  >         stats = merge.graft(repo, ctx, ctx.p1(), [b'local', b'graft'])
+  >         if stats.unresolvedcount:
+  >             nodelines = [repo[rev].hex() + b"\n" for rev in revs[pos:]]
+  >             with repo.wlock(), repo.vfs(b'graftstate', b'wb') as fp:
+  >                 fp.write(b''.join(nodelines))
+  >             raise error.Abort(b"unresolved conflicts")
+  >         else:
+  >             raise error.Abort(b"this command is only to write an old state"
+  >                               b"file for graft by creating conflicts. Doing graft without"
+  >                               b"conflicts should not be done by this")
+  > EOF
+
+  $ hg init oldgraft
+  $ cd oldgraft
+  $ for ch in a b c; do echo foo > $ch; hg add $ch; hg ci -Aqm "added "$ch; done;
+  $ hg log -GT "{rev}:{node|short} {desc}\n"
+  @  2:8be98ac1a569 added c
+  |
+  o  1:80e6d2c47cfe added b
+  |
+  o  0:f7ad41964313 added a
+  
+  $ hg up 0
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo bar > b
+  $ hg add b
+  $ hg ci -m "bar to b"
+  created new head
+  $ hg oldgraft -r 1 -r 2 --config extensions.oldgraft=$TESTTMP/oldgraft.py
+  merging b
+  warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
+  abort: unresolved conflicts
+  [255]
+
+  $ echo foo > b
+  $ hg resolve -m
+  (no more unresolved files)
+  continue: hg graft --continue
+  $ hg graft --continue
+  grafting 1:80e6d2c47cfe "added b"
+  grafting 2:8be98ac1a569 "added c"



To: pulkit, #hg-reviewers
Cc: durin42, mercurial-devel


More information about the Mercurial-devel mailing list