Show More
@@ -2555,7 +2555,7 b' def amend(ui, repo, old, extra, pats, op' | |||||
2555 | mapping = {old.node(): (newid,)} |
|
2555 | mapping = {old.node(): (newid,)} | |
2556 | obsmetadata = None |
|
2556 | obsmetadata = None | |
2557 | if opts.get('note'): |
|
2557 | if opts.get('note'): | |
2558 | obsmetadata = {'note': opts['note']} |
|
2558 | obsmetadata = {'note': encoding.fromlocal(opts['note'])} | |
2559 | scmutil.cleanupnodes(repo, mapping, 'amend', metadata=obsmetadata, |
|
2559 | scmutil.cleanupnodes(repo, mapping, 'amend', metadata=obsmetadata, | |
2560 | fixphase=True, targetphase=commitphase) |
|
2560 | fixphase=True, targetphase=commitphase) | |
2561 |
|
2561 |
@@ -1619,7 +1619,7 b' def debugobsolete(ui, repo, precursor=No' | |||||
1619 | if opts['rev']: |
|
1619 | if opts['rev']: | |
1620 | raise error.Abort('cannot select revision when creating marker') |
|
1620 | raise error.Abort('cannot select revision when creating marker') | |
1621 | metadata = {} |
|
1621 | metadata = {} | |
1622 | metadata['user'] = opts['user'] or ui.username() |
|
1622 | metadata['user'] = encoding.fromlocal(opts['user'] or ui.username()) | |
1623 | succs = tuple(parsenodeid(succ) for succ in successors) |
|
1623 | succs = tuple(parsenodeid(succ) for succ in successors) | |
1624 | l = repo.lock() |
|
1624 | l = repo.lock() | |
1625 | try: |
|
1625 | try: |
@@ -74,6 +74,7 b' import struct' | |||||
74 |
|
74 | |||
75 | from .i18n import _ |
|
75 | from .i18n import _ | |
76 | from . import ( |
|
76 | from . import ( | |
|
77 | encoding, | |||
77 | error, |
|
78 | error, | |
78 | node, |
|
79 | node, | |
79 | obsutil, |
|
80 | obsutil, | |
@@ -526,7 +527,7 b' class obsstore(object):' | |||||
526 | # prec: nodeid, predecessors changesets |
|
527 | # prec: nodeid, predecessors changesets | |
527 | # succs: tuple of nodeid, successor changesets (0-N length) |
|
528 | # succs: tuple of nodeid, successor changesets (0-N length) | |
528 | # flag: integer, flag field carrying modifier for the markers (see doc) |
|
529 | # flag: integer, flag field carrying modifier for the markers (see doc) | |
529 | # meta: binary blob, encoded metadata dictionary |
|
530 | # meta: binary blob in UTF-8, encoded metadata dictionary | |
530 | # date: (float, int) tuple, date of marker creation |
|
531 | # date: (float, int) tuple, date of marker creation | |
531 | # parents: (tuple of nodeid) or None, parents of predecessors |
|
532 | # parents: (tuple of nodeid) or None, parents of predecessors | |
532 | # None is used when no data has been recorded |
|
533 | # None is used when no data has been recorded | |
@@ -950,7 +951,8 b' def createmarkers(repo, relations, flag=' | |||||
950 | <relations> must be an iterable of (<old>, (<new>, ...)[,{metadata}]) |
|
951 | <relations> must be an iterable of (<old>, (<new>, ...)[,{metadata}]) | |
951 | tuple. `old` and `news` are changectx. metadata is an optional dictionary |
|
952 | tuple. `old` and `news` are changectx. metadata is an optional dictionary | |
952 | containing metadata for this marker only. It is merged with the global |
|
953 | containing metadata for this marker only. It is merged with the global | |
953 |
metadata specified through the `metadata` argument of this function |
|
954 | metadata specified through the `metadata` argument of this function. | |
|
955 | Any string values in metadata must be UTF-8 bytes. | |||
954 |
|
956 | |||
955 | Trying to obsolete a public changeset will raise an exception. |
|
957 | Trying to obsolete a public changeset will raise an exception. | |
956 |
|
958 | |||
@@ -964,11 +966,8 b' def createmarkers(repo, relations, flag=' | |||||
964 | if metadata is None: |
|
966 | if metadata is None: | |
965 | metadata = {} |
|
967 | metadata = {} | |
966 | if 'user' not in metadata: |
|
968 | if 'user' not in metadata: | |
967 |
|
|
969 | luser = repo.ui.config('devel', 'user.obsmarker') or repo.ui.username() | |
968 | if develuser: |
|
970 | metadata['user'] = encoding.fromlocal(luser) | |
969 | metadata['user'] = develuser |
|
|||
970 | else: |
|
|||
971 | metadata['user'] = repo.ui.username() |
|
|||
972 |
|
971 | |||
973 | # Operation metadata handling |
|
972 | # Operation metadata handling | |
974 | useoperation = repo.ui.configbool('experimental', |
|
973 | useoperation = repo.ui.configbool('experimental', |
@@ -12,6 +12,7 b' import re' | |||||
12 | from .i18n import _ |
|
12 | from .i18n import _ | |
13 | from . import ( |
|
13 | from . import ( | |
14 | diffutil, |
|
14 | diffutil, | |
|
15 | encoding, | |||
15 | node as nodemod, |
|
16 | node as nodemod, | |
16 | phases, |
|
17 | phases, | |
17 | util, |
|
18 | util, | |
@@ -822,7 +823,8 b' def markersusers(markers):' | |||||
822 | """ Returns a sorted list of markers users without duplicates |
|
823 | """ Returns a sorted list of markers users without duplicates | |
823 | """ |
|
824 | """ | |
824 | markersmeta = [dict(m[3]) for m in markers] |
|
825 | markersmeta = [dict(m[3]) for m in markers] | |
825 |
users = set(meta['user'] for meta in markersmeta |
|
826 | users = set(encoding.tolocal(meta['user']) for meta in markersmeta | |
|
827 | if meta.get('user')) | |||
826 |
|
828 | |||
827 | return sorted(users) |
|
829 | return sorted(users) | |
828 |
|
830 |
@@ -2581,3 +2581,61 b' Check other fatelog implementations' | |||||
2581 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
2581 | date: Thu Jan 01 00:00:00 1970 +0000 | |
2582 | summary: ROOT |
|
2582 | summary: ROOT | |
2583 |
|
2583 | |||
|
2584 | ||||
|
2585 | Test metadata encoding (issue5754) | |||
|
2586 | ================================== | |||
|
2587 | ||||
|
2588 | $ hg init $TESTTMP/metadata-encoding | |||
|
2589 | $ cd $TESTTMP/metadata-encoding | |||
|
2590 | $ cat <<'EOF' >> .hg/hgrc | |||
|
2591 | > [extensions] | |||
|
2592 | > amend = | |||
|
2593 | > EOF | |||
|
2594 | $ $PYTHON <<'EOF' | |||
|
2595 | > with open('test1', 'wb') as f: | |||
|
2596 | > f.write(b't\xe8st1') and None | |||
|
2597 | > with open('test2', 'wb') as f: | |||
|
2598 | > f.write(b't\xe8st2') and None | |||
|
2599 | > EOF | |||
|
2600 | $ mkcommit ROOT | |||
|
2601 | $ HGENCODING=latin-1 HGUSER="`cat test1`" mkcommit A0 | |||
|
2602 | $ echo 42 >> A0 | |||
|
2603 | $ hg amend -m "A1" --note "`cat test2`" | |||
|
2604 | $ HGENCODING=latin-1 hg amend -m "A2" \ | |||
|
2605 | > --config devel.user.obsmarker="`cat test2`" | |||
|
2606 | $ mkcommit B0 | |||
|
2607 | $ HGENCODING=latin-1 hg debugobsolete -u "`cat test2`" "`getid 'desc(B0)'`" | |||
|
2608 | obsoleted 1 changesets | |||
|
2609 | ||||
|
2610 | metadata should be stored in UTF-8, and debugobsolete doesn't decode it to | |||
|
2611 | local encoding since the command is supposed to show unmodified content: | |||
|
2612 | ||||
|
2613 | $ HGENCODING=latin-1 hg debugobsolete | |||
|
2614 | 5f66a482f0bb2fcaccfc215554ad5eb9f40b50f5 718c0d00cee1429bdb73064e0d88908c601507a8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'note': 't\xc3\xa8st2', 'operation': 'amend', 'user': 't\xc3\xa8st1'} | |||
|
2615 | 718c0d00cee1429bdb73064e0d88908c601507a8 1132562159b35bb27e1d6b80c80ee94a1659a4da 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 't\xc3\xa8st2'} | |||
|
2616 | e1724525bc3bec4472d7915a02811b938004a7a2 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 't\xc3\xa8st2'} | |||
|
2617 | ||||
|
2618 | metadata should be converted back to local encoding when displaying: | |||
|
2619 | ||||
|
2620 | $ HGENCODING=latin-1 hg fatelog --hidden | |||
|
2621 | @ e1724525bc3b | |||
|
2622 | | Obsfate: pruned by t\xe8st2 (at 1970-01-01 00:00 +0000); (esc) | |||
|
2623 | o 1132562159b3 | |||
|
2624 | | | |||
|
2625 | | x 718c0d00cee1 | |||
|
2626 | |/ Obsfate: rewritten using amend as 3:1132562159b3 by t\xe8st2 (at 1970-01-01 00:00 +0000); (esc) | |||
|
2627 | | x 5f66a482f0bb | |||
|
2628 | |/ Obsfate: rewritten using amend as 2:718c0d00cee1 by t\xe8st1 (at 1970-01-01 00:00 +0000); (esc) | |||
|
2629 | o ea207398892e | |||
|
2630 | ||||
|
2631 | $ HGENCODING=utf-8 hg fatelog --hidden | |||
|
2632 | @ e1724525bc3b | |||
|
2633 | | Obsfate: pruned by t\xc3\xa8st2 (at 1970-01-01 00:00 +0000); (esc) | |||
|
2634 | o 1132562159b3 | |||
|
2635 | | | |||
|
2636 | | x 718c0d00cee1 | |||
|
2637 | |/ Obsfate: rewritten using amend as 3:1132562159b3 by t\xc3\xa8st2 (at 1970-01-01 00:00 +0000); (esc) | |||
|
2638 | | x 5f66a482f0bb | |||
|
2639 | |/ Obsfate: rewritten using amend as 2:718c0d00cee1 by t\xc3\xa8st1 (at 1970-01-01 00:00 +0000); (esc) | |||
|
2640 | o ea207398892e | |||
|
2641 |
General Comments 0
You need to be logged in to leave comments.
Login now