prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  merge_user should also remove the old user
  Currently `merge_user` does not actually remove the old user.  You need to run `purge_user` following `merge_user` to completely remove the user.  This is dangerous and error prone, especially on older instances that have a large number of users.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pootle/apps/accounts/management/commands/merge_user.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 # -*- coding: utf-8 -*-
  3 #
  4 # Copyright (C) Pootle contributors.
  5 #
  6 # This file is a part of the Pootle project. It is distributed under the GPL3
  7 # or later license. See the LICENSE file for a copy of the license and the
  8 # AUTHORS file for copyright and authorship information.
  9 
  10 import accounts
  11 
  12 from . import UserCommand
  13 
  14 
  15 class Command(UserCommand):
  16     args = "user other_user"
  17     help = "Merge user to other_user"
  18 
  19     def handle(self, *args, **kwargs):
  20         super(Command, self).handle(*args, **kwargs)
  21         accounts.utils.UserMerger(self.get_user(username=args[0]),
  22                                   self.get_user(username=args[1])).merge()
  23
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/pootle/apps/accounts/management/commands/merge_user.py b/pootle/apps/accounts/management/commands/merge_user.py
  --- a/pootle/apps/accounts/management/commands/merge_user.py
  +++ b/pootle/apps/accounts/management/commands/merge_user.py
  @@ -7,6 +7,8 @@
   # or later license. See the LICENSE file for a copy of the license and the
   # AUTHORS file for copyright and authorship information.
   
  +from optparse import make_option
  +
   import accounts
   
   from . import UserCommand
  @@ -15,8 +17,22 @@
   class Command(UserCommand):
       args = "user other_user"
       help = "Merge user to other_user"
  +    shared_option_list = (
  +        make_option("--no-delete",
  +                    dest='delete',
  +                    action="store_false",
  +                    default=True,
  +                    help="Don't delete user after merging."),
  +    )
  +    option_list = UserCommand.option_list + shared_option_list
   
       def handle(self, *args, **kwargs):
           super(Command, self).handle(*args, **kwargs)
  -        accounts.utils.UserMerger(self.get_user(username=args[0]),
  +        src_user = self.get_user(username=args[0])
  +        accounts.utils.UserMerger(src_user,
                                     self.get_user(username=args[1])).merge()
  +
  +        if kwargs.get("delete"):
  +            self.stdout.write("Deleting user: %s...\n" % src_user.username)
  +            src_user.delete()
  +            self.stdout.write("User deleted: %s\n" % src_user.username)
  
verification_info: {"golden_diff": "diff --git a/pootle/apps/accounts/management/commands/merge_user.py b/pootle/apps/accounts/management/commands/merge_user.py\n--- a/pootle/apps/accounts/management/commands/merge_user.py\n+++ b/pootle/apps/accounts/management/commands/merge_user.py\n@@ -7,6 +7,8 @@\n # or later license. See the LICENSE file for a copy of the license and the\n # AUTHORS file for copyright and authorship information.\n \n+from optparse import make_option\n+\n import accounts\n \n from . import UserCommand\n@@ -15,8 +17,22 @@\n class Command(UserCommand):\n     args = \"user other_user\"\n     help = \"Merge user to other_user\"\n+    shared_option_list = (\n+        make_option(\"--no-delete\",\n+                    dest='delete',\n+                    action=\"store_false\",\n+                    default=True,\n+                    help=\"Don't delete user after merging.\"),\n+    )\n+    option_list = UserCommand.option_list + shared_option_list\n \n     def handle(self, *args, **kwargs):\n         super(Command, self).handle(*args, **kwargs)\n-        accounts.utils.UserMerger(self.get_user(username=args[0]),\n+        src_user = self.get_user(username=args[0])\n+        accounts.utils.UserMerger(src_user,\n                                   self.get_user(username=args[1])).merge()\n+\n+        if kwargs.get(\"delete\"):\n+            self.stdout.write(\"Deleting user: %s...\\n\" % src_user.username)\n+            src_user.delete()\n+            self.stdout.write(\"User deleted: %s\\n\" % src_user.username)\n", "issue": "merge_user should also remove the old user\nCurrently `merge_user` does not actually remove the old user.  You need to run `purge_user` following `merge_user` to completely remove the user.  This is dangerous and error prone, especially on older instances that have a large number of users.\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nimport accounts\n\nfrom . import UserCommand\n\n\nclass Command(UserCommand):\n    args = \"user other_user\"\n    help = \"Merge user to other_user\"\n\n    def handle(self, *args, **kwargs):\n        super(Command, self).handle(*args, **kwargs)\n        accounts.utils.UserMerger(self.get_user(username=args[0]),\n                                  self.get_user(username=args[1])).merge()\n", "path": "pootle/apps/accounts/management/commands/merge_user.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom optparse import make_option\n\nimport accounts\n\nfrom . import UserCommand\n\n\nclass Command(UserCommand):\n    args = \"user other_user\"\n    help = \"Merge user to other_user\"\n    shared_option_list = (\n        make_option(\"--no-delete\",\n                    dest='delete',\n                    action=\"store_false\",\n                    default=True,\n                    help=\"Don't delete user after merging.\"),\n    )\n    option_list = UserCommand.option_list + shared_option_list\n\n    def handle(self, *args, **kwargs):\n        super(Command, self).handle(*args, **kwargs)\n        src_user = self.get_user(username=args[0])\n        accounts.utils.UserMerger(src_user,\n                                  self.get_user(username=args[1])).merge()\n\n        if kwargs.get(\"delete\"):\n            self.stdout.write(\"Deleting user: %s...\\n\" % src_user.username)\n            src_user.delete()\n            self.stdout.write(\"User deleted: %s\\n\" % src_user.username)\n", "path": "pootle/apps/accounts/management/commands/merge_user.py"}]}