Submitter | phabricator |
---|---|
Date | Aug. 17, 2019, 8:38 p.m. |
Message ID | <differential-rev-PHID-DREV-hmecco3yaeef3hy5k5tb-req@mercurial-scm.org> |
Download | mbox | patch |
Permalink | /patch/41339/ |
State | Superseded |
Headers | show |
Comments
pulkit added inline comments. INLINE COMMENTS > shelve.py:416 > > +def _encodemergerecords(records): > + """Encode mergestate records to store in changeset extras. What do you think about refactoring the code to write mergestate v2 on disk and use that encoding to achieve this? REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6736/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6736 To: navaneeth.suresh, #hg-reviewers Cc: pulkit, mercurial-devel
navaneeth.suresh added inline comments. INLINE COMMENTS > pulkit wrote in shelve.py:416 > What do you think about refactoring the code to write mergestate v2 on disk and use that encoding to achieve this? i feel like the current approach is more simpler and easy to understand. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6736/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6736 To: navaneeth.suresh, #hg-reviewers Cc: pulkit, mercurial-devel
pulkit added inline comments. INLINE COMMENTS > navaneeth.suresh wrote in shelve.py:416 > i feel like the current approach is more simpler and easy to understand. It will be nice to use only way to encode mergestates at all the places. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6736/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6736 To: navaneeth.suresh, #hg-reviewers Cc: pulkit, mercurial-devel
navaneeth.suresh added inline comments. INLINE COMMENTS > pulkit wrote in shelve.py:416 > It will be nice to use only way to encode mergestates at all the places. Done and created D6966 <https://phab.mercurial-scm.org/D6966>. Abandoning this. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6736/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6736 To: navaneeth.suresh, #hg-reviewers Cc: pulkit, mercurial-devel
Patch
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)