Changeset 8333:8b7f3b826d11
- Timestamp:
- 12/01/07 20:13:13 (5 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
sage/misc/hg.py (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/misc/hg.py
r6993 r8333 23 23 ######################################################################## 24 24 # Copyright (C) 2006 William Stein <wstein@gmail.com> 25 # 2007 Jonathan Hanke <jonhanke@gmail.com> 25 26 # 26 27 # Distributed under the terms of the GNU General Public License (GPL) … … 62 63 \end{verbatim} 63 64 """ 64 def __init__(self, dir, name, url, target=None, cloneable=False, obj_name=''):65 def __init__(self, dir, name, pull_url, push_url, target=None, cloneable=False, obj_name=''): 65 66 """ 66 67 INPUT: 67 68 dir -- directory that will contain the repository 68 69 name -- a friendly name for the repository (only used for printing) 69 url -- a default URL to pull or record sends against (e.g.,70 pull_url -- a default URL to pull or record sends against (e.g., 70 71 this could be a master repository on modular.math.washington.edu) 72 push_url -- a default URL to push or record outgoing changes against (e.g., 73 this could be a local repository on your favorite computer) 71 74 target -- if the last part of dir is, e.g., sage-hg, 72 75 create a symlink from sage-hg to target. … … 75 78 self.__dir = os.path.abspath(dir) 76 79 self.__name = name 77 self.__url = url 80 self.__pull_url = pull_url 81 self.__push_url = push_url 78 82 self.__initialized = False 79 83 self.__target = target … … 83 87 def __repr__(self): 84 88 return "Hg repository '%s' in directory %s"%(self.__name, self.__dir) 89 90 91 def current_branch(self, print_flag=True): 92 """ 93 Lists the current branch. 94 """ 95 branch_name = branch_current_hg() 96 if print_flag: 97 print "The current branch is: " + branch_name 98 else: 99 return branch_name 100 101 def list_branches(self, print_flag=True): 102 """ 103 Print all branches in the current SAGE installation. 104 """ 105 try: 106 tmp_branch_list = [s[5:] for s in os.listdir(SAGE_ROOT + "/devel") if s.startswith("sage-")] 107 except: 108 raise RuntimeError, "Oops! We had trouble... Check that SAGE_ROOT gives the correct directory." 109 110 if print_flag: 111 print "Branches found:" 112 for s in tmp_branch_list: 113 print " " + s 114 else: 115 return tmp_branch_list 116 85 117 86 118 def status(self): … … 557 589 return self.__dir 558 590 559 def url(self):591 def pull_url(self): 560 592 """ 561 593 Return the default 'master url' for this repository. 562 594 """ 563 return self.__url 595 return self.__pull_url 596 597 def push_url(self): 598 """ 599 Return the default url for uploading this repository. 600 """ 601 return self.__push_url 564 602 565 603 … … 579 617 Use this to find changsets that are in your branch, but not in the 580 618 specified destination repository. If no destination is specified, the 581 official repository is used. 619 official repository is used. By default, push_url() is used. 582 620 583 621 From the Mercurial documentation: … … 586 624 a push was requested. 587 625 588 See pu ll() for valid destination format details.589 590 INPUT: 591 url: default: self. url() -- the official repository626 See push() for valid destination format details. 627 628 INPUT: 629 url: default: self.push_url() -- the official repository 592 630 * http://[user@]host[:port]/[path] 593 631 * https://[user@]host[:port]/[path] … … 607 645 """ 608 646 if url is None: 609 url = self.__ url647 url = self.__push_url 610 648 611 649 if not '/' in url: … … 621 659 622 660 INPUT: 623 url: default: self. url() -- the official repository661 url: default: self.pull_url() -- the official repository 624 662 * http://[user@]host[:port]/[path] 625 663 * https://[user@]host[:port]/[path] … … 652 690 653 691 if url is None: 654 url = self.__ url692 url = self.__pull_url 655 693 if not '/' in url: 656 694 url = '%s/devel/sage-%s'%(SAGE_ROOT, url) … … 665 703 print "If it says use 'hg merge' above, then you should" 666 704 print "type hg_%s.merge()."%self.__obj_name 705 706 def push(self, url=None, options=''): 707 """ 708 Push all new patches from the repository to the given destination. 709 710 INPUT: 711 url: default: self.push_url() -- the official repository 712 * http://[user@]host[:port]/[path] 713 * https://[user@]host[:port]/[path] 714 * ssh://[user@]host[:port]/[path] 715 * local directory (starting with a /) 716 * name of a branch (for hg_sage); no /'s 717 options: (default: '') 718 -e --ssh specify ssh command to use 719 -f --force run even when remote repository is unrelated 720 -r --rev a specific revision you would like to pull 721 --remotecmd specify hg command to run on the remote side 722 723 Some notes about using SSH with Mercurial: 724 - SSH requires an accessible shell account on the destination machine 725 and a copy of hg in the remote path or specified with as remotecmd. 726 - path is relative to the remote user's home directory by default. 727 Use an extra slash at the start of a path to specify an absolute path: 728 ssh://example.com//tmp/repository 729 - Mercurial doesn't use its own compression via SSH; the right thing 730 to do is to configure it in your ~/.ssh/ssh_config, e.g.: 731 Host *.mylocalnetwork.example.com 732 Compression off 733 Host * 734 Compression on 735 Alternatively specify "ssh -C" as your ssh command in your hgrc or 736 with the --ssh command line option. 737 """ 738 ##self._ensure_safe() 739 740 if url is None: 741 url = self.__push_url 742 if not '/' in url: 743 url = '%s/devel/sage-%s'%(SAGE_ROOT, url) 744 745 self('push %s %s'%(options, url)) 746 667 747 668 748 def merge(self, options=''): … … 854 934 r""" 855 935 Create an hg changeset bundle with the given filename against the 856 repository at the given url (which is by default the 857 'official' SAGE repository).936 repository at the given url (which is by default the 'official' 937 SAGE repository, unless push_url() is changed in a setup file). 858 938 859 939 If you have internet access, it's best to just do … … 872 952 filename -- output file in which to put bundle 873 953 options -- pass to hg 874 url -- url to bundle against (default: SAGE_SERVER )954 url -- url to bundle against (default: SAGE_SERVER, or push_url()) 875 955 base -- a base changeset revision number to bundle 876 956 against (doesn't require internet access) … … 881 961 882 962 if url is None: 883 url = self.__ url963 url = self.__push_url 884 964 885 965 # make sure that we don't accidentally create a file ending in '.hg.hg' … … 917 997 SAGE_ROOT = misc.SAGE_ROOT 918 998 try: 919 SAGE_ SERVER = os.environ['SAGE_HG_SERVER'].strip('/') + '/hg'999 SAGE_INCOMING_SERVER = os.environ['SAGE_HG_SERVER'].strip('/') + '/hg' 920 1000 except KeyError: 921 1001 try: 922 SAGE_ SERVER = os.environ['SAGE_SERVER'].strip('/') + '/hg'1002 SAGE_INCOMING_SERVER = os.environ['SAGE_SERVER'].strip('/') + '/hg' 923 1003 except KeyError: 924 1004 print "Falling back to a hard coded sage server in misc/hg.py" 925 SAGE_SERVER = "http://sage.math.washington.edu/sage/hg/" 1005 SAGE_INCOMING_SERVER = "http://sage.math.washington.edu/sage/hg/" 1006 1007 SAGE_OUTGOING_SERVER = os.getenv("SAGE_OUTGOING_SERVER") 1008 temp_branch_name = branch_current_hg() ## Delete this eventually <<---- TO FIX 1009 if SAGE_OUTGOING_SERVER == None: 1010 SAGE_OUTGOING_SERVER = SAGE_INCOMING_SERVER 1011 temp_incoming_branch_name = "main" ## Force use of the "main" branch (to avoid breaking anything for now). <<---- TO FIX 1012 else: 1013 print "Non-default server settings detected:" 1014 print " Incoming Server = ", SAGE_INCOMING_SERVER 1015 print " Outgoing Server = ", SAGE_OUTGOING_SERVER 1016 print 926 1017 927 1018 hg_sage = HG('%s/devel/sage'%SAGE_ROOT, 928 1019 'SAGE Library Source Code', 929 url='%s/sage-main'%SAGE_SERVER, 1020 pull_url='%s/sage-%s'%(SAGE_INCOMING_SERVER, temp_branch_name), 1021 push_url='%s/sage-%s'%(SAGE_OUTGOING_SERVER, temp_branch_name), 1022 1023 ## These are the eventual replacements for the above 2 lines (I hope!) <<---- TO FIX 1024 ##pull_url='%s/sage-%s'%(SAGE_INCOMING_SERVER, branch_current_hg()), 1025 ##push_url='%s/sage-%s'%(SAGE_OUTGOING_SERVER, branch_current_hg()), 1026 930 1027 cloneable=True, 931 1028 obj_name='sage') … … 933 1030 hg_doc = HG('%s/devel/doc'%SAGE_ROOT, 934 1031 'SAGE Documentation', 935 url='%s/doc-main'%SAGE_SERVER, 1032 pull_url='%s/doc-main'%SAGE_INCOMING_SERVER, 1033 push_url='%s/doc-main'%SAGE_OUTGOING_SERVER, 936 1034 obj_name='doc') 937 1035 938 1036 hg_scripts = HG('%s/local/bin/'%SAGE_ROOT, 939 1037 'SAGE Scripts', 940 url='%s/scripts-main'%SAGE_SERVER, 1038 pull_url='%s/scripts-main'%SAGE_INCOMING_SERVER, 1039 push_url='%s/scripts-main'%SAGE_OUTGOING_SERVER, 941 1040 obj_name='scripts') 942 1041 943 1042 hg_extcode = HG('%s/data/extcode'%SAGE_ROOT, 944 1043 'SAGE External System Code (e.g., PARI, MAGMA, etc.)', 945 url='%s/extcode-main'%SAGE_SERVER, 1044 pull_url='%s/extcode-main'%SAGE_INCOMING_SERVER, 1045 push_url='%s/extcode-main'%SAGE_OUTGOING_SERVER, 946 1046 obj_name='extcode') 947 1047
Note: See TracChangeset
for help on using the changeset viewer.
