D6736: shelve: add method for storing mergestate in changeset extras
navaneeth.suresh (Navaneeth Suresh)
phabricator at mercurial-scm.org
Sat Aug 17 20:38:30 UTC 2019
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
We store mergestate records in `.hg/merge`. This patch adds a method
of storage in changeset extras. This will help in the exchange of
mergestate records to other repos. Also, this can be used by
`shelve --unresolved` to store the mergestate records.
It uses the storage format supported for hg versions 3.7 or later. For the
time being, I have omitted the storage of the content of the local version
of unresolved files.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D6736
AFFECTED FILES
mercurial/shelve.py
CHANGE DETAILS
diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -413,6 +413,36 @@
cmdutil.exportfile(repo, [node], fp, opts=mdiff.diffopts(git=True),
match=match)
+def _encodemergerecords(records):
+ """Encode mergestate records to store in changeset extras.
+ Takes list of tuples as input and returns str.
+ """
+ items = [
+ '%s\033%s' % (rtype, record)
+ for rtype, record in sorted(records)
+ ]
+ return "\n".join(items)
+
+def _decodemergerecords(data):
+ """Decode mergestate record from changeset extras to return
+ a list of tuples.
+ """
+ records = []
+ for l in data.split('\n'):
+ rtype, record = l.split('\033')
+ records.append((rtype, record))
+ return records
+
+def _storeunresolvedmerge(ui, repo, name=None, extra=None):
+ """Store the mergestate information in changeset extra
+
+ This will clear the mergestate and also stores the mergestate
+ information for later restoration.
+ """
+ ms = merge.mergestate.read(repo)
+ extra['mergerecords'] = _encodemergerecords(ms._readrecords())
+ ms.reset()
+
def _includeunknownfiles(repo, pats, opts, extra):
s = repo.status(match=scmutil.match(repo[None], pats, opts),
unknown=True)
To: navaneeth.suresh, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list