##// END OF EJS Templates
graft: add no-commit mode (issue5631)...
Sushil khanchi -
r38492:622f79e3 default
parent child Browse files
Show More
@@ -2111,6 +2111,8 b' def forget(ui, repo, *pats, **opts):'
2111 ('', 'abort', False, _('abort interrupted graft')),
2111 ('', 'abort', False, _('abort interrupted graft')),
2112 ('e', 'edit', False, _('invoke editor on commit messages')),
2112 ('e', 'edit', False, _('invoke editor on commit messages')),
2113 ('', 'log', None, _('append graft info to log message')),
2113 ('', 'log', None, _('append graft info to log message')),
2114 ('', 'no-commit', None,
2115 _("don't commit, just apply the changes in working directory")),
2114 ('f', 'force', False, _('force graft')),
2116 ('f', 'force', False, _('force graft')),
2115 ('D', 'currentdate', False,
2117 ('D', 'currentdate', False,
2116 _('record the current date as commit date')),
2118 _('record the current date as commit date')),
@@ -2200,6 +2202,20 b' def _dograft(ui, repo, *revs, **opts):'
2200 **pycompat.strkwargs(opts))
2202 **pycompat.strkwargs(opts))
2201
2203
2202 cont = False
2204 cont = False
2205 if opts.get('no_commit'):
2206 if opts.get('edit'):
2207 raise error.Abort(_("cannot specify --no-commit and "
2208 "--edit together"))
2209 if opts.get('currentuser'):
2210 raise error.Abort(_("cannot specify --no-commit and "
2211 "--currentuser together"))
2212 if opts.get('currentdate'):
2213 raise error.Abort(_("cannot specify --no-commit and "
2214 "--currentdate together"))
2215 if opts.get('log'):
2216 raise error.Abort(_("cannot specify --no-commit and "
2217 "--log together"))
2218
2203 graftstate = statemod.cmdstate(repo, 'graftstate')
2219 graftstate = statemod.cmdstate(repo, 'graftstate')
2204
2220
2205 if opts.get('stop'):
2221 if opts.get('stop'):
@@ -2237,6 +2253,8 b' def _dograft(ui, repo, *revs, **opts):'
2237 opts['user'] = statedata['user']
2253 opts['user'] = statedata['user']
2238 if statedata.get('log'):
2254 if statedata.get('log'):
2239 opts['log'] = True
2255 opts['log'] = True
2256 if statedata.get('no_commit'):
2257 opts['no_commit'] = statedata.get('no_commit')
2240 nodes = statedata['nodes']
2258 nodes = statedata['nodes']
2241 revs = [repo[node].rev() for node in nodes]
2259 revs = [repo[node].rev() for node in nodes]
2242 else:
2260 else:
@@ -2323,6 +2341,8 b' def _dograft(ui, repo, *revs, **opts):'
2323 if not revs:
2341 if not revs:
2324 return -1
2342 return -1
2325
2343
2344 if opts.get('no_commit'):
2345 statedata['no_commit'] = True
2326 for pos, ctx in enumerate(repo.set("%ld", revs)):
2346 for pos, ctx in enumerate(repo.set("%ld", revs)):
2327 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
2347 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
2328 ctx.description().split('\n', 1)[0])
2348 ctx.description().split('\n', 1)[0])
@@ -2373,9 +2393,10 b' def _dograft(ui, repo, *revs, **opts):'
2373 else:
2393 else:
2374 cont = False
2394 cont = False
2375
2395
2376 # commit
2396 # commit if --no-commit is false
2377 node = repo.commit(text=message, user=user,
2397 if not opts.get('no_commit'):
2378 date=date, extra=extra, editor=editor)
2398 node = repo.commit(text=message, user=user, date=date, extra=extra,
2399 editor=editor)
2379 if node is None:
2400 if node is None:
2380 ui.warn(
2401 ui.warn(
2381 _('note: graft of %d:%s created no changes to commit\n') %
2402 _('note: graft of %d:%s created no changes to commit\n') %
@@ -312,7 +312,7 b' Show all commands + options'
312 debugwireargs: three, four, five, ssh, remotecmd, insecure
312 debugwireargs: three, four, five, ssh, remotecmd, insecure
313 debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure
313 debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure
314 files: rev, print0, include, exclude, template, subrepos
314 files: rev, print0, include, exclude, template, subrepos
315 graft: rev, continue, stop, abort, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
315 graft: rev, continue, stop, abort, edit, log, no-commit, force, currentdate, currentuser, date, user, tool, dry-run
316 grep: print0, all, diff, text, follow, ignore-case, files-with-matches, line-number, rev, allfiles, user, date, template, include, exclude
316 grep: print0, all, diff, text, follow, ignore-case, files-with-matches, line-number, rev, allfiles, user, date, template, include, exclude
317 heads: rev, topo, active, closed, style, template
317 heads: rev, topo, active, closed, style, template
318 help: extension, command, keyword, system
318 help: extension, command, keyword, system
@@ -1885,3 +1885,246 b' when we created new changesets on top of'
1885 new changesets detected on destination branch, can't strip
1885 new changesets detected on destination branch, can't strip
1886 graft aborted
1886 graft aborted
1887 working directory is now at 6b98ff0062dd
1887 working directory is now at 6b98ff0062dd
1888
1889 $ cd ..
1890
1891 ============================
1892 Testing --no-commit option:|
1893 ============================
1894
1895 $ hg init nocommit
1896 $ cd nocommit
1897 $ echo a > a
1898 $ hg ci -qAma
1899 $ echo b > b
1900 $ hg ci -qAmb
1901 $ hg up -q 0
1902 $ echo c > c
1903 $ hg ci -qAmc
1904 $ hg log -GT "{rev}:{node|short} {desc}\n"
1905 @ 2:d36c0562f908 c
1906 |
1907 | o 1:d2ae7f538514 b
1908 |/
1909 o 0:cb9a9f314b8b a
1910
1911
1912 Check reporting when --no-commit used with non-applicable options:
1913
1914 $ hg graft 1 --no-commit -e
1915 abort: cannot specify --no-commit and --edit together
1916 [255]
1917
1918 $ hg graft 1 --no-commit --log
1919 abort: cannot specify --no-commit and --log together
1920 [255]
1921
1922 $ hg graft 1 --no-commit -D
1923 abort: cannot specify --no-commit and --currentdate together
1924 [255]
1925
1926 Test --no-commit is working:
1927 $ hg graft 1 --no-commit
1928 grafting 1:d2ae7f538514 "b"
1929
1930 $ hg log -GT "{rev}:{node|short} {desc}\n"
1931 @ 2:d36c0562f908 c
1932 |
1933 | o 1:d2ae7f538514 b
1934 |/
1935 o 0:cb9a9f314b8b a
1936
1937
1938 $ hg diff
1939 diff -r d36c0562f908 b
1940 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1941 +++ b/b Thu Jan 01 00:00:00 1970 +0000
1942 @@ -0,0 +1,1 @@
1943 +b
1944
1945 Prepare wrdir to check --no-commit is resepected after --continue:
1946
1947 $ hg up -qC
1948 $ echo A>a
1949 $ hg ci -qm "A in file a"
1950 $ hg up -q 1
1951 $ echo B>a
1952 $ hg ci -qm "B in file a"
1953 $ hg log -GT "{rev}:{node|short} {desc}\n"
1954 @ 4:2aa9ad1006ff B in file a
1955 |
1956 | o 3:09e253b87e17 A in file a
1957 | |
1958 | o 2:d36c0562f908 c
1959 | |
1960 o | 1:d2ae7f538514 b
1961 |/
1962 o 0:cb9a9f314b8b a
1963
1964
1965 $ hg graft 3 --no-commit
1966 grafting 3:09e253b87e17 "A in file a"
1967 merging a
1968 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
1969 abort: unresolved conflicts, can't continue
1970 (use 'hg resolve' and 'hg graft --continue')
1971 [255]
1972
1973 Resolve conflict:
1974 $ echo A>a
1975 $ hg resolve --mark
1976 (no more unresolved files)
1977 continue: hg graft --continue
1978
1979 $ hg graft --continue
1980 grafting 3:09e253b87e17 "A in file a"
1981 $ hg log -GT "{rev}:{node|short} {desc}\n"
1982 @ 4:2aa9ad1006ff B in file a
1983 |
1984 | o 3:09e253b87e17 A in file a
1985 | |
1986 | o 2:d36c0562f908 c
1987 | |
1988 o | 1:d2ae7f538514 b
1989 |/
1990 o 0:cb9a9f314b8b a
1991
1992 $ hg diff
1993 diff -r 2aa9ad1006ff a
1994 --- a/a Thu Jan 01 00:00:00 1970 +0000
1995 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1996 @@ -1,1 +1,1 @@
1997 -B
1998 +A
1999
2000 $ hg up -qC
2001
2002 Check --no-commit is resepected when passed with --continue:
2003
2004 $ hg graft 3
2005 grafting 3:09e253b87e17 "A in file a"
2006 merging a
2007 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
2008 abort: unresolved conflicts, can't continue
2009 (use 'hg resolve' and 'hg graft --continue')
2010 [255]
2011
2012 Resolve conflict:
2013 $ echo A>a
2014 $ hg resolve --mark
2015 (no more unresolved files)
2016 continue: hg graft --continue
2017
2018 $ hg graft --continue --no-commit
2019 grafting 3:09e253b87e17 "A in file a"
2020 $ hg diff
2021 diff -r 2aa9ad1006ff a
2022 --- a/a Thu Jan 01 00:00:00 1970 +0000
2023 +++ b/a Thu Jan 01 00:00:00 1970 +0000
2024 @@ -1,1 +1,1 @@
2025 -B
2026 +A
2027
2028 $ hg log -GT "{rev}:{node|short} {desc}\n"
2029 @ 4:2aa9ad1006ff B in file a
2030 |
2031 | o 3:09e253b87e17 A in file a
2032 | |
2033 | o 2:d36c0562f908 c
2034 | |
2035 o | 1:d2ae7f538514 b
2036 |/
2037 o 0:cb9a9f314b8b a
2038
2039 $ hg up -qC
2040
2041 Test --no-commit when graft multiple revisions:
2042 When there is conflict:
2043 $ hg graft -r "2::3" --no-commit
2044 grafting 2:d36c0562f908 "c"
2045 grafting 3:09e253b87e17 "A in file a"
2046 merging a
2047 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
2048 abort: unresolved conflicts, can't continue
2049 (use 'hg resolve' and 'hg graft --continue')
2050 [255]
2051
2052 $ echo A>a
2053 $ hg resolve --mark
2054 (no more unresolved files)
2055 continue: hg graft --continue
2056 $ hg graft --continue
2057 grafting 3:09e253b87e17 "A in file a"
2058 $ hg diff
2059 diff -r 2aa9ad1006ff a
2060 --- a/a Thu Jan 01 00:00:00 1970 +0000
2061 +++ b/a Thu Jan 01 00:00:00 1970 +0000
2062 @@ -1,1 +1,1 @@
2063 -B
2064 +A
2065 diff -r 2aa9ad1006ff c
2066 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2067 +++ b/c Thu Jan 01 00:00:00 1970 +0000
2068 @@ -0,0 +1,1 @@
2069 +c
2070
2071 $ hg log -GT "{rev}:{node|short} {desc}\n"
2072 @ 4:2aa9ad1006ff B in file a
2073 |
2074 | o 3:09e253b87e17 A in file a
2075 | |
2076 | o 2:d36c0562f908 c
2077 | |
2078 o | 1:d2ae7f538514 b
2079 |/
2080 o 0:cb9a9f314b8b a
2081
2082 $ hg up -qC
2083
2084 When there is no conflict:
2085 $ echo d>d
2086 $ hg add d -q
2087 $ hg ci -qmd
2088 $ hg up 3 -q
2089 $ hg log -GT "{rev}:{node|short} {desc}\n"
2090 o 5:baefa8927fc0 d
2091 |
2092 o 4:2aa9ad1006ff B in file a
2093 |
2094 | @ 3:09e253b87e17 A in file a
2095 | |
2096 | o 2:d36c0562f908 c
2097 | |
2098 o | 1:d2ae7f538514 b
2099 |/
2100 o 0:cb9a9f314b8b a
2101
2102
2103 $ hg graft -r 1 -r 5 --no-commit
2104 grafting 1:d2ae7f538514 "b"
2105 grafting 5:baefa8927fc0 "d" (tip)
2106 $ hg diff
2107 diff -r 09e253b87e17 b
2108 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2109 +++ b/b Thu Jan 01 00:00:00 1970 +0000
2110 @@ -0,0 +1,1 @@
2111 +b
2112 diff -r 09e253b87e17 d
2113 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2114 +++ b/d Thu Jan 01 00:00:00 1970 +0000
2115 @@ -0,0 +1,1 @@
2116 +d
2117 $ hg log -GT "{rev}:{node|short} {desc}\n"
2118 o 5:baefa8927fc0 d
2119 |
2120 o 4:2aa9ad1006ff B in file a
2121 |
2122 | @ 3:09e253b87e17 A in file a
2123 | |
2124 | o 2:d36c0562f908 c
2125 | |
2126 o | 1:d2ae7f538514 b
2127 |/
2128 o 0:cb9a9f314b8b a
2129
2130 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now