##// END OF EJS Templates
commands: add a new debug command to print merge state...
Siddharth Agarwal -
r26501:0748083f default
parent child Browse files
Show More
@@ -2476,6 +2476,71 b' def debuglabelcomplete(ui, repo, *args):'
2476 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
2476 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
2477 debugnamecomplete(ui, repo, *args)
2477 debugnamecomplete(ui, repo, *args)
2478
2478
2479 @command('debugmergestate', [], '')
2480 def debugmergestate(ui, repo, *args):
2481 """print merge state
2482
2483 Use --verbose to print out information about whether v1 or v2 merge state
2484 was chosen."""
2485 def printrecords(version):
2486 ui.write(('* version %s records\n') % version)
2487 if version == 1:
2488 records = v1records
2489 else:
2490 records = v2records
2491
2492 for rtype, record in records:
2493 # pretty print some record types
2494 if rtype == 'L':
2495 ui.write(('local: %s\n') % record)
2496 elif rtype == 'O':
2497 ui.write(('other: %s\n') % record)
2498 elif rtype == 'F':
2499 r = record.split('\0')
2500 f, state, hash, lfile, afile, anode, ofile = r[0:7]
2501 if version == 1:
2502 onode = 'not stored in v1 format'
2503 flags = r[7]
2504 else:
2505 onode, flags = r[7:9]
2506 ui.write(('file: %s (state "%s", hash %s)\n')
2507 % (f, state, hash))
2508 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
2509 ui.write((' ancestor path: %s (node %s)\n') % (afile, anode))
2510 ui.write((' other path: %s (node %s)\n') % (ofile, onode))
2511 else:
2512 ui.write(('unrecognized entry: %s\t%s\n')
2513 % (rtype, record.replace('\0', '\t')))
2514
2515 ms = mergemod.mergestate(repo)
2516
2517 # sort so that reasonable information is on top
2518 v1records = ms._readrecordsv1()
2519 v2records = ms._readrecordsv2()
2520 order = 'LO'
2521 def key(r):
2522 idx = order.find(r[0])
2523 if idx == -1:
2524 return (1, r[1])
2525 else:
2526 return (0, idx)
2527 v1records.sort(key=key)
2528 v2records.sort(key=key)
2529
2530 if not v1records and not v2records:
2531 ui.write(('no merge state found\n'))
2532 elif not v2records:
2533 ui.note(('no version 2 merge state\n'))
2534 printrecords(1)
2535 elif ms._v1v2match(v1records, v2records):
2536 ui.note(('v1 and v2 states match: using v2\n'))
2537 printrecords(2)
2538 else:
2539 ui.note(('v1 and v2 states mismatch: using v1\n'))
2540 printrecords(1)
2541 if ui.verbose:
2542 printrecords(2)
2543
2479 @command('debugnamecomplete', [], _('NAME...'))
2544 @command('debugnamecomplete', [], _('NAME...'))
2480 def debugnamecomplete(ui, repo, *args):
2545 def debugnamecomplete(ui, repo, *args):
2481 '''complete "names" - tags, open branch names, bookmark names'''
2546 '''complete "names" - tags, open branch names, bookmark names'''
@@ -593,6 +593,23 b' Test usage of `hg resolve` in case of co'
593 use 'hg resolve' to retry unresolved file merges
593 use 'hg resolve' to retry unresolved file merges
594 [1]
594 [1]
595 $ hg status
595 $ hg status
596 $ hg debugmergestate
597 * version 2 records
598 local: b71750c4b0fdf719734971e3ef90dbeab5919a2d
599 other: a30dd8addae3ce71b8667868478542bc417439e6
600 file: foo (state "u", hash 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33)
601 local path: foo (flags "")
602 ancestor path: foo (node f89532f44c247a0e993d63e3a734dd781ab04708)
603 other path: foo (node f50039b486d6fa1a90ae51778388cad161f425ee)
604 $ mv .hg/merge/state2 .hg/merge/state2-moved
605 $ hg debugmergestate
606 * version 1 records
607 local: b71750c4b0fdf719734971e3ef90dbeab5919a2d
608 file: foo (state "u", hash 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33)
609 local path: foo (flags "")
610 ancestor path: foo (node f89532f44c247a0e993d63e3a734dd781ab04708)
611 other path: foo (node not stored in v1 format)
612 $ mv .hg/merge/state2-moved .hg/merge/state2
596 $ hg resolve -l # still unresolved
613 $ hg resolve -l # still unresolved
597 U foo
614 U foo
598 $ hg summary
615 $ hg summary
@@ -91,6 +91,7 b' Show debug commands if there are no othe'
91 debugknown
91 debugknown
92 debuglabelcomplete
92 debuglabelcomplete
93 debuglocks
93 debuglocks
94 debugmergestate
94 debugnamecomplete
95 debugnamecomplete
95 debugobsolete
96 debugobsolete
96 debugpathcomplete
97 debugpathcomplete
@@ -251,6 +252,7 b' Show all commands + options'
251 debugknown:
252 debugknown:
252 debuglabelcomplete:
253 debuglabelcomplete:
253 debuglocks: force-lock, force-wlock
254 debuglocks: force-lock, force-wlock
255 debugmergestate:
254 debugnamecomplete:
256 debugnamecomplete:
255 debugobsolete: flags, record-parents, rev, date, user
257 debugobsolete: flags, record-parents, rev, date, user
256 debugpathcomplete: full, normal, added, removed
258 debugpathcomplete: full, normal, added, removed
@@ -810,6 +810,8 b' Test list of internal help commands'
810 debuginstall test Mercurial installation
810 debuginstall test Mercurial installation
811 debugknown test whether node ids are known to a repo
811 debugknown test whether node ids are known to a repo
812 debuglocks show or modify state of locks
812 debuglocks show or modify state of locks
813 debugmergestate
814 print merge state
813 debugnamecomplete
815 debugnamecomplete
814 complete "names" - tags, open branch names, bookmark names
816 complete "names" - tags, open branch names, bookmark names
815 debugobsolete
817 debugobsolete
General Comments 0
You need to be logged in to leave comments. Login now