comparison hgext/mq.py @ 7994:3c22fdc741d8

mq: word-wrap help texts at 70 characters
author Martin Geisler <mg@daimi.au.dk>
date Sat, 04 Apr 2009 23:18:03 +0200
parents 7b813bdbd5d0
children 683d8ebcf434
comparison
equal deleted inserted replaced
7993:b83a11536fc6 7994:3c22fdc741d8
1622 qrepo.add(added) 1622 qrepo.add(added)
1623 1623
1624 def delete(ui, repo, *patches, **opts): 1624 def delete(ui, repo, *patches, **opts):
1625 """remove patches from queue 1625 """remove patches from queue
1626 1626
1627 The patches must not be applied, unless they are arguments to 1627 The patches must not be applied, unless they are arguments to the
1628 the --rev parameter. At least one patch or revision is required. 1628 --rev parameter. At least one patch or revision is required.
1629 1629
1630 With --rev, mq will stop managing the named revisions (converting 1630 With --rev, mq will stop managing the named revisions (converting
1631 them to regular mercurial changesets). The qfinish command should be 1631 them to regular mercurial changesets). The qfinish command should
1632 used as an alternative for qdel -r, as the latter option is deprecated. 1632 be used as an alternative for qdel -r, as the latter option is
1633 1633 deprecated.
1634 With --keep, the patch files are preserved in the patch directory.""" 1634
1635 With --keep, the patch files are preserved in the patch
1636 directory."""
1635 q = repo.mq 1637 q = repo.mq
1636 q.delete(repo, patches, opts) 1638 q.delete(repo, patches, opts)
1637 q.save_dirty() 1639 q.save_dirty()
1638 return 0 1640 return 0
1639 1641
1660 q.qseries(repo, start=start, status='U', summary=opts.get('summary')) 1662 q.qseries(repo, start=start, status='U', summary=opts.get('summary'))
1661 1663
1662 def qimport(ui, repo, *filename, **opts): 1664 def qimport(ui, repo, *filename, **opts):
1663 """import a patch 1665 """import a patch
1664 1666
1665 The patch is inserted into the series after the last applied patch. 1667 The patch is inserted into the series after the last applied
1666 If no patches have been applied, qimport prepends the patch 1668 patch. If no patches have been applied, qimport prepends the patch
1667 to the series. 1669 to the series.
1668 1670
1669 The patch will have the same name as its source file unless you 1671 The patch will have the same name as its source file unless you
1670 give it a new one with --name. 1672 give it a new one with --name.
1671 1673
1672 You can register an existing patch inside the patch directory 1674 You can register an existing patch inside the patch directory with
1673 with the --existing flag. 1675 the --existing flag.
1674 1676
1675 With --force, an existing patch of the same name will be overwritten. 1677 With --force, an existing patch of the same name will be
1678 overwritten.
1676 1679
1677 An existing changeset may be placed under mq control with --rev 1680 An existing changeset may be placed under mq control with --rev
1678 (e.g. qimport --rev tip -n patch will place tip under mq control). 1681 (e.g. qimport --rev tip -n patch will place tip under mq control).
1679 With --git, patches imported with --rev will use the git diff 1682 With --git, patches imported with --rev will use the git diff
1680 format. See the diffs help topic for information on why this is 1683 format. See the diffs help topic for information on why this is
1681 important for preserving rename/copy information and permission changes. 1684 important for preserving rename/copy information and permission
1685 changes.
1682 """ 1686 """
1683 q = repo.mq 1687 q = repo.mq
1684 q.qimport(repo, filename, patchname=opts['name'], 1688 q.qimport(repo, filename, patchname=opts['name'],
1685 existing=opts['existing'], force=opts['force'], rev=opts['rev'], 1689 existing=opts['existing'], force=opts['force'], rev=opts['rev'],
1686 git=opts['git']) 1690 git=opts['git'])
1689 1693
1690 def init(ui, repo, **opts): 1694 def init(ui, repo, **opts):
1691 """init a new queue repository 1695 """init a new queue repository
1692 1696
1693 The queue repository is unversioned by default. If -c is 1697 The queue repository is unversioned by default. If -c is
1694 specified, qinit will create a separate nested repository 1698 specified, qinit will create a separate nested repository for
1695 for patches (qinit -c may also be run later to convert 1699 patches (qinit -c may also be run later to convert an unversioned
1696 an unversioned patch repository into a versioned one). 1700 patch repository into a versioned one). You can use qcommit to
1697 You can use qcommit to commit changes to this queue repository.""" 1701 commit changes to this queue repository."""
1698 q = repo.mq 1702 q = repo.mq
1699 r = q.init(repo, create=opts['create_repo']) 1703 r = q.init(repo, create=opts['create_repo'])
1700 q.save_dirty() 1704 q.save_dirty()
1701 if r: 1705 if r:
1702 if not os.path.exists(r.wjoin('.hgignore')): 1706 if not os.path.exists(r.wjoin('.hgignore')):
1832 do('date', "%d %d" % util.makedate()) 1836 do('date', "%d %d" % util.makedate())
1833 1837
1834 def new(ui, repo, patch, *args, **opts): 1838 def new(ui, repo, patch, *args, **opts):
1835 """create a new patch 1839 """create a new patch
1836 1840
1837 qnew creates a new patch on top of the currently-applied patch (if any). 1841 qnew creates a new patch on top of the currently-applied patch (if
1838 It will refuse to run if there are any outstanding changes unless -f is 1842 any). It will refuse to run if there are any outstanding changes
1839 specified, in which case the patch will be initialized with them. You 1843 unless -f is specified, in which case the patch will be
1840 may also use -I, -X, and/or a list of files after the patch name to add 1844 initialized with them. You may also use -I, -X, and/or a list of
1841 only changes to matching files to the new patch, leaving the rest as 1845 files after the patch name to add only changes to matching files
1842 uncommitted modifications. 1846 to the new patch, leaving the rest as uncommitted modifications.
1843 1847
1844 -u and -d can be used to set the (given) user and date, respectively. 1848 -u and -d can be used to set the (given) user and date, respectively.
1845 -U and -D set user to current user and date to current date. 1849 -U and -D set user to current user and date to current date.
1846 1850
1847 -e, -m or -l set the patch header as well as the commit message. If none 1851 -e, -m or -l set the patch header as well as the commit message.
1848 is specified, the header is empty and the commit message is '[mq]: PATCH'. 1852 If none is specified, the header is empty and the commit message
1853 is '[mq]: PATCH'.
1849 1854
1850 Use the --git option to keep the patch in the git extended diff 1855 Use the --git option to keep the patch in the git extended diff
1851 format. Read the diffs help topic for more information on why this 1856 format. Read the diffs help topic for more information on why this
1852 is important for preserving permission changes and copy/rename 1857 is important for preserving permission changes and copy/rename
1853 information. 1858 information.
1866 return 0 1871 return 0
1867 1872
1868 def refresh(ui, repo, *pats, **opts): 1873 def refresh(ui, repo, *pats, **opts):
1869 """update the current patch 1874 """update the current patch
1870 1875
1871 If any file patterns are provided, the refreshed patch will contain only 1876 If any file patterns are provided, the refreshed patch will
1872 the modifications that match those patterns; the remaining modifications 1877 contain only the modifications that match those patterns; the
1873 will remain in the working directory. 1878 remaining modifications will remain in the working directory.
1874 1879
1875 If --short is specified, files currently included in the patch will 1880 If --short is specified, files currently included in the patch
1876 be refreshed just like matched files and remain in the patch. 1881 will be refreshed just like matched files and remain in the patch.
1877 1882
1878 hg add/remove/copy/rename work as usual, though you might want to use 1883 hg add/remove/copy/rename work as usual, though you might want to
1879 git-style patches (--git or [diff] git=1) to track copies and renames. 1884 use git-style patches (--git or [diff] git=1) to track copies and
1880 See the diffs help topic for more information on the git diff format. 1885 renames. See the diffs help topic for more information on the git
1886 diff format.
1881 """ 1887 """
1882 q = repo.mq 1888 q = repo.mq
1883 message = cmdutil.logmessage(opts) 1889 message = cmdutil.logmessage(opts)
1884 if opts['edit']: 1890 if opts['edit']:
1885 if not q.applied: 1891 if not q.applied:
1896 return ret 1902 return ret
1897 1903
1898 def diff(ui, repo, *pats, **opts): 1904 def diff(ui, repo, *pats, **opts):
1899 """diff of the current patch and subsequent modifications 1905 """diff of the current patch and subsequent modifications
1900 1906
1901 Shows a diff which includes the current patch as well as any changes which 1907 Shows a diff which includes the current patch as well as any
1902 have been made in the working directory since the last refresh (thus 1908 changes which have been made in the working directory since the
1903 showing what the current patch would become after a qrefresh). 1909 last refresh (thus showing what the current patch would become
1904 1910 after a qrefresh).
1905 Use 'hg diff' if you only want to see the changes made since the last 1911
1906 qrefresh, or 'hg export qtip' if you want to see changes made by the 1912 Use 'hg diff' if you only want to see the changes made since the
1907 current patch without including changes made since the qrefresh. 1913 last qrefresh, or 'hg export qtip' if you want to see changes made
1914 by the current patch without including changes made since the
1915 qrefresh.
1908 """ 1916 """
1909 repo.mq.diff(repo, pats, opts) 1917 repo.mq.diff(repo, pats, opts)
1910 return 0 1918 return 0
1911 1919
1912 def fold(ui, repo, *files, **opts): 1920 def fold(ui, repo, *files, **opts):
1913 """fold the named patches into the current patch 1921 """fold the named patches into the current patch
1914 1922
1915 Patches must not yet be applied. Each patch will be successively 1923 Patches must not yet be applied. Each patch will be successively
1916 applied to the current patch in the order given. If all the 1924 applied to the current patch in the order given. If all the
1917 patches apply successfully, the current patch will be refreshed 1925 patches apply successfully, the current patch will be refreshed
1918 with the new cumulative patch, and the folded patches will 1926 with the new cumulative patch, and the folded patches will be
1919 be deleted. With -k/--keep, the folded patch files will not 1927 deleted. With -k/--keep, the folded patch files will not be
1920 be removed afterwards. 1928 removed afterwards.
1921 1929
1922 The header for each folded patch will be concatenated with 1930 The header for each folded patch will be concatenated with the
1923 the current patch header, separated by a line of '* * *'.""" 1931 current patch header, separated by a line of '* * *'."""
1924 1932
1925 q = repo.mq 1933 q = repo.mq
1926 1934
1927 if not files: 1935 if not files:
1928 raise util.Abort(_('qfold requires at least one patch name')) 1936 raise util.Abort(_('qfold requires at least one patch name'))
2067 return newpath 2075 return newpath
2068 2076
2069 def push(ui, repo, patch=None, **opts): 2077 def push(ui, repo, patch=None, **opts):
2070 """push the next patch onto the stack 2078 """push the next patch onto the stack
2071 2079
2072 When --force is applied, all local changes in patched files will be lost. 2080 When --force is applied, all local changes in patched files will
2081 be lost.
2073 """ 2082 """
2074 q = repo.mq 2083 q = repo.mq
2075 mergeq = None 2084 mergeq = None
2076 2085
2077 if opts['merge']: 2086 if opts['merge']:
2089 return ret 2098 return ret
2090 2099
2091 def pop(ui, repo, patch=None, **opts): 2100 def pop(ui, repo, patch=None, **opts):
2092 """pop the current patch off the stack 2101 """pop the current patch off the stack
2093 2102
2094 By default, pops off the top of the patch stack. If given a patch name, 2103 By default, pops off the top of the patch stack. If given a patch
2095 keeps popping off patches until the named patch is at the top of the stack. 2104 name, keeps popping off patches until the named patch is at the
2105 top of the stack.
2096 """ 2106 """
2097 localupdate = True 2107 localupdate = True
2098 if opts['name']: 2108 if opts['name']:
2099 q = queue(ui, repo.join(""), repo.join(opts['name'])) 2109 q = queue(ui, repo.join(""), repo.join(opts['name']))
2100 ui.warn(_('using patch queue: %s\n') % q.path) 2110 ui.warn(_('using patch queue: %s\n') % q.path)
2206 return 0 2216 return 0
2207 2217
2208 def strip(ui, repo, rev, **opts): 2218 def strip(ui, repo, rev, **opts):
2209 """strip a revision and all its descendants from the repository 2219 """strip a revision and all its descendants from the repository
2210 2220
2211 If one of the working dir's parent revisions is stripped, the working 2221 If one of the working dir's parent revisions is stripped, the
2212 directory will be updated to the parent of the stripped revision. 2222 working directory will be updated to the parent of the stripped
2223 revision.
2213 """ 2224 """
2214 backup = 'all' 2225 backup = 'all'
2215 if opts['backup']: 2226 if opts['backup']:
2216 backup = 'strip' 2227 backup = 'strip'
2217 elif opts['nobackup']: 2228 elif opts['nobackup']:
2233 2244
2234 def select(ui, repo, *args, **opts): 2245 def select(ui, repo, *args, **opts):
2235 '''set or print guarded patches to push 2246 '''set or print guarded patches to push
2236 2247
2237 Use the qguard command to set or print guards on patch, then use 2248 Use the qguard command to set or print guards on patch, then use
2238 qselect to tell mq which guards to use. A patch will be pushed if it 2249 qselect to tell mq which guards to use. A patch will be pushed if
2239 has no guards or any positive guards match the currently selected guard, 2250 it has no guards or any positive guards match the currently
2240 but will not be pushed if any negative guards match the current guard. 2251 selected guard, but will not be pushed if any negative guards
2241 For example: 2252 match the current guard. For example:
2242 2253
2243 qguard foo.patch -stable (negative guard) 2254 qguard foo.patch -stable (negative guard)
2244 qguard bar.patch +stable (positive guard) 2255 qguard bar.patch +stable (positive guard)
2245 qselect stable 2256 qselect stable
2246 2257
2247 This activates the "stable" guard. mq will skip foo.patch (because 2258 This activates the "stable" guard. mq will skip foo.patch (because
2248 it has a negative match) but push bar.patch (because it 2259 it has a negative match) but push bar.patch (because it has a
2249 has a positive match). 2260 positive match).
2250 2261
2251 With no arguments, prints the currently active guards. 2262 With no arguments, prints the currently active guards.
2252 With one argument, sets the active guard. 2263 With one argument, sets the active guard.
2253 2264
2254 Use -n/--none to deactivate guards (no other arguments needed). 2265 Use -n/--none to deactivate guards (no other arguments needed).
2255 When no guards are active, patches with positive guards are skipped 2266 When no guards are active, patches with positive guards are
2256 and patches with negative guards are pushed. 2267 skipped and patches with negative guards are pushed.
2257 2268
2258 qselect can change the guards on applied patches. It does not pop 2269 qselect can change the guards on applied patches. It does not pop
2259 guarded patches by default. Use --pop to pop back to the last applied 2270 guarded patches by default. Use --pop to pop back to the last
2260 patch that is not guarded. Use --reapply (which implies --pop) to push 2271 applied patch that is not guarded. Use --reapply (which implies
2261 back to the current patch afterwards, but skip guarded patches. 2272 --pop) to push back to the current patch afterwards, but skip
2262 2273 guarded patches.
2263 Use -s/--series to print a list of all guards in the series file (no 2274
2264 other arguments needed). Use -v for more information.''' 2275 Use -s/--series to print a list of all guards in the series file
2276 (no other arguments needed). Use -v for more information.'''
2265 2277
2266 q = repo.mq 2278 q = repo.mq
2267 guards = q.active() 2279 guards = q.active()
2268 if args or opts['none']: 2280 if args or opts['none']:
2269 old_unapplied = q.unapplied(repo) 2281 old_unapplied = q.unapplied(repo)
2334 q.save_dirty() 2346 q.save_dirty()
2335 2347
2336 def finish(ui, repo, *revrange, **opts): 2348 def finish(ui, repo, *revrange, **opts):
2337 """move applied patches into repository history 2349 """move applied patches into repository history
2338 2350
2339 Finishes the specified revisions (corresponding to applied patches) by 2351 Finishes the specified revisions (corresponding to applied
2340 moving them out of mq control into regular repository history. 2352 patches) by moving them out of mq control into regular repository
2353 history.
2341 2354
2342 Accepts a revision range or the --applied option. If --applied is 2355 Accepts a revision range or the --applied option. If --applied is
2343 specified, all applied mq revisions are removed from mq control. 2356 specified, all applied mq revisions are removed from mq control.
2344 Otherwise, the given revisions must be at the base of the stack of 2357 Otherwise, the given revisions must be at the base of the stack of
2345 applied patches. 2358 applied patches.
2346 2359
2347 This can be especially useful if your changes have been applied to an 2360 This can be especially useful if your changes have been applied to
2348 upstream repository, or if you are about to push your changes to upstream. 2361 an upstream repository, or if you are about to push your changes
2362 to upstream.
2349 """ 2363 """
2350 if not opts['applied'] and not revrange: 2364 if not opts['applied'] and not revrange:
2351 raise util.Abort(_('no revisions specified')) 2365 raise util.Abort(_('no revisions specified'))
2352 elif opts['applied']: 2366 elif opts['applied']:
2353 revrange = ('qbase:qtip',) + revrange 2367 revrange = ('qbase:qtip',) + revrange