Commits

kankri committed 0fa627c

Strip the banner added by the "editconfig" command even if the user edited the
file (improves upon #d62acd3bd5bd).

  • Participants
  • Parent commits 65e0264

Comments (0)

Files changed (1)

File hgext/config.py

 
 def edit_config_file(ui, rc_file):
     orig_contents = open(rc_file, 'a+').read()
-    contents = "#HG: editing hg config file: %s\n\n%s" % (
-        rc_file, orig_contents)
+    banner = "#HG: editing hg config file: %s\n\n" % rc_file
+    contents = banner + orig_contents
     new_contents = ui.edit(contents, ui.username())
-    if new_contents != contents and new_contents != orig_contents:
+    new_contents = re.sub(r'^%s' % re.escape(banner), '', new_contents)
+    if new_contents != orig_contents:
         open(rc_file, 'w').write(new_contents)