Show More
@@ -413,6 +413,56 b' def getdescfromdrev(drev):' | |||||
413 | uri = 'Differential Revision: %s' % drev[r'uri'] |
|
413 | uri = 'Differential Revision: %s' % drev[r'uri'] | |
414 | return '\n\n'.join(filter(None, [title, summary, testplan, uri])) |
|
414 | return '\n\n'.join(filter(None, [title, summary, testplan, uri])) | |
415 |
|
415 | |||
|
416 | def getdiffmeta(diff): | |||
|
417 | """get commit metadata (date, node, user, p1) from a diff object | |||
|
418 | ||||
|
419 | The metadata could be "hg:meta", sent by phabsend, like: | |||
|
420 | ||||
|
421 | "properties": { | |||
|
422 | "hg:meta": { | |||
|
423 | "date": "1499571514 25200", | |||
|
424 | "node": "98c08acae292b2faf60a279b4189beb6cff1414d", | |||
|
425 | "user": "Foo Bar <foo@example.com>", | |||
|
426 | "parent": "6d0abad76b30e4724a37ab8721d630394070fe16" | |||
|
427 | } | |||
|
428 | } | |||
|
429 | ||||
|
430 | Or converted from "local:commits", sent by "arc", like: | |||
|
431 | ||||
|
432 | "properties": { | |||
|
433 | "local:commits": { | |||
|
434 | "98c08acae292b2faf60a279b4189beb6cff1414d": { | |||
|
435 | "author": "Foo Bar", | |||
|
436 | "time": 1499546314, | |||
|
437 | "branch": "default", | |||
|
438 | "tag": "", | |||
|
439 | "commit": "98c08acae292b2faf60a279b4189beb6cff1414d", | |||
|
440 | "rev": "98c08acae292b2faf60a279b4189beb6cff1414d", | |||
|
441 | "local": "1000", | |||
|
442 | "parents": ["6d0abad76b30e4724a37ab8721d630394070fe16"], | |||
|
443 | "summary": "...", | |||
|
444 | "message": "...", | |||
|
445 | "authorEmail": "foo@example.com" | |||
|
446 | } | |||
|
447 | } | |||
|
448 | } | |||
|
449 | ||||
|
450 | Note: metadata extracted from "local:commits" will lose time zone | |||
|
451 | information. | |||
|
452 | """ | |||
|
453 | props = diff.get(r'properties') or {} | |||
|
454 | meta = props.get(r'hg:meta') | |||
|
455 | if not meta and props.get(r'local:commits'): | |||
|
456 | commit = sorted(props[r'local:commits'].values())[0] | |||
|
457 | meta = { | |||
|
458 | r'date': r'%d 0' % commit[r'time'], | |||
|
459 | r'node': commit[r'rev'], | |||
|
460 | r'user': r'%s <%s>' % (commit[r'author'], commit[r'authorEmail']), | |||
|
461 | } | |||
|
462 | if len(commit.get(r'parents', ())) >= 1: | |||
|
463 | meta[r'parent'] = commit[r'parents'][0] | |||
|
464 | return meta or {} | |||
|
465 | ||||
416 | def readpatch(repo, params, write, stack=False): |
|
466 | def readpatch(repo, params, write, stack=False): | |
417 | """generate plain-text patch readable by 'hg import' |
|
467 | """generate plain-text patch readable by 'hg import' | |
418 |
|
468 | |||
@@ -438,9 +488,7 b' def readpatch(repo, params, write, stack' | |||||
438 | # Try to preserve metadata from hg:meta property. Write hg patch |
|
488 | # Try to preserve metadata from hg:meta property. Write hg patch | |
439 | # headers that can be read by the "import" command. See patchheadermap |
|
489 | # headers that can be read by the "import" command. See patchheadermap | |
440 | # and extract in mercurial/patch.py for supported headers. |
|
490 | # and extract in mercurial/patch.py for supported headers. | |
441 | props = diffs[str(diffid)][r'properties'] # could be empty list or dict |
|
491 | meta = getdiffmeta(diffs[str(diffid)]) | |
442 | if props and r'hg:meta' in props: |
|
|||
443 | meta = props[r'hg:meta'] |
|
|||
444 |
|
|
492 | for k in _metanamemap.keys(): | |
445 |
|
|
493 | if k in meta: | |
446 |
|
|
494 | header += '# %s %s\n' % (_metanamemap[k], meta[k]) |
General Comments 0
You need to be logged in to leave comments.
Login now