diff mercurial/commands.py @ 254:c03f58e5fd2d

unify checkout and resolve into update -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 unify checkout and resolve into update This replaces checkout and resolve with a single command: $ hg help co hg update [node] update or merge working directory If there are no outstanding changes in the working directory and there is a linear relationship between the current version and the requested version, the result is the requested version. Otherwise the result is a merge between the contents of the current working directory and the requested version. Files that changed between either parent are marked as changed for the next commit and a commit must be performed before any further updates are allowed. manifest hash: 513d285d7fb775d0560de49387042a685ea062f7 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFComS7ywK+sNU5EO8RAmgRAJ96GA6qvHLy0Jp0fzUrR2os2azPuACePsdC YBldZtA7yIuTnV2vIbn7OSE= =QtM/ -----END PGP SIGNATURE-----
author mpm@selenic.com
date Sat, 04 Jun 2005 18:34:35 -0800
parents 5eda6c542978
children 20a44c82795f
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Jun 04 15:16:48 2005 -0800
+++ b/mercurial/commands.py	Sat Jun 04 18:34:35 2005 -0800
@@ -164,18 +164,6 @@
     if rev: n = r.lookup(rev)
     sys.stdout.write(r.read(n))
 
-def checkout(ui, repo, changeset=None):
-    '''checkout a given changeset or the current tip'''
-    (c, a, d, u) = repo.diffdir(repo.root)
-    if c or a or d:
-        ui.warn("aborting (outstanding changes in working directory)\n")
-        sys.exit(1)
-
-    node = repo.changelog.tip()
-    if changeset:
-        node = repo.lookup(changeset)
-    repo.checkout(node)
-
 def commit(ui, repo, *files):
     """commit the specified files or all outstanding changes"""
     repo.commit(relpath(repo, files))
@@ -405,14 +393,6 @@
     """remove the specified files on the next commit"""
     repo.remove(relpath(repo, (file,) + files))
 
-def resolve(ui, repo, node=None):
-    '''merge a given node or the current tip into the working dir'''
-    if not node:
-        node = repo.changelog.tip()
-    else:
-        node = repo.lookup(node)
-    repo.resolve(node)
-
 def serve(ui, repo, **opts):
     from mercurial import hgweb
     hgweb.server(repo.root, opts["name"], opts["templates"],
@@ -453,6 +433,22 @@
 def undo(ui, repo):
     repo.undo()
 
+def update(ui, repo, node=None):
+    '''update or merge working directory
+
+    If there are no outstanding changes in the working directory and
+    there is a linear relationship between the current version and the
+    requested version, the result is the requested version.
+
+    Otherwise the result is a merge between the contents of the
+    current working directory and the requested version. Files that
+    changed between either parent are marked as changed for the next
+    commit and a commit must be performed before any further updates
+    are allowed.
+    '''
+    node = node and repo.lookup(node) or repo.changelog.tip()
+    repo.update(node)
+
 def verify(ui, repo):
     """verify the integrity of the repository"""
     return repo.verify()
@@ -468,7 +464,6 @@
                      'hg annotate [-u] [-c] [-n] [-r id] [files]'),
     "branch|clone": (branch, [], 'hg branch [path]'),
     "cat|dump": (cat, [], 'hg cat <file> [rev]'),
-    "checkout|co": (checkout, [], 'hg checkout [changeset]'),
     "commit|ci": (commit, [], 'hg commit [files]'),
     "debugaddchangegroup": (debugaddchangegroup, [], 'debugaddchangegroup'),
     "debugchangegroup": (debugchangegroup, [], 'debugchangegroup [roots]'),
@@ -501,7 +496,6 @@
                   'hg rawcommit [options] [files]'),
     "recover": (recover, [], "hg recover"),
     "remove": (remove, [], "hg remove [files]"),
-    "resolve": (resolve, [], 'hg resolve [node]'),
     "serve": (serve, [('p', 'port', 8000, 'listen port'),
                       ('a', 'address', '', 'interface address'),
                       ('n', 'name', os.getcwd(), 'repository name'),
@@ -511,6 +505,7 @@
     "tags": (tags, [], 'hg tags'),
     "tip": (tip, [], 'hg tip'),
     "undo": (undo, [], 'hg undo'),
+    "update|up|checkout|co|resolve": (update, [], 'hg update [node]'),
     "verify": (verify, [], 'hg verify'),
     }