comparison hgext/mq.py @ 10480:3076b39d7f3e stable

mq: unify implementation of qinit and init -Q
author Brendan Cully <brendan@kublai.com>
date Mon, 15 Feb 2010 00:16:59 -0800
parents 3113736dbac5
children dc9a803c1800
comparison
equal deleted inserted replaced
10479:bb508b312359 10480:3076b39d7f3e
1828 1828
1829 if opts.get('push') and not opts.get('rev'): 1829 if opts.get('push') and not opts.get('rev'):
1830 return q.push(repo, None) 1830 return q.push(repo, None)
1831 return 0 1831 return 0
1832 1832
1833 def init(ui, repo, **opts): 1833 def qinit(ui, repo, create):
1834 """init a new queue repository (DEPRECATED) 1834 """initialize a new queue repository
1835 1835
1836 The queue repository is unversioned by default. If 1836 This command also creates a series file for ordering patches, and
1837 -c/--create-repo is specified, qinit will create a separate nested 1837 an mq-specific .hgignore file in the queue repository, to exclude
1838 repository for patches (qinit -c may also be run later to convert 1838 the status and guards files (these contain mostly transient state)."""
1839 an unversioned patch repository into a versioned one). You can use
1840 qcommit to commit changes to this queue repository.
1841
1842 This command is deprecated. Without -c, it's implied by other relevant
1843 commands. With -c, use hg init -Q instead."""
1844 q = repo.mq 1839 q = repo.mq
1845 r = q.init(repo, create=opts['create_repo']) 1840 r = q.init(repo, create)
1846 q.save_dirty() 1841 q.save_dirty()
1847 if r: 1842 if r:
1848 if not os.path.exists(r.wjoin('.hgignore')): 1843 if not os.path.exists(r.wjoin('.hgignore')):
1849 fp = r.wopener('.hgignore', 'w') 1844 fp = r.wopener('.hgignore', 'w')
1850 fp.write('^\\.hg\n') 1845 fp.write('^\\.hg\n')
1856 if not os.path.exists(r.wjoin('series')): 1851 if not os.path.exists(r.wjoin('series')):
1857 r.wopener('series', 'w').close() 1852 r.wopener('series', 'w').close()
1858 r.add(['.hgignore', 'series']) 1853 r.add(['.hgignore', 'series'])
1859 commands.add(ui, r) 1854 commands.add(ui, r)
1860 return 0 1855 return 0
1856
1857 def init(ui, repo, **opts):
1858 """init a new queue repository (DEPRECATED)
1859
1860 The queue repository is unversioned by default. If
1861 -c/--create-repo is specified, qinit will create a separate nested
1862 repository for patches (qinit -c may also be run later to convert
1863 an unversioned patch repository into a versioned one). You can use
1864 qcommit to commit changes to this queue repository.
1865
1866 This command is deprecated. Without -c, it's implied by other relevant
1867 commands. With -c, use hg init -Q instead."""
1868 return qinit(ui, repo, create=opts['create_repo'])
1861 1869
1862 def clone(ui, source, dest=None, **opts): 1870 def clone(ui, source, dest=None, **opts):
1863 '''clone main and patch repository at same time 1871 '''clone main and patch repository at same time
1864 1872
1865 If source is local, destination will have no patches applied. If 1873 If source is local, destination will have no patches applied. If
2628 if not mq: 2636 if not mq:
2629 return orig(ui, *args, **kwargs) 2637 return orig(ui, *args, **kwargs)
2630 2638
2631 repopath = cmdutil.findrepo(os.getcwd()) 2639 repopath = cmdutil.findrepo(os.getcwd())
2632 repo = hg.repository(ui, repopath) 2640 repo = hg.repository(ui, repopath)
2633 q = repo.mq 2641 return qinit(ui, repo, True)
2634 r = q.init(repo, create=True)
2635 q.save_dirty()
2636
2637 if not os.path.exists(r.wjoin('.hgignore')):
2638 fp = r.wopener('.hgignore', 'w')
2639 fp.write('^\\.hg\n')
2640 fp.write('^\\.mq\n')
2641 fp.write('syntax: glob\n')
2642 fp.write('status\n')
2643 fp.write('guards\n')
2644 fp.close()
2645 if not os.path.exists(r.wjoin('series')):
2646 r.wopener('series', 'w').close()
2647 r.add(['.hgignore', 'series'])
2648 commands.add(ui, r)
2649 2642
2650 def mqcommand(orig, ui, repo, *args, **kwargs): 2643 def mqcommand(orig, ui, repo, *args, **kwargs):
2651 """Add --mq option to operate on patch repository instead of main""" 2644 """Add --mq option to operate on patch repository instead of main"""
2652 2645
2653 # some commands do not like getting unknown options 2646 # some commands do not like getting unknown options