Mercurial and Git clients can push and pull from this alias URL to interact with this repository. You can change to which repository an alias points by going to the Aliases link on the project page.
# hginit.py - TortoiseHg dialog to initialize a repo## Copyright 2008 Steve Borho <steve@borho.org># Copyright 2010 Johan Samyn <johan.samyn@gmail.com>## This software may be used and distributed according to the terms of the# GNU General Public License version 2, incorporated herein by reference.importosfrommercurialimporthg,ui,error,utilfromtortoisehg.hgqt.i18nimport_fromtortoisehg.hgqtimportqtlibfromtortoisehg.utilimporthglib,shlibfromPyQt4.QtCoreimport*fromPyQt4.QtGuiimport*classInitDialog(QDialog):"""TortoiseHg init dialog"""def__init__(self,destdir=[],opts={},parent=None):super(InitDialog,self).__init__(parent)# main layoutself.vbox=QVBoxLayout()self.vbox.setSpacing(6)self.grid=QGridLayout()self.grid.setSpacing(6)self.vbox.addLayout(self.grid)# dest widgetsself.dest_lbl=QLabel(_('Destination path:'))self.dest_edit=QLineEdit()self.dest_edit.setMinimumWidth(300)self.dest_btn=QPushButton(_('Browse...'))self.dest_btn.setAutoDefault(False)self.grid.addWidget(self.dest_lbl,0,0)self.grid.addWidget(self.dest_edit,0,1)self.grid.addWidget(self.dest_btn,0,2)# options checkboxesself.add_files_chk=QCheckBox(_('Add special files (.hgignore, ...)'))self.make_pre_1_7_chk=QCheckBox(_('Make repo compatible with Mercurial <1.7'))self.run_wb_chk=QCheckBox(_('Show in Workbench after init'))self.grid.addWidget(self.add_files_chk,1,1)self.grid.addWidget(self.make_pre_1_7_chk,2,1)ifnotself.parent():self.grid.addWidget(self.run_wb_chk,3,1)# buttonsself.init_btn=QPushButton(_('Create'))self.init_btn.setDefault(True)self.close_btn=QPushButton(_('&Close'))self.close_btn.setAutoDefault(False)self.hbox=QHBoxLayout()self.hbox.addStretch(0)self.hbox.addWidget(self.init_btn)self.hbox.addWidget(self.close_btn)self.vbox.addLayout(self.hbox)# some extrasself.hgcmd_lbl=QLabel(_('Hg command:'))self.hgcmd_lbl.setAlignment(Qt.AlignRight)self.hgcmd_txt=QLineEdit()self.hgcmd_txt.setReadOnly(True)self.grid.addWidget(self.hgcmd_lbl,4,0)self.grid.addWidget(self.hgcmd_txt,4,1)# init defaultsself.cwd=os.getcwd()path=os.path.abspath(destdiranddestdir[0]orself.cwd)ifos.path.isfile(path):path=os.path.dirname(path)self.dest_edit.setText(hglib.tounicode(path))self.add_files_chk.setChecked(True)self.make_pre_1_7_chk.setChecked(False)self.compose_command()# dialog settingsself.setWindowTitle(_('Init'))self.setWindowIcon(qtlib.geticon('hg-init'))self.setWindowFlags(self.windowFlags()&~Qt.WindowContextHelpButtonHint)self.setLayout(self.vbox)self.layout().setSizeConstraint(QLayout.SetFixedSize)self.dest_edit.setFocus()# connecting slotsself.dest_edit.textChanged.connect(self.compose_command)self.dest_btn.clicked.connect(self.browse_clicked)self.init_btn.clicked.connect(self.init)self.close_btn.clicked.connect(self.close)self.make_pre_1_7_chk.toggled.connect(self.compose_command)defbrowse_clicked(self):"""Select the destination directory"""dest=hglib.fromunicode(self.dest_edit.text())ifnotos.path.exists(dest):dest=os.path.dirname(dest)FD=QFileDialog caption = _('Select Destination Folder')
path = FD.getExistingDirectory(parent=self, caption=caption,
options=FD.ShowDirsOnly | FD.ReadOnly)
- response = str(path)- if response:
- self.dest_edit.setText(response)
+ if path:
+ self.dest_edit.setText(path)
def compose_command(self):
# just a stub for extension with extra options (--mq, --ssh, ...)
cmd=['hg','init']ifself.make_pre_1_7_chk.isChecked():cmd.append('--config format.dotencode=False')cmd.append(self.getPath())self.hgcmd_txt.setText(hglib.tounicode(' '.join(cmd)))defgetPath(self):returnhglib.fromunicode(self.dest_edit.text()).strip()definit(self):dest=self.getPath()ifdest=='':qtlib.ErrorMsgBox(_('Error executing init'),_('Destination path is empty'),_('Please enter the directory path'))self.dest_edit.setFocus()returnFalsedest=os.path.normpath(dest)self.dest_edit.setText(hglib.tounicode(dest))udest=self.dest_edit.text()ifnotos.path.exists(dest):p=destl=0whilenotos.path.exists(p):l+=1p,t=os.path.split(p)ifnott:break# already root pathifl>1:res=qtlib.QuestionMsgBox(_('Init'),_('Are you sure about adding the new repository ''%d extra levels deep?')%l,_('Path exists up to:\n%s\nand you asked for:\n%s')%(p,udest),defaultbutton=QMessageBox.No)ifnotres:self.dest_edit.setFocus()returntry:# create the folder, just like Hg wouldos.makedirs(dest)except:qtlib.ErrorMsgBox(_('Error executing init'),_('Cannot create folder %s')%udest)returnFalse_ui=ui.ui()# dotencode is the new default repo format in Mercurial 1.7ifself.make_pre_1_7_chk.isChecked():_ui.setconfig('format','dotencode','False')try:# create the new repohg.repository(_ui,dest,create=1)excepterror.RepoError,inst:qtlib.ErrorMsgBox(_('Error executing init'),_('Unable to create new repository'),hglib.tounicode(str(inst)))returnFalseexceptutil.Abort,e:ife.hint:err=_('%s (hint: %s)')%(hglib.tounicode(str(e)),hglib.tounicode(e.hint))else:err=hglib.tounicode(str(e))qtlib.ErrorMsgBox(_('Error executing init'),_('Error when creating repository'),err)returnFalseexcept:importtracebackqtlib.ErrorMsgBox(_('Error executing init'),_('Error when creating repository'),traceback.format_exc())returnFalse# Create the .hg* file, mainly to workaround# Explorer's problem in creating files with a name# beginning with a dot.if(self.add_files_chk.isChecked()andos.path.exists(os.path.sep.join([dest,'.hg']))):hgignore=os.path.join(dest,'.hgignore')ifnotos.path.exists(hgignore):try:open(hgignore,'wb')except:passifself.run_wb_chk.isChecked():fromtortoisehg.hgqtimportruntry:run.log(ui.ui(),root=dest)exceptException,e:qtlib.WarningMsgBox(_('Init'),_('<p>Repository successfully created at</p><p>%s</p>')%dest,_('<p>But could not run Workbench for it.</p><p>%s</p>')%hglib.tounicode(str(e)))else:ifnotself.parent():qtlib.InfoMsgBox(_('Init'),_('<p>Repository successfully created at</p><p>%s</p>')%udest)self.accept()defreject(self):super(InitDialog,self).reject()defrun(ui,*pats,**opts):returnInitDialog(pats,opts)
Attach a Trello Card
Add a tag
Your session has expired
You are no longer logged in. Please log in and try your request again.
Filter RSS Feed
This RSS feed URL allows you to see the contents of your current filter using any feed reader.
This link includes a special authentication token. If you share the URL with anyone else, they can see this RSS feed's activity. You can disable these tokens when needed.
Your current filter is unsaved; changing it won't affect this RSS feed.