Skip to content

Commit

Permalink
status: remove pickle formatter, fix test
Browse files Browse the repository at this point in the history
Summary:
Remove pickle formatter, as part of python3 migration.

Fix test-status.t for python3 compatibility.

Remove test-status.t python2 requirement.

Reviewed By: xavierd

Differential Revision: D22121912

fbshipit-source-id: 1cfdd18880198ef16973463ed24cf9afb28a7afb
  • Loading branch information
Meyer Jacobs authored and facebook-github-bot committed Jun 19, 2020
1 parent da38165 commit 49d5ada
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
24 changes: 1 addition & 23 deletions eden/scm/edenscm/mercurial/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@
from .node import hex, short


# pyre-fixme[11]: Annotation `pickle` is not defined as a type.
pickle = util.pickle


class _nullconverter(object):
"""convert non-primitive data types to be processed by formatter"""

Expand All @@ -140,9 +136,7 @@ def formatdate(date, fmt):
@staticmethod
def formatdict(data, key, value, fmt, sep):
"""convert dict or key-value pairs to appropriate dict format"""
# use plain dict instead of util.sortdict so that data can be
# serialized as a builtin dict in pickle output
return dict(data)
return data

@staticmethod
def formatlist(data, name, fmt, sep):
Expand Down Expand Up @@ -355,20 +349,6 @@ def end(self):
self._out.write("]\n")


class pickleformatter(baseformatter):
def __init__(self, ui, out, topic, opts):
baseformatter.__init__(self, ui, topic, opts, _nullconverter)
self._out = out
self._data = []

def _showitem(self):
self._data.append(self._item)

def end(self):
baseformatter.end(self)
self._out.write(pickle.dumps(self._data))


class jsonformatter(baseformatter):
def __init__(self, ui, out, topic, opts):
baseformatter.__init__(self, ui, topic, opts, _nullconverter)
Expand Down Expand Up @@ -587,8 +567,6 @@ def formatter(ui, out, topic, opts):
template = opts.get("template", "")
if template == "json":
return jsonformatter(ui, out, topic, opts)
elif template == "pickle":
return pickleformatter(ui, out, topic, opts)
elif template == "debug":
return debugformatter(ui, out, topic, opts)
elif template != "":
Expand Down
12 changes: 2 additions & 10 deletions eden/scm/tests/test-status.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#require py2
#chg-compatible

$ hg init repo1
Expand Down Expand Up @@ -231,13 +230,6 @@ hg status -A:
}
]

$ hg status -A -Tpickle > pickle
>>> from __future__ import print_function
>>> import pickle
>>> print(sorted((x['status'], x['path']) for x in pickle.load(open("pickle"))))
[('!', 'deleted'), ('?', 'pickle'), ('?', 'unknown'), ('A', 'added'), ('A', 'copied'), ('C', '.gitignore'), ('C', 'modified'), ('I', 'ignored'), ('R', 'removed')]
$ rm pickle

$ echo "ignoreddir/" > .gitignore
$ mkdir ignoreddir
$ touch ignoreddir/file
Expand Down Expand Up @@ -447,12 +439,12 @@ hg status of binary file starting with '\1\n', a separator for metadata:

$ hg init repo5
$ cd repo5
>>> _ = open("010a", "wb").write("\1\nfoo")
>>> _ = open("010a", "wb").write(b"\1\nfoo")
$ hg ci -q -A -m 'initial checkin'
$ hg status -A
C 010a

>>> _ = open("010a", "wb").write("\1\nbar")
>>> _ = open("010a", "wb").write(b"\1\nbar")
$ hg status -A
M 010a
$ hg ci -q -m 'modify 010a'
Expand Down

0 comments on commit 49d5ada

Please sign in to comment.