##// END OF EJS Templates
Make debuginstall actually attempt to use external patch and merge...
Matt Mackall -
r3846:18855084 default
parent child Browse files
Show More
@@ -10,7 +10,7 b' from node import *'
10 from i18n import gettext as _
10 from i18n import gettext as _
11 demandload(globals(), "bisect os re sys signal imp urllib pdb shlex stat")
11 demandload(globals(), "bisect os re sys signal imp urllib pdb shlex stat")
12 demandload(globals(), "fancyopts ui hg util lock revlog bundlerepo")
12 demandload(globals(), "fancyopts ui hg util lock revlog bundlerepo")
13 demandload(globals(), "difflib patch time help")
13 demandload(globals(), "difflib patch time help mdiff tempfile")
14 demandload(globals(), "traceback errno version atexit")
14 demandload(globals(), "traceback errno version atexit")
15 demandload(globals(), "archival changegroup cmdutil hgweb.server sshserver")
15 demandload(globals(), "archival changegroup cmdutil hgweb.server sshserver")
16
16
@@ -830,6 +830,13 b' def debugindexdot(ui, file_):'
830 def debuginstall(ui):
830 def debuginstall(ui):
831 '''test Mercurial installation'''
831 '''test Mercurial installation'''
832
832
833 def writetemp(contents):
834 (fd, name) = tempfile.mkstemp()
835 f = os.fdopen(fd, "wb")
836 f.write(contents)
837 f.close()
838 return name
839
833 problems = 0
840 problems = 0
834
841
835 # encoding
842 # encoding
@@ -867,7 +874,31 b' def debuginstall(ui):'
867 if not patcher:
874 if not patcher:
868 ui.write(_(" Can't find patch or gpatch in PATH\n"))
875 ui.write(_(" Can't find patch or gpatch in PATH\n"))
869 problems += 1
876 problems += 1
870 # should actually attempt a patch here
877 else:
878 # actually attempt a patch here
879 a = "1\n2\n3\n4\n"
880 b = "1\n2\n3\ninsert\n4\n"
881 d = mdiff.unidiff(a, None, b, None, "a")
882 fa = writetemp(a)
883 fd = writetemp(d)
884 fp = os.popen('%s %s %s' % (patcher, fa, fd))
885 files = []
886 output = ""
887 for line in fp:
888 output += line
889 if line.startswith('patching file '):
890 pf = util.parse_patch_output(line.rstrip())
891 files.append(pf)
892 if files != [fa]:
893 ui.write(_(" unexpected patch output!"))
894 ui.write(data)
895 problems += 1
896 a = file(fa).read()
897 if a != b:
898 ui.write(_(" patch test failed!"))
899 problems += 1
900 os.unlink(fa)
901 os.unlink(fd)
871
902
872 # merge helper
903 # merge helper
873 ui.status(_("Checking merge helper...\n"))
904 ui.status(_("Checking merge helper...\n"))
@@ -883,7 +914,22 b' def debuginstall(ui):'
883 else:
914 else:
884 ui.write(_(" Can't find merge helper '%s' in PATH\n") % cmd)
915 ui.write(_(" Can't find merge helper '%s' in PATH\n") % cmd)
885 problems += 1
916 problems += 1
886 # should attempt a non-conflicting merge here
917 else:
918 # actually attempt a patch here
919 fa = writetemp("1\n2\n3\n4\n")
920 fl = writetemp("1\n2\n3\ninsert\n4\n")
921 fr = writetemp("begin\n1\n2\n3\n4\n")
922 r = os.system('%s %s %s %s' % (cmd, fl, fa, fr))
923 if r:
924 ui.write(_(" got unexpected merge error %d!") % r)
925 problems += 1
926 m = file(fl).read()
927 if m != "begin\n1\n2\n3\ninsert\n4\n":
928 ui.write(_(" got unexpected merge results!") % r)
929 ui.write(m)
930 os.unlink(fa)
931 os.unlink(fl)
932 os.unlink(fr)
887
933
888 # editor
934 # editor
889 ui.status(_("Checking commit editor...\n"))
935 ui.status(_("Checking commit editor...\n"))
@@ -1,3 +1,3 b''
1 #!/bin/sh
1 #!/bin/sh
2
2
3 hg debuginstall
3 HGMERGE=merge hg debuginstall
General Comments 0
You need to be logged in to leave comments. Login now