##// END OF EJS Templates
add backout command....
Vadim Gelfer -
r2158:ec96c451 default
parent child Browse files
Show More
@@ -0,0 +1,51 b''
1 #!/bin/sh
2
3 echo '# basic operation'
4 hg init basic
5 cd basic
6 echo a > a
7 hg commit -d '0 0' -A -m a
8 echo b >> a
9 hg commit -d '1 0' -m b
10
11 hg backout -d '2 0' tip
12 cat a
13
14 echo '# file that was removed is recreated'
15 cd ..
16 hg init remove
17 cd remove
18
19 echo content > a
20 hg commit -d '0 0' -A -m a
21
22 hg rm a
23 hg commit -d '1 0' -m b
24
25 hg backout -d '2 0' --merge tip
26 cat a
27
28 echo '# backout of backout is as if nothing happened'
29
30 hg backout -d '3 0' --merge tip
31 cat a
32
33 echo '# backout with merge'
34 cd ..
35 hg init merge
36 cd merge
37
38 echo line 1 > a
39 hg commit -d '0 0' -A -m a
40
41 echo line 2 >> a
42 hg commit -d '1 0' -m b
43
44 echo line 3 >> a
45 hg commit -d '2 0' -m c
46
47 hg backout --merge -d '3 0' 1
48 hg commit -d '4 0' -m d
49 cat a
50
51 exit 0
@@ -0,0 +1,19 b''
1 # basic operation
2 adding a
3 changeset 2:b38a34ddfd9f backs out changeset 1:a820f4f40a57
4 a
5 # file that was removed is recreated
6 adding a
7 adding a
8 changeset 2:44cd84c7349a backs out changeset 1:76862dcce372
9 content
10 # backout of backout is as if nothing happened
11 removing a
12 changeset 3:0dd8a0ed5e99 backs out changeset 2:44cd84c7349a
13 cat: a: No such file or directory
14 # backout with merge
15 adding a
16 changeset 3:6c77ecc28460 backs out changeset 1:314f55b1bf23
17 merging with changeset 2:b66ea5b77abb
18 merging a
19 line 1
@@ -19,6 +19,11 b' class UnknownCommand(Exception):'
19 class AmbiguousCommand(Exception):
19 class AmbiguousCommand(Exception):
20 """Exception raised if command shortcut matches more than one command."""
20 """Exception raised if command shortcut matches more than one command."""
21
21
22 def bail_if_changed(repo):
23 modified, added, removed, deleted, unknown = repo.changes()
24 if modified or added or removed or deleted:
25 raise util.Abort(_("outstanding uncommitted changes"))
26
22 def filterfiles(filters, files):
27 def filterfiles(filters, files):
23 l = [x for x in files if x in filters]
28 l = [x for x in files if x in filters]
24
29
@@ -930,6 +935,44 b' def archive(ui, repo, dest, **opts):'
930 archival.archive(repo, dest, node, opts.get('type') or 'files',
935 archival.archive(repo, dest, node, opts.get('type') or 'files',
931 not opts['no_decode'], matchfn, prefix)
936 not opts['no_decode'], matchfn, prefix)
932
937
938 def backout(ui, repo, rev, **opts):
939 '''reverse effect of earlier changeset
940
941 Commit the backed out changes as a new changeset.
942
943 If you back out a changeset other than the tip, a new head is
944 created. The --merge option remembers the parent of the working
945 directory before starting the backout, then merges the new head
946 with it afterwards, to save you from doing this by hand. The
947 result of this merge is not committed, as for a normal merge.'''
948
949 bail_if_changed(repo)
950 op1, op2 = repo.dirstate.parents()
951 if op2 != nullid:
952 raise util.Abort(_('outstanding uncommitted merge'))
953 node = repo.lookup(rev)
954 parent, p2 = repo.changelog.parents(node)
955 if parent == nullid:
956 raise util.Abort(_('cannot back out a change with no parents'))
957 if p2 != nullid:
958 raise util.Abort(_('cannot back out a merge'))
959 repo.update(node, force=True)
960 revert_opts = opts.copy()
961 revert_opts['rev'] = hex(parent)
962 revert(ui, repo, **revert_opts)
963 commit_opts = opts.copy()
964 commit_opts['addremove'] = False
965 if not commit_opts['message']:
966 commit_opts['message'] = _("Backed out changeset %s") % (hex(node))
967 commit(ui, repo, **commit_opts)
968 def nice(node):
969 return '%d:%s' % (repo.changelog.rev(node), short(node))
970 ui.status(_('changeset %s backs out changeset %s\n') %
971 (nice(repo.changelog.tip()), nice(node)))
972 if opts['merge'] and op1 != node:
973 ui.status(_('merging with changeset %s\n') % nice(op1))
974 update(ui, repo, hex(op1), **opts)
975
933 def bundle(ui, repo, fname, dest="default-push", **opts):
976 def bundle(ui, repo, fname, dest="default-push", **opts):
934 """create a changegroup file
977 """create a changegroup file
935
978
@@ -1797,9 +1840,7 b' def import_(ui, repo, patch1, *patches, '
1797 patches = (patch1,) + patches
1840 patches = (patch1,) + patches
1798
1841
1799 if not opts['force']:
1842 if not opts['force']:
1800 modified, added, removed, deleted, unknown = repo.changes()
1843 bail_if_changed(repo)
1801 if modified or added or removed or deleted:
1802 raise util.Abort(_("outstanding uncommitted changes"))
1803
1844
1804 d = opts["base"]
1845 d = opts["base"]
1805 strip = opts["strip"]
1846 strip = opts["strip"]
@@ -2899,6 +2940,17 b' table = {'
2899 ('I', 'include', [], _('include names matching the given patterns')),
2940 ('I', 'include', [], _('include names matching the given patterns')),
2900 ('X', 'exclude', [], _('exclude names matching the given patterns'))],
2941 ('X', 'exclude', [], _('exclude names matching the given patterns'))],
2901 _('hg archive [OPTION]... DEST')),
2942 _('hg archive [OPTION]... DEST')),
2943 'backout':
2944 (backout,
2945 [('', 'message', '', _('use <text> as commit message')),
2946 ('', 'merge', None, _('merge with old dirstate parent after backout')),
2947 ('l', 'logfile', '', _('read commit message from <file>')),
2948 ('d', 'date', '', _('record datecode as commit date')),
2949 ('u', 'user', '', _('record user as committer')),
2950 ('I', 'include', [], _('include names matching the given patterns')),
2951 ('X', 'exclude', [], _('exclude names matching the given patterns'))],
2952 _('hg backout [OPTION]... [FILE]...')),
2953
2902 "bundle":
2954 "bundle":
2903 (bundle,
2955 (bundle,
2904 [('f', 'force', None,
2956 [('f', 'force', None,
@@ -42,6 +42,7 b' list of commands (use "hg help -v" to sh'
42 addremove add all new files, delete all missing files
42 addremove add all new files, delete all missing files
43 annotate show changeset information per file line
43 annotate show changeset information per file line
44 archive create unversioned archive of a repository revision
44 archive create unversioned archive of a repository revision
45 backout reverse effect of earlier changeset
45 bundle create a changegroup file
46 bundle create a changegroup file
46 cat output the latest or given revisions of files
47 cat output the latest or given revisions of files
47 clone make a copy of an existing repository
48 clone make a copy of an existing repository
@@ -84,6 +85,7 b' list of commands (use "hg help -v" to sh'
84 addremove add all new files, delete all missing files
85 addremove add all new files, delete all missing files
85 annotate show changeset information per file line
86 annotate show changeset information per file line
86 archive create unversioned archive of a repository revision
87 archive create unversioned archive of a repository revision
88 backout reverse effect of earlier changeset
87 bundle create a changegroup file
89 bundle create a changegroup file
88 cat output the latest or given revisions of files
90 cat output the latest or given revisions of files
89 clone make a copy of an existing repository
91 clone make a copy of an existing repository
General Comments 0
You need to be logged in to leave comments. Login now